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("ProjectChatUiState tracks dispatch execution ids for reply wait after confirming a group dispatch", async () => { const source = await readSource("../android/app/src/main/java/com/hyzq/boss/ProjectChatUiState.java"); assert.match( source, /public final List executionIds;/, "expected ReplyWaitSpec to retain the dispatch execution ids it is waiting on", ); assert.match( source, /JSONArray executions = response\.optJSONArray\("executions"\);/, "expected dispatch confirm wait resolution to inspect the executions returned by the server", ); assert.match( source, /collectExecutionIds\(executions\)/, "expected dispatch confirm wait resolution to normalize execution ids into the wait spec", ); assert.match( source, /hasTrackedDispatchExecutionReply\(\s*@Nullable JSONArray dispatchPlans,\s*@Nullable List executionIds\s*\)/, "expected a helper that checks reply progress against tracked dispatch executions", ); }); test("ProjectDetailActivity polls dispatch reply waits against tracked execution ids instead of only latest message id", async () => { const source = await readSource("../android/app/src/main/java/com/hyzq/boss/ProjectDetailActivity.java"); assert.match( source, /enqueueReplyWaitPoll\(waitSpec,\s*includeDispatchPlans\);/, "expected reply wait polling to receive the full wait spec, not just a baseline message id", ); assert.match( source, /private void pollUntilReply\(\s*ProjectChatUiState\.ReplyWaitSpec waitSpec,\s*boolean includeDispatchPlans\s*\)/, "expected pollUntilReply to read the richer wait spec", ); assert.match( source, /ProjectChatUiState\.hasTrackedDispatchExecutionReply\(snapshot\.dispatchPlans,\s*waitSpec\.executionIds\)/, "expected reply polling to use tracked dispatch executions when waiting on group replies", ); });