Skip to content

Fix validation of disabled nutrition goals - #1324

Merged
rolandgeider merged 1 commit into
wger-project:masterfrom
ucod3:fix/disabled-nutrition-goal-validation
Oct 21, 2026
Merged

rolandgeider merged 1 commit into
wger-project:masterfrom
ucod3:fix/disabled-nutrition-goal-validation

Conversation

@ucod3

@ucod3 ucod3 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

Saving a nutrition plan is blocked if a goal contains an invalid value and the user then switches goals off. The field disappears, but its validation error still prevents submission.

To reproduce: enable goals, enter 7000 for energy, disable goals, and submit. This change lets the plan save with its goals cleared, as intended. It excludes disabled goals from validation and revalidates when the switch changes to clear stale field errors. Re-enabling goals preserves their values and restores validation.

Only PlanForm.tsx and its existing test file change. There are no dependency or backend changes.

Related Issue(s)

Related context: #993 and wger-project/wger#1641 established that disabled goals should be cleared from the payload. That issue is already closed; this addresses the remaining validation case rather than claiming to close it again.

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)

Validation

  • Five new regression cases failed before the fix, covering each goal field.
  • npm test -- src/components/Nutrition/widgets/forms/PlanForm.test.tsx --maxWorkers=1: 15 passing tests, including editing an existing plan and re-enabling invalid goals.
  • npm run typecheck: passed.
  • ESLint on both changed files: passed. Full npm run lint: no errors, two existing warnings in unrelated files.
  • TZ=<zone> npm run test:coverage -- --maxWorkers=2: 180 files and 1,174 tests passed in each of UTC, America/Toronto, and Asia/Kolkata.
  • Full-suite runs logged two example.com DNS errors also present in the untouched baseline; this PR does not fix those unrelated test requests.
  • git diff --check: passed.

A separate Codex reviewer reviewed the exact patch and independently reran the 15 focused tests and typecheck, reporting PASS. This draft is ready for maintainer review; no user-performed code review is claimed.

AI assistance

Implemented, inspected, and tested using the OpenAI Codex agent. The model identity exposed to the implementation session is GPT-6; a more specific serving-model identifier is not available. Independent review also used a separate Codex agent.

@ucod3
ucod3 marked this pull request as ready for review October 21, 2026 01:58
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 83.83% (+0.005%) from 83.825% — ucod3:fix/disabled-nutrition-goal-validation into wger-project:master

@rolandgeider
rolandgeider merged commit baac41a into wger-project:master Oct 21, 2026
8 checks passed
@rolandgeider

Copy link
Copy Markdown
Member

thanks!

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.

3 participants