Files
boss/tests/project-chat-page-realtime-events.test.ts

21 lines
874 B
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));
const projectChatPagePath = path.join(testsDir, "../src/app/conversations/[projectId]/page.tsx");
test("project chat page listens to conversation updates for realtime refresh", async () => {
const source = await readFile(projectChatPagePath, "utf8");
const realtimeRefreshConfig = source.match(/<RealtimeRefresh[\s\S]*?events=\{\[([\s\S]*?)\]\}/);
assert.ok(realtimeRefreshConfig, "expected project chat page to declare RealtimeRefresh events");
assert.match(
realtimeRefreshConfig[1],
/"conversation\.updated"/,
"expected project chat page to refresh when conversation.updated is emitted",
);
});