Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/cli/src/ui/auth/AuthDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ import { UIActionsContext } from '../contexts/UIActionsContext.js';
import type { UIState } from '../contexts/UIStateContext.js';
import type { UIActions } from '../contexts/UIActionsContext.js';

const discoverProviderModelsMock = vi.hoisted(() =>
vi.fn().mockResolvedValue(null),
);

vi.mock('@qwen-code/qwen-code-core', async (importOriginal) => ({
...(await importOriginal<typeof import('@qwen-code/qwen-code-core')>()),
discoverProviderModels: discoverProviderModelsMock,
}));

type UIStateOverrides = Partial<UIState> & Partial<UIState['auth']>;

type UIActionsOverrides = Partial<UIActions> & Partial<UIActions['auth']>;
Expand Down Expand Up @@ -144,6 +153,18 @@ const waitForSelectedOption = async (
);
};

const waitForText = async (
lastFrame: () => string | undefined,
expectedText: string,
) => {
await vi.waitFor(
() => {
expect(lastFrame()).toContain(expectedText);
},
{ timeout: WAIT_FOR_TIMEOUT },
);
};

const pressEnterAndWaitFor = async (
stdin: { write: (s: string) => void },
lastFrame: () => string | undefined,
Expand Down Expand Up @@ -1103,6 +1124,7 @@ describe('AuthDialog', { timeout: 15000 }, () => {
},
{ timeout: WAIT_FOR_TIMEOUT },
);
await moveDownAndWaitForSelection(stdin, lastFrame, 'Grok (xAI) API Key');
await moveDownAndWaitForSelection(stdin, lastFrame, 'MiniMax API Key');
await pressEnterAndWaitFor(
stdin,
Expand Down Expand Up @@ -1249,6 +1271,7 @@ describe('AuthDialog', { timeout: 15000 }, () => {
lastFrame,
'Alibaba ModelStudio · Step 3/3 · Model IDs',
);
await waitForText(lastFrame, 'Enter model IDs directly');
stdin.write('\r');
await vi.waitFor(
() => {
Expand Down Expand Up @@ -1329,6 +1352,7 @@ describe('AuthDialog', { timeout: 15000 }, () => {
lastFrame,
'Alibaba ModelStudio · Step 3/3 · Model IDs',
);
await waitForText(lastFrame, 'Enter model IDs directly');

// The Model IDs input is pre-filled with the saved custom model id
// (which only exists in settings, never among the built-in defaults).
Expand Down
Loading
Loading