Add unattended end-to-end self-test mode for the production webview
VOICED_SELFTEST_OUT runs the Diagnostics checks plus an issue, archive, export (searchable, flattened, re-render), cancel and archive-immutability flow through the real IPC, writes a JSON report and exits. Inert without the variable; doubles as the per-release gate on installed builds.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { bytesEqual, createStepLog, dirOf } from "./selfTestSteps";
|
||||
|
||||
describe("createStepLog", () => {
|
||||
it("records passes, expectation failures and throws without throwing itself", async () => {
|
||||
let t = 0;
|
||||
const log = createStepLog(() => (t += 10));
|
||||
await log.run("a", async () => "fine");
|
||||
await log.run("b", async () => ({ ok: false, detail: "wrong" }));
|
||||
await log.run("c", async () => {
|
||||
throw new Error("boom");
|
||||
});
|
||||
expect(log.steps).toEqual([
|
||||
{ name: "a", ok: true, ms: 10, detail: "fine" },
|
||||
{ name: "b", ok: false, ms: 10, detail: "wrong" },
|
||||
{ name: "c", ok: false, ms: 10, detail: "Error: boom" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("dirOf / bytesEqual", () => {
|
||||
it("splits posix and windows paths", () => {
|
||||
expect(dirOf("/tmp/x/report.json")).toBe("/tmp/x");
|
||||
expect(dirOf("C:\\out\\report.json")).toBe("C:\\out");
|
||||
expect(dirOf("/report.json")).toBe("/");
|
||||
expect(dirOf("report.json")).toBe("");
|
||||
});
|
||||
it("compares bytes", () => {
|
||||
expect(bytesEqual(new Uint8Array([1, 2]), new Uint8Array([1, 2]))).toBe(true);
|
||||
expect(bytesEqual(new Uint8Array([1, 2]), new Uint8Array([1, 3]))).toBe(false);
|
||||
expect(bytesEqual(new Uint8Array([1]), new Uint8Array([1, 2]))).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user