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("ProjectDetailActivity derives a subtitle suffix from realtime connection state", async () => { const source = await readSource("../android/app/src/main/java/com/hyzq/boss/ProjectDetailActivity.java"); assert.match( source, /private String realtimeStatusLabel\(\)/, "expected chat page to centralize realtime status wording", ); assert.match( source, /return isRealtimeConnected\(\) \? "实时已连接" : "实时重连中";/, "expected chat page to distinguish healthy realtime from reconnecting state", ); }); test("ProjectDetailActivity appends realtime status to the header subtitle", async () => { const source = await readSource("../android/app/src/main/java/com/hyzq/boss/ProjectDetailActivity.java"); assert.match( source, /updateProjectHeader\(title,\s*buildProjectSubtitle\([^)]*\)\);/, "expected project chat header to still flow through updateProjectHeader", ); assert.match( source, /currentScreenSubtitle = withRealtimeStatus\(subtitle\);/, "expected current subtitle cache to include realtime status", ); assert.match( source, /configureScreen\(title,\s*currentScreenSubtitle\);/, "expected rendered subtitle to include realtime status", ); }); test("ProjectDetailActivity refreshes the subtitle when realtime connectivity changes", async () => { const source = await readSource("../android/app/src/main/java/com/hyzq/boss/ProjectDetailActivity.java"); assert.match( source, /private boolean lastKnownRealtimeConnected;/, "expected chat page to remember the last rendered realtime state", ); assert.match( source, /syncRealtimeStatusIndicator\(\);/, "expected chat page to refresh subtitle state from lifecycle and realtime hooks", ); });