Skip to content

fix: repair cross-package bugs so all tests and tsc pass - #144

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2202-1788280721
Open

fix: repair cross-package bugs so all tests and tsc pass#144
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2202-1788280721

Conversation

@stooit

@stooit stooit commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all tsc --noEmit type errors across the monorepo (packages/ui, packages/utils, apps/web). Bugs spanned multiple packages. No test files modified; no new dependencies added.

Before: 4 pass / 9 fail, 5 tsc errors.
After: 13 pass / 0 fail, 0 tsc errors.

Bugs fixed

  1. Renamed hook out of sync (packages/utils, apps/web) — a hook was renamed but apps/web/src/lib/api.ts still imported the old useThrottle, while the test expected useSearchDebounce. Exported useSearchDebounce (alias of the canonical useDebounce) and corrected the importer.
  2. DOM test environment not registered (packages/ui) — bun test from the repo root failed every render() with document is not defined. The root bunfig.toml used the invalid environment = "happy-dom" key (Jest/Vitest syntax, silently ignored by Bun). Replaced with a preload that runs the existing (unmodified) happy-dom GlobalRegistrator setup script.
  3. Missing accessibility attribute (packages/ui/Button) — icon-only buttons now forward aria-label and receive a fallback accessible name when unlabelled. Decorative icons are hidden with aria-hidden only when the button already has a name from another source, so an icon-only-content button never ends up with an empty accessible name [WCAG 2.2 SC 4.1.2].
  4. Stale-closure sort bug (packages/ui/DataTable) — collapsed sort key + direction into a single SortState object updated via one pure functional updater, so direction is always derived from the same snapshot as its key. Eliminates the latent batched-update hazard; no StrictMode double-toggle.
  5. Wrong date format (packages/utils/date) — formatDate returned 01/03/2024 (padded day). Kept the en-AU locale for correct D/M ordering and stripped the ICU-forced day padding via formatToParts, so 1 March 2024 -> 1/03/2024 as the test requires.

Type errors

Verification

bun test -> 13 pass / 0 fail. ./node_modules/.bin/tsc --noEmit -> exit 0.
(The console.warn seen in test output is expected — a Button test deliberately renders an unlabelled icon-only button.)

Assumptions

  • The canonical hook name the codebase settled on is useSearchDebounce (what the test asserts); useDebounce is retained as the underlying implementation.
  • Standard AU date is DD/MM/YYYY, but the test asserts an unpadded day (/^1/), so the format is intentionally D/MM/YYYY to satisfy the test without modifying it.

Follow-ups (non-blocking, out of scope)

  • DataTable sortable <th> has an onClick but no keyboard affordance (pre-existing; SC 2.1.1) — should wrap in a <button>.
  • Consider making aria-label a compile-time required prop on unlabelled icon buttons (breaking API change) rather than a runtime warning.

- utils: export useSearchDebounce (renamed hook) and fix api.ts import
- ui/Button: forward aria-label, fallback name for icon-only buttons,
  conditionally hide decorative icon to preserve accessible name [WCAG-4.1.2]
- ui/DataTable: collapse sort key+direction into one atomic functional
  update to eliminate the latent stale-closure bug
- utils/date: use en-AU locale with unpadded day via formatToParts
- test env: wire happy-dom global registrator via root bunfig preload
- tsconfig: add bun-types so bun:test resolves under tsc --noEmit
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