fix: repair failing tests and type errors across monorepo - #158
Open
stooit wants to merge 1 commit into
Open
Conversation
- fix(test): load happy-dom via bunfig preload so root bun test gets a DOM - fix(web): update stale useThrottle import to renamed useDebounce (aliased as useSearchDebounce) - fix(a11y): apply aria-label to Button for accessible name [WCAG-4.1.2] - fix(utils): strip en-AU day padding so formatDate emits d/MM/yyyy - chore(ts): include bun-types so bun:test resolves
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 9 failing tests and eliminates type errors across the monorepo.
bun testnow reports 13 pass / 0 fail andnpx tsc --noEmitexits clean. No test files or dependencies were modified — 5 source files changed.Root-cause fixes
bunfig.toml—environment = "happy-dom"is a Vitest/Jest key that Bun silently ignores, so theuiReact tests hitReferenceError: document is not defined. Switched to Bun'spreload = ["./packages/ui/test/setup.ts"]so a DOM is available whenbun testruns from the repo root (per-package runs still work).apps/web/src/lib/api.ts— the hook was renameduseThrottle→useDebounceinpackages/utils; the stale import broke the re-exportuseSearchDebounce. Updated the import/alias. Public export surface is unchanged (useDebounceis not leaked as a new export).packages/ui/src/components/Button/Button.tsx— appliedaria-labelso an icon-only button has an accessible name (WCAG 2.2 SC 4.1.2), plus a dev-only warning when an icon-only button lacks an explicit label.packages/utils/src/format/date.ts— the failure was zero-padding (01/03/2024), not field ordering as the old comment claimed. Strips the day's leading zero while keepingen-AU, emitting1/03/2024. Comment corrected.tsconfig.json— added"types": ["bun-types"]sobun:testresolves (was 4× TS2307).Verification
bun test→ 13 pass / 0 failnpx tsc --noEmit→ exit 0formatDatespot-checked across padded/unpadded days and multiple timezones.Reviewer notes / follow-ups (out of scope, non-blocking)
aria-labelrequired for the icon-only variant (compile-time enforcement) — deferred because it would require amending a test that's out of scope here.date.ts:formatDate(1/03/2024) andformatDateTime(1/3/24) use inconsistent month padding / year width; no test coversformatDateTime. Neither formatter pinstimeZone— pre-existing, not a regression.Assumptions
bun testmust pass (not just per-package), driving thebunfig.tomlpreload fix.1/03/2024is the intended output per the test assertion/^1/.