Skip to content

refactor(tests): migrate backend and gadget tests to shared mocks#1005

Merged
aaight merged 2 commits intodevfrom
feature/backend-gadget-shared-mocks-69c1676685872a809b421334
Mar 23, 2026
Merged

refactor(tests): migrate backend and gadget tests to shared mocks#1005
aaight merged 2 commits intodevfrom
feature/backend-gadget-shared-mocks-69c1676685872a809b421334

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 23, 2026

Summary

  • Created tests/helpers/backendMocks.ts with shared mock objects for file logger, cascadeEnv, repo utils, session state, and agent logger
  • Migrated adapter.test.ts to use mockFileLoggerModule, mockCascadeEnvModule, mockRepoModule, mockSessionStateModule, mockAgentLoggerModule from backendMocks.ts and mockSentryModule, mockLifecycleModule from sharedMocks.ts
  • Migrated agent-profiles.test.ts to use mockGitHubClientModule from sharedMocks.ts instead of an inline github client mock
  • Migrated tests/unit/gadgets/github.test.ts to use mockGitHubClientModule from sharedMocks.ts

Test plan

  • npx vitest run --project unit-backends — all 812 tests pass
  • npx vitest run --project unit-core — all 3751 tests pass
  • npm run lint — no errors
  • npm run typecheck — no errors
  • No test logic or assertions were changed — pure refactor

Card: https://trello.com/c/69c1676685872a809b421334

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — Clean test mock consolidation that follows established sharedMocks.ts patterns. All changes are mechanical (moving inline mock definitions to shared helpers) with no test logic modifications. Verified:

  • backendMocks.ts mock shapes match the replaced inline definitions exactly
  • mockGitHubClientModule from sharedMocks.ts is a superset of both replaced inline GitHub client mocks (in agent-profiles.test.ts and github.test.ts), so no mock coverage is lost
  • The Sentry assertion migration from mockCaptureException to mockSentryModule.captureException correctly references the same underlying vi.fn()
  • Import reordering in github.test.ts (moving module imports below vi.mock() calls) is correct and aligns with Vitest hoisting semantics
  • All CI checks pass

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit b5b0a2f into dev Mar 23, 2026
9 checks passed
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.

2 participants