Skip to content

test(marketplace): pin the agent detail page's load path - #742

Merged
philmerrell merged 1 commit into
developfrom
test/agent-detail-page-spec
Jul 25, 2026
Merged

test(marketplace): pin the agent detail page's load path#742
philmerrell merged 1 commit into
developfrom
test/agent-detail-page-spec

Conversation

@philmerrell

Copy link
Copy Markdown
Contributor

Adds the spec AgentDetailPage never had. Follow-up to #740 — that PR fixed the bug, this one
makes it impossible to reintroduce silently.

Why this is worth a PR of its own

The phase 3 bug (#740) shipped from 66f38346 until yesterday, and the reason nobody caught it
is 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/:id had never successfully loaded in a browser.

The one thing that makes this test worth having

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<string>() that the router sets
after construction — which is the entire bug. A spec that hands id in at construction time
(TestBed.createComponent with inputs pre-supplied) passes against the broken code and proves
nothing. 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.getAgent is actually called, with the bound id
  • the error banner is absent on the happy path

A zero-request page is what the bug produced, so those are the two facts that matter.

Verified both directions

Component state Result
constructor() (the bug, pre-#740) 5/5 failgetAgent "called 1 times, but got 0 times"; error() = 'Failed to load this agent.'
ngOnInit() (#740, now on develop) 5/5 pass

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=false

Coverage

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-spec
mock pollution. No production code is touched — one new file, 155 lines.

🤖 Generated with Claude Code

`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>
@philmerrell
philmerrell merged commit 8c816a3 into develop Jul 25, 2026
4 checks passed
@philmerrell
philmerrell deleted the test/agent-detail-page-spec branch July 25, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant