fix: repair cross-package bugs so tests and tsc pass#69
Open
stooit wants to merge 1 commit into
Open
Conversation
- bunfig.toml: preload happy-dom setup so DOM globals register when tests run from root (fixes 'document is not defined' in packages/ui) - apps/web api.ts: import renamed useDebounce (was useThrottle) for the useSearchDebounce re-export - utils/date.ts: use en-AU dateStyle:'short' for day-first formatting - ui/Button: pass ariaLabel through to the button element - ui/DataTable: use functional setState updater to fix stale-closure sort direction - tsconfig.json: add bun-types so tsc resolves bun test globals
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 test(13/13 pass) andtsc --noEmit(clean) are both green. No test files were modified and no dependencies were added.Fixes
bunfig.toml— addedpreload = ["./packages/ui/test/setup.ts"]under[test]. When tests run from the repo root the root bunfig applies, but the happy-dom global registrator only ran via thepackages/uibunfig — sopackages/uiReact tests hitdocument is not defined. Preloading the setup at the root registers the DOM globals.apps/web/src/lib/api.ts— the hook was renameduseThrottle→useDebouncein@e2e/utils, but this file still imported/re-exported the old name, breaking theuseSearchDebouncere-export. Updated the import and re-export touseDebounce.packages/utils/src/format/date.ts—formatDateused explicitmonth/day/year: "numeric"options which rendered US month-first order. Switched to{ dateStyle: "short" }on theen-AUlocale so dates are day-first with no leading zero on single-digit days (e.g.1/03/2024).packages/ui/src/components/Button/Button.tsx— the destructuredariaLabelprop was never applied. Addedaria-label={iconOnly ? (ariaLabel ?? "") : ariaLabel}so icon-only buttons always carry the attribute (required by the test) and other buttons set it only when provided.packages/ui/src/components/DataTable/DataTable.tsx—handleSortreadsortDirfrom a stale closure, so a second click did not toggle to descending. Switched to the functional updatersetSortDir(prev => prev === "asc" ? "desc" : "asc").Supporting change
tsconfig.json— added"types": ["bun-types"]sotsc --noEmitresolves the Bun test globals (test,expect, …) used in the.test.tsfiles.bun-typesis already an installed dependency; no new deps added.Verification
bun test→ 13 pass / 0 failtsc --noEmit→ clean (exit 0)git diff --name-onlyconfirms notest/files were touched.Assumptions
bunfig.toml, the DOMsetup.tspreload, andtsconfig.jsonas configuration (not test files), so editing them is within the "do not modify test files" constraint.icon-only without aria-labeltest requires the attribute to be present (non-null) wheniconOnlyis set, so the empty-string fallback is intentional and kept.