Skip to content

[test-helpers] Add EuiDraggableObject - #9936

Open
steliosmavro wants to merge 7 commits into
elastic:mainfrom
steliosmavro:stelios/test-helpers-draggable
Open

[test-helpers] Add EuiDraggableObject#9936
steliosmavro wants to merge 7 commits into
elastic:mainfrom
steliosmavro:stelios/test-helpers-draggable

Conversation

@steliosmavro

@steliosmavro steliosmavro commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds EuiDraggableObject, a Playwright Component Object that keyboard-reorders EuiDraggable items, following the package's CONTRIBUTING guide.

Prototyped and validated against a real Kibana consumer first per the guide's lifecycle. Kibana PR: elastic/kibana#286130 (CI green, 8/8 + 20/20 on a repeat-3 flake check).

API

reorder(steps): focuses the handle, lifts it (Space), moves it steps positions (ArrowDown/ArrowUp), drops it (Space). Deliberately keyboard-only — that's the accessible interaction @hello-pangea/dnd (which EuiDraggable wraps) itself supports, and it's how every real consumer already drives it. No mouse-drag simulation.

testSubj targets the item's own drag handle. With the default customDragHandle={false} that's the EuiDraggable item itself (EUI spreads dragHandleProps onto the same element as draggableProps in that case); with a custom handle it's that inner element instead. A component-type guard verifies testSubj actually resolves to an enabled handle (via the data-rfd-drag-handle-draggable-id attribute @hello-pangea/dnd sets), rather than silently no-oping on a non-handle element.

A finding from authoring this

The design initially included a settle-wait after dropping (waiting for a euiDraggable--isDragging class to clear), mirrored from a Kibana consumer that checked for it. That class hasn't existed since this component's styling moved to Emotion — the check was a no-op in both current EUI main and the @elastic/eui version Kibana has installed. Dropped it rather than replace it with something that verifies nothing; consumers should assert the resulting order with a retrying expect, which settles on its own.

Testing

tsc --noEmit clean. Playwright validation specs pass against Storybook (Display/EuiDroppablePlayground, with data-test-subj added to its two items): 3/3, covering forward reorder, backward reorder, and identity persistence after a move.

Adds a WithStableTestSubjects EuiDroppable story fixture (per-item
data-test-subj that survives a reorder, unlike the generic examples
which default every item to the same subj) to validate against.
@steliosmavro
steliosmavro marked this pull request as ready for review August 20, 2026 07:34
@steliosmavro
steliosmavro requested a review from a team as a code owner August 20, 2026 07:34
@steliosmavro steliosmavro self-assigned this Aug 20, 2026
kibanamachine and others added 2 commits August 20, 2026 07:38
Verify testSubj resolves to an enabled drag handle via the
data-rfd-drag-handle-draggable-id attribute @hello-pangea/dnd sets,
instead of silently no-oping. Adds a spec covering the disabled case.
@weronikaolejniczak weronikaolejniczak added the skip-changelog-eui Use on PRs to skip changelog requirement (for @elastic/eui) label Aug 24, 2026
@weronikaolejniczak
weronikaolejniczak self-requested a review August 25, 2026 10:04
Comment thread packages/eui/src/components/drag_and_drop/droppable.stories.tsx
Comment thread packages/test-helpers/src/playwright/components/drag_and_drop/object.spec.ts Outdated
- Drop the dedicated WithStableTestSubjects fixture story; add
  data-test-subj directly to EuiDroppable's existing Playground
  story instead, per review — Playground already covers this, no
  separate story needed. Removes its stale VRT baselines.
- Move the [data-rfd-draggable-id] selector into selectors.ts.
- Shorten the class/method doc comments; the detail moved to the
  package README.
- Remove the disabled-draggable validation test — it was closer to
  testing EuiDraggable's own rendering behavior than the helper.

Addresses review feedback from @weronikaolejniczak.

@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.

Let's resolve the conflicts with main.

@steliosmavro

Copy link
Copy Markdown
Contributor Author

Thanks for the review @weronikaolejniczak ! I resolved the conflicts from the previously added helper changes.

@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.

  1. README says "put testSubj on the handle, not on the EuiDraggable wrapper" but in Playground we put it on <EuiDraggable>. We should update README to be more clear in what cases this is necessary.
  2. PR description is stale with the recent changes.

data-test-subj on <EuiDraggable> in Playground is correct: with the
default customDragHandle={false}, EUI spreads dragHandleProps onto
the same element as draggableProps, so the wrapper IS the handle.
Only a custom drag handle moves it to a separate inner element.
Previous wording implied they're always different elements.

Addresses review feedback from @weronikaolejniczak.
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @steliosmavro

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @steliosmavro

steliosmavro added a commit to steliosmavro/eui that referenced this pull request Aug 25, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog-eui Use on PRs to skip changelog requirement (for @elastic/eui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants