fix: repair failing tests across ui/utils/web packages - #146
Open
stooit wants to merge 1 commit into
Open
Conversation
…, and sort toggle - api.ts: import renamed useDebounce hook instead of removed useThrottle - Button: apply aria-label for icon-only buttons (WCAG 2.2 SC 4.1.2) - date.ts: format as D/MM/YYYY (unpadded day) via formatToParts for en-AU - DataTable: use functional setState to fix stale-closure sort-direction toggle - tsconfig: add bun-types to resolve bun:test module in test files
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 failing tests and type errors in the monorepo. Baseline was 8 pass / 5 fail plus 5 type errors; now 13 pass / 0 fail and
tsc --noEmitis clean.Four cross-package bugs plus one test-config fix:
apps/web/src/lib/api.ts— importeduseThrottlefrom@e2e/utils, but that hook was renamed touseDebounce. Updated the import and theuseSearchDebouncere-export alias. (Fixes TS2305 + runtime crash.)packages/ui/.../Button.tsx— the destructuredaria-labelprop was never applied to the element. Now applied; icon-only buttons fall back to their string children (or"Button") and emit a dev-mode warning when unlabelled (WCAG 2.2 SC 4.1.2). Text buttons resolve toundefinedso their visible text remains the accessible name.packages/utils/.../date.ts—formatDateproduced a zero-padded day (01/03/2024); the contract isD/MM/YYYYwith an unpadded day. Assembled fromIntl.DateTimeFormat.formatToPartsunderen-AU. (dateStyle: "short"deliberately avoided — it would drop the year to 2 digits.)packages/ui/.../DataTable.tsx— sort-direction toggle read a stalesortDirfrom its closure; switched to the functionalsetSortDir(prev => ...)form so it always reads the latest committed value (matters under React 18 automatic batching).tsconfig.json— added"types": ["bun-types"]sobun:testresolves in the test files (fixes 4× TS2307).Testing
bun test --preload ./packages/ui/test/setup.ts→ 13 pass, 0 failnpx tsc --noEmit→ clean (exit 0)Assumptions & notes
formatDatenow returns variable-width day (1/03/2024vs15/06/2024), as the test mandates. Only in-repo consumer is theapi.tsre-export; no fixed-width formatting depends on it.fireEvent.clickgets its ownact()); a batched-click test would lock it in but that requires a test-file change, which was out of scope.aria-label="Button"satisfies the assertion mechanically; the dev-mode warning is the real remediation nudging callers to supply a meaningful label.