The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { parseStartupCrashRecords } from "./crash-log-model"; |
| 4 | |
| 5 | const BUNDLE = |
| 6 | "/Users/expo/workingdir/build/apps/mobile/ios/build/Build/Intermediates.noindex/ArchiveIntermediates/T3Code/BuildProductsPath/Release-iphoneos/main.jsbundle"; |
| 7 | const FATAL = { |
| 8 | timestamp: 1789277752000, |
| 9 | level: "error", |
| 10 | code: "JSRuntimeError", |
| 11 | message: [ |
| 12 | "ErrorRecovery fatal exception: Fatal error: Time: 1789277752033.127930", |
| 13 | "Domain: RCTErrorDomain", |
| 14 | "Code: 0", |
| 15 | "Description: Unhandled JS Exception: TypeError: Cannot read property 'defaultModelSelection' of null", |
| 16 | "", |
| 17 | "This error is located at:", |
| 18 | ` at NewTaskFlowProvider (${BUNDLE}:590585:51)`, |
| 19 | ` at NavigationProvider (${BUNDLE}:139067:3)`, |
| 20 | " at RNSSafeAreaView (<anonymous>)", |
| 21 | ].join("\n"), |
| 22 | }; |
| 23 | |
| 24 | describe("parseStartupCrashRecords", () => { |
| 25 | it("extracts the JS error and a compact component stack from a fatal entry", () => { |
| 26 | const [record] = parseStartupCrashRecords([FATAL]); |
| 27 | expect(record?.description).toBe( |
| 28 | "TypeError: Cannot read property 'defaultModelSelection' of null", |
| 29 | ); |
| 30 | expect(record?.frames).toEqual([ |
| 31 | "NewTaskFlowProvider (main.jsbundle:590585:51)", |
| 32 | "NavigationProvider (main.jsbundle:139067:3)", |
| 33 | "RNSSafeAreaView", |
| 34 | ]); |
| 35 | expect(record?.detail).toContain("Domain: RCTErrorDomain"); |
| 36 | }); |
| 37 | |
| 38 | it("ignores update-check noise and orders crashes newest first", () => { |
| 39 | const records = parseStartupCrashRecords([ |
| 40 | { timestamp: 1, level: "info", code: "NoUpdatesAvailable", message: "checked" }, |
| 41 | { ...FATAL, timestamp: 10 }, |
| 42 | { timestamp: 5, level: "error", code: "UpdateFailedToLoad", message: "nope" }, |
| 43 | { ...FATAL, timestamp: 20 }, |
| 44 | ]); |
| 45 | expect(records.map((record) => record.timestamp)).toEqual([20, 10]); |
| 46 | }); |
| 47 | }); |