-
Notifications
You must be signed in to change notification settings - Fork 69
fix: Fixes tests failing in React 17 #3112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
465a76a
Update r17-packages.json
TheSonOfThomp a725e3d
Update transformToNestedData.spec.ts
TheSonOfThomp edf5214
Update DrawerToolbarContext.spec.tsx
TheSonOfThomp a40c4e7
Update Message.spec.tsx
TheSonOfThomp 8db4bec
WIP resizable
TheSonOfThomp eafc748
Update setup.js
TheSonOfThomp 273485a
useResizable
TheSonOfThomp 78307c0
Update useScreenReaderAnnouncer.tsx
TheSonOfThomp 8e59066
Update ProgressBar.spec.tsx
TheSonOfThomp 2941777
changeset
TheSonOfThomp a4dbbc4
Update .changeset/progress-bar-strict.md
TheSonOfThomp bc5f979
Update react17.yml
TheSonOfThomp 4b73c15
Update react17.yml
TheSonOfThomp fef534b
Update react17.yml
TheSonOfThomp 7ad5fde
export isReact17
TheSonOfThomp 3a448af
Update transformToNestedData.spec.ts
TheSonOfThomp 0aca769
Update transformToNestedData.spec.ts
TheSonOfThomp 7c75776
rm cache: false
TheSonOfThomp 0ebe400
useDrawerToolbarContext tests
TheSonOfThomp 0218746
consistent queryByRole
TheSonOfThomp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@leafygreen-ui/progress-bar': patch | ||
--- | ||
|
||
Updates ProgressBar `useScreenReaderAnnouncer` to deterministically return a consistent status message (primarily a concern in React 17 strict mode) |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { MutableRefObject } from 'react'; | ||
import { fireEvent } from '@testing-library/dom'; | ||
import { act } from '@testing-library/react'; | ||
|
||
import { renderHook } from '@leafygreen-ui/testing-lib'; | ||
import { act, renderHook } from '@leafygreen-ui/testing-lib'; | ||
|
||
import { useResizable } from './useResizable'; | ||
import { KEYBOARD_RESIZE_PIXEL_STEP } from './useResizable.constants'; | ||
|
@@ -11,16 +11,20 @@ import { Position } from './useResizable.types'; | |
Object.defineProperty(window, 'innerWidth', { value: 1024 }); | ||
Object.defineProperty(window, 'innerHeight', { value: 768 }); | ||
|
||
const mockDiv: HTMLDivElement = document.createElement('div'); | ||
|
||
describe('useResizable', () => { | ||
const mockRef = { | ||
current: { | ||
...mockDiv, | ||
offsetWidth: 300, | ||
offsetHeight: 300, | ||
style: { | ||
...mockDiv.style, | ||
setProperty: jest.fn(), | ||
removeProperty: jest.fn(), | ||
}, | ||
}, | ||
} as HTMLDivElement, | ||
}; | ||
Comment on lines
+14
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious why this was needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Started getting flaky TS errors otherwise |
||
|
||
beforeEach(() => { | ||
|
@@ -73,17 +77,20 @@ describe('useResizable', () => { | |
); | ||
|
||
// current is read-only from outside the hook but for testing we can set it directly | ||
(result.current.resizableRef as any).current = mockRef.current; | ||
const resultRef = result.current | ||
.resizableRef as MutableRefObject<HTMLDivElement>; | ||
resultRef.current = mockRef.current; | ||
|
||
// Start resizing | ||
const resizerProps = result.current.getResizerProps(); | ||
|
||
// Trigger a MouseDown event to initiate resizing | ||
act(() => { | ||
// @ts-expect-error - onMouseDown expects all properties of MouseEvent | ||
resizerProps?.onMouseDown({ | ||
preventDefault: jest.fn(), | ||
const mouseDownEvent = new MouseEvent('mousedown', { | ||
clientX: 300, | ||
clientY: 300, | ||
}); | ||
resizerProps?.onMouseDown(mouseDownEvent); | ||
}); | ||
|
||
// Simulate mouse movement | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.