fix: repair cross-package bugs so all tests and tsc pass - #144
Open
stooit wants to merge 1 commit into
Open
Conversation
- utils: export useSearchDebounce (renamed hook) and fix api.ts import - ui/Button: forward aria-label, fallback name for icon-only buttons, conditionally hide decorative icon to preserve accessible name [WCAG-4.1.2] - ui/DataTable: collapse sort key+direction into one atomic functional update to eliminate the latent stale-closure bug - utils/date: use en-AU locale with unpadded day via formatToParts - test env: wire happy-dom global registrator via root bunfig preload - tsconfig: add bun-types so bun:test resolves under tsc --noEmit
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 9 failing tests and all
tsc --noEmittype errors across the monorepo (packages/ui,packages/utils,apps/web). Bugs spanned multiple packages. No test files modified; no new dependencies added.Before: 4 pass / 9 fail, 5 tsc errors.
After: 13 pass / 0 fail, 0 tsc errors.
Bugs fixed
packages/utils,apps/web) — a hook was renamed butapps/web/src/lib/api.tsstill imported the olduseThrottle, while the test expecteduseSearchDebounce. ExporteduseSearchDebounce(alias of the canonicaluseDebounce) and corrected the importer.packages/ui) —bun testfrom the repo root failed everyrender()withdocument is not defined. The rootbunfig.tomlused the invalidenvironment = "happy-dom"key (Jest/Vitest syntax, silently ignored by Bun). Replaced with apreloadthat runs the existing (unmodified) happy-domGlobalRegistratorsetup script.packages/ui/Button) — icon-only buttons now forwardaria-labeland receive a fallback accessible name when unlabelled. Decorative icons are hidden witharia-hiddenonly when the button already has a name from another source, so an icon-only-content button never ends up with an empty accessible name [WCAG 2.2 SC 4.1.2].packages/ui/DataTable) — collapsed sort key + direction into a singleSortStateobject updated via one pure functional updater, so direction is always derived from the same snapshot as its key. Eliminates the latent batched-update hazard; no StrictMode double-toggle.packages/utils/date) —formatDatereturned01/03/2024(padded day). Kept theen-AUlocale for correct D/M ordering and stripped the ICU-forced day padding viaformatToParts, so1 March 2024->1/03/2024as the test requires.Type errors
bun:testmodule-not-found (4 files) resolved by wiring the already-installedbun-typesintotsconfig.jsontypes(no new dependency).useThrottlemissing-export error resolved by fix fix: resolve all failing tests and type errors across monorepo #1.Verification
bun test-> 13 pass / 0 fail../node_modules/.bin/tsc --noEmit-> exit 0.(The
console.warnseen in test output is expected — a Button test deliberately renders an unlabelled icon-only button.)Assumptions
useSearchDebounce(what the test asserts);useDebounceis retained as the underlying implementation.DD/MM/YYYY, but the test asserts an unpadded day (/^1/), so the format is intentionallyD/MM/YYYYto satisfy the test without modifying it.Follow-ups (non-blocking, out of scope)
DataTablesortable<th>has anonClickbut no keyboard affordance (pre-existing; SC 2.1.1) — should wrap in a<button>.aria-labela compile-time required prop on unlabelled icon buttons (breaking API change) rather than a runtime warning.