Repository navigation
Wire PRT program-rules fixtures into Storybook - #24
Conversation
…d Programme demos Replaces the ANC/Child Programme Storybook demos with an event-program-rules and a tracker-program-rules demo driven by the new PRT fixtures, which exercise nearly every program-rule action type. Adds a metadata-export denormalizer since the fixtures are flat metadata-export packages rather than the pre-joined shape the resolvers expect, threads `optionGroups` into `useEventForm` so HIDEOPTIONGROUP/SHOWOPTIONGROUP have something to resolve against, and adds an optional Feedback slot to the shared form components for DISPLAYTEXT/DISPLAYKEYVALUEPAIR. Also fixes a Mantine adapter bug found via the new stories: D2BooleanField passed field.value straight to SegmentedControl, so an unset boolean field fell back to Mantine's first-item default and silently rendered as "Yes". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 53 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded event and tracker program-rule fixtures, metadata resolvers, shared adapter interactions, and Storybook stories for DHIS2 UI, Mantine, and MUI. Added optional form feedback and option-group support. Removed legacy Storybook examples and interactions. ChangesProgram-rules Storybook coverage
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant StorybookPlay
participant ProgrammeEventForm
participant useEventForm
participant MetadataFixture
participant Feedback
StorybookPlay->>ProgrammeEventForm: Render form and enter rule inputs
ProgrammeEventForm->>useEventForm: Update event values
useEventForm->>MetadataFixture: Resolve program rules and option groups
MetadataFixture-->>useEventForm: Return resolved metadata
useEventForm-->>ProgrammeEventForm: Apply visibility, validation, and assignments
ProgrammeEventForm->>Feedback: Render feedback and indicators
StorybookPlay->>ProgrammeEventForm: Submit form
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Stale comment
Left a non-blocking comment: Cursor Security Agent finished as skipped, so required automated security review did not complete successfully and this PR is not approved. Cursor Bugbot was not present on the PR checks. Human review is needed; no reviewers were assigned because the only assignable user is the PR author.
Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
apps/storybook/interactions/eventProgramRulesInteractions.ts (1)
68-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the shared adapter helpers into one module.
MANTINE_BOOLEAN_SEGMENT_VALUE,clickMantineBooleanSegment,pickBooleanOption,findFeedbackText,canvasOf,Canvas,StoryPlayContext, andStoryPlayare duplicated inapps/storybook/interactions/trackerProgramRulesInteractions.ts. The two copies have already diverged: this file resolves the portalled dhis2-ui option withscreen.findByTexton Line 104, while the tracker copy useswithin(document.body).findByText.
.fallowrc.jsonignores onlyapps/storybook/stories/**and setsminOccurrences: 3, so a two-file clone stays invisible to the duplication check.Move these helpers into a shared module, for example
apps/storybook/interactions/adapterHelpers.ts, and parameterize the adapter union once.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/storybook/interactions/eventProgramRulesInteractions.ts` around lines 68 - 116, Extract MANTINE_BOOLEAN_SEGMENT_VALUE, clickMantineBooleanSegment, pickBooleanOption, findFeedbackText, canvasOf, Canvas, StoryPlayContext, and StoryPlay into a shared adapterHelpers module, defining the adapter union there once. Update both eventProgramRulesInteractions.ts and trackerProgramRulesInteractions.ts to import and reuse these helpers, preserving the existing DHIS2 portalled-option behavior and removing the duplicated definitions.apps/storybook/fixtures/metadataExport.ts (1)
439-453: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the raw fixture object casts with
satisfies.
buildRawEventProgramConfigandbuildRawTrackerConfigboth return shaped objects already annotated withRawEventProgramConfigResultandRawTrackerConfigResult; theascasts bypass structural checks if either raw config type changes. Usesatisfiesat these return sites so shape drift fails at compile time.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/storybook/fixtures/metadataExport.ts` around lines 439 - 453, Replace the `as RawEventProgramConfigResult` cast on the object returned by `buildRawEventProgramConfig` with a `satisfies RawEventProgramConfigResult` check, and make the same change for the return object in `buildRawTrackerConfig` using `RawTrackerConfigResult`. Preserve the existing object shapes while ensuring TypeScript validates them structurally.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/storybook/fixtures/tracker-program-rules-example.json`:
- Around line 748-766: Update the fixture so section ykSoYFhrMb1 is attached to
follow-up stage xizfjWb34Ed: add the stage reference to the section and include
the section ID in that stage’s programStageSections list. Preserve the existing
HIDESECTION rule PRT-T16 so the tracker demo renders and covers its target; only
remove the section and rule if the fixture intentionally omits stage-level
forms.
In `@apps/storybook/interactions/eventProgramRulesInteractions.ts`:
- Around line 212-237: The fallback branch of showWarningAboveHundred in
apps/storybook/interactions/eventProgramRulesInteractions.ts lines 212-237 must
assert NUMBER_EXCEEDS_WARNING rather than rechecking the input value. Apply the
same change to the fallback branch of the corresponding age-warning play in
apps/storybook/interactions/trackerProgramRulesInteractions.ts lines 156-181,
asserting AGE_IMPLAUSIBLE_WARNING; add adapter-specific warning selectors if
mantine or mui render the warning differently, without replacing these checks
with input-value assertions.
---
Nitpick comments:
In `@apps/storybook/fixtures/metadataExport.ts`:
- Around line 439-453: Replace the `as RawEventProgramConfigResult` cast on the
object returned by `buildRawEventProgramConfig` with a `satisfies
RawEventProgramConfigResult` check, and make the same change for the return
object in `buildRawTrackerConfig` using `RawTrackerConfigResult`. Preserve the
existing object shapes while ensuring TypeScript validates them structurally.
In `@apps/storybook/interactions/eventProgramRulesInteractions.ts`:
- Around line 68-116: Extract MANTINE_BOOLEAN_SEGMENT_VALUE,
clickMantineBooleanSegment, pickBooleanOption, findFeedbackText, canvasOf,
Canvas, StoryPlayContext, and StoryPlay into a shared adapterHelpers module,
defining the adapter union there once. Update both
eventProgramRulesInteractions.ts and trackerProgramRulesInteractions.ts to
import and reuse these helpers, preserving the existing DHIS2 portalled-option
behavior and removing the duplicated definitions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 03e75e56-430f-44bb-ae9a-335d7d9b73dd
📒 Files selected for processing (38)
.claude/launch.json.fallowrc.jsonapps/storybook/components/ProgrammeEventForm.tsxapps/storybook/components/ProgrammeRegistrationForm.tsxapps/storybook/decorators/withEventForm.tsxapps/storybook/fixtures/anc.event.jsonapps/storybook/fixtures/anc.stage.jsonapps/storybook/fixtures/anc.tsapps/storybook/fixtures/child-programme.event.jsonapps/storybook/fixtures/child-programme.stage.jsonapps/storybook/fixtures/child-programme.tracker.jsonapps/storybook/fixtures/childProgramme.tsapps/storybook/fixtures/event-program-rules-example.jsonapps/storybook/fixtures/eventProgramRules.tsapps/storybook/fixtures/metadataExport.tsapps/storybook/fixtures/tracker-program-rules-example.jsonapps/storybook/fixtures/trackerProgramRules.tsapps/storybook/interactions/ancInteractions.tsapps/storybook/interactions/childProgrammeInteractions.tsapps/storybook/interactions/childProgrammeRegistrationInteractions.tsapps/storybook/interactions/eventProgramRulesInteractions.tsapps/storybook/interactions/trackerProgramRulesInteractions.tsapps/storybook/stories/dhis2-ui/AncForm.stories.tsxapps/storybook/stories/dhis2-ui/ChildProgrammeForm.stories.tsxapps/storybook/stories/dhis2-ui/ChildProgrammeRegistrationForm.stories.tsxapps/storybook/stories/dhis2-ui/EventProgramRulesForm.stories.tsxapps/storybook/stories/dhis2-ui/TrackerProgramRulesForm.stories.tsxapps/storybook/stories/mantine/AncForm.stories.tsxapps/storybook/stories/mantine/ChildProgrammeForm.stories.tsxapps/storybook/stories/mantine/ChildProgrammeRegistrationForm.stories.tsxapps/storybook/stories/mantine/EventProgramRulesForm.stories.tsxapps/storybook/stories/mantine/TrackerProgramRulesForm.stories.tsxapps/storybook/stories/mui/AncForm.stories.tsxapps/storybook/stories/mui/ChildProgrammeForm.stories.tsxapps/storybook/stories/mui/ChildProgrammeRegistrationForm.stories.tsxapps/storybook/stories/mui/EventProgramRulesForm.stories.tsxapps/storybook/stories/mui/TrackerProgramRulesForm.stories.tsxcomponents/mantine/src/fields/widgets/ChoiceFields.tsx
💤 Files with no reviewable changes (19)
- apps/storybook/fixtures/anc.ts
- apps/storybook/stories/mui/AncForm.stories.tsx
- apps/storybook/fixtures/anc.event.json
- apps/storybook/fixtures/child-programme.tracker.json
- apps/storybook/fixtures/anc.stage.json
- apps/storybook/fixtures/child-programme.event.json
- apps/storybook/interactions/childProgrammeInteractions.ts
- apps/storybook/stories/mantine/AncForm.stories.tsx
- apps/storybook/stories/mantine/ChildProgrammeForm.stories.tsx
- apps/storybook/stories/mantine/ChildProgrammeRegistrationForm.stories.tsx
- apps/storybook/stories/dhis2-ui/AncForm.stories.tsx
- apps/storybook/interactions/childProgrammeRegistrationInteractions.ts
- apps/storybook/stories/dhis2-ui/ChildProgrammeForm.stories.tsx
- apps/storybook/stories/dhis2-ui/ChildProgrammeRegistrationForm.stories.tsx
- apps/storybook/stories/mui/ChildProgrammeRegistrationForm.stories.tsx
- apps/storybook/stories/mui/ChildProgrammeForm.stories.tsx
- apps/storybook/interactions/ancInteractions.ts
- apps/storybook/fixtures/childProgramme.ts
- apps/storybook/fixtures/child-programme.stage.json
…ixture The "Hideable follow-up section" (ykSoYFhrMb1) had no programStage back- reference, and the Follow-up stage listed no programStageSections, so the PRT-T16 HIDESECTION rule pointed at a section no stage could ever render. Mirrors the event fixture's section<->stage linkage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Left a non-blocking comment: Cursor Security Agent finished as skipped, so required automated security review did not complete successfully and this PR is not approved. Cursor Bugbot was not present on the PR checks. Human review is needed; no reviewers were assigned because the only assignable collaborator is the PR author.
Sent by Cursor Approval Agent: Pull Request Router and Approver


Summary
event-program-rules-example.json/tracker-program-rules-example.json), which exercise nearly every program-rule action type (HIDEFIELD, HIDESECTION, ASSIGN, SETMANDATORYFIELD, SHOWWARNING/SHOWERROR, HIDEOPTION/HIDEOPTIONGROUP/SHOWOPTIONGROUP, DISPLAYTEXT/DISPLAYKEYVALUEPAIR), across all 3 UI adapters (dhis2-ui, mantine, mui).apps/storybook/fixtures/metadataExport.ts, a denormalizer that turns the fixtures' flat DHIS2 metadata-export shape into the pre-joined shaperesolveEventProgramMetadata/resolveTrackerProgramMetadataexpect (no existing helper did this).optionGroupsintowithEventForm/useEventFormso HIDEOPTIONGROUP/SHOWOPTIONGROUP have group-membership data to resolve against, and adds an optionalFeedbackslot toProgrammeEventForm/ProgrammeRegistrationFormfor DISPLAYTEXT/DISPLAYKEYVALUEPAIR.D2BooleanFieldpassedfield.valuestraight to Mantine'sSegmentedControl, so an unset boolean field (nodefaultValuessupplied) silently fell back to Mantine's first-item default and rendered as "Yes".storybookentry to.claude/launch.jsonand scopes.fallowrc.json's duplication check away fromapps/storybook/stories/**(the per-adapter story trio pattern is intentional repo-wide duplication).Test plan
pnpm --filter storybook test— 101/101 interaction tests pass across dhis2-ui/mantine/muipnpm typecheck— clean across all workspace packagespnpm lint— clean (eslint + prettier) on all touched filesfallow audit— passes (no newly introduced dead code, complexity, or duplication)🤖 Generated with Claude Code
Summary by CodeRabbit