Merge pull request #2658 from wucm667/feat/account-test-chat-completions-path

feat(account): 测试连接支持 OpenAI-compatible Chat Completions 路径
This commit is contained in:
Wesley Liddick authored and GitHub committed 2026-05-22 17:31:14 +08:00
commit a33a294970
4 files changed
+348 -10

No files matched your search

@@ -513,6 +513,12 @@ const handleEvent = (event: {
}
break
case 'status':
if (event.text) {
addLine(event.text, 'text-cyan-300')
}
break
case 'image':
if (event.image_url) {
generatedImages.value.push({
@@ -147,4 +147,46 @@ describe('AccountTestModal', () => {
mode: 'compact'
})
})
it('renders Chat Completions path status from test SSE', async () => {
const encoder = new TextEncoder()
const chunks = [
encoder.encode('data: {"type":"status","text":"已通过 /v1/chat/completions 验证"}\n\n'),
encoder.encode('data: {"type":"test_complete","success":true}\n\n')
]
global.fetch = vi.fn().mockResolvedValue({
ok: true,
body: {
getReader: () => ({
read: vi.fn().mockImplementation(() => Promise.resolve(
chunks.length > 0
? { done: false, value: chunks.shift() }
: { done: true, value: undefined }
))
})
}
} as any)
const wrapper = mount(AccountTestModal, {
props: {
show: true,
account: buildAccount()
},
global: {
stubs: {
BaseDialog: BaseDialogStub,
Select: SelectStub,
TextArea: TextAreaStub,
Icon: true
}
}
})
await flushPromises()
;(wrapper.vm as any).selectedModelId = 'gpt-5.4'
await (wrapper.vm as any).startTest()
await flushPromises()
expect(wrapper.text()).toContain('已通过 /v1/chat/completions 验证')
})
})