Files
ForgeFlow/tests/ipc-contract.test.mjs
T
NuklearRabbit 4ad698c4eb Release ForgeFlow 0.8.1
Add advanced Git and deployment workflows, secure backups and auditing, live Gitea integration, desktop notifications, connection validation, and the premium responsive UX refresh.
2026-07-26 00:42:17 +02:00

52 lines
1.5 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
test("every preload invoke channel has a registered IPC handler", async () => {
const preload = await readFile(
new URL("../preload.cjs", import.meta.url),
"utf8",
);
const ipc = await readFile(
new URL("../src/main/ipc.cjs", import.meta.url),
"utf8",
);
const invokes = [...preload.matchAll(/invoke\(\s*['"]([^'"]+)['"]/g)].map(
(match) => match[1],
);
const handlers = new Set(
[...ipc.matchAll(/register\(\s*['"]([^'"]+)['"]/g)].map(
(match) => match[1],
),
);
assert.ok(invokes.length > 40, "expected the complete renderer API surface");
assert.deepEqual(
invokes.filter((channel) => !handlers.has(channel)),
[],
);
});
test("every renderer bridge call is exposed by the preload contract", async () => {
const renderer = await readFile(
new URL("../src/renderer/app.js", import.meta.url),
"utf8",
);
const preload = await readFile(
new URL("../preload.cjs", import.meta.url),
"utf8",
);
const calls = new Set(
[...renderer.matchAll(/window\.forgeflow\.([A-Za-z0-9_]+)\s*\(/g)].map(
(match) => match[1],
),
);
const exposed = new Set(
[...preload.matchAll(/^\s{2}([A-Za-z0-9_]+):/gm)].map((match) => match[1]),
);
assert.ok(calls.size > 40, "expected the complete renderer bridge surface");
assert.deepEqual(
[...calls].filter((method) => !exposed.has(method)),
[],
);
});