Skip to content

Chart only bounded mg dose ranges and cover remaining branches - #317

Open
LunaUrsa wants to merge 1 commit into
uatfrom
fix/303-dose-chart-coverage
Open

LunaUrsa wants to merge 1 commit into
uatfrom
fix/303-dose-chart-coverage

Conversation

@LunaUrsa

Copy link
Copy Markdown
Contributor

Summary

Closes #303.

Dose chart (#303). addDosages now parses each dose with a new parseDoseRangeMg util:

  • Converts ng, ug/µg, mg and g to milligrams before plotting, so 800-1500ug (0.8–1.5) and 1.5-3mg share one axis.
  • Reads both endpoints when each carries its own unit (325mg-650mg).
  • Leaves out of the chart anything that is not a bounded mass range: open-ended doses (3mg+), rates (25-50ug/hr), per-kg doses, single values, unitless and reversed ranges. Open-ended doses are no longer drawn with an invented 1.5× upper bound.
  • The table still shows every dose exactly as written. The chart is hidden when nothing can be plotted, and a caption explains that it shows bounded mg ranges only.

Unreachable code removed (to keep branch coverage meaningful under the 90% CI gate from #311):

  • DrugInfo.tsx: null guards in addDurations and the duration tooltip. durationTiming only ever holds defined entries.
  • appeal.tsx: the "unknown" ban-status fallback (hasAppeal implies appeal is set), and the status checks in canReappeal / canShowReminder (callers already filter by DENIED / RECEIVED).
  • appeal.tsx: the "Appeal Accepted!" card inside the has_appeal view. Reviewer note: it could only appear for a moment right after submitting a new appeal, while latestAppeal still held the previous accepted one and before checkBan() refreshed it. Showing "Appeal Accepted / Join Discord" there was misleading. Accepted appeals still show in the not-banned view.

Appeal token refresh. Concurrent callers share one pending refresh promise (dropped the separate isRefreshingRef flag), and the refresh interval lives in the effect's scope rather than a ref. Behavior is unchanged; new tests cover a slow ban check overlapping a refresh, and a submission sharing a background refresh.

Tests. New and extended tests bring statements, branches, functions and lines to 100%. DrugInfo.test.tsx keeps the literal tooltip assertion style from d391a7c, updated for the mg values.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / chore
  • Other (describe above)

Checklist

Test plan

  • npm run test:coverage: 29 suites, 152 tests pass; 100% statements, branches, functions and lines.
  • parseDoseRangeMg has fixtures for every form in Factsheet dose chart compares incompatible units and misparses ranges #303 (800-1500ug, 1.5-3mg, 325mg-650mg, ug/hr) plus mixed µg/mg, open-ended, per-kg, reversed and overflow cases.
  • npx eslint . and npx next build pass.
  • Not checked in a browser: the factsheet dose chart and the appeal flow were verified through the test suite only.

🤖 Generated with Claude Code

Parse factsheet dose ranges with parseDoseRangeMg: convert ng, ug/µg, mg
and g to milligrams, require two explicit endpoints, and leave open-ended
doses, rates (ug/hr), per-kg doses and reversed ranges out of the chart.
The table still shows every dose as written, and the chart is hidden when
nothing can be plotted. Closes #303.

Remove branches that could never run: the null guards in addDurations and
the duration tooltip (durationTiming only holds defined entries), the
"unknown" ban-status fallback, the redundant status checks in canReappeal
and canShowReminder (their callers already filter by status), and the
"Appeal Accepted" card in the has_appeal view.

Simplify the appeal token refresh to share one pending refresh promise and
keep the refresh interval in the effect's scope.

Add tests so statements, branches, functions and lines reach 100%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Factsheet dose chart compares incompatible units and misparses ranges

1 participant