Skip to content

Commit a5b7df9

Browse files
committed
fix(test): add getModelsConfig mock and update QWEN_OAUTH test expectations
- Add getModelsConfig() to Config mocks in gemini.test.tsx (3 failures) - Update validateNonInterActiveAuth test to expect exit for QWEN_OAUTH since validateAuthMethod now returns an error for discontinued free tier
1 parent cbfdc7b commit a5b7df9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/cli/src/gemini.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ vi.mock('./config/config.js', () => ({
4949
getQuestion: vi.fn(() => ''),
5050
isInteractive: () => false,
5151
getWarnings: vi.fn(() => []),
52+
getModelsConfig: vi.fn(() => ({ getCurrentAuthType: () => null })),
5253
} as unknown as Config),
5354
parseArguments: vi.fn().mockResolvedValue({}),
5455
isDebugMode: vi.fn(() => false),
@@ -179,6 +180,7 @@ describe('gemini.tsx main function', () => {
179180
getProjectRoot: () => '/',
180181
getOutputFormat: () => OutputFormat.TEXT,
181182
getWarnings: () => [],
183+
getModelsConfig: () => ({ getCurrentAuthType: () => null }),
182184
getSessionId: () => 'test-session-id',
183185
} as unknown as Config;
184186
});
@@ -347,6 +349,7 @@ describe('gemini.tsx main function', () => {
347349
getInputFormat: () => 'stream-json',
348350
getContentGeneratorConfig: () => ({ authType: 'test-auth' }),
349351
getWarnings: () => [],
352+
getModelsConfig: () => ({ getCurrentAuthType: () => null }),
350353
getUsageStatisticsEnabled: () => true,
351354
getSessionId: () => 'test-session-id',
352355
getOutputFormat: () => OutputFormat.TEXT,
@@ -448,6 +451,7 @@ describe('gemini.tsx main function kitty protocol', () => {
448451
getScreenReader: () => false,
449452
getGeminiMdFileCount: () => 0,
450453
getWarnings: () => [],
454+
getModelsConfig: () => ({ getCurrentAuthType: () => null }),
451455
getUsageStatisticsEnabled: () => true,
452456
getSessionId: () => 'test-session-id',
453457
} as unknown as Config);

packages/cli/src/validateNonInterActiveAuth.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('validateNonInterActiveAuth', () => {
181181
expect(refreshAuthMock).toHaveBeenCalledWith(AuthType.USE_OPENAI);
182182
});
183183

184-
it('uses configured QWEN_OAUTH if provided', async () => {
184+
it('exits with error for QWEN_OAUTH (free tier discontinued)', async () => {
185185
const nonInteractiveConfig = createMockConfig({
186186
refreshAuth: refreshAuthMock,
187187
getModelsConfig: vi.fn().mockReturnValue({
@@ -190,12 +190,12 @@ describe('validateNonInterActiveAuth', () => {
190190
getGenerationConfig: vi.fn().mockReturnValue({}),
191191
}),
192192
});
193-
await validateNonInteractiveAuth(
194-
undefined,
195-
nonInteractiveConfig,
196-
mockSettings,
193+
await expect(
194+
validateNonInteractiveAuth(undefined, nonInteractiveConfig, mockSettings),
195+
).rejects.toThrow('process.exit(1)');
196+
expect(mockWriteStderrLine).toHaveBeenCalledWith(
197+
expect.stringContaining('discontinued'),
197198
);
198-
expect(refreshAuthMock).toHaveBeenCalledWith(AuthType.QWEN_OAUTH);
199199
});
200200

201201
it('exits if validateAuthMethod returns error', async () => {

0 commit comments

Comments
 (0)