Repository navigation
[WRONG BRANCH] fix(gui): re-enable invalidated routing dry-runs #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,6 +250,56 @@ test("routing clears stale dry-run results when switching profiles", async () => | |
| } | ||
| }); | ||
|
|
||
| test("routing re-enables dry-run after inputs invalidate a pending request", async () => { | ||
| let releaseDryRun!: () => void; | ||
| const dryRunGate = new Promise<void>(resolve => { | ||
| releaseDryRun = resolve; | ||
| }); | ||
|
|
||
| installFetch(async (url, init) => { | ||
| if (url.endsWith("/api/routing-profiles") && (init?.method ?? "GET") === "GET") { | ||
| return Response.json({ profiles: [PROFILE] }); | ||
| } | ||
| if (url.endsWith("/api/routing-analytics")) { | ||
| return Response.json(ANALYTICS); | ||
| } | ||
| if (url.endsWith("/api/routing-profiles/dry-run") && init?.method === "POST") { | ||
| await dryRunGate; | ||
| return Response.json(DRY_RUN_OK); | ||
| } | ||
| return new Response("missing", { status: 404 }); | ||
| }); | ||
|
|
||
| const { container, root } = await mountPage(); | ||
| try { | ||
| const evaluate = [...container.querySelectorAll<HTMLButtonElement>("button")] | ||
| .find(button => button.textContent?.includes("Evaluate candidates")); | ||
|
Comment on lines
+275
to
+276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Use the locale value or a stable selector for the evaluation button. The test searches for the translated label As per path instructions, user-visible strings in 🤖 Prompt for AI AgentsSource: Path instructions |
||
| const tools = container.querySelector<HTMLInputElement>('input[type="checkbox"]'); | ||
| expect(evaluate).toBeTruthy(); | ||
| expect(tools).toBeTruthy(); | ||
|
|
||
| await act(async () => { evaluate!.click(); }); | ||
| expect(evaluate!.disabled).toBe(true); | ||
|
|
||
| await act(async () => { tools!.click(); }); | ||
| expect(evaluate!.disabled).toBe(false); | ||
|
|
||
| await act(async () => { | ||
| releaseDryRun(); | ||
| await Promise.resolve(); | ||
| }); | ||
| await tick(3); | ||
|
|
||
| expect(evaluate!.disabled).toBe(false); | ||
| expect(container.textContent).not.toContain("0.910"); | ||
| } finally { | ||
| await act(async () => { | ||
| releaseDryRun(); | ||
| root.unmount(); | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| test("routing refreshes the selected profile after reload", async () => { | ||
| let profilesPayload: unknown[] = [PROFILE]; | ||
| installFetch((url, init) => { | ||
|
|
@@ -344,4 +394,3 @@ test("routing ignores a stale load body that finishes after a newer retry", asyn | |
| }); | ||
| } | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🔵 Trivial
Confirm whether
clearDryRun()must cancel the network request.clearDryRun()resetsrunningand invalidates the generation, butrunDryRun()leaves the existingfetch()in flight. If the user starts another dry-run, the invalidated POST can run in parallel with the new POST. The generation guard prevents stale UI results, but it does not stop server-side work. If the management API performs non-trivial work, add anAbortControllerfor each run and abort it fromclearDryRun(); otherwise document that invalidation cancels only the UI result.🤖 Prompt for AI Agents