summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/ui/components/AuthDialog.test.tsx38
-rw-r--r--packages/cli/src/ui/components/AuthDialog.tsx5
2 files changed, 40 insertions, 3 deletions
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(
+ <AuthDialog
+ onSelect={onSelect}
+ settings={settings}
+ initialErrorMessage="Initial error"
+ />,
+ );
+ 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(
diff --git a/packages/cli/src/ui/components/AuthDialog.tsx b/packages/cli/src/ui/components/AuthDialog.tsx
index cea6727f..a33e284d 100644
--- a/packages/cli/src/ui/components/AuthDialog.tsx
+++ b/packages/cli/src/ui/components/AuthDialog.tsx
@@ -66,6 +66,11 @@ export function AuthDialog({
useInput((_input, key) => {
if (key.escape) {
+ // Prevent exit if there is an error message.
+ // This means they user is not authenticated yet.
+ if (errorMessage) {
+ return;
+ }
if (settings.merged.selectedAuthType === undefined) {
// Prevent exiting if no auth method is set
setErrorMessage(