Skip to content

fix: resolve 4 cross-package bugs causing test failures#20

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/job-e2e-tier3-2417-1780042367
Open

fix: resolve 4 cross-package bugs causing test failures#20
stooit wants to merge 1 commit into
mainfrom
quantcode/job-e2e-tier3-2417-1780042367

Conversation

@stooit
Copy link
Copy Markdown
Contributor

@stooit stooit commented May 29, 2026

Summary

Fixes all 9 failing tests across 4 test files in this TypeScript monorepo by addressing 4 cross-package bugs:

  • Renamed hook (apps/web/src/lib/api.ts): The useDebounce hook in packages/utils was imported as useThrottle and re-exported as a non-existent name. Fixed to import useDebounce and re-export it as useSearchDebounce (which the web app's test expects).

  • Date format (packages/utils/src/format/date.ts): Changed format string from dd/MM/yyyy to d/MM/yyyy — the test expects no zero-padding on the day.

  • Stale closure (packages/ui/src/components/DataTable/DataTable.tsx): The sort click handler captured stale state. Fixed by using functional setState update (prev => ...) so it always reads the latest sort direction.

  • Accessibility (packages/ui/src/components/Button/Button.tsx): The Button component wasn't passing through aria-label. Fixed by spreading remaining props onto the button element.

  • DOM environment (bunfig.toml): UI tests failed with document is not defined because bun 1.3.14 doesn't support environment = "happy-dom" in bunfig.toml. Fixed by preloading a setup script that calls GlobalRegistrator.register().

Verification

bun test → 13 pass, 0 fail
npx tsc --noEmit → only expected 'bun:test' module errors remain

Assumptions

  • The bun:test TypeScript errors are pre-existing and acceptable (bun runtime types not in tsconfig)
  • happy-dom global registration is safe for all test files (non-DOM tests are unaffected)

- Fix renamed hook: re-export useDebounce as useSearchDebounce in api.ts
- Fix date format: use 'd/MM/yyyy' (no zero-padded day) in date utility
- Fix stale closure: use functional setState in DataTable sort handler
- Fix a11y: spread aria-label prop through Button component
- Fix DOM environment: configure happy-dom preload in root bunfig.toml
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