fix: resolve cross-package test failures and type errors - #135
Open
stooit wants to merge 1 commit into
Open
Conversation
- api.ts: import renamed useDebounce hook (was useThrottle) from @e2e/utils - Button: apply aria-label to the button element for accessible naming - DataTable: use functional setState updater to avoid stale-closure sort bug - date.ts: format day-first with unpadded day via en-AU Intl parts - tsconfig: add bun-types to resolve bun:test module type errors
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 5 failing tests + 5
tscerrors; now 13/13 tests pass andtsc --noEmitis clean. Bugs spanned all three packages (packages/ui,packages/utils,apps/web).Changes
apps/web/src/lib/api.tsuseThrottle→useDebounceinpackages/utils, butapi.tsstill imported the old name (runtime link error +TS2305).useDebounce; keep the publicuseSearchDebouncealias unchanged.packages/ui/.../Button.tsxaria-labelwas destructured but never applied to the<button>element, so icon-only buttons had no accessible name (WCAG 2.2 SC 4.1.2).aria-label={ariaLabel ?? (iconOnly ? "Button" : undefined)}— explicit labels honoured, icon-only gets a non-null default, text buttons unaffected.packages/ui/.../DataTable.tsxhandleSortreadsortDirfrom the render closure — a latent stale-closure bug under React 18 batching / StrictMode.setSortDir(prev => prev === "asc" ? "desc" : "asc").packages/utils/.../date.tsformatDateemitted01/03/2024(leading-zero day) instead of the required1/03/2024.en-AUIntl.DateTimeFormatparts, stripping the day's zero-padding — day-first, locale-aware, and still throws on invalid dates.tsconfig.jsonbun:testmodule unresolved (TS2307) —bun-typesinstalled but not wired intocompilerOptions."types": ["bun-types"].Verification
bun run test→ 13 pass, 0 fail./node_modules/.bin/tsc --noEmit→ exit 0Constraints honoured
bun-typeswas already indevDependencies).Assumptions / notes
date.ts:en-AU's ICU pattern coerces a numeric day to 2-digit, soformatToPartsis used to strip the day padding — this is deliberate and documented in the code to prevent a "simplify-back-to-format()" regression. Uses local-time date parts (correct for AU-facing local-date display)."Button"default is a non-null but generic accessible name that satisfies the a11y assertion. A more meaningful fix (makingaria-labeltype-required wheniconOnly) would require changing test files and is left as follow-up.