Files
Voiced/src/lib/selfTestSteps.test.ts
T
xavierk 92904f169c 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.
2026-10-04 06:17:04 +05:30

34 lines
1.3 KiB
TypeScript

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);
});
});