Skip to content

fix: resolve cross-package test and type failures#33

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2404-1781024713
Open

fix: resolve cross-package test and type failures#33
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2404-1781024713

Conversation

@stooit

@stooit stooit commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing bun test cases and npx tsc --noEmit source type errors across the monorepo. Final state: 13/13 tests pass, 0 source type errors. No test files modified, no dependencies added.

Bugs fixed

  1. DOM test environment not applied at repo root (bunfig.toml)
    Root-level bun test set environment = "happy-dom" but never preloaded the setup script that injects DOM globals, so UI component tests failed with ReferenceError: document is not defined. Added preload = ["./packages/ui/test/setup.ts"] to the root config (and environment = "happy-dom" to packages/ui/bunfig.toml) so GlobalRegistrator.register() runs regardless of where tests are invoked.

  2. Missing accessibility attribute (packages/ui/src/components/Button/Button.tsx)
    The aria-label prop was declared but never applied to the rendered <button>. Destructured and forwarded it.

  3. Stale-closure bug in sort toggle (packages/ui/src/components/DataTable/DataTable.tsx)
    handleSort read sortDir from the closure. Switched to the functional updater form so the controlled re-render test passes.

  4. Wrong date format (packages/utils/src/format/date.ts)
    en-AU formatting produced zero-padded / 2-digit-year output. Reworked to emit day-first with a 4-digit year (D/MM/YYYY), satisfying both the tests and the documented contract.

  5. Renamed hook still imported under old name (apps/web/src/lib/api.ts)
    useThrottle was renamed to useDebounce in @e2e/utils. Updated the import and re-export (keeping the useSearchDebounce alias).

Verification

  • bun test (from repo root): 13 pass, 0 fail
  • npx tsc --noEmit: no source type errors (only pre-existing bun:test module-resolution noise in test files, which were not modified)

Assumptions

  • The Cannot find module 'bun:test' tsc errors originate in test files and are pre-existing environmental noise; per the constraint not to modify test files, these were left untouched.
  • Each fix targets the root cause matching the test's assertion rather than masking it (verified via code review).

- ui: register happy-dom in root bunfig preload so root-level bun test injects DOM globals
- ui(Button): wire declared aria-label prop onto rendered button element
- ui(DataTable): fix stale-closure in sort toggle via functional state updater
- utils(date): format en-AU as D/MM/YYYY (4-digit year) instead of zero-padded numeric
- web(api): update import/re-export for renamed useThrottle -> useDebounce hook
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