38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
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 message events with a lightweight project chat payload", async () => {
|
|
const source = await readSource("../src/app/api/v1/events/route.ts");
|
|
|
|
assert.match(
|
|
source,
|
|
/projectMessagesPayload:\s*buildProjectMessagesRealtimePayload\(state,\s*String\(payload\.projectId \?\? ""\)\)/,
|
|
"expected realtime event route to include a lightweight project chat payload for message events",
|
|
);
|
|
});
|
|
|
|
test("ProjectDetailActivity applies lightweight realtime chat payloads before scheduling reloads", async () => {
|
|
const source = await readSource("../android/app/src/main/java/com/hyzq/boss/ProjectDetailActivity.java");
|
|
|
|
assert.match(
|
|
source,
|
|
/if \(tryApplyRealtimeMessagesPatch\(event\)\) \{\s*return;\s*\}/,
|
|
"expected chat page to try a local realtime message patch before falling back to debounced reloads",
|
|
);
|
|
assert.match(
|
|
source,
|
|
/JSONObject projectMessagesPayload = event\.payload\.optJSONObject\("projectMessagesPayload"\);/,
|
|
"expected chat page to read the lightweight message payload from realtime events",
|
|
);
|
|
assert.match(
|
|
source,
|
|
/renderLoadedProjectSnapshot\(new ProjectSnapshot\(projectMessagesPayload,\s*null,\s*null\)\);/,
|
|
"expected chat page to render the local realtime payload without forcing a network request",
|
|
);
|
|
});
|