[9.3] [ML] Fix flaky source_selection test by asserting against the visible callout copy (#280705)#280873
Open
kibanamachine wants to merge 1 commit into
Open
[9.3] [ML] Fix flaky source_selection test by asserting against the visible callout copy (#280705)#280873kibanamachine wants to merge 1 commit into
kibanamachine wants to merge 1 commit into
Conversation
… callout copy (elastic#280705) Fixes elastic#280686 - likely introduced by elastic#235054 (cc `@paulinashakirova`) ### Summary - The `analyticsCreateSourceIndexModalCcsErrorCallOut` callout is rendered with `announceOnMount`, so EUI mounts a screen-reader `role="status"` copy of the title (and body) alongside the visible copy. - Three positive assertions used single-match `queryByText(...)`, which throws `Found multiple elements` whenever the SR copy is present — a timing-dependent flake. - This patch switches those three assertions to `getAllByText(...)[0]`, asserting against the visible copy (which precedes the live-region copy in the DOM). No production change — `announceOnMount` is intended a11y behavior. ### Context - Follows the [failed-test investigator's proposed fix](elastic#280686 (comment)) exactly (the already-merged `getAllByText(...)[0]` pattern from elastic#269061). - Failure was on `main` in the `kibana-on-merge` Jest lane ([build 103893](https://buildkite.com/elastic/kibana-on-merge/builds/103893#019f9342-9398-4616-9954-22fbe43a9695)); the `announceOnMount` copy is populated on a `setTimeout`, so whether the duplicate exists when the assertion runs is a race. - Also fixes the identical title+body assertions in the sibling test (subject of elastic#254968), which carry the same bug. <details> <summary>Verification</summary> #### Verified locally - `✅ Passed: node scripts/eslint x-pack/platform/plugins/shared/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.test.tsx` - `✅ Passed: node scripts/jest x-pack/platform/plugins/shared/ml/public/application/data_frame_analytics/pages/analytics_management/components/source_selection/source_selection.test.tsx` — all 5 tests pass #### Not verified locally - `node scripts/type_check --project x-pack/platform/plugins/shared/ml/tsconfig.json` was killed by the sandbox's memory limit (SIGKILL) before completing, twice. The change is a test-only edit using standard `@testing-library/react` APIs (`getAllByText(...)[0]` returns an `HTMLElement`) and introduces no new types. </details> <details> <summary>Backporting guidance</summary> Applied `backport:version` with `v9.5.0`, `v9.4.5`, and `v9.3.9`. The `announceOnMount` root cause was introduced by elastic#235054 (`v9.3.0`), and the test file exists unchanged on the `9.5`, `9.4`, and `9.3` release branches, so the patch applies there cleanly. The `8.19` branch predates `announceOnMount` (no duplicate copy, no flake), so it is excluded. </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/30081512525) for elastic#280686 · 229.9 AIC · ⌖ 11.5 AIC · ⊞ 672 · [◷](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: 30081512525, workflow_id: flaky-test-fixer, run: https://github.com/elastic/kibana/actions/runs/30081512525 --> <!-- gh-aw-workflow-id: flaky-test-fixer --> <!-- gh-aw-workflow-call-id: elastic/kibana/flaky-test-fixer --> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit d4e18e0)
Contributor
Author
💚 Build Succeeded
Metrics [docs]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto9.3:Questions ?
Please refer to the Backport tool documentation