fix: resolve 4 cross-package bugs causing test failures#20
Open
stooit wants to merge 1 commit into
Open
Conversation
- Fix renamed hook: re-export useDebounce as useSearchDebounce in api.ts - Fix date format: use 'd/MM/yyyy' (no zero-padded day) in date utility - Fix stale closure: use functional setState in DataTable sort handler - Fix a11y: spread aria-label prop through Button component - Fix DOM environment: configure happy-dom preload in root bunfig.toml
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 across 4 test files in this TypeScript monorepo by addressing 4 cross-package bugs:
Renamed hook (
apps/web/src/lib/api.ts): TheuseDebouncehook inpackages/utilswas imported asuseThrottleand re-exported as a non-existent name. Fixed to importuseDebounceand re-export it asuseSearchDebounce(which the web app's test expects).Date format (
packages/utils/src/format/date.ts): Changed format string fromdd/MM/yyyytod/MM/yyyy— the test expects no zero-padding on the day.Stale closure (
packages/ui/src/components/DataTable/DataTable.tsx): The sort click handler captured stale state. Fixed by using functionalsetStateupdate (prev => ...) so it always reads the latest sort direction.Accessibility (
packages/ui/src/components/Button/Button.tsx): The Button component wasn't passing througharia-label. Fixed by spreading remaining props onto the button element.DOM environment (
bunfig.toml): UI tests failed withdocument is not definedbecause bun 1.3.14 doesn't supportenvironment = "happy-dom"in bunfig.toml. Fixed by preloading a setup script that callsGlobalRegistrator.register().Verification
Assumptions
bun:testTypeScript errors are pre-existing and acceptable (bun runtime types not in tsconfig)