Skip to content

fix: repair cross-package bugs so all tests and types pass - #140

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2173-1787947446
Open

fix: repair cross-package bugs so all tests and types pass#140
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2173-1787947446

Conversation

@stooit

@stooit stooit commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors across the monorepo. bun test && tsc --noEmit now reports 13 pass / 0 fail and tsc exit 0.

Bugs spanned all three packages plus test/type configuration.

Changes

  • packages/utils + apps/web — a debounce hook was referenced under a stale name (useThrottle) that no longer existed. Reconciled the export in utils and updated apps/web/src/lib/api.ts to import the canonical useDebounce / expose useSearchDebounce as the tests expect.
  • packages/ui/Button — icon-only buttons lacked an accessible name. Added aria-label wiring with a fallback of "Unlabelled button" (chosen over "Button" so the missing-label case stays visible to manual a11y audit / log review rather than being silently masked).
  • packages/ui/DataTable — fixed a stale-closure bug in the sort handler (caught by the "sorts descending on second click" test) by moving sort key + direction into a single atomic SortState, avoiding nested/stale state updates under StrictMode.
  • packages/ui/bunfig.toml + root bunfig.toml — the UI package's bunfig overrode the root config and dropped environment = "happy-dom", so UI tests ran without a DOM (document is not defined). Restored happy-dom for the UI tests while keeping the existing preload.
  • packages/utils/date.tsformatDate zero-padded day 1 (01/03/2024); switched to dateStyle: "short" so 1 March 2024 renders starting with 1, matching the test and consistent with formatDateTime.
  • tsconfig.json — added bun types so bun:test resolves under tsc --noEmit (no test files modified).

Constraints honoured

  • No test files modified.
  • No new dependencies added (happy-dom and bun types were already installed).
  • Scope limited to what the tests/types required.

Notes / assumptions for reviewers

  • Date format: under bun's ICU, the numeric-parts alternatives still zero-pad the day for en-AU; dateStyle: "short" was the option that satisfied /^1/ while keeping the other date assertions green. Side effect: the year is now 2-digit. The test does not assert the year; flagged in case 4-digit years matter for your context.
  • Button fallback is a visibility mechanism, not a hard gate — automated scanners still see a present accessible name. A stronger fix (required aria-label via a discriminated union when iconOnly) was out of scope as it would break tsc on the unmodifiable test file.

Verification

bun test         -> 13 pass, 0 fail
npx tsc --noEmit -> exit 0

- utils: reconcile debounce hook export; api.ts imports useSearchDebounce/useDebounce instead of removed useThrottle
- ui/Button: add aria-label with an audit-visible fallback for icon-only buttons
- ui/DataTable: fix stale-closure sort bug via a single atomic SortState
- ui: restore happy-dom environment for the ui package's bun tests (kept existing preload)
- utils/date: use dateStyle short so day 1 is not zero-padded (locale/format fix)
- 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