Skip to content

fix: nih account expiry warning says "1 days" (#1109) - #1140

Merged
frano-m merged 1 commit into
mainfrom
frano-m/1109-nih-expiry-singular-day
Oct 22, 2026
Merged

frano-m merged 1 commit into
mainfrom
frano-m/1109-nih-expiry-singular-day

Conversation

@frano-m

@frano-m frano-m commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1109

What changed

  • getExpiryMessage now says "1 day" when the rounded-up count is 1 and "N days" otherwise.
  • getExpireTimeInDays and getExpiryMessage moved out of nihAccountExpiryWarning.tsx into a sibling utils.ts (per CODING_STANDARDS: no functions in component files) and are exported so they can be unit-tested. The component now destructures useAuthenticationNIHExpiry() directly (the || {} fallback was unreachable).
  • New unit tests: tests/nihAccountExpiryWarningUtils.test.ts (frozen clock; under a day, exactly a day, just over a day, several days, expired, missing/past timestamp).
  • New Storybook stories for NIHAccountExpiryWarning — Expired, ExpiresInDays, ExpiresInOneDay — that mock TerraProfileContext so the real hook runs. They are also picked up by the a11y suite.

Why

getExpireTimeInDays rounds up, so any link expiring within 24 hours rendered "will expire in 1 days". Found in the #1038 review.

Assumptions I made

  • Rounding up is kept as-is: a link expiring in 30 minutes still reads "1 day", and 24h + 1 minute reads "2 days". Changing that is a product call outside this issue.
  • A count of 0 (only reachable in a millisecond race, or without a timestamp, which the component never shows) stays plural: "0 days". Pre-existing behaviour.
  • A plain days === 1 ternary rather than a shared/Intl.PluralRules helper — this is the only count-plus-noun message in the library.
  • Story timestamps are computed relative to Date.now() at module load, so a Storybook left open for many hours will drift. Fine for a demo; not used for visual snapshots.

How to verify

  1. npm test -- tests/nihAccountExpiryWarningUtils.test.ts — all tests pass.
  2. npm run storybook, open NIHAccountExpiryWarning (under the Export component path):
    • Expires In One Day → "…will expire in 1 day."
    • Expires In Days → "…will expire in 3 days."
    • Expired → "…has expired."

Definition of done:

  • The warning reads "1 day" for a single day and "N days" otherwise. → step 2 (Expires In One Day / Expires In Days), and step 1.
  • A test covers the singular and plural messages. → step 1.

Screenshots

  • findable-ui-1109-expires-in-one-day.png — Expires In One Day story: "will expire in 1 day."
  • findable-ui-1109-expires-in-days.png — Expires In Days story: "will expire in 3 days."
  • findable-ui-1109-expired.png — Expired story: "has expired."
  • findable-ui-1109-expiry-warning-stories.gif — clicking through the three stories in Storybook.

🤖 Generated with Claude Code
🐦 Built with cc-claude-tools

findable-ui-1109-expired findable-ui-1109-expires-in-days findable-ui-1109-expires-in-one-day findable-ui-1109-expiry-warning-stories

Copilot AI balanced review requested due to automatic review settings October 21, 2026 05:24
@frano-m
frano-m marked this pull request as ready for review October 21, 2026 05:26

Copilot AI 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.

🟢 Approval recommended

Static review found no blocking issues in this focused fix with regression coverage; tests were not executed.

No open issues 🎉

What changed in this PR

Fixes #1109 by using “1 day” in the NIH account expiry warning while preserving existing rounding behavior.

Changes:

  • Extracts expiry helpers into a testable utility module.
  • Adds regression tests for singular, plural, and expiry boundary cases.
  • Adds three Storybook examples for expired and expiring links.
File Description
tests/​nihAccountExpiryWarningUtils.test.ts Adds frozen-clock regression tests.
src/​components/​Export/​components/​ExportToTerra/​components/​TerraSetUpForm/​components/​NIHAccountExpiryWarning/​utils.ts Extracts helpers and fixes pluralization.
src/​components/​Export/​components/​ExportToTerra/​components/​TerraSetUpForm/​components/​NIHAccountExpiryWarning/​stories/​nihAccountExpiryWarning.stories.tsx Adds three warning stories.
src/​components/​Export/​components/​ExportToTerra/​components/​TerraSetUpForm/​components/​NIHAccountExpiryWarning/​stories/​args.ts Provides mock Terra profile contexts.
src/​components/​Export/​components/​ExportToTerra/​components/​TerraSetUpForm/​components/​NIHAccountExpiryWarning/​nihAccountExpiryWarning.tsx Uses extracted helpers and removes an unnecessary fallback.

Review effort: Balanced

@NoopDog NoopDog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Fran, looks good.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 04:29
@frano-m
frano-m force-pushed the frano-m/1109-nih-expiry-singular-day branch from b710e1d to 99eb682 Compare October 22, 2026 04:29

Copilot AI 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.

🟢 Approval recommended

The focused fix satisfies the issue with regression coverage and no identified blocking issues; automated checks were not run during this review.

No open issues 🎉

Review effort: Balanced

@frano-m
frano-m merged commit a9ae53e into main Oct 22, 2026
3 checks passed
@frano-m
frano-m deleted the frano-m/1109-nih-expiry-singular-day branch October 22, 2026 04:37
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.

NIH account expiry warning says "1 days"

3 participants