Files
boss/tests/config-pages-realtime-refresh.test.ts
2026-04-07 18:26:17 +08:00

48 lines
1.9 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
async function readSource(relativePath: string) {
return readFile(new URL(`../${relativePath}`, import.meta.url), "utf8");
}
test("ai accounts page refreshes when AI account state changes", async () => {
const source = await readSource("src/app/me/ai-accounts/page.tsx");
assert.match(source, /import \{ RealtimeRefresh \}/, "expected ai accounts page to import RealtimeRefresh");
assert.match(source, /<RealtimeRefresh/, "expected ai accounts page to render RealtimeRefresh");
assert.match(
source,
/events=\{\["ai_accounts\.updated"\]\}/,
"expected ai accounts page to refresh on ai_accounts.updated",
);
});
test("storage page refreshes when storage config changes", async () => {
const source = await readSource("src/app/me/storage/page.tsx");
assert.match(source, /import \{ RealtimeRefresh \}/, "expected storage page to import RealtimeRefresh");
assert.match(source, /<RealtimeRefresh/, "expected storage page to render RealtimeRefresh");
assert.match(
source,
/events=\{\["storage\.updated"\]\}/,
"expected storage page to refresh on storage.updated",
);
});
test("master agent settings pages refresh when master agent config changes", async () => {
for (const relativePath of [
"src/app/me/master-agent/page.tsx",
"src/app/me/master-agent/takeover/page.tsx",
]) {
const source = await readSource(relativePath);
assert.match(source, /import \{ RealtimeRefresh \}/, `expected ${relativePath} to import RealtimeRefresh`);
assert.match(source, /<RealtimeRefresh/, `expected ${relativePath} to render RealtimeRefresh`);
assert.match(
source,
/events=\{\["master_agent\.settings\.updated"\]\}/,
`expected ${relativePath} to refresh on master_agent.settings.updated`,
);
}
});