From 5ab20aa50371a99b7a4e0f206c8f03fdeabb6f75 Mon Sep 17 00:00:00 2001 From: mateaix <7333791@qq.com> Date: Tue, 15 Sep 2026 11:10:33 +0800 Subject: [PATCH] test(ui): isolate team run SSE subscription --- mateclaw-ui/src/composables/chat/__tests__/useTeamRuns.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mateclaw-ui/src/composables/chat/__tests__/useTeamRuns.test.ts b/mateclaw-ui/src/composables/chat/__tests__/useTeamRuns.test.ts index 59b28bc8..4f114851 100644 --- a/mateclaw-ui/src/composables/chat/__tests__/useTeamRuns.test.ts +++ b/mateclaw-ui/src/composables/chat/__tests__/useTeamRuns.test.ts @@ -26,6 +26,7 @@ function axiosResponse(data: T): AxiosResponse { describe('useTeamRuns', () => { it('uses the paged conversation API for the first page and cursor continuation', async () => { + const fetch = vi.spyOn(globalThis, 'fetch').mockRejectedValue(new Error('offline SSE fixture')) const page = vi.spyOn(teamRunApi, 'listByConversationPage') .mockResolvedValueOnce(axiosResponse({ items: [run('2')], nextCursor: 'older' })) .mockResolvedValueOnce(axiosResponse({ items: [run('1')], nextCursor: null })) @@ -38,6 +39,7 @@ describe('useTeamRuns', () => { expect(page).toHaveBeenNthCalledWith(1, 'lead', { limit: 20 }) expect(page).toHaveBeenNthCalledWith(2, 'lead', { cursor: 'older', limit: 20 }) expect(legacy).not.toHaveBeenCalled() + expect(fetch).toHaveBeenCalledOnce() expect(state.runs.value.map(item => item.id)).toEqual(['2', '1']) scope.stop() vi.restoreAllMocks()