fix(cli): update ModelDialog tests for composite-key model identity

Add missing getModelsConfig and getActiveRuntimeModelSnapshot mocks,
and update switchModel assertion to expect the new { baseUrl } options
object introduced in 4c4ebb81c.
This commit is contained in:
pomelo-nwu 2026-05-07 23:07:02 +08:00
parent 4c4ebb81ca
commit 2b3a8c07e6

View file

@ -70,6 +70,10 @@ const renderComponent = (
authType: AuthType.QWEN_OAUTH,
})),
),
getModelsConfig: vi.fn(() => ({
getGenerationConfig: vi.fn(() => ({ baseUrl: undefined })),
})),
getActiveRuntimeModelSnapshot: vi.fn(() => undefined),
// --- Functions used by ClearcutLogger ---
getUsageStatisticsEnabled: vi.fn(() => true),
@ -268,11 +272,9 @@ describe('<ModelDialog />', () => {
// Select a non-OAuth model (USE_OPENAI)
await childOnSelect(`${AuthType.USE_OPENAI}::gpt-4`);
expect(switchModel).toHaveBeenCalledWith(
AuthType.USE_OPENAI,
'gpt-4',
undefined,
);
expect(switchModel).toHaveBeenCalledWith(AuthType.USE_OPENAI, 'gpt-4', {
baseUrl: undefined,
});
expect(mockSettings.setValue).toHaveBeenCalledWith(
SettingScope.User,
'model.name',
@ -370,6 +372,10 @@ describe('<ModelDialog />', () => {
it('updates initialIndex when config context changes', () => {
const mockGetModel = vi.fn(() => DEFAULT_QWEN_MODEL);
const mockGetAuthType = vi.fn(() => 'qwen-oauth');
const mockGetModelsConfig = vi.fn(() => ({
getGenerationConfig: vi.fn(() => ({ baseUrl: undefined })),
}));
const mockGetActiveRuntimeModelSnapshot = vi.fn(() => undefined);
const mockSettings = {
isTrusted: true,
user: { settings: {} },
@ -393,6 +399,8 @@ describe('<ModelDialog />', () => {
authType: AuthType.QWEN_OAUTH,
})),
),
getModelsConfig: mockGetModelsConfig,
getActiveRuntimeModelSnapshot: mockGetActiveRuntimeModelSnapshot,
} as unknown as Config
}
>
@ -417,6 +425,8 @@ describe('<ModelDialog />', () => {
authType: AuthType.QWEN_OAUTH,
})),
),
getModelsConfig: mockGetModelsConfig,
getActiveRuntimeModelSnapshot: mockGetActiveRuntimeModelSnapshot,
} as unknown as Config;
rerender(