Skip to content

Commit 8e8757b

Browse files
kibanamachineclaudemarkov00
authored
[Lens] Use fireEvent for flyout close-button click to fix Jest timeout (#290263)
Fixes #290124 ### Summary - The only case using `await userEvent.click` (`flyout_wrapper.test.tsx:92`) hit the 5000 ms timeout under CI parallel load, while the three synchronous cases rendering the same component passed — the async interaction machinery, not the assertion, ran out of budget. - The close button's handler is a plain synchronous `onClick={onCancel}`, so nothing needs awaiting. This swaps `userEvent.click` for `fireEvent.click` (which RTL still wraps in `act`), removing the pointer/actionability/tooltip-timer overhead while the `expect(onCancel).toHaveBeenCalledTimes(1)` still reads synchronously. | Runtime vs. 5s budget | Passed | Avg | Max | | --- | --- | --- | --- | | Before fix | 25/25 | 66ms | 106ms | | After fix | 25/25 | 24ms | 27ms | ### Context - Follows the [failed-test investigator's proposed fix](#290124 (comment)) verbatim; independent code review of `flyout_wrapper.tsx:112` (`onClick={onCancel}`) and the test file confirmed the diagnosis is still current. - Failures were on `kibana-on-merge - main` (Jest Tests), reported twice — first on 2026-09-09 and again on 2026-09-10 with the same `Exceeded timeout of 5000 ms` signature. - The close button is wrapped in an `EuiToolTip` that arms show/hide timers on hover, which is what tipped `userEvent`'s overhead past the 5s budget under load; the local runtime table above shows the swap cuts the per-test cost by ~64% and removes the tail. <details> <summary>Verification</summary> #### Verified locally - ✅ Passed: `node scripts/eslint x-pack/platform/plugins/shared/lens/public/app_plugin/shared/edit_on_the_fly/flyout_wrapper.test.tsx` - ✅ Passed: `node scripts/jest x-pack/platform/plugins/shared/lens/public/app_plugin/shared/edit_on_the_fly/flyout_wrapper.test.tsx`: 25/25 passed before the fix (avg 66ms, max 106ms), 25/25 after (avg 24ms, max 27ms) #### Not verified locally - The 5s timeout does not reproduce locally — it only surfaces under CI parallel load — so the pass counts above cannot prove the flake is gone. What they do show is that the fix removes the async `userEvent` machinery and lowers the test's cost, which is the mechanism behind the timeout. </details> > [!NOTE] > Share feedback in #kibana-qa. Mention `@copilot` to make quick changes. > Generated by [Flaky Test Fixer](https://github.com/elastic/kibana/actions/runs/34463750481) for #290124 · claude · opus · 270.2 AIC · ⌖ 64.9 AIC · ⊞ 14.5K · [◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests) <!-- gh-aw-agentic-workflow: Flaky Test Fixer, engine: claude, version: 2.1.165, model: opus, id: 34463750481, workflow_id: flaky-test-fixer, run: https://github.com/elastic/kibana/actions/runs/34463750481 --> <!-- gh-aw-workflow-id: flaky-test-fixer --> <!-- gh-aw-workflow-call-id: elastic/kibana/flaky-test-fixer --> Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com> Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
1 parent ddc08a0 commit 8e8757b

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

x-pack/platform/plugins/shared/lens/public/app_plugin/shared/edit_on_the_fly/flyout_wrapper.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
*/
77

88
import React from 'react';
9-
import { screen } from '@testing-library/react';
10-
import userEvent from '@testing-library/user-event';
9+
import { fireEvent, screen } from '@testing-library/react';
1110
import { renderWithReduxStore } from '../../../mocks';
1211
import { FlyoutWrapper } from './flyout_wrapper';
1312
import type { FlyoutWrapperProps } from './types';
@@ -89,7 +88,7 @@ describe('Flyout wrapper', () => {
8988
it('should call onCancel when the header close button is clicked', async () => {
9089
const { onCancel } = mountFlyoutWrapper();
9190

92-
await userEvent.click(screen.getByTestId('euiFlyoutCloseButton'));
91+
fireEvent.click(screen.getByTestId('euiFlyoutCloseButton'));
9392

9493
expect(onCancel).toHaveBeenCalledTimes(1);
9594
});

0 commit comments

Comments
 (0)