fix: repair cross-package test failures and type errors - #110
Open
stooit wants to merge 1 commit into
Open
Conversation
Fix all failing tests (13/13 pass) and eliminate tsc --noEmit errors across the monorepo without modifying tests or adding dependencies. - bunfig.toml: register happy-dom via `preload` (the `environment` key is Vitest/Jest syntax silently ignored by Bun), so `document` is defined for @testing-library/react in Button/DataTable tests - tsconfig.json: add `types: ["bun-types"]` so `bun:test` resolves and test files typecheck clean - packages/utils/src/format/date.ts: use Intl formatToParts to emit an unpadded day (1/03/2024) for en-AU while preserving the 4-digit year - apps/web/src/lib/api.ts: import the renamed utils hook under its current export name - packages/ui/Button: provide an accessible name (aria-label) for icon-only buttons, with a dev warning when none is supplied - packages/ui/DataTable: fix stale-closure in the sort handler using functional setState so descending sort works on the second click
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. Final state:
bun test= 13 pass / 0 fail,npx tsc --noEmit= clean (exit 0). No test files were modified and no dependencies were added (bun-types,happy-dom, and@happy-dom/global-registratorwere already present).Root causes & fixes
bunfig.tomlenvironment = "happy-dom"key is Vitest/Jest syntax and is silently ignored by Bun, sodocumentwas undefined in@testing-library/reactrenders. Switched topreloadso happy-dom registers globally.tsconfig.jsontypes: ["bun-types"]soimport { ... } from "bun:test"resolves and test files typecheck.packages/utils/src/format/date.tsen-AUorder was already correct (dd/MM/y); the real failure was a padded day. Now usesIntl.DateTimeFormat().formatToPartsto emit an unpadded day (1/03/2024) while keeping the 4-digit year.apps/web/src/lib/api.tspackages/utilsbut imported under its old name. Updated the import to the current export name.packages/ui/src/components/Button/Button.tsxaria-labelso they have an accessible name (WCAG 2.2 SC 4.1.2), with a dev-onlyconsole.warnwhen a caller supplies none.packages/ui/src/components/DataTable/DataTable.tsxsortDirfrom its closure. Switched to the functionalsetStateform so a second click correctly toggles to descending.Verification
bun test-> 13 pass / 0 failnpx tsc --noEmit-> exit 0, no errorsAssumptions & notes
BUG:comments were misleading (the date comment blamed field ordering; the DataTable stale-closure test happened to pass underfireEvent's per-clickact()). Fixes target the actual root causes, and the DataTable functional-setState change is retained as it addresses a genuine latent bug in that intended category.aria-labelfallback value is generic;process.envin the browser-targeted UI package could betypeof-guarded; the now-redundant--preloadflag inpackage.jsoncould be dropped.