fix: repair cross-package test failures and clean type errors - #124
Open
stooit wants to merge 1 commit into
Open
fix: repair cross-package test failures and clean type errors#124stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
Fix all failing tests and eliminate type errors across the monorepo: - apps/web: rename stale useThrottle import to useDebounce and re-export as useSearchDebounce (packages/utils renamed the hook) - packages/ui Button: apply aria-label to icon-only buttons with a string-children/'Button' fallback so iconOnly buttons always have an accessible name (WCAG 2.2 SC 4.1.2) - packages/utils formatDate: emit an unpadded day (1/03/2024) using Intl formatToParts under en-AU, keeping a 4-digit year - tsconfig: register bun-types so bun:test resolves under tsc --noEmit bun run test: 13 pass / 0 fail. npx tsc --noEmit: clean.
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 eliminates all type errors across the monorepo. Baseline was 8 pass / 5 fail plus a
tscerror; now 13 pass / 0 fail andnpx tsc --noEmitexits 0 with no output.Changes
apps/web/src/lib/api.ts— theuseThrottlehook was renamed touseDebounceinpackages/utils, but the app still imported the old name (TS2305). Updated the import touseDebounceand re-exported it asuseSearchDebounce(which the api test asserts). Merged the two duplicate@e2e/utilsimports.packages/ui/src/components/Button/Button.tsx—iconOnlybuttons never appliedaria-label, leaving them with no accessible name (WCAG 2.2 SC 4.1.2). Now appliesaria-labelwith a fallback chain: explicit label → string children →"Button", so an icon-only button always has a non-null accessible name.packages/utils/src/format/date.ts—formatDateemitted a zero-padded day (01/03/2024); the test expects an unpadded day (1/03/2024). Reimplemented withIntl.DateTimeFormat.formatToPartsunderen-AU, producing an unpadded day while keeping a 4-digit year. (Ordering was never the bug —Intlignores option order; the failing assertion was day padding.)tsconfig.json— added"types": ["bun-types"]sobun:testresolves undertsc --noEmit(the 4 remainingbun:testTS2307 errors).bun-typeswas already installed; it just wasn't registered. Verified@types/reactstill resolves via the module import graph, so nothing regressed.Verification
bun run test→ 13 pass / 0 failnpx tsc --noEmit→ exit 0, cleanConstraints honoured
package.json/ lockfile untouched).Assumptions & decisions
formatToPartsoverdateStyle: "short"to keep an unambiguous 4-digit year (1/03/2024) rather than1/3/24; both would pass the test.process.env.NODE_ENVdev-console.warnto Button. Sincepackages/uiships as raw source (main → ./src/index.ts),processmay be undefined in a browser bundler →ReferenceErrorat render. No test required it, so it was removed as a latent hazard.aria-hiddenon the icon not added: would have created a nameless-button regression for<Button icon />used withouticonOnly(the fallback is gated oniconOnly). Left the icon wrapper unchanged.Known-remaining (out of scope — tests pass, not touched)
DataTable.tsxcarries a documented stale-closure bug inhandleSort, but its tests pass — left untouched per "fix only what tests require". Worth a follow-up issue.formatDatedepends on the ambient timezone; addingtimeZone: "UTC"was avoided since it would render wrong dates for real AU users. Tests are stable across UTC/Sydney/Perth.