Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2359-1785093688
Open

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

Conversation

@stooit

@stooit stooit commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. bun test is now 13/13 green and npx tsc --noEmit exits 0. No test files were modified and no dependencies were added.

Bugs spanned all three packages plus root tooling config; several were masked by a broken test DOM environment that had to be fixed first.

Changes

File Fix
bunfig.toml The [test] block used environment = "happy-dom", a Vitest/Jest key that Bun silently ignores — so @testing-library/react renders failed with document is not defined. Switched to preload = ["./packages/ui/test/setup.ts"], which registers the already-installed happy-dom global. This unblocked the Button + DataTable render tests.
tsconfig.json Added "types": ["bun-types", "react"] so bun:test resolves under tsc (react re-added explicitly since specifying types disables automatic @types/* inclusion).
apps/web/src/lib/api.ts The hook was renamed to useDebounce in packages/utils, but this file still imported the old useThrottle. Updated the import and the re-export, preserving the as useSearchDebounce alias the test consumes.
packages/utils/src/format/date.ts formatDate zero-padded single-digit days (01/03/2024); the test expects a non-padded day-first format (1/03/2024). Adjusted the Intl.DateTimeFormat options accordingly. formatDateTime left untouched.
packages/ui/src/components/Button/Button.tsx The destructured ariaLabel was never rendered, so icon-only buttons had no accessible name (WCAG 2.2 SC 4.1.2). Now renders aria-label for icon-only buttons (falling back to string children) with a dev-only console.warn when an icon-only button has no label. Visible-text buttons are unaffected.
packages/ui/src/components/DataTable/DataTable.tsx Stale-closure bug: the sort-direction toggle read sortDir captured at handler-creation time, so a second click on the same column didn't flip to descending. Replaced with a functional setSortDir updater. Also removed the now-obsolete BUG: comments.

Verification

  • bun test -> 13 pass / 0 fail (the icon-only aria-label line in output is an intentional console.warn from a passing WCAG test, not a failure)
  • npx tsc --noEmit -> exit 0, no diagnostics

Assumptions

  • DOM environment via preload was chosen because packages/ui/test/setup.ts and @happy-dom/global-registrator were already present — this honours the "no new dependencies" constraint.
  • en-GB locale in formatDate produces the exact non-padded day-first string the test asserts.
  • aria-label scoped to iconOnly so visible-text buttons keep their text as the accessible name.

Review

Reviewed by the review agent (independently re-ran the suite and tsc). One flagged item — stale BUG comments in DataTable.tsx — was fixed before commit.

- bunfig.toml: use test preload for happy-dom DOM registration (Bun ignores the Vitest-only 'environment' key)
- tsconfig.json: add bun-types so bun:test resolves under tsc
- api.ts: import renamed useDebounce (was stale useThrottle), keep useSearchDebounce alias
- date.ts: format day as non-padded so day-first output matches expected format
- Button.tsx: render aria-label for icon-only buttons (WCAG 2.2 SC 4.1.2) with dev warning
- DataTable.tsx: fix stale-closure sort toggle via functional setState updater; drop obsolete BUG comments
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