test(chat): check run route and issue-run field without source-layout literals

Match the registered run route path and the runsForIssue select block's
runId field instead of a full JSX line and a fixed character window, so
harmless refactors do not break the guidance regression test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 committed 2026-11-07 16:09:03 -06:00
1 parent 123d7fb940
commit a490180801
1 file changed
+4 -4
@@ -998,13 +998,13 @@ describe("chat prompt policy", () => {
it("tells chat how to link execution runs to the registered run route and name their agents", () => {
const app = readFileSync(new URL("../../../ui/src/App.tsx", import.meta.url), "utf8");
expect(app).toContain('<Route path="agents/:agentId/runs/:runId" element={<AgentDetail />} />');
expect(app).toMatch(/<Route\s+path="agents\/:agentId\/runs\/:runId"/);
expect(AGENT_CHAT_DIRECTIVE).toContain("/<prefix>/agents/<agentId>/runs/<runId> using the run's returned agentId.");
// Issue run listings expose the run ID as runId, not id; the guidance must name the field each response returns.
const activity = readFileSync(new URL("../services/activity.ts", import.meta.url), "utf8");
const listing = activity.slice(activity.indexOf("runsForIssue"), activity.indexOf("runsForIssue") + 4000);
expect(listing).toContain("runId: heartbeatRuns.id,");
expect(listing).not.toMatch(/\bid: heartbeatRuns\.id\b/);
const listing = activity.match(/runsForIssue:\s*async\b[\s\S]*?\.select\(\{([\s\S]*?)\n\s*\}\)/)?.[1] ?? "";
expect(listing).toMatch(/^\s*runId:\s*heartbeatRuns\.id\s*,/m);
expect(listing).not.toMatch(/^\s*id:/m);
expect(AGENT_CHAT_DIRECTIVE).toContain("Issue run listings (GET /api/issues/{id}/runs) return the run ID as runId");
expect(AGENT_CHAT_DIRECTIVE).toContain("use id only from responses that return the run itself, such as GET /api/heartbeat-runs/{runId}");
expect(AGENT_CHAT_DIRECTIVE).not.toContain("returned agentId and id");