Skip to content

test(ci): repair 3 pre-existing test failures on main - #286

Closed
samxu01 wants to merge 1 commit into
mainfrom
fix/ci-pre-existing-failures
Closed

test(ci): repair 3 pre-existing test failures on main#286
samxu01 wants to merge 1 commit into
mainfrom
fix/ci-pre-existing-failures

Conversation

@samxu01

@samxu01 samxu01 commented May 3, 2026

Copy link
Copy Markdown
Contributor

Why

`Test & Coverage` has red-barred every PR since #275 due to three test files that drifted from legitimate production refactors:

Test file Tests failing Root cause
`podController.test.js` 4 Controller added `isBot` to populate signature; `joinPod` requires `DM_POD_TYPES_GUARD` at runtime
`dmService.test.ts` 2 `f9ff990c23` changed agent-room naming to displayName chain; tests still asserted old ` ()` format
`registry.list-agents-config.test.js` 1 (timeout) Route added User/DMService/AgentIdentityService deps; test didn't mock them, real Mongoose User.find queued forever

What

podController.test.js

  • Update populate expectations to `'username profilePicture isBot'`
  • Add `DM_POD_TYPES_GUARD: new Set(['agent-room', 'agent-dm'])` to the agentIdentityService jest mock so `joinPod`'s runtime require returns the guard rather than `{}`

dmService.test.ts

  • Fixture: add `botMetadata.displayName: 'task-clerk'` so the resolution chain returns the expected label
  • Replace `names the room with instanceId suffix` (asserts dead format) with two intent-aligned tests: displayName overrides function args, instanceId is the fallback when displayName missing and instanceId is non-default

registry.list-agents-config.test.js

  • Add jest mocks for `models/User`, `services/dmService`, `services/agentIdentityService` (the route's other deps)

Test plan

  • `Test & Coverage` job goes green for the 7 previously-failing tests
  • No new failures introduced

🤖 Generated with Claude Code

These have been red-barring every PR for the last week — fixes catch the
test fixtures up to recent legitimate refactors of the production code.

1. podController.test.js — 4 failures
   - createPod / removeMember / joinPod populate assertions: controller
     added `isBot` to the `members` populate signature
     (`'username profilePicture isBot'`); update both expectations.
   - joinPod 403 third-person guard: controller now does
     `require('../services/agentIdentityService').DM_POD_TYPES_GUARD`
     at runtime per ADR-001 §3.10. The test-level mock of
     agentIdentityService omitted the guard set, so the require returned
     `{}` and `.has()` threw before reaching the 403 path. Add
     `DM_POD_TYPES_GUARD: new Set(['agent-room', 'agent-dm'])` to the
     mock so the test exercises the real guard.
   - joinPod regular-pod regression test: same root cause; same fix.

2. dmService.test.ts — 2 failures
   - f9ff990 changed agent-room labels from `<runtime> (<instance>)`
     to the User.botMetadata.displayName chain. Tests still asserted the
     old format. Update the fixture to set displayName, replace the
     stale "names the room with instanceId suffix" test with two
     intent-aligned ones (displayName overrides function args; instanceId
     is the fallback when displayName missing and instanceId is non-default).

3. registry.list-agents-config.test.js — 1 timeout (10s)
   - GET /pods/:podId/agents calls User.find, dmService.canViewPod, and
     AgentIdentityService.buildAgentUsername. None were jest-mocked in
     this test, so User.find queued forever against an unconnected real
     Mongoose model and the test timed out at 10s. Add the three mocks.

All three failures are stale-test, not stale-code — production behavior
is correct; tests just hadn't kept up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samxu01

samxu01 commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Squash-merged locally to preserve Sam Xu attribution. Closing.

samxu01 added a commit that referenced this pull request May 3, 2026
Test & Coverage was red on every PR since #275 due to stale fixtures, not
stale code. Three test files updated:

1. podController.test.js — populate signatures now include `isBot`; add
   DM_POD_TYPES_GUARD to agentIdentityService jest mock so joinPod's
   runtime require resolves the ADR-001 §3.10 guard.

2. dmService.test.ts — agent-room labels now come from User.botMetadata
   .displayName (per f9ff990) instead of `<runtime> (<instance>)`.
   Update fixture and replace one stale test with two intent-aligned
   ones (displayName overrides args; instanceId is fallback).

3. registry.list-agents-config.test.js — add jest mocks for User,
   dmService, agentIdentityService so the 10s timeout (Mongoose
   User.find against unconnected DB) goes away.

Pure test repair, zero production changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samxu01 samxu01 closed this May 3, 2026
@samxu01
samxu01 deleted the fix/ci-pre-existing-failures branch May 3, 2026 23:42
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