refactor(api): stages → src/api modules (Effort 1)#62
Conversation
Mechanical move of the stages feature from src/hooks/queries/stages to src/api/stages, adding queryOptions factories for the query hooks. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K513rsQz6Lg1HbbfYiafrE
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Summary by QodoRefactor stages queries into src/api/stages with queryOptions factories Description
Diagram
High-Level Assessment
Files changed (25)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
109 rules 1. Test mocks useStageQuery
|
| import * as useStageQueryModule from "@/api/stages/useStageQuery"; | ||
|
|
||
| type StageQueryResult = ReturnType<typeof useStageQueryModule.useStageQuery>; | ||
|
|
||
| vi.mock("@/hooks/queries/stages/useStageQuery"); | ||
| vi.mock("@/api/stages/useStageQuery"); |
There was a problem hiding this comment.
2. Test mocks usestagequery 📜 Skill insight ▣ Testability
StagePin.test.tsx mocks the internal hook module @/api/stages/useStageQuery, which violates the requirement to only mock at external system boundaries. This makes the test couple to internal module structure and breaks under internal refactors.
Agent Prompt
## Issue description
The test mocks an internal collaborator (`@/api/stages/useStageQuery`) via `vi.mock(...)`, which violates the rule that mocks must be used only at system boundaries.
## Issue Context
Instead of mocking `useStageQuery`, render `StagePin` with a real `QueryClientProvider` and seed the query cache for `stagesKeys.byId(stageId)` (or mock the external boundary, e.g., Supabase network calls, via a boundary-level approach).
## Fix Focus Areas
- src/components/StagePin.test.tsx[4-8]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
… key normalization Two deviations the mechanical move introduced: - types.ts re-exported Stage from sets (violates no-export-from rule); restore the original local definition (Database stages Row), as on main. - useStageQuery/useStagesByEdition switched stagesKeys.byId(stageId || "") to stageQuery(stageId!); restore ?? "" so the disabled-state key matches main (stageId can be null). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K513rsQz6Lg1HbbfYiafrE
|
Triage of Qodo's three findings — two were real deviations the move introduced (now fixed in 1. 3. 2. Lint/build/290 tests green after the fix. Generated by Claude Code |
Mechanical move of the
stagesfeature fromsrc/hooks/queries/stagestosrc/api/stages, addingqueryOptionsfactories for the query hooks. No behavior change. Part of #52.Manual verification
pnpm run lint && pnpm test && pnpm run buildall pass.Generated by Claude Code