-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[React@18] Fix remaining unit tests #207195
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,10 @@ jest.mock('../../../../sourcerer/containers'); | |
jest.mock('../../open_timeline/use_timeline_status'); | ||
jest.mock('react-redux', () => { | ||
const origin = jest.requireActual('react-redux'); | ||
const mockDispatch = jest.fn(); | ||
return { | ||
...origin, | ||
useDispatch: jest.fn(), | ||
useDispatch: jest.fn(() => mockDispatch), | ||
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. |
||
}; | ||
}); | ||
jest.mock('react-router-dom', () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,12 +88,7 @@ export const useTimelineTypes = ({ | |
|
||
const onFilterClicked = useCallback( | ||
(tabId: TimelineType, tabStyle: TimelineTabsStyle) => { | ||
setTimelineTypes((prevTimelineTypes) => { | ||
if (prevTimelineTypes !== tabId) { | ||
setTimelineTypes(tabId); | ||
} | ||
return prevTimelineTypes; | ||
}); | ||
setTimelineTypes(tabId); | ||
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. This fixes Given the failed test, it seems there was a genuine runtime bug with React@18. It appears that the behavior of this pattern has changed in React@18 compared to React@17. I suspect that the original logic was lost over several refactorings and there is no need to nest setState in the same setState anymore, but please doublecheck |
||
}, | ||
[setTimelineTypes] | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes [job] [logs] Jest Tests / When on the trusted applications page should search using expected exception item fields