mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 16:26:30 +00:00
fix: support grok cli compatibility routes
This commit is contained in:
@@ -59,17 +59,17 @@ function createStreamResponse(lines: string[]) {
|
||||
} as Response
|
||||
}
|
||||
|
||||
function mountModal() {
|
||||
function mountModal(account: Record<string, unknown> = {
|
||||
id: 42,
|
||||
name: 'Gemini Image Test',
|
||||
platform: 'gemini',
|
||||
type: 'apikey',
|
||||
status: 'active'
|
||||
}) {
|
||||
return mount(AccountTestModal, {
|
||||
props: {
|
||||
show: false,
|
||||
account: {
|
||||
id: 42,
|
||||
name: 'Gemini Image Test',
|
||||
platform: 'gemini',
|
||||
type: 'apikey',
|
||||
status: 'active'
|
||||
}
|
||||
account
|
||||
} as any,
|
||||
global: {
|
||||
stubs: {
|
||||
@@ -144,4 +144,42 @@ describe('AccountTestModal', () => {
|
||||
expect(preview.exists()).toBe(true)
|
||||
expect(preview.attributes('src')).toBe('data:image/png;base64,QUJD')
|
||||
})
|
||||
|
||||
it('grok 账号测试默认选择 Grok 模型', async () => {
|
||||
getAvailableModels.mockResolvedValue([
|
||||
{ id: 'grok-4.3', display_name: 'Grok 4.3' },
|
||||
{ id: 'grok-build-0.1', display_name: 'Grok Build 0.1' }
|
||||
])
|
||||
global.fetch = vi.fn().mockResolvedValue(
|
||||
createStreamResponse([
|
||||
'data: {"type":"test_start","model":"grok-4.3"}\n',
|
||||
'data: {"type":"content","text":"ok"}\n',
|
||||
'data: {"type":"test_complete","success":true}\n'
|
||||
])
|
||||
) as any
|
||||
|
||||
const wrapper = mountModal({
|
||||
id: 13,
|
||||
name: 'Grok Account',
|
||||
platform: 'grok',
|
||||
type: 'oauth',
|
||||
status: 'active'
|
||||
})
|
||||
await wrapper.setProps({ show: true })
|
||||
await flushPromises()
|
||||
|
||||
const buttons = wrapper.findAll('button')
|
||||
const startButton = buttons.find((button) => button.text().includes('admin.accounts.startTest'))
|
||||
expect(startButton).toBeTruthy()
|
||||
|
||||
await startButton!.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(global.fetch).toHaveBeenCalledTimes(1)
|
||||
const [, request] = (global.fetch as any).mock.calls[0]
|
||||
expect(JSON.parse(request.body)).toEqual({
|
||||
model_id: 'grok-4.3',
|
||||
prompt: ''
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user