补充错误采集状态过滤测试

覆盖预期认证四xx与可报告网络状态
This commit is contained in:
2026-09-01 19:07:15 +08:00
parent de1982f84e
commit 3c7fcfb6cd
@@ -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();