test(marketplace): pin the agent detail page's load path - #742
Merged
Conversation
`AgentDetailPage` had no spec, which is the only reason the phase 3 bug (`load()` in the constructor, fixed in f60951b) reached users: the page rendered "Failed to load this agent." with no HTTP request behind it, and nothing in CI looked. Five tests over the load path. The two that would have caught it assert that `AgentApiService.getAgent` is called with the bound id, and that the error banner is absent on the happy path — deliberately not assertions about the rendered agent, since a zero-request page is what the bug actually produced.⚠️ The component is routed through `RouterTestingHarness` with `provideRouter(routes, withComponentInputBinding())` rather than constructed directly. That is load-bearing, not ceremony: `id` is an `input.required` the router sets *after* construction, so handing it in at construction time makes every assertion here pass against the broken code too. Verified both ways — red against the constructor form (`getAgent` called 0 times), green against the fix. Services are stubbed via DI tokens rather than `vi.mock`, per the repo convention on cross-spec mock pollution. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the spec
AgentDetailPagenever had. Follow-up to #740 — that PR fixed the bug, this onemakes it impossible to reintroduce silently.
Why this is worth a PR of its own
The phase 3 bug (#740) shipped from
66f38346until yesterday, and the reason nobody caught itis entirely the missing spec: the page rendered a plausible "Failed to load this agent." banner
with no HTTP request behind it — no console error, no failed request, nothing to grep for.
/agents/:idhad never successfully loaded in a browser.The one thing that makes this test worth having
The component is routed through
RouterTestingHarnesswithprovideRouter(routes, withComponentInputBinding())rather than constructed directly.That is load-bearing, not ceremony.
idis aninput.required<string>()that the router setsafter construction — which is the entire bug. A spec that hands
idin at construction time(
TestBed.createComponentwith inputs pre-supplied) passes against the broken code and provesnothing. There's a comment saying so at the top of the file, because this is exactly the kind of
setup a future reader would try to simplify away.
The two assertions that would have caught it are deliberately not about the rendered agent:
AgentApiService.getAgentis actually called, with the bound idA zero-request page is what the bug produced, so those are the two facts that matter.
Verified both directions
constructor()(the bug, pre-#740)getAgent"called 1 times, but got 0 times";error()='Failed to load this agent.'ngOnInit()(#740, now ondevelop)Run on this branch: 5 passed. Full
src/app/agents/**suite: 8 files, 77 tests, green.npx ng test --include src/app/agents/detail/agent-detail.page.spec.ts --watch=falseCoverage
Five tests over the load path: request-issued-with-bound-id; no error banner on success;
runnability fetched separately for the same id; a failing-read negative control (without it,
"banner absent" could pass on a page incapable of rendering one); and the advisory-runnability
path, where a runnability failure must not error the whole page (D6).
Services are stubbed via DI tokens rather than
vi.mock, per the repo convention on cross-specmock pollution. No production code is touched — one new file, 155 lines.
🤖 Generated with Claude Code