Files
boss/tests/status-pages-realtime-refresh.test.ts
2026-04-07 18:00:14 +08:00

50 lines
2.0 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import path from "node:path";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
const testsDir = path.dirname(fileURLToPath(import.meta.url));
async function readWorkspaceFile(relativePath: string) {
return readFile(path.join(testsDir, "..", relativePath), "utf8");
}
test("thread detail page refreshes when context risk updates for its project", async () => {
const source = await readWorkspaceFile("src/app/threads/[threadId]/page.tsx");
assert.match(source, /import \{ RealtimeRefresh \}/, "expected thread page to import RealtimeRefresh");
assert.match(source, /projectId=\{detail\.snapshot\.projectId\}/, "expected thread page to scope realtime refresh to its project");
assert.match(source, /"project\.context_risk\.updated"/, "expected thread page to listen for context risk updates");
});
test("me and about pages refresh when OTA status changes", async () => {
const [mePage, aboutPage] = await Promise.all([
readWorkspaceFile("src/app/me/page.tsx"),
readWorkspaceFile("src/app/me/about/page.tsx"),
]);
for (const [label, source] of [
["me", mePage],
["about", aboutPage],
] as const) {
assert.match(source, /<RealtimeRefresh/, `expected ${label} page to render RealtimeRefresh`);
assert.match(source, /"ota\.updated"/, `expected ${label} page to listen for OTA updates`);
}
});
test("ops pages refresh when risk or audit status changes", async () => {
const [opsPage, auditPage] = await Promise.all([
readWorkspaceFile("src/app/me/ops/page.tsx"),
readWorkspaceFile("src/app/me/ops/audit/page.tsx"),
]);
for (const [label, source] of [
["ops", opsPage],
["audit", auditPage],
] as const) {
assert.match(source, /<RealtimeRefresh/, `expected ${label} page to render RealtimeRefresh`);
assert.match(source, /"project\.context_risk\.updated"/, `expected ${label} page to listen for risk updates`);
}
});