Skip to content

[test-helpers] Add EuiRangeObject - #9957

Merged
steliosmavro merged 6 commits into
elastic:mainfrom
steliosmavro:stelios/test-helpers-range
Aug 27, 2026
Merged

[test-helpers] Add EuiRangeObject#9957
steliosmavro merged 6 commits into
elastic:mainfrom
steliosmavro:stelios/test-helpers-range

Conversation

@steliosmavro

@steliosmavro steliosmavro commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds EuiRangeObject, a Playwright Component Object for EuiRange and EuiDualRange, following the package's CONTRIBUTING guide.

No live Scout consumer exists yet for this either, so this is Storybook-validated only, same as EuiFilterButtonObject (#9942).

A real EUI gap this fixes

On a plain EuiRange rendered with showInput, EUI spreads the consumer's data-test-subj onto both the native range slider and the visible number input. A plain page.getByTestId(x) then resolves to two elements and throws in Playwright's strict mode. Confirmed by reading the source and reproducing it against Storybook, not just inferred. Full rationale, including why EuiDualRange does not have this problem, is in the component README.

API

  • slider: a Locator for the native <input type="range">, always resolving to exactly one element.
  • numberInput: a Locator for the visible number input, present only on a plain EuiRange with showInput.

Deliberately excludes EuiDualRange's min/max inputs and popover mechanics. See the README's "Deliberately out of scope" section for why.

Testing

tsc --noEmit clean. 3 Playwright validation specs pass against Storybook (Forms/EuiRange, Playground story), 9/9 on a repeat-3 flake check. Specs assert only on this helper's own disambiguation (element counts), not on EuiRange's own behavior.

Playwright Component Object for EuiRange/EuiDualRange, following the package
CONTRIBUTING guide.

Fixes a real EUI test-subj collision: a plain EuiRange rendered with
showInput spreads the consumer's data-test-subj onto both the native range
slider and the visible number input, so a plain getByTestId throws a
Playwright strict-mode error. slider and numberInput disambiguate by class so
each resolves to exactly one element.

Deliberately excludes EuiDualRange's min/max inputs (need their own separate
data-test-subj via minInputProps/maxInputProps, the consumer's own concern)
and popover open/close mechanics (EuiPopover already exposes those
synchronously).
Per Weronika's review feedback on the EuiDraggableObject PR (elastic#9936):
comments should be short pointers to the README, not repeat the full
rationale in the code too, and specs should not assert on EuiRange's own
behavior (the number input mirroring the slider's value), only on this
helper's own disambiguation.
@steliosmavro steliosmavro self-assigned this Aug 26, 2026
@steliosmavro
steliosmavro marked this pull request as ready for review August 26, 2026 07:15
@steliosmavro
steliosmavro requested a review from a team as a code owner August 26, 2026 07:15

@weronikaolejniczak weronikaolejniczak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one blocker. Otherwise looks good 👌🏻

Comment thread packages/test-helpers/src/components/form/range/README.md

| Member | Description |
|---|---|
| `slider` | `Locator` for the native `<input type="range">`. Always resolves to exactly one element. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slider is not “always exactly one element”. showInput: 'inputWithPopover' still puts data-test-subj on both the trigger input and the slider but the slider lives in the popover panel. EuiPopover only mounts that panel when open.

Comment on lines +29 to +30
- **`EuiDualRange`'s min/max number inputs**: rendered only with `showInput`, and need their own `data-test-subj` via `minInputProps`/`maxInputProps`. That is the consumer's own test-subj to target directly, not ambiguous the way the plain `EuiRange` case is.
- **`EuiDualRange`'s `inputWithPopover` open/close**: its popover only opens by clicking a number input, not the delimiter between them. That is a real EUI behavioral quirk, but a single documented fact rather than DOM ambiguity, and popover mechanics are already exposed synchronously by `EuiPopover` itself (`aria-expanded`/`aria-controls`). Drive it from your test directly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the limitation around min/max, we cannot query it. But I think we're making EuiDualRange depend on EuiRange semantics too much where these are 2 separate components and we should actually separately also navigate to EuiDualRange story and test it.

Weronika found slider does not always resolve to exactly one element:
with showInput=inputWithPopover it lives inside the popover panel and
is not mounted until the popover opens. Corrected the README and
object.ts docs and added a spec proving it.

Also added a spec that navigates to EuiDualRange's own Playground
story instead of assuming its behavior from EuiRange's, per her second
comment.

@weronikaolejniczak weronikaolejniczak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🟢 Thanks, Stelios 💪🏻

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @steliosmavro

@steliosmavro
steliosmavro enabled auto-merge (squash) August 27, 2026 13:52
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @steliosmavro

@steliosmavro
steliosmavro merged commit 1183b2f into elastic:main Aug 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants