import test from "node:test"; import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; async function readSource(path: string) { return readFile(new URL(path, import.meta.url), "utf8"); } test("events route enriches project conversation events with a visible home item patch", async () => { const source = await readSource("../src/app/api/v1/events/route.ts"); assert.match( source, /getConversationHomeItemForProject/, "expected realtime event route to resolve visible conversation items for project updates", ); assert.match( source, /conversationItem:\s*getConversationHomeItemForProject\(state,\s*String\(payload\.projectId \?\? ""\)\)/, "expected enriched event payload to carry a conversation item slot", ); assert.match( source, /threadConversationItem:\s*getConversationThreadItemForProject\(state,\s*String\(payload\.projectId \?\? ""\)\)/, "expected enriched event payload to carry a direct thread item slot for folder pages", ); }); test("MainActivity applies realtime conversation patches without forcing a network refresh", async () => { const [mainActivity, mapper] = await Promise.all([ readSource("../android/app/src/main/java/com/hyzq/boss/MainActivity.java"), readSource("../android/app/src/main/java/com/hyzq/boss/WechatSurfaceMapper.java"), ]); assert.match( mainActivity, /tryApplyConversationRealtimePatch\(event\)/, "expected root conversation page to try a local realtime patch before falling back to network refresh", ); assert.match( mainActivity, /WechatSurfaceMapper\.mergeConversationHomeItem\(/, "expected root conversation page to merge realtime conversation items locally", ); assert.match( mapper, /public static JSONArray mergeConversationHomeItem\(/, "expected surface mapper to expose a home-feed merge helper for realtime patches", ); });