fix: resolve four cross-package test failures in monorepo - #130
Open
stooit wants to merge 1 commit into
Open
Conversation
- utils: export useSearchDebounce (was renamed); reconcile api.ts import - ui/Button: forward aria-label; guarantee accessible name for icon-only buttons and only mark icon decorative when other name exists (WCAG 4.1.2) - ui/DataTable: fix stale-closure sort by merging key+dir into one atomic functional state update so second click toggles descending - utils/formatDate: day-first en-AU format without zero-padded day (1/03/2024)
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 the type error in the monorepo.
bun run test→ 13 pass, 0 fail;npx tsc --noEmit→ only pre-existingbun:testmodule errors in test files remain (unrelated, in test files that must not be modified). No test files changed, no dependencies added.Bugs fixed (one per package area)
packages/utils/apps/web— renamed hook mismatch. The debounce hook was referenced under stale names (useSearchDebouncemissing at runtime,useThrottleat type-check). ExporteduseSearchDebounce(alias of the genuineuseDebounce) from@e2e/utilsand reconciled the duplicate imports/re-export inapps/web/src/lib/api.ts.api.tsonly re-exports the hook, so no call-site behaviour changed.packages/ui/Button— missing accessible name (WCAG 2.2 SC 4.1.2).aria-labelwas destructured but never applied. Now forwarded; icon-only buttons always get an accessible name (explicit label, else a dev-warned fallback). The icon wrapper is markedaria-hiddenonly when other accessible text exists — so<Button icon={…} />(icon, no children, noticonOnly) keeps the icon's text as its name.packages/ui/DataTable— stale-closure sort. The sort handler readsortDirfrom a stale render closure, so a second click didn't toggle to descending. MergedsortKey/sortDirinto a single object updated via one functionalsetState, making the key+direction update atomic. Render body andaria-sortoutput are unchanged.packages/utils/formatDate— format string. Returned01/03/2024(zero-padded day) instead of the expected day-first1/03/2024. UsesIntl.DateTimeFormat('en-AU')viaformatToParts, stripping padding from the day part only (2-digit month, 4-digit year retained). Satisfies all date test assertions.Assumptions
1/03/2024), inferred from the test assertions.useSearchDebounceis the canonical hook name; keptuseDebounceexported too so existing consumers are unaffected.Cannot find module 'bun:test'tsc errors are out of scope (they live in test files, which were not modified).Testing
bun run test— 13 passed, 0 failednpx tsc --noEmit— no new type errors (theuseThrottleerror is resolved)Follow-ups (non-blocking)
aria-labelcompile-time required foriconOnlybuttons instead of a runtime fallback.<Button icon={…} />(non-iconOnly) case has no committed test; adding one would prevent regressing the a11y fix.