Skip to content

fix: repair cross-package test failures and type errors - #110

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2164-1786119732
Open

fix: repair cross-package test failures and type errors#110
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2164-1786119732

Conversation

@stooit

@stooit stooit commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. Final state: bun test = 13 pass / 0 fail, npx tsc --noEmit = clean (exit 0). No test files were modified and no dependencies were added (bun-types, happy-dom, and @happy-dom/global-registrator were already present).

Root causes & fixes

Area File Fix
DOM test env bunfig.toml The environment = "happy-dom" key is Vitest/Jest syntax and is silently ignored by Bun, so document was undefined in @testing-library/react renders. Switched to preload so happy-dom registers globally.
Type resolution tsconfig.json Added types: ["bun-types"] so import { ... } from "bun:test" resolves and test files typecheck.
Date locale/format packages/utils/src/format/date.ts The en-AU order was already correct (dd/MM/y); the real failure was a padded day. Now uses Intl.DateTimeFormat().formatToParts to emit an unpadded day (1/03/2024) while keeping the 4-digit year.
Renamed hook apps/web/src/lib/api.ts The hook was renamed in packages/utils but imported under its old name. Updated the import to the current export name.
Accessibility (Button) packages/ui/src/components/Button/Button.tsx Icon-only buttons now receive an aria-label so they have an accessible name (WCAG 2.2 SC 4.1.2), with a dev-only console.warn when a caller supplies none.
Stale closure (DataTable) packages/ui/src/components/DataTable/DataTable.tsx Sort handler read a stale sortDir from its closure. Switched to the functional setState form so a second click correctly toggles to descending.

Verification

  • bun test -> 13 pass / 0 fail
  • npx tsc --noEmit -> exit 0, no errors

Assumptions & notes

  • Two in-repo BUG: comments were misleading (the date comment blamed field ordering; the DataTable stale-closure test happened to pass under fireEvent's per-click act()). Fixes target the actual root causes, and the DataTable functional-setState change is retained as it addresses a genuine latent bug in that intended category.
  • Reviewer follow-ups (non-blocking, left out to keep this diff minimal to what tests require): the icon-only aria-label fallback value is generic; process.env in the browser-targeted UI package could be typeof-guarded; the now-redundant --preload flag in package.json could be dropped.

Fix all failing tests (13/13 pass) and eliminate tsc --noEmit errors
across the monorepo without modifying tests or adding dependencies.

- bunfig.toml: register happy-dom via `preload` (the `environment` key
  is Vitest/Jest syntax silently ignored by Bun), so `document` is
  defined for @testing-library/react in Button/DataTable tests
- tsconfig.json: add `types: ["bun-types"]` so `bun:test` resolves and
  test files typecheck clean
- packages/utils/src/format/date.ts: use Intl formatToParts to emit an
  unpadded day (1/03/2024) for en-AU while preserving the 4-digit year
- apps/web/src/lib/api.ts: import the renamed utils hook under its
  current export name
- packages/ui/Button: provide an accessible name (aria-label) for
  icon-only buttons, with a dev warning when none is supplied
- packages/ui/DataTable: fix stale-closure in the sort handler using
  functional setState so descending sort works on the second click
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