fix: resolve failing tests across ui, utils, and web packages - #142
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests across ui, utils, and web packages#142stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- utils: export debounce hook as useSearchDebounce (was renamed) and update apps/web/src/lib/api.ts to import the current name - ui/Button: apply aria-label on icon-only buttons (WCAG 4.1.2), with a safe fallback and a dev-only warning when no explicit label is given - ui/DataTable: fix stale-closure sort bug by collapsing sort key/dir into one atomic state updated via a functional setState updater - utils/formatDate: use en-GB day-first format so the day is unpadded (1/03/2024) as the test expects - tsconfig: add "types": ["bun-types"] so bun:test resolves under tsc
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 (via
bun run test) was 5 fail / 8 pass plus 5tscerrors; now 13 pass / 0 fail andtsc --noEmitis clean.Root causes & fixes
Hook rename mismatch (
packages/utils/src/index.ts,apps/web/src/lib/api.ts)The debounce hook is consumed as
useSearchDebounce, butapi.tsstill imported the olduseThrottlename (TS2305). Exported the hook asuseSearchDebounceand updated the import.Button missing accessible name (
packages/ui/src/components/Button/Button.tsx)Icon-only buttons rendered no
aria-label(WCAG 4.1.2). Now applies a caller-provided label when present, with a safe fallback so the attribute is never null, plus a dev-onlyconsole.warnwhen an icon-only button has no explicit label.DataTable stale-closure sort bug (
packages/ui/src/components/DataTable/DataTable.tsx)The sort handler read
sortDircaptured at handler-creation time, so batched clicks never toggled to descending. Collapsed the separate key/diruseStateinto one atomicsortobject updated via a functionalsetSort(prev => ...)updater.formatDate padded the day (
packages/utils/src/format/date.ts)en-AUpads the day to two digits even withday: "numeric". Switched toen-GB(same day-first ordering, unpadded day) so2024-03-01->1/03/2024as the test expects.bun:testtype resolution (tsconfig.json)Added
"types": ["bun-types"]soimport ... from "bun:test"resolves undertsc --noEmit. No dependency added (bun-typeswas already present).Assumptions
bun run test(the npm script adds the required happy-dom preload); rawbun testfails withdocument is not definedand is not the intended invocation.aria-labelfallback satisfies WCAG 4.1.2 at the attribute level; a stronger type-level requirement was intentionally not applied because a test renders an icon-only button without a label and test files must not change.Verification
bun run test-> 13 pass, 0 failnpx tsc --noEmit-> exit 0, no outputReviewed by the review subagent: approved, no blockers.