Skip to content

fix: repair cross-package hook import, aria-label forwarding, and AU date format - #152

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2188-1788538740
Open

fix: repair cross-package hook import, aria-label forwarding, and AU date format#152
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2188-1788538740

Conversation

@stooit

@stooit stooit commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. Before: 8 pass / 5 fail and 5 tsc errors. After: 13 pass / 0 fail and tsc --noEmit is clean (exit 0).

Four source files changed; no test files modified and no dependencies added (per task constraints).

Fixes

  • apps/web/src/lib/api.ts — the useThrottle import no longer existed in @e2e/utils after the hook was renamed to useDebounce. Updated the import to useDebounce and collapsed the duplicate @e2e/utils imports. The useSearchDebounce alias export (which api.test.ts asserts on) is preserved. useThrottle was only ever a name — the underlying hook was always a trailing-edge debounce — so there is no behavioural regression.
  • packages/ui/src/components/Button/Button.tsxaria-label was not forwarded to the underlying <button>. It is now applied, with a fallback label for icon-only buttons that lack an explicit label plus a dev-only console.warn (WCAG 2.2 SC 4.1.2). Text buttons receive aria-label={undefined}, so no spurious attribute is rendered.
  • packages/utils/src/format/date.tsformatDate produced 01/03/2024; the test requires the day without a leading zero (1/03/2024). Rewrote using Intl.DateTimeFormat().formatToParts to strip the day's leading zero while keeping the en-AU DD/MM/YYYY shape. formatDateTime is byte-identical (untouched).
  • tsconfig.json — added bun-types to the types array so import ... from "bun:test" in the test files resolves (cleared all TS2307 errors). bun-types was already a devDependency.

Verification

bun run test                     -> 13 pass, 0 fail
./node_modules/.bin/tsc --noEmit -> exit 0, no output

No files under */test/ were modified; no package.json/lockfile changes.

Assumptions

  • Kept the day-only leading-zero strip for formatDate (1/03/2024) because it satisfies the test with a 4-digit year. dateStyle: "short" would give 1/3/24 (2-digit year) — avoided to prevent a potential regression against the year format.
  • Used a non-null fallback aria-label for unlabelled icon-only buttons because the test asserts aria-label is not.toBeNull(); the test could not be modified.

Follow-ups (out of scope — not required by any test)

Raised by review, deliberately deferred to keep this change to "fix only what the tests require":

  1. formatDate day/month zero-padding is a D/MM hybrid and inconsistent with formatDateTime; and neither function pins a timeZone, so output is host-zone dependent (pre-existing).
  2. Button's "Button" fallback label satisfies the test but conveys no purpose; the warning keys off the iconOnly flag rather than actual absence of text, and fires in the render body. Worth revisiting alongside the test assertion.
  3. DataTable.tsx still carries a BUG: docblock about a stale closure; its 3 tests pass and the claim appears inaccurate.
  4. bun-types is pinned to "latest" — worth pinning for reproducible builds.

… format

- api.ts: import useDebounce instead of the removed useThrottle after the
  package rename; keep the useSearchDebounce alias the test asserts on
- Button: forward aria-label and add an icon-only fallback label with a
  dev-only warning (WCAG 2.2 SC 4.1.2)
- formatDate: strip the day's leading zero for the en-AU locale via
  Intl formatToParts (1/03/2024, not 01/03/2024)
- tsconfig: add bun-types to the types array so bun:test resolves

Fixes all 5 failing tests; tsc --noEmit is clean.
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.

1 participant