[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation - #290648
Conversation
Mock use_bulk_update_case in the looped severity-update test so the mutation is a synchronous jest.fn() and assert against it, mirroring the stable use_status_action.test.tsx sibling. This removes the real react-query mutation lifecycle (run four times in a loop) that could exceed the 5s Jest budget under CI parallel load. Toaster tests keep the real hook so their toast-rendering coverage is preserved. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
⏭️ Flaky-fix verification skippedThis is a Jest-only change ( Why the flaky test runner wasn't usedThe How release-note and backport labels were chosenApplied
|
…on-24484a5ce591ed24
💛 Build succeeded, but was flaky
Failed CI Steps
Metrics [docs]
Test Failures
History
|
|
Starting backport for target branches: 8.19, 9.4, 9.5 |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
… test by mocking mutation (#290648) (#291131) # Backport This will backport the following commits from `main` to `9.5`: - [[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)](#290648) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Kibana Machine","email":"42973632+kibanamachine@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-09-15T12:33:10Z","message":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)\n\nFixes #207712\n\n### Summary\n- `useSeverityAction` \"update the severity cases\" timed out (`Exceeded\ntimeout of 5000 ms`) on CI Jest jobs.\n- The test drove the **real** `useUpdateCases` react-query mutation four\ntimes in a loop (only `containers/api` was mocked), and asserted\n`onActionSuccess`/`updateCases` **synchronously** after a `waitFor` that\nonly gated on the synchronous `onAction` — so under CI parallel load the\naccumulated mutation lifecycle could blow the 5s budget.\n- This mocks `use_bulk_update_case` for that one test so `mutate` is a\nsynchronous `jest.fn()` and asserts against it, exactly as the stable\n`use_status_action.test.tsx` sibling does. The toaster `it.each` tests\nkeep the real hook, so their real-toast coverage is unchanged.\n\n| Runtime vs. 5s budget | Passed | Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 34ms | 58ms |\n| After fix | 25/25 | 16ms | 23ms |\n\n### Context\n- Follows the [failed-test investigator's proposed\nfix](https://github.com/elastic/kibana/issues/207712#issuecomment-4918460920)\n(mock the mutation hook like `status` does). That comment was stale\n(posted 2026-07-08, with failures after it), so the analysis was\nre-verified against current `main`: the flaky shape is still present and\nthe diagnosis holds. This PR departs from the comment in one detail —\nrather than restructuring the toaster tests, it leaves them on the real\nhook so no assertion coverage is lost.\n- Failures were `kibana-on-merge` Jest jobs: first on `main` (Jan 2025,\nthen skipped and later un-skipped), recurring on `8.x` (Apr 2025) and\nrepeatedly on `8.19` through 2026, most recently 2026-09-11.\n- Ruled out a product bug: the timeout is entirely test-orchestration\ncost (real mutation lifecycle looped four times); the production paths\nrun only through immediately-resolving mocked `api` calls, so there is\nno product-side race.\n\n<details>\n<summary>Verification</summary>\n\n#### Verified locally\n\n- ✅ Passed: `node scripts/eslint\nx-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsx`\n- ✅ Passed: `node scripts/jest\n.../severity/use_severity_action.test.tsx` in a 25x loop: 25/25 before\nthe fix (avg 34ms, max 58ms), 25/25 after (avg 16ms, max 23ms) — the\nafter-fix run removes the real async mutation, halving the looped test's\nruntime.\n\n#### Not verified locally\n\n- The flake does not reproduce on this runner (it passes 25/25 even\nunpatched), because the timeout only surfaces under CI's parallel CPU\nload — neither loop ran under that load. The fix is validated by\nremoving the uncontrolled async source rather than by a\nfailing-then-passing local loop.\n\n</details>\n\n> [!NOTE]\n> Share feedback in #kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by [Flaky Test\nFixer](https://github.com/elastic/kibana/actions/runs/34622699025) for\n#207712 · claude · opus · 318.4 AIC · ⌖ 64.3 AIC · ⊞ 14.5K ·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\nCo-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>","sha":"b3251aa587584cafa5897cea4d517a505a90bb82","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","flaky-test-fixer","flaky-fix-check:skipped","v9.6.0"],"title":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation","number":290648,"url":"https://github.com/elastic/kibana/pull/290648","mergeCommit":{"message":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)\n\nFixes #207712\n\n### Summary\n- `useSeverityAction` \"update the severity cases\" timed out (`Exceeded\ntimeout of 5000 ms`) on CI Jest jobs.\n- The test drove the **real** `useUpdateCases` react-query mutation four\ntimes in a loop (only `containers/api` was mocked), and asserted\n`onActionSuccess`/`updateCases` **synchronously** after a `waitFor` that\nonly gated on the synchronous `onAction` — so under CI parallel load the\naccumulated mutation lifecycle could blow the 5s budget.\n- This mocks `use_bulk_update_case` for that one test so `mutate` is a\nsynchronous `jest.fn()` and asserts against it, exactly as the stable\n`use_status_action.test.tsx` sibling does. The toaster `it.each` tests\nkeep the real hook, so their real-toast coverage is unchanged.\n\n| Runtime vs. 5s budget | Passed | Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 34ms | 58ms |\n| After fix | 25/25 | 16ms | 23ms |\n\n### Context\n- Follows the [failed-test investigator's proposed\nfix](https://github.com/elastic/kibana/issues/207712#issuecomment-4918460920)\n(mock the mutation hook like `status` does). That comment was stale\n(posted 2026-07-08, with failures after it), so the analysis was\nre-verified against current `main`: the flaky shape is still present and\nthe diagnosis holds. This PR departs from the comment in one detail —\nrather than restructuring the toaster tests, it leaves them on the real\nhook so no assertion coverage is lost.\n- Failures were `kibana-on-merge` Jest jobs: first on `main` (Jan 2025,\nthen skipped and later un-skipped), recurring on `8.x` (Apr 2025) and\nrepeatedly on `8.19` through 2026, most recently 2026-09-11.\n- Ruled out a product bug: the timeout is entirely test-orchestration\ncost (real mutation lifecycle looped four times); the production paths\nrun only through immediately-resolving mocked `api` calls, so there is\nno product-side race.\n\n<details>\n<summary>Verification</summary>\n\n#### Verified locally\n\n- ✅ Passed: `node scripts/eslint\nx-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsx`\n- ✅ Passed: `node scripts/jest\n.../severity/use_severity_action.test.tsx` in a 25x loop: 25/25 before\nthe fix (avg 34ms, max 58ms), 25/25 after (avg 16ms, max 23ms) — the\nafter-fix run removes the real async mutation, halving the looped test's\nruntime.\n\n#### Not verified locally\n\n- The flake does not reproduce on this runner (it passes 25/25 even\nunpatched), because the timeout only surfaces under CI's parallel CPU\nload — neither loop ran under that load. The fix is validated by\nremoving the uncontrolled async source rather than by a\nfailing-then-passing local loop.\n\n</details>\n\n> [!NOTE]\n> Share feedback in #kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by [Flaky Test\nFixer](https://github.com/elastic/kibana/actions/runs/34622699025) for\n#207712 · claude · opus · 318.4 AIC · ⌖ 64.3 AIC · ⊞ 14.5K ·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\nCo-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>","sha":"b3251aa587584cafa5897cea4d517a505a90bb82"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/290648","number":290648,"mergeCommit":{"message":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)\n\nFixes #207712\n\n### Summary\n- `useSeverityAction` \"update the severity cases\" timed out (`Exceeded\ntimeout of 5000 ms`) on CI Jest jobs.\n- The test drove the **real** `useUpdateCases` react-query mutation four\ntimes in a loop (only `containers/api` was mocked), and asserted\n`onActionSuccess`/`updateCases` **synchronously** after a `waitFor` that\nonly gated on the synchronous `onAction` — so under CI parallel load the\naccumulated mutation lifecycle could blow the 5s budget.\n- This mocks `use_bulk_update_case` for that one test so `mutate` is a\nsynchronous `jest.fn()` and asserts against it, exactly as the stable\n`use_status_action.test.tsx` sibling does. The toaster `it.each` tests\nkeep the real hook, so their real-toast coverage is unchanged.\n\n| Runtime vs. 5s budget | Passed | Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 34ms | 58ms |\n| After fix | 25/25 | 16ms | 23ms |\n\n### Context\n- Follows the [failed-test investigator's proposed\nfix](https://github.com/elastic/kibana/issues/207712#issuecomment-4918460920)\n(mock the mutation hook like `status` does). That comment was stale\n(posted 2026-07-08, with failures after it), so the analysis was\nre-verified against current `main`: the flaky shape is still present and\nthe diagnosis holds. This PR departs from the comment in one detail —\nrather than restructuring the toaster tests, it leaves them on the real\nhook so no assertion coverage is lost.\n- Failures were `kibana-on-merge` Jest jobs: first on `main` (Jan 2025,\nthen skipped and later un-skipped), recurring on `8.x` (Apr 2025) and\nrepeatedly on `8.19` through 2026, most recently 2026-09-11.\n- Ruled out a product bug: the timeout is entirely test-orchestration\ncost (real mutation lifecycle looped four times); the production paths\nrun only through immediately-resolving mocked `api` calls, so there is\nno product-side race.\n\n<details>\n<summary>Verification</summary>\n\n#### Verified locally\n\n- ✅ Passed: `node scripts/eslint\nx-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsx`\n- ✅ Passed: `node scripts/jest\n.../severity/use_severity_action.test.tsx` in a 25x loop: 25/25 before\nthe fix (avg 34ms, max 58ms), 25/25 after (avg 16ms, max 23ms) — the\nafter-fix run removes the real async mutation, halving the looped test's\nruntime.\n\n#### Not verified locally\n\n- The flake does not reproduce on this runner (it passes 25/25 even\nunpatched), because the timeout only surfaces under CI's parallel CPU\nload — neither loop ran under that load. The fix is validated by\nremoving the uncontrolled async source rather than by a\nfailing-then-passing local loop.\n\n</details>\n\n> [!NOTE]\n> Share feedback in #kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by [Flaky Test\nFixer](https://github.com/elastic/kibana/actions/runs/34622699025) for\n#207712 · claude · opus · 318.4 AIC · ⌖ 64.3 AIC · ⊞ 14.5K ·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\nCo-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>","sha":"b3251aa587584cafa5897cea4d517a505a90bb82"}}]}] BACKPORT--> Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com> Co-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>
… test by mocking mutation (#290648) (#291130) # Backport This will backport the following commits from `main` to `9.4`: - [[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)](#290648) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Kibana Machine","email":"42973632+kibanamachine@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-09-15T12:33:10Z","message":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)\n\nFixes #207712\n\n### Summary\n- `useSeverityAction` \"update the severity cases\" timed out (`Exceeded\ntimeout of 5000 ms`) on CI Jest jobs.\n- The test drove the **real** `useUpdateCases` react-query mutation four\ntimes in a loop (only `containers/api` was mocked), and asserted\n`onActionSuccess`/`updateCases` **synchronously** after a `waitFor` that\nonly gated on the synchronous `onAction` — so under CI parallel load the\naccumulated mutation lifecycle could blow the 5s budget.\n- This mocks `use_bulk_update_case` for that one test so `mutate` is a\nsynchronous `jest.fn()` and asserts against it, exactly as the stable\n`use_status_action.test.tsx` sibling does. The toaster `it.each` tests\nkeep the real hook, so their real-toast coverage is unchanged.\n\n| Runtime vs. 5s budget | Passed | Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 34ms | 58ms |\n| After fix | 25/25 | 16ms | 23ms |\n\n### Context\n- Follows the [failed-test investigator's proposed\nfix](https://github.com/elastic/kibana/issues/207712#issuecomment-4918460920)\n(mock the mutation hook like `status` does). That comment was stale\n(posted 2026-07-08, with failures after it), so the analysis was\nre-verified against current `main`: the flaky shape is still present and\nthe diagnosis holds. This PR departs from the comment in one detail —\nrather than restructuring the toaster tests, it leaves them on the real\nhook so no assertion coverage is lost.\n- Failures were `kibana-on-merge` Jest jobs: first on `main` (Jan 2025,\nthen skipped and later un-skipped), recurring on `8.x` (Apr 2025) and\nrepeatedly on `8.19` through 2026, most recently 2026-09-11.\n- Ruled out a product bug: the timeout is entirely test-orchestration\ncost (real mutation lifecycle looped four times); the production paths\nrun only through immediately-resolving mocked `api` calls, so there is\nno product-side race.\n\n<details>\n<summary>Verification</summary>\n\n#### Verified locally\n\n- ✅ Passed: `node scripts/eslint\nx-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsx`\n- ✅ Passed: `node scripts/jest\n.../severity/use_severity_action.test.tsx` in a 25x loop: 25/25 before\nthe fix (avg 34ms, max 58ms), 25/25 after (avg 16ms, max 23ms) — the\nafter-fix run removes the real async mutation, halving the looped test's\nruntime.\n\n#### Not verified locally\n\n- The flake does not reproduce on this runner (it passes 25/25 even\nunpatched), because the timeout only surfaces under CI's parallel CPU\nload — neither loop ran under that load. The fix is validated by\nremoving the uncontrolled async source rather than by a\nfailing-then-passing local loop.\n\n</details>\n\n> [!NOTE]\n> Share feedback in #kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by [Flaky Test\nFixer](https://github.com/elastic/kibana/actions/runs/34622699025) for\n#207712 · claude · opus · 318.4 AIC · ⌖ 64.3 AIC · ⊞ 14.5K ·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\nCo-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>","sha":"b3251aa587584cafa5897cea4d517a505a90bb82","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","flaky-test-fixer","flaky-fix-check:skipped","v9.6.0"],"title":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation","number":290648,"url":"https://github.com/elastic/kibana/pull/290648","mergeCommit":{"message":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)\n\nFixes #207712\n\n### Summary\n- `useSeverityAction` \"update the severity cases\" timed out (`Exceeded\ntimeout of 5000 ms`) on CI Jest jobs.\n- The test drove the **real** `useUpdateCases` react-query mutation four\ntimes in a loop (only `containers/api` was mocked), and asserted\n`onActionSuccess`/`updateCases` **synchronously** after a `waitFor` that\nonly gated on the synchronous `onAction` — so under CI parallel load the\naccumulated mutation lifecycle could blow the 5s budget.\n- This mocks `use_bulk_update_case` for that one test so `mutate` is a\nsynchronous `jest.fn()` and asserts against it, exactly as the stable\n`use_status_action.test.tsx` sibling does. The toaster `it.each` tests\nkeep the real hook, so their real-toast coverage is unchanged.\n\n| Runtime vs. 5s budget | Passed | Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 34ms | 58ms |\n| After fix | 25/25 | 16ms | 23ms |\n\n### Context\n- Follows the [failed-test investigator's proposed\nfix](https://github.com/elastic/kibana/issues/207712#issuecomment-4918460920)\n(mock the mutation hook like `status` does). That comment was stale\n(posted 2026-07-08, with failures after it), so the analysis was\nre-verified against current `main`: the flaky shape is still present and\nthe diagnosis holds. This PR departs from the comment in one detail —\nrather than restructuring the toaster tests, it leaves them on the real\nhook so no assertion coverage is lost.\n- Failures were `kibana-on-merge` Jest jobs: first on `main` (Jan 2025,\nthen skipped and later un-skipped), recurring on `8.x` (Apr 2025) and\nrepeatedly on `8.19` through 2026, most recently 2026-09-11.\n- Ruled out a product bug: the timeout is entirely test-orchestration\ncost (real mutation lifecycle looped four times); the production paths\nrun only through immediately-resolving mocked `api` calls, so there is\nno product-side race.\n\n<details>\n<summary>Verification</summary>\n\n#### Verified locally\n\n- ✅ Passed: `node scripts/eslint\nx-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsx`\n- ✅ Passed: `node scripts/jest\n.../severity/use_severity_action.test.tsx` in a 25x loop: 25/25 before\nthe fix (avg 34ms, max 58ms), 25/25 after (avg 16ms, max 23ms) — the\nafter-fix run removes the real async mutation, halving the looped test's\nruntime.\n\n#### Not verified locally\n\n- The flake does not reproduce on this runner (it passes 25/25 even\nunpatched), because the timeout only surfaces under CI's parallel CPU\nload — neither loop ran under that load. The fix is validated by\nremoving the uncontrolled async source rather than by a\nfailing-then-passing local loop.\n\n</details>\n\n> [!NOTE]\n> Share feedback in #kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by [Flaky Test\nFixer](https://github.com/elastic/kibana/actions/runs/34622699025) for\n#207712 · claude · opus · 318.4 AIC · ⌖ 64.3 AIC · ⊞ 14.5K ·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\nCo-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>","sha":"b3251aa587584cafa5897cea4d517a505a90bb82"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/290648","number":290648,"mergeCommit":{"message":"[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation (#290648)\n\nFixes #207712\n\n### Summary\n- `useSeverityAction` \"update the severity cases\" timed out (`Exceeded\ntimeout of 5000 ms`) on CI Jest jobs.\n- The test drove the **real** `useUpdateCases` react-query mutation four\ntimes in a loop (only `containers/api` was mocked), and asserted\n`onActionSuccess`/`updateCases` **synchronously** after a `waitFor` that\nonly gated on the synchronous `onAction` — so under CI parallel load the\naccumulated mutation lifecycle could blow the 5s budget.\n- This mocks `use_bulk_update_case` for that one test so `mutate` is a\nsynchronous `jest.fn()` and asserts against it, exactly as the stable\n`use_status_action.test.tsx` sibling does. The toaster `it.each` tests\nkeep the real hook, so their real-toast coverage is unchanged.\n\n| Runtime vs. 5s budget | Passed | Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 34ms | 58ms |\n| After fix | 25/25 | 16ms | 23ms |\n\n### Context\n- Follows the [failed-test investigator's proposed\nfix](https://github.com/elastic/kibana/issues/207712#issuecomment-4918460920)\n(mock the mutation hook like `status` does). That comment was stale\n(posted 2026-07-08, with failures after it), so the analysis was\nre-verified against current `main`: the flaky shape is still present and\nthe diagnosis holds. This PR departs from the comment in one detail —\nrather than restructuring the toaster tests, it leaves them on the real\nhook so no assertion coverage is lost.\n- Failures were `kibana-on-merge` Jest jobs: first on `main` (Jan 2025,\nthen skipped and later un-skipped), recurring on `8.x` (Apr 2025) and\nrepeatedly on `8.19` through 2026, most recently 2026-09-11.\n- Ruled out a product bug: the timeout is entirely test-orchestration\ncost (real mutation lifecycle looped four times); the production paths\nrun only through immediately-resolving mocked `api` calls, so there is\nno product-side race.\n\n<details>\n<summary>Verification</summary>\n\n#### Verified locally\n\n- ✅ Passed: `node scripts/eslint\nx-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsx`\n- ✅ Passed: `node scripts/jest\n.../severity/use_severity_action.test.tsx` in a 25x loop: 25/25 before\nthe fix (avg 34ms, max 58ms), 25/25 after (avg 16ms, max 23ms) — the\nafter-fix run removes the real async mutation, halving the looped test's\nruntime.\n\n#### Not verified locally\n\n- The flake does not reproduce on this runner (it passes 25/25 even\nunpatched), because the timeout only surfaces under CI's parallel CPU\nload — neither loop ran under that load. The fix is validated by\nremoving the uncontrolled async source rather than by a\nfailing-then-passing local loop.\n\n</details>\n\n> [!NOTE]\n> Share feedback in #kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by [Flaky Test\nFixer](https://github.com/elastic/kibana/actions/runs/34622699025) for\n#207712 · claude · opus · 318.4 AIC · ⌖ 64.3 AIC · ⊞ 14.5K ·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\nCo-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>","sha":"b3251aa587584cafa5897cea4d517a505a90bb82"}}]}] BACKPORT--> Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com> Co-authored-by: Valentina Radtke <valentina.glagoleva@elastic.co>
Fixes #207712
Summary
useSeverityAction"update the severity cases" timed out (Exceeded timeout of 5000 ms) on CI Jest jobs.useUpdateCasesreact-query mutation four times in a loop (onlycontainers/apiwas mocked), and assertedonActionSuccess/updateCasessynchronously after awaitForthat only gated on the synchronousonAction— so under CI parallel load the accumulated mutation lifecycle could blow the 5s budget.use_bulk_update_casefor that one test somutateis a synchronousjest.fn()and asserts against it, exactly as the stableuse_status_action.test.tsxsibling does. The toasterit.eachtests keep the real hook, so their real-toast coverage is unchanged.Context
statusdoes). That comment was stale (posted 2026-07-08, with failures after it), so the analysis was re-verified against currentmain: the flaky shape is still present and the diagnosis holds. This PR departs from the comment in one detail — rather than restructuring the toaster tests, it leaves them on the real hook so no assertion coverage is lost.kibana-on-mergeJest jobs: first onmain(Jan 2025, then skipped and later un-skipped), recurring on8.x(Apr 2025) and repeatedly on8.19through 2026, most recently 2026-09-11.apicalls, so there is no product-side race.Verification
Verified locally
node scripts/eslint x-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsxnode scripts/jest .../severity/use_severity_action.test.tsxin a 25x loop: 25/25 before the fix (avg 34ms, max 58ms), 25/25 after (avg 16ms, max 23ms) — the after-fix run removes the real async mutation, halving the looped test's runtime.Not verified locally
Note
Share feedback in #kibana-qa. Mention
@copilotto make quick changes.