fix(cli): clean up connection commands (#62)

* fix(cli): clean up connection commands

* test(cli): update connection smoke coverage

* Fix setup output formatting

* fix notion setup picker exit
This commit is contained in:
Andrey Avtomonov 2026-05-13 15:04:50 +02:00 committed by GitHub
parent 4973ca562f
commit e1e9c4af91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 1096 additions and 5342 deletions

View file

@ -17,9 +17,11 @@ function makeTracker(ctrlCValues: boolean[]): SetupInterruptTracker {
describe('setup interrupt confirmation', () => {
const originalIsTTY = process.stdin.isTTY;
const originalRef = process.stdin.ref;
afterEach(() => {
Object.defineProperty(process.stdin, 'isTTY', { configurable: true, value: originalIsTTY });
Object.defineProperty(process.stdin, 'ref', { configurable: true, value: originalRef });
});
it('fails before opening a prompt when interactive setup has no tty', async () => {
@ -33,6 +35,26 @@ describe('setup interrupt confirmation', () => {
expect(prompt).not.toHaveBeenCalled();
});
it('refs stdin before opening a real interactive prompt', async () => {
const calls: string[] = [];
Object.defineProperty(process.stdin, 'isTTY', { configurable: true, value: true });
Object.defineProperty(process.stdin, 'ref', {
configurable: true,
value: vi.fn(() => {
calls.push('ref');
return process.stdin;
}),
});
const prompt = vi.fn(async () => {
calls.push('prompt');
return 'continued';
});
await expect(withSetupInterruptConfirmation(prompt)).resolves.toBe('continued');
expect(calls).toEqual(['ref', 'prompt']);
});
it('asks before exiting on Ctrl+C and reruns the active prompt when declined', async () => {
const prompt = vi.fn(async () => (prompt.mock.calls.length === 1 ? CANCEL : 'continued'));
const confirmExit = vi.fn(async () => false);