diff --git a/apps/ai-game-creator-shell/tests/errorReporting.test.ts b/apps/ai-game-creator-shell/tests/errorReporting.test.ts index ccb91162d..671fde789 100644 --- a/apps/ai-game-creator-shell/tests/errorReporting.test.ts +++ b/apps/ai-game-creator-shell/tests/errorReporting.test.ts @@ -22,6 +22,7 @@ import { installWebviewLogBridge, markClientErrorEventsSubmitted, resetClientErrorEventsForTests, + shouldCaptureClientError, submitErrorReportBatch, } from '../src/services/errorReporting'; @@ -80,6 +81,15 @@ describe('客户端错误报告池', () => { expect(fetchClientHttp).not.toHaveBeenCalled(); }); + it('只采集网络错误、408 和 5xx', () => { + expect(shouldCaptureClientError({ status: 400 })).toBe(false); + expect(shouldCaptureClientError({ status: 401 })).toBe(false); + expect(shouldCaptureClientError({ status: 429 })).toBe(false); + expect(shouldCaptureClientError({ status: 408 })).toBe(true); + expect(shouldCaptureClientError({ status: 503 })).toBe(true); + expect(shouldCaptureClientError({ networkError: true })).toBe(true); + }); + it('将 WebView console 输出写入普通文本日志 command', async () => { const consoleInfo = vi.spyOn(console, 'info').mockImplementation(() => {}); const uninstall = installWebviewLogBridge();