Skip to content

[Cases] Fix flaky useSeverityAction 'update the severity cases' test by mocking mutation - #290648

Merged
kibanamachine merged 2 commits into
mainfrom
fix/flaky-207712-severity-action-mock-mutation-24484a5ce591ed24
Sep 15, 2026
Merged

kibanamachine merged 2 commits into
mainfrom
fix/flaky-207712-severity-action-mock-mutation-24484a5ce591ed24

Conversation

@kibanamachine

@kibanamachine kibanamachine commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #207712

Summary

  • useSeverityAction "update the severity cases" timed out (Exceeded timeout of 5000 ms) on CI Jest jobs.
  • The test drove the real useUpdateCases react-query mutation four times in a loop (only containers/api was mocked), and asserted onActionSuccess/updateCases synchronously after a waitFor that only gated on the synchronous onAction — so under CI parallel load the accumulated mutation lifecycle could blow the 5s budget.
  • This mocks use_bulk_update_case for that one test so mutate is a synchronous jest.fn() and asserts against it, exactly as the stable use_status_action.test.tsx sibling does. The toaster it.each tests keep the real hook, so their real-toast coverage is unchanged.
Runtime vs. 5s budget Passed Avg Max
Before fix 25/25 34ms 58ms
After fix 25/25 16ms 23ms

Context

  • Follows the failed-test investigator's proposed fix (mock the mutation hook like status does). That comment was stale (posted 2026-07-08, with failures after it), so the analysis was re-verified against current main: 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.
  • Failures were kibana-on-merge Jest jobs: first on main (Jan 2025, then skipped and later un-skipped), recurring on 8.x (Apr 2025) and repeatedly on 8.19 through 2026, most recently 2026-09-11.
  • Ruled out a product bug: the timeout is entirely test-orchestration cost (real mutation lifecycle looped four times); the production paths run only through immediately-resolving mocked api calls, so there is no product-side race.
Verification

Verified locally

  • ✅ Passed: node scripts/eslint x-pack/platform/plugins/shared/cases/public/components/actions/severity/use_severity_action.test.tsx
  • ✅ Passed: node scripts/jest .../severity/use_severity_action.test.tsx in 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

  • The flake does not reproduce on this runner (it passes 25/25 even unpatched), because the timeout only surfaces under CI's parallel CPU load — neither loop ran under that load. The fix is validated by removing the uncontrolled async source rather than by a failing-then-passing local loop.

Note

Share feedback in #kibana-qa. Mention @copilot to make quick changes.

Generated by Flaky Test Fixer for #207712 · claude · opus · 318.4 AIC · ⌖ 64.3 AIC · ⊞ 14.5K ·

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>
@kibanamachine kibanamachine added the flaky-test-fixer Automated PR created by the flaky test fixer workflow label Sep 11, 2026
@github-actions github-actions Bot added backport:all-open Backport to all branches that could still receive a release flaky-fix-check:skipped Flaky fix verifier: runner can't verify this fix (e.g. no Jest support) release_note:skip Skip the PR/issue when compiling release notes labels Sep 11, 2026
@kibanamachine

Copy link
Copy Markdown
Contributor Author

⏭️ Flaky-fix verification skipped

This is a Jest-only change (use_severity_action.test.tsx), so the /flaky runner can add no signal — required CI is the whole verdict. The patch is a compliant Jest fix (it removes the real async mutation step rather than adding retries or a timeout bump). Applied release_note:skip and backport:all-open.

Why the flaky test runner wasn't used

The /flaky runner accepts only FTR and Scout configs. This PR only touches the Jest test use_severity_action.test.tsx, which the fixer already validated by local repetition (25/25 before and after).

How release-note and backport labels were chosen

Applied release_note:skip because the change is test-only and not user-facing.

  • v9.5.4 → included; 9.5 has the identical pre-fix test file and the useUpdateCases hook, so the patch applies unchanged.
  • v9.4.7 → included; 9.4 has the identical pre-fix test file, so the patch applies unchanged.
  • v8.19.22 → included; 8.19 has the identical pre-fix test file and the useUpdateCases hook, so the patch applies unchanged.

Generated by Flaky Fix Verifier for #290648 · claude · opus · 191.1 AIC · ⌖ 37.4 AIC · ⊞ 15.8K ·

@kibanamachine
kibanamachine marked this pull request as ready for review September 11, 2026 17:06
@kibanamachine
kibanamachine requested a review from a team as a code owner September 11, 2026 17:06
@kibanamachine
kibanamachine enabled auto-merge (squash) September 11, 2026 17:06
@kibanamachine

Copy link
Copy Markdown
Contributor Author

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

Test Failures

  • [job] [logs] FTR Configs #109 / discover discover field visualize button "before all" hook for "shows "visualize" field button"
  • [job] [logs] Scout Lane #52 - serverless-observability_complete / default / local-serverless-observability_complete - Synthetics manage rules privilege - lets a read user with can_manage_rules enable default alerting
  • [job] [logs] Scout Lane #19 - stateful-classic / default / local-stateful-classic - Synthetics manage rules privilege - lets a read user with can_manage_rules enable default alerting

History

@kibanamachine
kibanamachine merged commit b3251aa into main Sep 15, 2026
41 checks passed
@kibanamachine
kibanamachine deleted the fix/flaky-207712-severity-action-mock-mutation-24484a5ce591ed24 branch September 15, 2026 12:33
@kibanamachine

Copy link
Copy Markdown
Contributor Author

Starting backport for target branches: 8.19, 9.4, 9.5

https://github.com/elastic/kibana/actions/runs/34969522594

@kibanamachine

Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19
9.4
9.5

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Sep 15, 2026
… 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>
kibanamachine added a commit that referenced this pull request Sep 15, 2026
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:all-open Backport to all branches that could still receive a release flaky-fix-check:skipped Flaky fix verifier: runner can't verify this fix (e.g. no Jest support) flaky-test-fixer Automated PR created by the flaky test fixer workflow release_note:skip Skip the PR/issue when compiling release notes v9.4.7 v9.5.4 v9.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing test: Jest Tests.x-pack/platform/plugins/shared/cases/public/components/actions/severity - useSeverityAction update the severity cases

2 participants