Skip to content

test: fix Prisma mock drift for pulse-league + article + tracks - #53

Merged
Tatenda merged 1 commit into
developfrom
chore/fix-prisma-mock-tests
May 26, 2026
Merged

test: fix Prisma mock drift for pulse-league + article + tracks#53
Tatenda merged 1 commit into
developfrom
chore/fix-prisma-mock-tests

Conversation

@Tatenda

@Tatenda Tatenda commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes 26 failing tests caused by Prisma mock drift after recent service refactors. Scope is limited to test files only — no schema, migration, jest.setup.js, or src/lib/mcp/* changes.

  • pulse-league-service.test.ts (25 cases): getLatestEligibilityScores was refactored from groupBy + N×findFirst into a single $queryRaw (DISTINCT ON) for perf. Tests still mocked the old shape, so every case threw _db.prisma.$queryRaw is not a function. Added $queryRaw to the prisma mock plus a mockEligibilityScores(scores) helper that seeds the raw rows directly, and replaced all the old groupBy/findFirst setup blocks with calls to it.
  • article-service.test.ts (1 case): getArticleBySlug now reads from prisma.contentLink to resolve linked tool slugs. The mock didn't include contentLink, so the slug-lookup case threw Cannot read properties of undefined (reading findMany). Added contentLink.findMany (resolves to []) to the mock.
  • tracks/route.test.ts: investigated — already passing as-is. No change needed.

All 82 tests across the three suites pass locally. tsc --noEmit is clean for these files (the only error is a pre-existing missing docs-index.generated.json in src/lib/mcp/, which is in active PR review on #48 and outside scope).

Test plan

  • yarn test src/lib/services/__tests__/pulse-league-service.test.ts --ci — 34/34 pass
  • yarn test src/lib/services/__tests__/article-service.test.ts --ci — 45/45 pass
  • yarn test src/app/api/tracks/__tests__/route.test.ts --ci — 3/3 pass
  • CI confirms no regressions in other suites

🤖 Generated with Claude Code

pulse-league-service: getLatestEligibilityScores was refactored from
groupBy + N×findFirst into a single $queryRaw (DISTINCT ON). Tests
still mocked the old shape. Add $queryRaw to the prisma mock and a
mockEligibilityScores helper, replacing all groupBy/findFirst setup
across the 25 affected cases.

article-service: getArticleBySlug now reads from prisma.contentLink to
resolve linked tool slugs. Mock contentLink.findMany so the slug
lookup test stops throwing 'Cannot read properties of undefined
(reading findMany)'.

tracks/route: already passing — no change needed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel

vercel Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
music-next Building Building Preview, Comment May 26, 2026 7:27pm

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1dc5856c-d3af-4685-a90a-8d4df382867d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/fix-prisma-mock-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Tatenda
Tatenda merged commit ae87a88 into develop May 26, 2026
3 of 5 checks passed
@Tatenda
Tatenda deleted the chore/fix-prisma-mock-tests branch May 26, 2026 19:30
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