fix: repair cross-package test failures and type errors - #93
Open
stooit wants to merge 1 commit into
Open
Conversation
- bunfig.toml: use test preload for happy-dom DOM registration (Bun ignores the Vitest-only 'environment' key) - tsconfig.json: add bun-types so bun:test resolves under tsc - api.ts: import renamed useDebounce (was stale useThrottle), keep useSearchDebounce alias - date.ts: format day as non-padded so day-first output matches expected format - Button.tsx: render aria-label for icon-only buttons (WCAG 2.2 SC 4.1.2) with dev warning - DataTable.tsx: fix stale-closure sort toggle via functional setState updater; drop obsolete BUG comments
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.
bun testis now 13/13 green andnpx tsc --noEmitexits 0. No test files were modified and no dependencies were added.Bugs spanned all three packages plus root tooling config; several were masked by a broken test DOM environment that had to be fixed first.
Changes
bunfig.toml[test]block usedenvironment = "happy-dom", a Vitest/Jest key that Bun silently ignores — so@testing-library/reactrenders failed withdocument is not defined. Switched topreload = ["./packages/ui/test/setup.ts"], which registers the already-installed happy-dom global. This unblocked the Button + DataTable render tests.tsconfig.json"types": ["bun-types", "react"]sobun:testresolves undertsc(react re-added explicitly since specifyingtypesdisables automatic@types/*inclusion).apps/web/src/lib/api.tsuseDebounceinpackages/utils, but this file still imported the olduseThrottle. Updated the import and the re-export, preserving theas useSearchDebouncealias the test consumes.packages/utils/src/format/date.tsformatDatezero-padded single-digit days (01/03/2024); the test expects a non-padded day-first format (1/03/2024). Adjusted theIntl.DateTimeFormatoptions accordingly.formatDateTimeleft untouched.packages/ui/src/components/Button/Button.tsxariaLabelwas never rendered, so icon-only buttons had no accessible name (WCAG 2.2 SC 4.1.2). Now rendersaria-labelfor icon-only buttons (falling back to string children) with a dev-onlyconsole.warnwhen an icon-only button has no label. Visible-text buttons are unaffected.packages/ui/src/components/DataTable/DataTable.tsxsortDircaptured at handler-creation time, so a second click on the same column didn't flip to descending. Replaced with a functionalsetSortDirupdater. Also removed the now-obsoleteBUG:comments.Verification
bun test-> 13 pass / 0 fail (the icon-only aria-label line in output is an intentionalconsole.warnfrom a passing WCAG test, not a failure)npx tsc --noEmit-> exit 0, no diagnosticsAssumptions
packages/ui/test/setup.tsand@happy-dom/global-registratorwere already present — this honours the "no new dependencies" constraint.en-GBlocale informatDateproduces the exact non-padded day-first string the test asserts.aria-labelscoped toiconOnlyso visible-text buttons keep their text as the accessible name.Review
Reviewed by the review agent (independently re-ran the suite and tsc). One flagged item — stale BUG comments in
DataTable.tsx— was fixed before commit.