Skip to content

Fix XComs e2e filter tests: scope the filter input by testid - #72438

Merged
bbovenzi merged 3 commits into
apache:mainfrom
Kunal8954:fix/xcoms-e2e-filter-testid
Sep 4, 2026
Merged

bbovenzi merged 3 commits into
apache:mainfrom
Kunal8954:fix/xcoms-e2e-filter-testid

Conversation

@Kunal8954

Copy link
Copy Markdown
Contributor

closes: #72433

What's the problem

XComsPage.applyFilter() locates the just-added filter pill's input with:

const filterPill = this.page
  .locator("div")
  .filter({ hasText: `${filterName}:` })
  .first();
const filterInput = filterPill.getByRole("textbox");

.filter({ hasText }) matches on descendant text, so it doesn't just match the specific filter pill div — it matches every ancestor div whose subtree happens to contain that text too. That used to be harmless because .first() happened to land on the right element, but #71554's DOM restructuring changed the filter bar's markup enough that .first() now resolves to a much broader ancestor, and getByRole("textbox") on it matches every textbox inside that ancestor instead of the one intended — hence "strict mode violation: locator resolved to 12 elements instead of 1".

The fix

Give the actively-editing pill's input a stable data-testid="filter-pill-input" (TextSearchFilter.tsx, passed straight through InputWithAddon's prop spread onto the underlying <Input>), and scope applyFilter() to page.getByTestId("filter-pill-input") directly instead of the ancestor-text search.

Only one filter pill is ever in edit mode at a time (an added pill enters edit mode immediately, and closes — collapsing to a chip — as soon as Enter/Escape is pressed or it loses focus), so a single, non-keyed testid is all applyFilter() needs; no per-filter key plumbing into the e2e layer.

Tests

Added a FilterBar test (FilterBar.test.tsx) asserting getByTestId("filter-pill-input") returns exactly the active pill's textbox. Verified it's a real regression test by temporarily reverting the data-testid locally — the new test (and only that test) failed with the same kind of "unable to find element" error this issue describes, confirming it actually exercises the bug.

Verification

  • vitest run on src/components/FilterBar: 22/22 passing (including the new test).
  • eslint --quiet on every touched file: clean.
  • tsc -p tsconfig.app.json: clean.
  • prettier --check: clean.
  • Branch rebased onto current main before running all of the above.
  • Could not run the actual Playwright e2e spec here (no live Airflow webserver/browser in this environment) — the added unit test exercises the same DOM-shape bug at the component level instead, and XComsPage.applyFilter()'s new locator is a straightforward, minimal change built directly on top of that verified testid.

Disclosure: this PR was prepared with the assistance of Claude Code (the commit carries a Co-Authored-By trailer). I reviewed the change and take responsibility for it.

🤖 Generated with Claude Code

https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh

xcoms.spec.ts's filter tests locate the active filter pill's input via
page.locator("div").filter({ hasText: `${filterName}:` }), which
matches any ancestor whose descendant text contains that string.
apache#71554 restructured the filter bar's DOM so more than one ancestor now
matches, and .first() no longer reliably picks the actual pill -
getByRole("textbox") on it resolves to every textbox inside whichever
div wins, throwing "resolved to 12 elements instead of 1".

Give the actively-editing pill's input a stable data-testid
(filter-pill-input) instead of relying on ancestor text matching, and
scope XComsPage.applyFilter() to it directly. Only one pill is ever in
edit mode at a time, so the testid alone is enough - no per-filter key
plumbing needed.

Added a FilterBar test that fails without the fix (verified locally by
reverting the testid and confirming the new test - and only that
test - breaks).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh
@boring-cyborg boring-cyborg Bot added the area:UI Related to UI/UX. For Frontend Developers. label Sep 2, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh
This reverts commit 06fd055.
@bbovenzi
bbovenzi merged commit 0f7f45f into apache:main Sep 4, 2026
89 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 4, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@Kunal8954

Copy link
Copy Markdown
Contributor Author

Thanks for the review @bbovenzi. Will pick up more in this area.

ccoliu added a commit to ccoliu/airflow that referenced this pull request Sep 5, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
…72438)

* Fix XComs e2e filter tests: scope the filter input by testid

xcoms.spec.ts's filter tests locate the active filter pill's input via
page.locator("div").filter({ hasText: `${filterName}:` }), which
matches any ancestor whose descendant text contains that string.
apache#71554 restructured the filter bar's DOM so more than one ancestor now
matches, and .first() no longer reliably picks the actual pill -
getByRole("textbox") on it resolves to every textbox inside whichever
div wins, throwing "resolved to 12 elements instead of 1".

Give the actively-editing pill's input a stable data-testid
(filter-pill-input) instead of relying on ancestor text matching, and
scope XComsPage.applyFilter() to it directly. Only one pill is ever in
edit mode at a time, so the testid alone is enough - no per-filter key
plumbing needed.

Added a FilterBar test that fails without the fix (verified locally by
reverting the testid and confirming the new test - and only that
test - breaks).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh

* Add newsfragment

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh

* Revert "Add newsfragment"

This reverts commit 06fd055.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Kunal8954 <your-github-email@example.com>
vatsrahul1001 added a commit that referenced this pull request Sep 24, 2026
…#73666)

* Fix XComs e2e filter tests: scope the filter input by testid

xcoms.spec.ts's filter tests locate the active filter pill's input via
page.locator("div").filter({ hasText: `${filterName}:` }), which
matches any ancestor whose descendant text contains that string.
matches, and .first() no longer reliably picks the actual pill -
getByRole("textbox") on it resolves to every textbox inside whichever
div wins, throwing "resolved to 12 elements instead of 1".

Give the actively-editing pill's input a stable data-testid
(filter-pill-input) instead of relying on ancestor text matching, and
scope XComsPage.applyFilter() to it directly. Only one pill is ever in
edit mode at a time, so the testid alone is enough - no per-filter key
plumbing needed.

Added a FilterBar test that fails without the fix (verified locally by
reverting the testid and confirming the new test - and only that
test - breaks).


Claude-Session: https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh

* Add newsfragment


Claude-Session: https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh

* Revert "Add newsfragment"

This reverts commit 06fd055.

---------



(cherry picked from commit 0f7f45f)

Co-authored-by: Kunal <kunalsharma000780@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Kunal8954 <your-github-email@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI e2e: xcoms.spec.ts filter tests broken

3 participants