Skip to content

test(mobile): mock useMealTypes in DiaryScreen tests - #2108

Merged
CodeWithCJ merged 1 commit into
mainfrom
dev
Aug 13, 2026
Merged

test(mobile): mock useMealTypes in DiaryScreen tests#2108
CodeWithCJ merged 1 commit into
mainfrom
dev

Conversation

@CodeWithCJ

@CodeWithCJ CodeWithCJ commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Fixes a TypeError in DiaryScreen.test.tsx where DiaryScreen component invocations threw "useMealTypes is not a function".

DiaryScreen calls useMealTypes() to resolve meal section labels, but the test file's explicit mock of src/hooks did not include useMealTypes.

Related to PR #2063

Tip

Help us review and merge your PR faster!
Please ensure you have completed the Checklist below.
For Frontend changes, please run pnpm run validate to check for any errors.
PRs that include tests and clear screenshots are highly preferred!
Note: AI-generated descriptions must be manually edited for conciseness. Do not paste raw AI summaries.

Description

What problem does this PR solve?
(Keep it concise. 1–2 sentences.)

How did you implement the solution?
(Brief technical approach.)

Linked Issue: Closes #

How to Test

  1. Check out this branch and run ...
  2. Navigate to...
  3. Verify that...

PR Type

  • Issue (bug fix)
  • New Feature
  • Refactor
  • Documentation

Checklist

All PRs:

  • [MANDATORY - ALL] Integrity & License: I certify this is my own work, free of malicious code, and I agree to the License terms.

New features only:

  • [MANDATORY for new feature] Alignment: I have raised a GitHub issue and it was reviewed/approved by maintainers or it was approved on Discord.

Frontend changes (SparkyFitnessFrontend/):

  • [MANDATORY for Frontend changes] Quality: I have run pnpm run validate and it passes.
  • [MANDATORY for Frontend changes] Translations: I have only updated the English (en) translation file.

Backend changes (SparkyFitnessServer/):

  • [MANDATORY for Backend changes] Code Quality: I have run typecheck, lint, and tests. New files use TypeScript, new endpoints have Zod schemas, and new endpoints include tests.
  • [MANDATORY for Backend changes] Database Security: I have updated rls_policies.sql for any new user-specific tables.

UI changes (components, screens, pages):

  • [MANDATORY for UI changes] Screenshots: I have attached Before/After screenshots below.

Mobile changes (SparkyFitnessMobile/):

  • [MANDATORY for Mobile changes] Tested on device or emulator: I have verified the changes work on iOS or Android.

Screenshots

Click to expand

Before

before

After

after

Notes for Reviewers

Optional — use this for anything that doesn't fit above: known tradeoffs, areas you'd like specific feedback on, qustions you have or context that helps reviewers.

Fixes a TypeError in DiaryScreen.test.tsx where DiaryScreen component
invocations threw "useMealTypes is not a function".

DiaryScreen calls useMealTypes() to resolve meal section labels, but
the test file's explicit mock of src/hooks did not include useMealTypes.
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

PR Validation Results

Change Detection

  • 📱 Mobile changes detected

⚠️ Recommendations (1)

  • Please link a related GitHub issue (Linked Issue: Closes #123).

✅ All required checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f42fda02-fd6e-4d42-8946-815a97c7877a

📥 Commits

Reviewing files that changed from the base of the PR and between 77ade33 and 3f5b02b.

📒 Files selected for processing (1)
  • SparkyFitnessMobile/__tests__/screens/DiaryScreen.test.tsx

📝 Walkthrough

Walkthrough

The DiaryScreen test setup now includes a default useMealTypes mock that returns an empty list without loading or error states.

Changes

DiaryScreen test setup

Layer / File(s) Summary
Add meal types mock
SparkyFitnessMobile/__tests__/screens/DiaryScreen.test.tsx
The test mocks useMealTypes with no meal types and inactive loading and error states.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Mergeability Score: ⚪ Minimal · up to 3f5b0

This PR adds the missing hook mock needed by DiaryScreen tests and does not change production behavior. No actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested reviewers: dragonk

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the mobile test change: mocking useMealTypes in DiaryScreen tests.
Description check ✅ Passed The description explains the TypeError and fix, and records relevant testing and PR-type details despite some unfilled template placeholders.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

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.

@CodeWithCJ
CodeWithCJ merged commit 26f79b4 into main Aug 13, 2026
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mobile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant