返回 DeepSeek-Reasonix
firebase_crash_view.test.ts
根目录 / workers / crash-report / src / firebase_crash_view.test.ts
1 import { describe, expect, it } from "vitest";
2 import { firebaseMeta, firebaseSamples, type FirebaseGroupRow } from "./firebase_crash_view";
3
4 describe("Firebase diagnostic read conversion", () => {
5 it("preserves structured attribution and event identity", () => {
6 const diagnostics = {
7 subjectVersion: "v1.38.7",
8 subjectBuildCommit: "subject-build",
9 subjectChannel: "stable",
10 observerVersion: "v1.38.10",
11 incidentId: "incident-1",
12 };
13 const reports = firebaseSamples({
14 first: {
15 eventId: "a".repeat(32),
16 receivedAt: "2026-09-18T00:00:00Z",
17 groupCount: 1,
18 writerGeneration: 1,
19 sampleEpoch: 1,
20 version: "v1.38.10",
21 buildCommit: "observer-build",
22 channel: "stable",
23 errorFamily: "react.maximum_update_depth",
24 diagnostics,
25 },
26 });
27
28 expect(reports).toHaveLength(1);
29 expect(reports[0]).toMatchObject({
30 version: "v1.38.7",
31 build_commit: "subject-build",
32 channel: "stable",
33 error_family: "react.maximum_update_depth",
34 event_id: "a".repeat(32),
35 incident_id: "incident-1",
36 });
37 expect(JSON.parse(reports[0]!.diagnostics ?? "{}")).toEqual(diagnostics);
38 });
39
40 it("carries regression metadata into Firebase group snapshots", () => {
41 const row = {
42 fingerprint: "f".repeat(64),
43 kind: "crash",
44 count: 2,
45 first_seen: "2026-09-17T00:00:00Z",
46 last_seen: "2026-09-18T00:00:00Z",
47 first_version: "v1.38.7",
48 last_version: "v1.38.10",
49 status: "resolved",
50 title: "failure",
51 source: "react",
52 label: "",
53 error_type: "Error",
54 top_frame: "render",
55 severity: "high",
56 last_os: "windows",
57 last_arch: "amd64",
58 last_build_commit: "build",
59 last_channel: "stable",
60 regressed_at: "",
61 regression_review: "suspected",
62 resolution_platform: "windows",
63 resolution_runtime: "electron",
64 resolution_basis: "fixed by change 123",
65 last_category: "crash",
66 } satisfies FirebaseGroupRow;
67
68 expect(firebaseMeta(row)).toMatchObject({
69 regressionReview: "suspected",
70 resolutionPlatform: "windows",
71 resolutionRuntime: "electron",
72 resolutionBasis: "fixed by change 123",
73 lastCategory: "crash",
74 });
75 });
76 });
77
77 lines TYPESCRIPT