Skip to content

[9.5] [ML] Fix flaky source_selection test by asserting against the visible callout copy (#280705)#280875

Merged
kibanamachine merged 1 commit into
elastic:9.5from
kibanamachine:backport/9.5/pr-280705
Jul 24, 2026
Merged

[9.5] [ML] Fix flaky source_selection test by asserting against the visible callout copy (#280705)#280875
kibanamachine merged 1 commit into
elastic:9.5from
kibanamachine:backport/9.5/pr-280705

Conversation

@kibanamachine

Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.5:

Questions ?

Please refer to the Backport tool documentation

… 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)
@kibanamachine

Copy link
Copy Markdown
Contributor Author

💚 Build Succeeded

Metrics [docs]

✅ unchanged

cc @kibanamachine

@kibanamachine
kibanamachine merged commit fcfb61a into elastic:9.5 Jul 24, 2026
65 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant