- Electron crash handlers (render-process-gone, child-process-gone, unresponsive/responsive, process warnings) with a circuit-breaker auto-reload for renderer crashes - Renderer error capture (window.onerror, unhandledrejection, React ErrorBoundary) forwarded to the main log via a one-way IPC channel - Memory-pressure heartbeat measured against the V8 heap_size_limit - Gated DEBUG log level (RD_DEBUG) and an in-memory ring of recent WARN/ERROR lines, exposed via the /errors endpoint and support bundle - Disk-error classification (ENOSPC etc.) on download failures and integrity-check pass/fail logging
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { classifyDiskError } from "../src/main/fs-error";
|
|
import { isDebugFlagEnabled } from "../src/main/logger";
|
|
|
|
describe("classifyDiskError", () => {
|
|
it("maps ENOSPC from an error code to a disk-full reason", () => {
|
|
const err = Object.assign(new Error("write ENOSPC"), { code: "ENOSPC" });
|
|
expect(classifyDiskError(err)).toMatch(/Festplatte voll/);
|
|
});
|
|
|
|
it("maps EACCES from a code to a permission reason", () => {
|
|
const err = Object.assign(new Error("nope"), { code: "EACCES" });
|
|
expect(classifyDiskError(err)).toMatch(/Zugriff verweigert/);
|
|
});
|
|
|
|
it("lower-case codes are normalized", () => {
|
|
const err = Object.assign(new Error("x"), { code: "enospc" });
|
|
expect(classifyDiskError(err)).toMatch(/ENOSPC/);
|
|
});
|
|
|
|
it("falls back to scanning the message text when no code is present", () => {
|
|
expect(classifyDiskError(new Error("operation failed: ENOSPC on volume"))).toMatch(/Festplatte voll/);
|
|
});
|
|
|
|
it("handles a plain string error", () => {
|
|
expect(classifyDiskError("EROFS: read-only file system")).toMatch(/schreibgeschützt/);
|
|
});
|
|
|
|
it("returns null for an unrelated error", () => {
|
|
expect(classifyDiskError(new Error("write_drain_timeout"))).toBeNull();
|
|
expect(classifyDiskError(new Error("premature close"))).toBeNull();
|
|
expect(classifyDiskError(null)).toBeNull();
|
|
expect(classifyDiskError(undefined)).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("isDebugFlagEnabled", () => {
|
|
it("is true for affirmative values", () => {
|
|
for (const v of ["1", "true", "TRUE", "yes", "on", " on "]) {
|
|
expect(isDebugFlagEnabled(v)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("is false for empty/negative/garbage values", () => {
|
|
for (const v of [undefined, "", "0", "false", "off", "no", "maybe"]) {
|
|
expect(isDebugFlagEnabled(v)).toBe(false);
|
|
}
|
|
});
|
|
});
|