Skip to content

test(web): add unit tests for usage format helpers - #79

Merged
wolfiesch merged 1 commit into
LycaonLLC:mainfrom
dylantirandaz:test/usage-format-unit-tests
Jul 19, 2026
Merged

test(web): add unit tests for usage format helpers#79
wolfiesch merged 1 commit into
LycaonLLC:mainfrom
dylantirandaz:test/usage-format-unit-tests

Conversation

@dylantirandaz

@dylantirandaz dylantirandaz commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

What this changes

Adds one colocated test file, apps/web/src/features/usage/format.test.ts, covering the previously untested pure formatter module apps/web/src/features/usage/format.ts. No source changes — this PR adds tests for previously untested behavior only.

Coverage pins the exact output strings of the observable contract:

  • formatDuration: 'a few seconds' below 5s, negative clamping, pluralization, and the s → m → h → day rounding boundaries (59s/60s, 59m/60m, 47h/48h → 2 days).
  • ageLabel: future timestamps ('in X'), the ±5s 'just now' window, and past 'X ago'.
  • usageAmountLabel: used/limit vs remaining-only vs fraction-only rendering, the 'No amount reported' fallback, percent precision (2 decimals below 1%, 1 decimal at/above), byte thresholds at exact GiB/MiB/KiB/B boundaries, USD formatting, and unit suffixes (tokens/requests/min).
  • limitDisplayName: tier/window suffix appending, case-insensitive dedup, and 'quota window' suppression.
  • resetLabel: null cases, passed resets, future countdown.
  • capacityLabel: account pluralization.
  • savedResetLabel: null/zero cases, pluralization, expiry parsing with unparseable/past/due-now filtering, sort order, and the 'next expires in X' suffix.
  • reportIdentityDetail: org/plan composition and account-label dedup.

Verfication

  • pnpm --filter @t4-code/web test — 72 files, 1029 tests passed (includes the new file).
  • pnpm check — passes (release contract, provenance, lint --deny-warnings, typecheck).
  • Did not run the full repo pnpm test; per project notes, the pre-existing packages/client transcript-retention test failure on main is unrelated to this change.

Checklist

  • pnpm check passes (release contract, provenance, lint, typecheck)
  • pnpm test passes; new behavior has a test that fails without this change (this PR is the tests; no source behavior changed)
  • Any pasted logs or screenshots are redacted: no secrets, tokens, pairing codes, or private paths
  • Ported code (T3 Code / OMP) follows the provenance rules in THIRD_PARTY_NOTICES.md

@wolfiesch
wolfiesch force-pushed the test/usage-format-unit-tests branch from 4220cb6 to 787b75b Compare July 19, 2026 22:31
@wolfiesch
wolfiesch force-pushed the test/usage-format-unit-tests branch from 787b75b to aa366a9 Compare July 19, 2026 22:38
@wolfiesch
wolfiesch merged commit 185ea8b into LycaonLLC:main Jul 19, 2026
4 checks passed
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