From 3c7fcfb6cd2d98047303b270c31c8bd5879828da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 1 Sep 2026 19:07:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=94=99=E8=AF=AF=E9=87=87?= =?UTF-8?q?=E9=9B=86=E7=8A=B6=E6=80=81=E8=BF=87=E6=BB=A4=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 覆盖预期认证四xx与可报告网络状态 --- .../ai-game-creator-shell/tests/errorReporting.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) 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();