Skip to content

test(ui): content-first fallback regression tests (medications + registry) — #015#1054

Merged
BigSimmo merged 4 commits into
mainfrom
claude/site-audit-quick-wins-21v9gb
Jul 22, 2026
Merged

test(ui): content-first fallback regression tests (medications + registry) — #015#1054
BigSimmo merged 4 commits into
mainfrom
claude/site-audit-quick-wins-21v9gb

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

Tests-only. Adds focused regression coverage for the content-first detail rendering shipped in #1024 — the behavior that previously had no direct unit test (only an e2e smoke on the medication page and a regression test that mocks the clients out). Closes ledger item #15. No runtime code changes.

Two new *.dom.test.tsx files (9 tests), following the existing registry-retry.dom.test.tsx pattern (vi.hoisted holder + mocked hook + render-prop children / real provider):

tests/registry-content-first.dom.test.tsx (RegistryRecordLoader)

  • Content-first: the public fixture paints during loading, not a spinner.
  • Governance safety (the CodeRabbit point on perf(ui): content-first detail pages + loading & motion quick wins #1024): a fixture's locallyVerified: true is neutralized to false in the provisional paint, then reconciled from authoritative governance when ready (unverified → false, locally_reviewed → true).
  • Owner-only slugs (no fixture) still show the spinner.

tests/medication-content-first.dom.test.tsx (MedicationRecordPage)

  • Content-first: the fallback record paints during loading, not the skeleton.
  • The live record swaps in once the fetch resolves.
  • No fallback → skeleton while loading / error state on a failed fetch.
  • Graceful: a failed live fetch keeps showing fallback content, not an error.

RAG impact: no retrieval behaviour change — tests-only, no retrieval/ranking/selection/eval or product code touched.

Verification

  • npm run typecheck — clean
  • npm run lint — clean
  • npm run test — full offline unit suite green, 9 new tests pass (the only failure is the pre-existing sandbox-only pdf-extraction-budget flake, unrelated to this change — a Python child-process timing test, no worker/PDF files touched here).
  • npm run verify:pr-local — not run in-session; the above cover this tests-only change. CI runs the full gate.

Risk and rollout

  • Risk: None — new test files only; cannot affect runtime behavior.
  • Rollback: revert the single commit.
  • Provider or production effects: None.

Notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01UbhUVWVJRwDibC2YtJ6aRX


Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Added coverage for displaying available medication and registry content immediately while fresh data loads.
    • Added coverage for replacing provisional content with live records once loading completes.
    • Added validation for loading and error states when no fallback content is available.
    • Added checks that verification status is safely reconciled with authoritative data.

…egistry

Locks in the content-first behavior shipped in #1024, including the
clinical-governance guarantee CodeRabbit flagged (no authoritative verification
badge before live governance reconciles).

registry-content-first.dom.test.tsx (RegistryRecordLoader):
- content-first: the public fixture paints during loading, not a spinner
- governance safety: a fixture's `locallyVerified` is neutralized to false in
  the provisional paint, then reconciled from authoritative governance on ready
- owner-only slugs (no fixture) still show the spinner

medication-content-first.dom.test.tsx (MedicationRecordPage):
- content-first: the fallback record paints during loading, not the skeleton
- the live record swaps in on resolve
- no fallback -> skeleton while loading / error state on a failed fetch
- graceful: a failed live fetch keeps showing fallback content, not an error

Addresses outstanding-issues #15. Tests-only; no runtime change.

Verified: typecheck, lint, and the full offline unit suite pass (9 new tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UbhUVWVJRwDibC2YtJ6aRX
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@BigSimmo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c7261bae-d6f3-43a5-a365-9dc0c40d888a

📥 Commits

Reviewing files that changed from the base of the PR and between d254eef and 39094ae.

📒 Files selected for processing (1)
  • tests/medication-content-first.dom.test.tsx
📝 Walkthrough

Walkthrough

Adds DOM test coverage for content-first fallback behavior in medication and registry record loaders, including provisional rendering, live-data replacement, validation reconciliation, loading states, and fetch-error handling.

Changes

Content-first fallback tests

Layer / File(s) Summary
Medication fallback and fetch-state coverage
tests/medication-content-first.dom.test.tsx
Mocks medication detail state and verifies fallback rendering, live-record replacement, loading and error states, and fallback retention after fetch failure.
Registry fallback and validation reconciliation
tests/registry-content-first.dom.test.tsx
Mocks registry loader state and verifies immediate fallback rendering, provisional locallyVerified neutralization, authoritative validation reconciliation, and no-fallback loading behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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 is concise and accurately summarizes the tests-only content-first regression coverage.
Description check ✅ Passed The description covers summary, verification, risk, and rollout, and matches the tests-only change.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/site-audit-quick-wins-21v9gb

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

@supabase

supabase Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@BigSimmo
BigSimmo marked this pull request as ready for review July 22, 2026 01:37
@BigSimmo
BigSimmo enabled auto-merge (squash) July 22, 2026 01:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/medication-content-first.dom.test.tsx (1)

58-63: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test doesn't actually exercise the fallback-governance neutralization on error.

This test never passes fallbackGovernance, so the guarded branch it's meant to validate — governance = data?.governance ?? (error ? undefined : fallbackGovernance) in medication-record-page.tsx — always evaluates to undefined regardless of whether the ternary's error check works correctly. If that guard regressed (e.g., dropped the error ? check entirely), this test would still pass, which undercuts the "authoritative governance reconciles" coverage claimed in the PR description.

✅ Suggested strengthening
   it("keeps showing fallback content when the live fetch fails (graceful content-first)", () => {
     hook.detail = { data: null, loading: false, error: "boom" };
-    renderPage(<MedicationRecordPage slug="example" fallbackRecord={record} />);
+    renderPage(
+      <MedicationRecordPage
+        slug="example"
+        fallbackRecord={record}
+        fallbackGovernance={{ sourceStatus: "current", validationStatus: "approved" }}
+      />,
+    );
     expect(screen.getByRole("heading", { name: record.name })).toBeInTheDocument();
     expect(screen.queryByText("boom")).not.toBeInTheDocument();
+    // fallbackGovernance must not be presented as authoritative once the fetch failed
+    expect(screen.queryByText(/locally verified/i)).not.toBeInTheDocument();
   });
🤖 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 `@tests/medication-content-first.dom.test.tsx` around lines 58 - 63, Strengthen
the test case in the “keeps showing fallback content when the live fetch fails”
block by passing a non-empty fallbackGovernance value to MedicationRecordPage,
then assert the rendered result confirms governance is neutralized when
hook.detail.error is present. Keep the existing fallback content assertions and
ensure the test would fail if the error guard in the governance reconciliation
logic were removed.
🤖 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.

Nitpick comments:
In `@tests/medication-content-first.dom.test.tsx`:
- Around line 58-63: Strengthen the test case in the “keeps showing fallback
content when the live fetch fails” block by passing a non-empty
fallbackGovernance value to MedicationRecordPage, then assert the rendered
result confirms governance is neutralized when hook.detail.error is present.
Keep the existing fallback content assertions and ensure the test would fail if
the error guard in the governance reconciliation logic were removed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5546fce9-a8a0-4f2e-b12d-08f22d00b468

📥 Commits

Reviewing files that changed from the base of the PR and between 9fb9bc7 and d254eef.

📒 Files selected for processing (2)
  • tests/medication-content-first.dom.test.tsx
  • tests/registry-content-first.dom.test.tsx

claude and others added 2 commits July 22, 2026 01:49
CodeRabbit review on #1054: the "graceful on error" test never passed
fallbackGovernance, so it did not actually exercise the
`governance = data?.governance ?? (error ? undefined : fallbackGovernance)`
guard in medication-record-page.tsx — it would still pass if the `error ?`
check were dropped.

Partial-mock medication-badges (keep all real exports so the detail body renders;
wrap medicationIdentityBadges in a call-through spy) and add two tests asserting
the exact governance the page hands down: present while loading, dropped to
undefined once the fetch fails. Now fails if the error guard regresses.

(CodeRabbit's suggested `/locally verified/i` assertion was vacuous — there is no
such text; the badge label is "Reviewed" and `isReviewed` also has record-based
logic, so asserting the governance argument via the spy is the robust signal.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UbhUVWVJRwDibC2YtJ6aRX
@BigSimmo
BigSimmo merged commit e788264 into main Jul 22, 2026
17 checks passed
@BigSimmo
BigSimmo deleted the claude/site-audit-quick-wins-21v9gb branch July 22, 2026 02:03
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.

2 participants