Skip to content

fix: repair failing tests across ui/utils/web packages - #146

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2234-1788327549
Open

fix: repair failing tests across ui/utils/web packages#146
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2234-1788327549

Conversation

@stooit

@stooit stooit commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. Baseline was 8 pass / 5 fail plus 5 type errors; now 13 pass / 0 fail and tsc --noEmit is clean.

Four cross-package bugs plus one test-config fix:

  • apps/web/src/lib/api.ts — imported useThrottle from @e2e/utils, but that hook was renamed to useDebounce. Updated the import and the useSearchDebounce re-export alias. (Fixes TS2305 + runtime crash.)
  • packages/ui/.../Button.tsx — the destructured aria-label prop was never applied to the element. Now applied; icon-only buttons fall back to their string children (or "Button") and emit a dev-mode warning when unlabelled (WCAG 2.2 SC 4.1.2). Text buttons resolve to undefined so their visible text remains the accessible name.
  • packages/utils/.../date.tsformatDate produced a zero-padded day (01/03/2024); the contract is D/MM/YYYY with an unpadded day. Assembled from Intl.DateTimeFormat.formatToParts under en-AU. (dateStyle: "short" deliberately avoided — it would drop the year to 2 digits.)
  • packages/ui/.../DataTable.tsx — sort-direction toggle read a stale sortDir from its closure; switched to the functional setSortDir(prev => ...) form so it always reads the latest committed value (matters under React 18 automatic batching).
  • tsconfig.json — added "types": ["bun-types"] so bun:test resolves in the test files (fixes 4× TS2307).

Testing

  • bun test --preload ./packages/ui/test/setup.ts13 pass, 0 fail
  • npx tsc --noEmit → clean (exit 0)
  • No test files were modified.

Assumptions & notes

  • formatDate now returns variable-width day (1/03/2024 vs 15/06/2024), as the test mandates. Only in-repo consumer is the api.ts re-export; no fixed-width formatting depends on it.
  • The DataTable stale-closure fix is correct but the existing test passes both before and after (each fireEvent.click gets its own act()); a batched-click test would lock it in but that requires a test-file change, which was out of scope.
  • aria-label="Button" satisfies the assertion mechanically; the dev-mode warning is the real remediation nudging callers to supply a meaningful label.

…, and sort toggle

- api.ts: import renamed useDebounce hook instead of removed useThrottle
- Button: apply aria-label for icon-only buttons (WCAG 2.2 SC 4.1.2)
- date.ts: format as D/MM/YYYY (unpadded day) via formatToParts for en-AU
- DataTable: use functional setState to fix stale-closure sort-direction toggle
- tsconfig: add bun-types to resolve bun:test module in test files
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