mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 04:00:36 +00:00
This commit is contained in:
parent
d820c2335b
commit
925d747b9d
13 changed files with 40 additions and 382 deletions
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
||||
import { aboutCommand } from './aboutCommand.js';
|
||||
import type { CommandContext } from './types.js';
|
||||
import { type CommandContext } from './types.js';
|
||||
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
|
||||
import * as versionUtils from '../../utils/version.js';
|
||||
import { MessageType } from '../types.js';
|
||||
|
||||
import type { IdeClient } from '@google/gemini-cli-core';
|
||||
import type { IdeClient } from '../../../../core/src/ide/ide-client.js';
|
||||
|
||||
vi.mock('../../utils/version.js', () => ({
|
||||
getCliVersion: vi.fn(),
|
||||
|
|
@ -29,11 +29,10 @@ describe('aboutCommand', () => {
|
|||
getModel: vi.fn(),
|
||||
getIdeClient: vi.fn(),
|
||||
getIdeMode: vi.fn().mockReturnValue(true),
|
||||
getGeminiClient: vi.fn(),
|
||||
},
|
||||
settings: {
|
||||
merged: {
|
||||
selectedAuthType: 'oauth-gca',
|
||||
selectedAuthType: 'test-auth',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -53,11 +52,6 @@ describe('aboutCommand', () => {
|
|||
vi.spyOn(mockContext.services.config!, 'getIdeClient').mockReturnValue({
|
||||
getDetectedIdeDisplayName: vi.fn().mockReturnValue('test-ide'),
|
||||
} as Partial<IdeClient> as IdeClient);
|
||||
vi.spyOn(mockContext.services.config!, 'getGeminiClient').mockReturnValue({
|
||||
getUserTier: vi.fn().mockReturnValue(undefined),
|
||||
} as unknown as ReturnType<
|
||||
NonNullable<typeof mockContext.services.config>['getGeminiClient']
|
||||
>);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
@ -89,10 +83,9 @@ describe('aboutCommand', () => {
|
|||
osVersion: 'test-os',
|
||||
sandboxEnv: 'no sandbox',
|
||||
modelVersion: 'test-model',
|
||||
selectedAuthType: 'oauth-gca',
|
||||
selectedAuthType: 'test-auth',
|
||||
gcpProject: 'test-gcp-project',
|
||||
ideClient: 'test-ide',
|
||||
userTier: undefined,
|
||||
},
|
||||
expect.any(Number),
|
||||
);
|
||||
|
|
@ -132,14 +125,11 @@ describe('aboutCommand', () => {
|
|||
});
|
||||
|
||||
it('should not show ide client when it is not detected', async () => {
|
||||
// Change to oauth type that doesn't use GCP project
|
||||
mockContext.services.settings.merged.selectedAuthType = 'oauth';
|
||||
|
||||
vi.spyOn(mockContext.services.config!, 'getIdeClient').mockReturnValue({
|
||||
getDetectedIdeDisplayName: vi.fn().mockReturnValue(undefined),
|
||||
} as Partial<IdeClient> as IdeClient);
|
||||
|
||||
process.env['SANDBOX'] = '';
|
||||
process.env.SANDBOX = '';
|
||||
if (!aboutCommand.action) {
|
||||
throw new Error('The about command must have an action.');
|
||||
}
|
||||
|
|
@ -153,8 +143,8 @@ describe('aboutCommand', () => {
|
|||
osVersion: 'test-os',
|
||||
sandboxEnv: 'no sandbox',
|
||||
modelVersion: 'test-model',
|
||||
selectedAuthType: 'oauth',
|
||||
gcpProject: '',
|
||||
selectedAuthType: 'test-auth',
|
||||
gcpProject: 'test-gcp-project',
|
||||
ideClient: '',
|
||||
}),
|
||||
expect.any(Number),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue