mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-04 20:00:00 +08:00
test(aiCore): 更新客户端兼容性测试的mock数据
添加isOpenAIModel等mock函数用于测试 修复AnthropicVertexClient的mock路径 添加注释说明服务层不应调用React Hook
This commit is contained in:
parent
aaa56da614
commit
4cf239f165
@ -21,6 +21,7 @@ vi.mock('@renderer/config/models', () => ({
|
|||||||
anthropic: [],
|
anthropic: [],
|
||||||
gemini: []
|
gemini: []
|
||||||
},
|
},
|
||||||
|
isOpenAIModel: vi.fn().mockReturnValue(true),
|
||||||
isOpenAILLMModel: vi.fn().mockReturnValue(true),
|
isOpenAILLMModel: vi.fn().mockReturnValue(true),
|
||||||
isOpenAIChatCompletionOnlyModel: vi.fn().mockReturnValue(false),
|
isOpenAIChatCompletionOnlyModel: vi.fn().mockReturnValue(false),
|
||||||
isAnthropicLLMModel: vi.fn().mockReturnValue(false),
|
isAnthropicLLMModel: vi.fn().mockReturnValue(false),
|
||||||
@ -73,6 +74,7 @@ vi.mock('@logger', () => ({
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// 到底是谁想出来的在服务层调用 React Hook ?????????
|
||||||
// Mock additional services and hooks that might be imported
|
// Mock additional services and hooks that might be imported
|
||||||
vi.mock('@renderer/hooks/useVertexAI', () => ({
|
vi.mock('@renderer/hooks/useVertexAI', () => ({
|
||||||
getVertexAILocation: vi.fn().mockReturnValue('us-central1'),
|
getVertexAILocation: vi.fn().mockReturnValue('us-central1'),
|
||||||
@ -80,7 +82,9 @@ vi.mock('@renderer/hooks/useVertexAI', () => ({
|
|||||||
getVertexAIServiceAccount: vi.fn().mockReturnValue({
|
getVertexAIServiceAccount: vi.fn().mockReturnValue({
|
||||||
privateKey: 'test-key',
|
privateKey: 'test-key',
|
||||||
clientEmail: 'test@example.com'
|
clientEmail: 'test@example.com'
|
||||||
})
|
}),
|
||||||
|
isVertexAIConfigured: vi.fn().mockReturnValue(true),
|
||||||
|
isVertexProvider: vi.fn().mockReturnValue(true)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
vi.mock('@renderer/hooks/useSettings', () => ({
|
vi.mock('@renderer/hooks/useSettings', () => ({
|
||||||
@ -124,7 +128,7 @@ vi.mock('@google-cloud/vertexai', () => ({
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
// Mock the circular dependency between VertexAPIClient and AnthropicVertexClient
|
// Mock the circular dependency between VertexAPIClient and AnthropicVertexClient
|
||||||
vi.mock('@renderer/aiCore/clients/anthropic/AnthropicVertexClient', () => {
|
vi.mock('@renderer/aiCore/legacy/clients/anthropic/AnthropicVertexClient', () => {
|
||||||
const MockAnthropicVertexClient = vi.fn()
|
const MockAnthropicVertexClient = vi.fn()
|
||||||
MockAnthropicVertexClient.prototype.getClientCompatibilityType = vi.fn().mockReturnValue(['AnthropicVertexAPIClient'])
|
MockAnthropicVertexClient.prototype.getClientCompatibilityType = vi.fn().mockReturnValue(['AnthropicVertexAPIClient'])
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user