refactor(api): genres → src/api modules (Effort 1)#60
Conversation
Mechanical move of the genres feature from src/hooks/queries/genres to src/api/genres, 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(api): move genres queries/mutations to src/api/genres Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
109 rules 1. genresKeys.all uses arrow
|
| export const genresKeys = { | ||
| all: () => ["genres"] as const, | ||
| }; |
There was a problem hiding this comment.
1. genreskeys.all uses arrow 📘 Rule violation ⚙ Maintainability
genresKeys.all is implemented as an arrow function, but this rule requires named/exported functions to use function declarations. Keeping arrow functions for named utilities can undermine consistent refactor style and enforcement.
Agent Prompt
## Issue description
`genresKeys.all` is a named/exported function implemented as an arrow function inside an exported object. The compliance rule requires function declaration syntax (`function Name(...) {}`) for named/exported functions.
## Issue Context
This module is part of the new `src/api/genres` structure; keep query key factories compliant while preserving the existing `genresKeys.all()` call sites.
## Fix Focus Areas
- src/api/genres/types.ts[6-8]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| import * as useGenresModule from "@/api/genres/useGenres"; | ||
|
|
||
| vi.mock("@/hooks/queries/genres/useGenres"); | ||
| vi.mock("@/api/genres/useGenres"); |
There was a problem hiding this comment.
2. Test mocks usegenres hook 📜 Skill insight ▣ Testability
GenreBadge.test.tsx mocks the internal useGenres hook module, which is an internal collaborator rather than an external system boundary. This makes the test brittle to refactors (e.g., changing which hook/component provides genres) while keeping behavior the same.
Agent Prompt
## Issue description
The test mocks an internal module (`@/api/genres/useGenres`) instead of mocking only at a system boundary. This violates the testing compliance requirement and makes the test depend on implementation details.
## Issue Context
`GenreBadge` uses `useGenres()` internally. Instead of mocking that hook, prefer testing through the component’s observable behavior by providing the real hook with a `QueryClientProvider` and seeding React Query data (or mocking the Supabase client / network boundary).
## Fix Focus Areas
- src/components/GenreBadge.test.tsx[4-6]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Triage of Qodo's two findings — both pre-existing/codebase-consistent, no behavior impact; keeping #60 a mechanical move: 1. 2. Test mocks internal No code changes here. Generated by Claude Code |
Mechanical move of the
genresfeature fromsrc/hooks/queries/genrestosrc/api/genres, 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