Skip to content

fix: rewrite flaky anvil pagination e2e to test-id locators (#4830)#4836

Merged
NoopDog merged 2 commits into
mainfrom
fran/4830-anvil-pagination-e2e-rewrite
May 15, 2026
Merged

fix: rewrite flaky anvil pagination e2e to test-id locators (#4830)#4836
NoopDog merged 2 commits into
mainfrom
fran/4830-anvil-pagination-e2e-rewrite

Conversation

@frano-m
Copy link
Copy Markdown
Contributor

@frano-m frano-m commented May 14, 2026

Summary

Rewrites e2e/anvil/anvil-pagination.spec.ts end-to-end and removes the three obsolete shared helpers it was the last consumer of. Brings the spec in line with the locator and layout conventions established in anvil-filters.spec.ts.

Spec changes:

  • 3 monolithic tests → 9 per-behaviour tests, each named for the single property it asserts.
  • Locators switched to getByTestId (TEST_IDS.TABLE_PAGINATION, TABLE_PAGINATION_RESULTS, TABLE_FIRST_CELL, FILTER_ITEM, FILTER_COUNT, SEARCH_ALL_FILTERS) — no .Mui* class top-level locators, no xpath ancestor traversal.
  • Pagination transitions now use a triggerActionAndWaitForUpdate(target, action) content-poll primitive: capture the anchor's textContent, run the action, expect.poll until it differs. Replaces waitForLoadState (which doesn't track post-fetch row swap).
  • Filter-item clicks use dispatchEvent("click") per the webkit-overlay workaround already adopted in e2e/features/common/filters.ts.
  • Shared helper reuse: closeAutocompletePopper from e2e/features/common/filters.ts instead of a raw ESC keypress.
  • Conditional test.fail() removed (every test now asserts deterministic outcomes).
  • Top-of-file constants block (PAGE_SIZE, PAGES_TO_NAVIGATE, SAMPLE_NAVIGATIONS, FILTER_COUNT_MIN/MAX, ENTITY_URL, ENTITY_URL_WITH_FIRST_CELL) replaces inline magic numbers.
  • Helpers alphabetised under a /* ——— helpers ——— */ divider, non-exported.

Why two entity URLs: ENTITY_URL = "/files" is used for 8 of 9 tests (and for the filter-count-in-range search). The "shows different table content on every page" test overrides to "/biosamples" because Files' first cell renders only an icon download button — textContent() returns "" and can't anchor a per-row diff.

Helper cleanup in e2e/testFunctions.ts:

  • Deleted testFirstPagePagination, filterAndTestLastPagePagination, testPaginationContent (the spec was their only caller).
  • Deleted pagination-only constants PAGE_COUNT_REGEX, MAX_PAGINATIONS, MAX_FILTER_LENGTH.
  • Removed the now-unused KEYBOARD_KEYS import. TabDescription, getFirstRowNthColumnCellLocator, filterRegex are retained — used elsewhere.

Closes #4830.

Test plan

  • npx tsc --noEmit, npm run lint, npm run check-format pass
  • npx playwright test -c playwright_anvil.config.ts e2e/anvil/anvil-pagination.spec.ts — 27/27 across chromium/firefox/webkit (1.1 min)
  • npm run test:anvil-cmg — full anvil suite, 132/132 across all three browsers (7.9 min)
  • Watch CI for several runs to confirm no Firefox/webkit flakes

Out of scope (potential follow-up)

triggerActionAndWaitForUpdate is a general "perform action, wait for in-place data update" primitive. Other specs (sort, filter-apply) would benefit from sharing it. Hoist to e2e/features/common/utils.ts in a follow-up — deferred to keep this PR scoped.

🤖 Generated with Claude Code

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 CMG pagination E2E spec to use more focused, test-id-based Playwright assertions and removes obsolete shared pagination helpers that were only used by the old spec.

Changes:

  • Replaces 3 broad pagination tests with smaller behavior-specific pagination tests.
  • Adds local helpers for pagination parsing, navigation polling, and dynamic filter selection.
  • Removes unused legacy pagination helpers/constants from e2e/testFunctions.ts.

Reviewed changes

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

File Description
e2e/anvil/anvil-pagination.spec.ts Rewrites pagination coverage around test-id locators, content-change polling, and per-behavior assertions.
e2e/testFunctions.ts Removes obsolete shared pagination helpers and related unused imports/constants.

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

Comment thread e2e/anvil/anvil-pagination.spec.ts Outdated
@frano-m frano-m force-pushed the fran/4830-anvil-pagination-e2e-rewrite branch from ad8e96e to a6a3d9c Compare May 14, 2026 05:46
@frano-m frano-m marked this pull request as ready for review May 14, 2026 06:09
@NoopDog NoopDog merged commit 0e3c442 into main May 15, 2026
3 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.

fix: flaky anvil-cmg pagination e2e test — rewrite to test-id-based locators

3 participants