-
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
[React@18] Fix remaining unit tests #207195
Conversation
return { | ||
...origin, | ||
useDispatch: jest.fn(), | ||
useDispatch: jest.fn(() => mockDispatch), |
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.
} | ||
return prevTimelineTypes; | ||
}); | ||
setTimelineTypes(tabId); |
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.
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
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.
I agree ✅.
Pinging @elastic/appex-sharedux (Team:SharedUX) |
security-threat-hunting-investigations
await waitFor(async () => { | ||
await expect(findAllByTestId('trustedAppsListPage-card')).resolves.toHaveLength(10); | ||
expect(getAllByTestId('trustedAppsListPage-card')).toHaveLength(10); |
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.
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.
DW changes LGTM, thanks for addressing this!
💚 Build Succeeded
Metrics [docs]Async chunks
|
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.
Changes LGTM on behalf of @elastic/security-threat-hunting-investigations . Thank you for fixing these.
} | ||
return prevTimelineTypes; | ||
}); | ||
setTimelineTypes(tabId); |
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.
I agree ✅.
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12886839217 |
(cherry picked from commit 5766467)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.x`: - [[React@18] Fix remaining unit tests (#207195)](#207195) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Anton Dosov","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-21T12:22:16Z","message":"[React@18] Fix remaining unit tests (#207195)","sha":"57664673595086f917a268b273b90bb8af2d2c8d","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:SharedUX","backport:prev-minor","React@18"],"title":"[React@18] Fix remaining unit tests ","number":207195,"url":"https://github.com/elastic/kibana/pull/207195","mergeCommit":{"message":"[React@18] Fix remaining unit tests (#207195)","sha":"57664673595086f917a268b273b90bb8af2d2c8d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/207195","number":207195,"mergeCommit":{"message":"[React@18] Fix remaining unit tests (#207195)","sha":"57664673595086f917a268b273b90bb8af2d2c8d"}}]}] BACKPORT--> Co-authored-by: Anton Dosov <[email protected]>
…d search using expected exception item fields (#208396) (#208574) # Backport This will backport the following commits from `main` to `8.x`: - [[React@18] fix When on the host isolation exceptions page should search using expected exception item fields (#208396)](#208396) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Anton Dosov","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-28T16:32:02Z","message":"[React@18] fix When on the host isolation exceptions page should search using expected exception item fields (#208396)\n\n## Summary\r\n\r\nfix\r\nhttps://github.com//pull/208339#issuecomment-2615621371\r\n\r\n- [ ]\r\n[[job]](https://buildkite.com/elastic/kibana-pull-request/builds/270417#0194a78a-264a-4056-8026-2be65f9e16b9)\r\n[[logs]](https://buildkite.com/organizations/elastic/pipelines/kibana-pull-request/builds/270417/jobs/0194a78a-264a-4056-8026-2be65f9e16b9/artifacts/0194a7ad-2ab6-40c2-a11c-685683bbb663)\r\nJest Integration Tests / When on the host isolation exceptions page\r\nshould search using expected exception item fields\r\n\r\n\r\nFix the test so it passes with React@18\r\n\r\n\r\n```\r\nREACT_18=true node scripts/jest --config=x-pack/solutions/security/plugins/security_solution/jest.integration.config.js /x-pack/solutions/security/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/integration_tests/host_isolation_exceptions_list.test.tsx\r\n```\r\n\r\n\r\nWe already saw a very similar timeout failure here:\r\nhttps://github.com//pull/207195/files#r1922454027","sha":"8f10ac2163de398e8d22a0d14a5cbe99ccc951fa","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:SharedUX","backport:prev-minor","React@18"],"title":"[React@18] fix When on the host isolation exceptions page should search using expected exception item fields","number":208396,"url":"https://github.com/elastic/kibana/pull/208396","mergeCommit":{"message":"[React@18] fix When on the host isolation exceptions page should search using expected exception item fields (#208396)\n\n## Summary\r\n\r\nfix\r\nhttps://github.com//pull/208339#issuecomment-2615621371\r\n\r\n- [ ]\r\n[[job]](https://buildkite.com/elastic/kibana-pull-request/builds/270417#0194a78a-264a-4056-8026-2be65f9e16b9)\r\n[[logs]](https://buildkite.com/organizations/elastic/pipelines/kibana-pull-request/builds/270417/jobs/0194a78a-264a-4056-8026-2be65f9e16b9/artifacts/0194a7ad-2ab6-40c2-a11c-685683bbb663)\r\nJest Integration Tests / When on the host isolation exceptions page\r\nshould search using expected exception item fields\r\n\r\n\r\nFix the test so it passes with React@18\r\n\r\n\r\n```\r\nREACT_18=true node scripts/jest --config=x-pack/solutions/security/plugins/security_solution/jest.integration.config.js /x-pack/solutions/security/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/integration_tests/host_isolation_exceptions_list.test.tsx\r\n```\r\n\r\n\r\nWe already saw a very similar timeout failure here:\r\nhttps://github.com//pull/207195/files#r1922454027","sha":"8f10ac2163de398e8d22a0d14a5cbe99ccc951fa"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208396","number":208396,"mergeCommit":{"message":"[React@18] fix When on the host isolation exceptions page should search using expected exception item fields (#208396)\n\n## Summary\r\n\r\nfix\r\nhttps://github.com//pull/208339#issuecomment-2615621371\r\n\r\n- [ ]\r\n[[job]](https://buildkite.com/elastic/kibana-pull-request/builds/270417#0194a78a-264a-4056-8026-2be65f9e16b9)\r\n[[logs]](https://buildkite.com/organizations/elastic/pipelines/kibana-pull-request/builds/270417/jobs/0194a78a-264a-4056-8026-2be65f9e16b9/artifacts/0194a7ad-2ab6-40c2-a11c-685683bbb663)\r\nJest Integration Tests / When on the host isolation exceptions page\r\nshould search using expected exception item fields\r\n\r\n\r\nFix the test so it passes with React@18\r\n\r\n\r\n```\r\nREACT_18=true node scripts/jest --config=x-pack/solutions/security/plugins/security_solution/jest.integration.config.js /x-pack/solutions/security/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/integration_tests/host_isolation_exceptions_list.test.tsx\r\n```\r\n\r\n\r\nWe already saw a very similar timeout failure here:\r\nhttps://github.com//pull/207195/files#r1922454027","sha":"8f10ac2163de398e8d22a0d14a5cbe99ccc951fa"}}]}] BACKPORT--> Co-authored-by: Anton Dosov <[email protected]>
Summary
Part of #206952
Fixes remaining unit tests that are failing with React@18
The idea is that tests should pass with both React 17 and 18. To run a unit tests with React@18: