Skip to content

fix: rewrite flaky anvil catalog filter e2e test#4763

Open
frano-m wants to merge 4 commits intomainfrom
fran/4751-anvil-catalog-filter-test
Open

fix: rewrite flaky anvil catalog filter e2e test#4763
frano-m wants to merge 4 commits intomainfrom
fran/4751-anvil-catalog-filter-test

Conversation

@frano-m
Copy link
Copy Markdown
Contributor

@frano-m frano-m commented Apr 9, 2026

Summary

Closes #4751

  • Rewrote anvilcatalog-filters.spec.ts to be self-contained (no testFunctions.ts dependency), with inline helpers, test.describe blocks, and test.beforeEach for setup
  • Fixed race conditions causing flaky failures: assert filter state changes (tag visible/hidden) before pressing Escape, and wait for checkbox state after clicking
  • Scoped locators to data-testid="filters" and data-testid="search-all-filters" containers instead of searching the whole page
  • Used test IDs (filter-item, filter-term) and MUI class constants (MuiChip-root) instead of fragile role/text selectors
  • Click the filter-item (MUI list button) directly rather than the nested checkbox input
  • Removed unused exports from testFunctions.ts (testSelectFiltersThroughSearchBar, testDeselectFiltersThroughSearchBar, getLastRowNthColumnTextLocator)
  • Removed unused ANVIL_CATALOG_FILTERS array and index constants from anvilcatalog-tabs.ts
  • Added CHIP to shared MUI_CLASSES constants and ANVIL_CATALOG_CATEGORY_NAMES to catalog constants

Test plan

  • All 6 filter tests pass on Chromium (verified locally, multiple runs)
  • Verify tests pass on Firefox and WebKit in CI

🤖 Generated with Claude Code

Rewrite the filter select/deselect e2e tests to be self-contained, use
test IDs and scoped locators, and fix race conditions that caused flaky
failures — particularly on webkit where Escape could cancel a pending
filter state update.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR rewrites the AnVIL catalog “Search all filters” Playwright E2E spec to eliminate flakiness by making interactions/locators more deterministic and removing dependencies on shared helper functions.

Changes:

  • Replaced the existing anvilcatalog-filters.spec.ts implementation with a self-contained version using scoped data-testid locators and inline helpers.
  • Reduced test flakiness by adding explicit state assertions around checkbox/tag state transitions and keyboard dismissals.
  • Removed now-unused helper exports/constants and added shared constants (MUI_CLASSES.CHIP, ANVIL_CATALOG_CATEGORY_NAMES) to support the new selectors.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
e2e/anvil-catalog/anvilcatalog-filters.spec.ts Full rewrite of the flaky filter search E2E tests with scoped locators and inline helpers.
e2e/testFunctions.ts Removes unused filter-search helpers and an unused table-cell locator export.
e2e/anvil-catalog/anvilcatalog-tabs.ts Removes unused filter name/index constants.
e2e/features/common/constants.ts Adds MUI_CLASSES.CHIP selector constant used by the updated spec.
e2e/anvil-catalog/constants.ts Adds ANVIL_CATALOG_CATEGORY_NAMES used to drive the rewritten tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

frano-m and others added 3 commits April 9, 2026 17:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…4751)

Fix stale popover issue where MUI keeps old popovers in the DOM during
exit animations, causing firstFilterItem to match items from the wrong
dropdown. Wait for popovers to fully unmount before opening new ones,
scope filter items to the active popover, and scope search results to
the autocomplete popper.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

[AnVIL Catalog] Fix flaky e2e test: deselecting filters through Search all Filters textbox

3 participants