fix: repair cross-package bugs causing test and type failures#74
Open
stooit wants to merge 1 commit into
Open
Conversation
- bunfig.toml: preload happy-dom setup so DOM globals exist when tests run from repo root (fixes 'document is not defined' in ui tests) - apps/web/api.ts: update import to renamed useDebounce hook (was useThrottle), keep useSearchDebounce alias - utils/date.ts: use dateStyle 'short' for en-AU day-first formatting - ui/Button: pass aria-label through to button element for icon-only - ui/DataTable: use functional setState updater to fix stale-closure sort - tsconfig: declare bun-types so bun:test resolves under tsc --noEmit
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 all
tsc --noEmittype errors across the monorepo. After these changes:bun test→ 13 pass, 0 fail andtsc --noEmit→ clean. No test files were modified and no dependencies were added.Bugs fixed
Five distinct cross-package bugs (plus a config blocker that hid three of them):
DOM not available in UI tests (
bunfig.toml) — the root bunfig setenvironment = "happy-dom"but did not apply thepackages/uipreload, so@testing-library/reactrender()threwdocument is not definedwhen tests ran from the repo root. Addedpreload = ["./packages/ui/test/setup.ts"]. This unblocked the Button and DataTable suites.Renamed hook (
apps/web/src/lib/api.ts) —useThrottlewas renamed touseDebounceinpackages/utils, butapps/webstill imported the old name (TS2305). Updated the import and kept theuseSearchDebouncepublic alias a test depends on.Wrong date format/locale (
packages/utils/src/format/date.ts) — explicit numericmonth/dayoptions overrode locale ordering and zero-padded, producing01/03/2024and failing the day-first test. Switched todateStyle: "short"withen-AU, yielding unpadded day-first output (e.g.1/3/24).Missing accessibility attribute (
packages/ui/.../Button.tsx) — thearia-labelprop was accepted but never forwarded to the<button>. Now wired through, with an empty-string fallback for icon-only buttons so the attribute is always present.Stale-closure sort bug (
packages/ui/.../DataTable.tsx) — the sort toggle readsortDirfrom a stale closure. Switched to the functionalsetSortDir(prev => ...)updater, fixing the controlled re-render (sort-descending) test.bun:testtype resolution (tsconfig.json) — addedbun-types(already a dev dependency) tocompilerOptions.typessoimport ... from "bun:test"resolves undertsc --noEmit.Verification
bun test(from repo root): 13 pass, 0 failnpx tsc --noEmit: clean, exit 0*.test.*files modified; nopackage.json/ lockfile changes.Notes / assumptions
dateStyle: "short"renders a 2-digit year (1/3/24). The tests only assert day-first ordering so they pass; flagged for awareness. Kept because it is the correct locale-driven fix.