Skip to content

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

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

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

Conversation

@philmerrell

Copy link
Copy Markdown
Contributor

What

Adds agent-detail.page.spec.ts — the file whose absence let the phase 3 bug fixed in #740 reach users. AgentDetailPage had no spec at all, so a page that rendered "Failed to load this agent." with no HTTP request behind it looked fine to CI.

Five tests over the load path:

  • requests the agent the router bound to id
  • does not show the error banner when the read succeeds
  • asks for runnability separately, for the same id
  • shows the error banner when the read actually fails
  • keeps the page when only runnability fails

The two that would have caught the original bug assert that AgentApiService.getAgent is called with the bound id, and that the banner is absent on the happy path — deliberately not assertions about the rendered agent, because a zero-request page is what the bug actually produced.

The load-bearing part

⚠️ The component is routed through RouterTestingHarness with provideRouter(routes, withComponentInputBinding()) rather than constructed directly. That is not ceremony: id is an input.required that 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.

Please keep that shape if this spec is ever refactored; a TestBed.createComponent with inputs pre-supplied silently stops testing the thing that broke.

Services are stubbed via DI tokens rather than vi.mock, per the repo convention on cross-spec mock pollution.

Verification

npm test (i.e. ng test — there is no standalone vitest config, so a bare npx vitest run fails wholesale and is not the right invocation):

Depends on

#740 (merged) — the ngOnInit fix these tests pin.

Deploy

None. Test-only; no runtime code touched.

🤖 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 94bf615 into develop Jul 25, 2026
4 checks passed
@philmerrell
philmerrell deleted the test/agent-detail-page-load-spec branch July 25, 2026 21:13
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