From 4e84989d8f6330027327f4fc214055c1cd7bf45b Mon Sep 17 00:00:00 2001 From: Tommaso Sciortino Date: Mon, 7 Jul 2025 16:27:24 -0700 Subject: Fix double "esc" bug in Auth dialog (#3493) --- packages/cli/src/ui/components/AuthDialog.test.tsx | 38 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'packages/cli/src/ui/components/AuthDialog.test.tsx') diff --git a/packages/cli/src/ui/components/AuthDialog.test.tsx b/packages/cli/src/ui/components/AuthDialog.test.tsx index 15c6d68a..8f07e2a5 100644 --- a/packages/cli/src/ui/components/AuthDialog.test.tsx +++ b/packages/cli/src/ui/components/AuthDialog.test.tsx @@ -45,9 +45,7 @@ describe('AuthDialog', () => { const onSelect = vi.fn(); const settings: LoadedSettings = new LoadedSettings( { - settings: { - selectedAuthType: undefined, - }, + settings: {}, path: '', }, { @@ -74,6 +72,40 @@ describe('AuthDialog', () => { unmount(); }); + it('should not exit if there is already an error message', async () => { + const onSelect = vi.fn(); + const settings: LoadedSettings = new LoadedSettings( + { + settings: {}, + path: '', + }, + { + settings: {}, + path: '', + }, + [], + ); + + const { lastFrame, stdin, unmount } = render( + , + ); + await wait(); + + expect(lastFrame()).toContain('Initial error'); + + // Simulate pressing escape key + stdin.write('\u001b'); // ESC key + await wait(); + + // Should not call onSelect + expect(onSelect).not.toHaveBeenCalled(); + unmount(); + }); + it('should allow exiting when auth method is already selected', async () => { const onSelect = vi.fn(); const settings: LoadedSettings = new LoadedSettings( -- cgit v1.2.3