Skip to content

[Significant events] Cut the event flyout Actions-menu test cost - #301793

Open
kibanamachine wants to merge 1 commit into
mainfrom
fix/flaky-300968-actions-menu-test-cost-6c0b2fdf5dd84d5b
Open

kibanamachine wants to merge 1 commit into
mainfrom
fix/flaky-300968-actions-menu-test-cost-6c0b2fdf5dd84d5b

Conversation

@kibanamachine

Copy link
Copy Markdown
Contributor

Fixes #300968

Summary

  • Five EventFlyout cases that open the footer Actions menu drove the entire cost of the file and ran past Jest's 5s budget under CI load — only offers Mark inactive... at 5.358s, and opens a new chat from the Actions menu at 5.233s in the latest failure. Nothing failed an assertion.
  • They opened the menu with await userEvent.click, whose pointer sequence re-checks computed pointer-events styles across the whole flyout tree on every click. This swaps all nine clicks for fireEvent.click: togglePopover is a plain setIsOpen state update (menu_button.tsx:134-137) and RTL wraps fireEvent in act, so the item is queryable on the next line — the tests need the menu open, not a full pointer sequence.
  • Mark inactive was the only entry in actionMenuPanels without a data-test-subj, so five assertions reached for role + accessible name — RTL's most expensive query. It now carries one, making those assertions plain attribute lookups like its siblings'.
  • No timeout bump: the patch makes the test cheaper rather than waiting longer.
Runtime vs. 5s budget Passed Avg Max
Before fix 25/25 655ms 707ms
After fix 25/25 142ms 278ms

Relevant history

Context

  • Follows the latest investigator analysis, which supersedes its own earlier one: the first analysis pinned the cost on the *ByRole(..., { name }) menu assertions, but opens a new chat from the Actions menu already queries by test id with a single render and still blew the budget, so the dominant cost is the shared await userEvent.click path. Local profiling confirms this — see Verification.
  • The failing case does not reproduce on an idle runner (707ms against a 5000ms budget); CI timings are ~7.6x local for this case, which is what puts it over the edge.
  • Failures landed on kibana-on-merge for 9.6, twice in three days (build 114241, build 114692); the second build timed out on two of the five cases. The shard was not degraded (2 failures out of 15,857 cases). The same unfixed test is on main, so the fix lands here.
  • Ruled out a product-side race: every hook the flyout consumes is mocked to settled data, so no longer wait could resolve anything.
Verification

Verified locally

  • ✅ Passed: node scripts/eslint x-pack/solutions/observability/plugins/nightshift/public/components/entities/significant_event/event_flyout.test.tsx x-pack/solutions/observability/plugins/nightshift/public/components/entities/significant_event/event_flyout.tsx

  • ✅ Passed: node scripts/jest x-pack/.../significant_event/event_flyout.test.tsx — 25 runs before the fix and 25 after, 25/25 passing in both loops (the flake needs CI load and does not reproduce on an idle runner), with the five Actions-menu cases dropping from 2384ms avg / 2537ms max combined to 611ms / 767ms — 3.9x cheaper:

    Case Before (avg/max) After (avg/max)
    only offers Mark inactive... (reported) 655ms / 707ms 142ms / 278ms
    opens a new chat from the Actions menu 476ms / 505ms 147ms / 167ms
    marks an active event inactive... 503ms / 534ms 136ms / 175ms
    runs an investigation from the footer... 375ms / 503ms 104ms / 119ms
    offers a new chat instead... 373ms / 389ms 80ms / 89ms

    Afterwards no Actions-menu case is among the most expensive in the file — they sit at the level of the plain-render cases (~56–143ms).

  • ✅ Passed: no not wrapped in act warnings appear after the userEvent → fireEvent swap, confirming the menu item is in the DOM synchronously and no gating findByTestId is needed.

Not verified locally

  • Behavior under CI's parallel load, which is what pushed these cases over the budget — neither loop ran under contention.
  • Type checking was left to CI.

Important

The flaky test runner may verify the PR, but the owning team is responsible the next steps:

  • Review and merge it (update the branch or add missing labels if needed)
  • Make changes (check out the branch locally, or ask @copilot if Copilot is enabled on your account)
  • Close it if it is not worth shipping (share feedback in #kibana-qa)

Generated by Flaky Test Fixer for #300968 · claude · opus · 394 AIC · ⌖ 58.5 AIC · ⊞ 15.4K · ◷

The five EventFlyout cases that open the footer Actions menu drove the
entire cost of the file and timed out against Jest's 5s budget under CI
load. They opened the menu with `await userEvent.click`, whose pointer
sequence re-checks computed `pointer-events` styles across the whole
flyout tree on every click, and probed `Mark inactive` by role +
accessible name because it was the one menu item without a
`data-test-subj`.

Drive the menu with `fireEvent.click` instead -- `togglePopover` is a
plain `setIsOpen` state update and RTL wraps `fireEvent` in `act`, so the
item is queryable on the next line -- and give `Mark inactive` a
`data-test-subj` so its assertions are attribute lookups like its
siblings'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown
Contributor
🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!
  • Click to trigger kibana-static-checks for this PR!

@kibanamachine kibanamachine added the Team:nightshift Nightshift team. When scope is known, use sub-teams: sre-agent, context-and-research, investigations label Oct 29, 2026
@github-actions github-actions Bot added backport:version Backport to applied version labels 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 v9.6.0 labels Oct 29, 2026
@kibanamachine

Copy link
Copy Markdown
Contributor Author

⏭️ Flaky-fix verification skipped

This is a Jest-only change, so the flaky test runner can add no signal and the required CI Jest run is the whole verdict. Applied release_note:skip, backport:version and v9.6.0.

Why the flaky test runner wasn't used

The /flaky runner accepts only FTR and Scout configs. This PR touches event_flyout.test.tsx (Jest) plus a one-line data-test-subj addition in event_flyout.tsx, and the plugin's only Scout spec (test/scout/ui/tests/nightshift.spec.ts) never opens the event flyout's Actions menu — so no runner-supported config exercises the change. Repeated runs would also add nothing here: the fix removes cost rather than mitigating a race.

Screened the patch against the fix guidelines before skipping. togglePopover is a plain setIsOpen state update and resolvePanels spreads ...item, so the menu items are in the DOM synchronously after fireEvent.click and the new data-test-subj reaches the rendered item. The assertions still drive mockOpenChat / mockSignificantEventsFetch, nothing is skipped or loosened to pass, and no timeout was raised — this cuts the work rather than hiding the failure.

How release-note and backport labels were chosen

Applied release_note:skip because the only product change adds a data-test-subj attribute, which changes no user-facing behavior.

  • v9.6.0 → has both changed files, with the five Actions-menu cases and the Mark inactive item byte-identical to main's pre-fix state, so the patch applies unadapted.
  • v9.5.6 → the nightshift plugin does not exist on 9.5.
  • v9.4.9 → the nightshift plugin does not exist on 9.4.
  • v8.19.24 → the nightshift plugin does not exist on 8.19.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • raw.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "raw.githubusercontent.com"

See Network Configuration for more information.

Generated by Flaky Fix Verifier for #301793 · claude · opus · 345.8 AIC · ⌖ 58 AIC · ⊞ 16.9K · ◷

@kibanamachine
kibanamachine marked this pull request as ready for review October 29, 2026 21:01
@kibanamachine
kibanamachine requested a review from a team as a code owner October 29, 2026 21:01
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown
Contributor

Pinging @elastic/nightshift (Team:nightshift)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels 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 Team:nightshift Nightshift team. When scope is known, use sub-teams: sre-agent, context-and-research, investigations v9.6.0

Projects

None yet

1 participant