Skip to content

test(playwright): add stricter ESLint locator rules and fix all violations#17611

Merged
priyabratadas-dh merged 11 commits into
masterfrom
playwright/lint-rules-addition
May 28, 2026
Merged

test(playwright): add stricter ESLint locator rules and fix all violations#17611
priyabratadas-dh merged 11 commits into
masterfrom
playwright/lint-rules-addition

Conversation

@priyabratadas-dh
Copy link
Copy Markdown
Contributor

@priyabratadas-dh priyabratadas-dh commented May 28, 2026

Summary

  • Adds two new ESLint rules to the Playwright test suite (eslint.config.js):
    • playwright/no-raw-locators (error) — bans page.locator('css-string') in favour of semantic APIs (getByTestId, getByRole, getByText, getByTitle, getByLabel)
    • playwright/no-nth-methods (warn) — flags first() / last() / nth() usage
  • Fixes all no-raw-locators errors across every POM file and spec file (32 files, 0 errors remaining)
  • Adds groups.page.ts POM for the Groups entity page

What changed

ESLint configeslint.config.js + package.json dependency bump

POM files — replaced raw CSS locators with semantic Playwright APIs in:
business-attribute, confirmation-modal, modal, searchbar, sidebar, dataset-health, dataset, domains, entity-documentation, glossary, groups, incidents, ingestion, lineage-v2, login, ownership-management, policies, search, tags, welcome-modal

Spec files — same treatment for:
external-document-profile, v2-lineage-column-path, v2-lineage-graph, add-users, dataset-ownership, deprecations, manage-ingestion-secret-privilege, query-and-filter-search, searchv2, structured-props-drawer-font

Raw locators that have no semantic equivalent (Ant Design internal CSS classes, XPath ancestor traversals, prefix/substring data-testid selectors, ProseMirror/Remirror editor classes, auto-generated React HTML ids) are suppressed with targeted eslint-disable-next-line comments explaining the reason.

Test plan

  • yarn lint reports 0 errors (151 pre-existing no-nth-methods warnings remain)
  • CI Playwright suite passes (no functional test logic was changed — only locator expression syntax)

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

Linear: CAT-2166

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
401 1 400 29
View the top 1 failed test(s) by shortest run time
mutations-v2/v2-domains.spec.ts::add remove domain › add entities to domain
Stack Traces | 240s run time
Test timeout of 120000ms exceeded.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

priyabratadas-dh and others added 6 commits May 28, 2026 14:43
Expands the eslint-plugin-playwright ruleset to enforce locator best
practices and catch common test anti-patterns:

- `no-raw-locators` (error): CSS/XPath strings banned in spec files;
  iframes exempted as they have no ARIA equivalent. This is the primary
  guard against brittle selector coupling.
- `prefer-native-locators` (warn): nudges toward getByRole/getByLabel
  over page.locator() where a semantic built-in exists.
- `no-nth-methods` (warn): first()/nth() usually signals a missing
  data-testid.
- `no-element-handle` (error): ElementHandle is deprecated in favour
  of the Locator API.
- `no-eval` (error): page.$eval/$$eval are hard to debug and race-prone.
- `missing-playwright-await` (error): catches forgotten awaits.
- `no-standalone-expect` (error): prevents assertions outside test blocks.
- `no-focused-test` (error): blocks accidental .only commits.
- `prefer-web-first-assertions` (error): enforces async-safe assertion style.
- `no-duplicate-hooks` (error): catches duplicated beforeEach/afterEach.
- `prefer-hooks-on-top` (warn): keeps hook order readable.

Also bumps the engines.node floor to >=22.0.0 to match ESLint v10's
minimum requirement (ESLint v10 requires Node ≥20; we standardise on 22
which is the active LTS and matches the project's CI node version).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… and spec files

Replace page.locator('css-string') calls with semantic Playwright APIs
(getByTestId, getByRole, getByText, getByTitle, getByLabel) wherever possible.
Add eslint-disable-next-line only for irreplaceable cases: Ant Design internal
CSS classes, XPath ancestor traversals, prefix/substring data-testid selectors,
ProseMirror/Remirror editor classes, and auto-generated React HTML ids.
…lays

Replace fixed 15 s timeouts on sidebar-node and contents-tab visibility
checks with reload-and-retry loops (up to 60 s) so tests survive slow ES
indexing in CI. Add explicit toBeVisible waits before filtersToggleButton
clicks to prevent page-closed errors when the Related Assets panel is slow
to render. Extend test.setTimeout on all glossary lifecycle, navigation,
term-filter, and tag-assign tests to give the combined entity-creation +
ES-indexing steps enough wall-clock budget.

Environment-only failures (welcome-modal arrow-key / escape_key, structured-
props Mulish font, domains OOM, managed-ingestion 180 s) require frontend
code changes or infrastructure fixes and cannot be addressed in test code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… dual toggle-filters-button

- filtersToggleButton: scope to activeTabPanel to avoid matching the second
  instance rendered inside the SearchSelect batch-add modal; removes the
  broken .and(locator(':visible')) intersection pattern
- clickSidebarNode: replace reload-retry with direct URL navigation since
  freshly-created nodes take >60 s to appear in ES and the tests only need
  navigation, not a test of the sidebar click itself
- clickSidebarTerm: increase waitFor to 45 s + scrollIntoViewIfNeeded for
  pre-seeded terms that may need the parent node to auto-expand first
- expectEntityInContentsTab: increase toPass timeout 45 s → 90 s; always
  enter the retry body so reload is guaranteed on first check
- expectSidebarContainsNode: increase toPass timeout 60 s → 120 s
- v2-glossary.spec.ts: add test.describe.configure({ mode: 'serial' }) to
  prevent parallel browser instances competing for memory (OOM crashes);
  adjust timeouts to cover the extended ES-indexing retry budgets
- v2-glossary-navigation.spec.ts: increase move-test timeouts 150 s → 180 s
  to cover the 90 s expectEntityInContentsTab budget plus overhead

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@priyabratadas-dh priyabratadas-dh force-pushed the playwright/lint-rules-addition branch from 50ce81a to 7442d0d Compare May 28, 2026 09:13
…ox not textbox

getByRole('textbox') never matched the AntD Select inner <input role="combobox">
inside tag-term-modal-input, causing pressSequentially to wait until the 150 s
test timeout fired and the browser crashed. Change to getByRole('combobox').

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alwaysmeticulous
Copy link
Copy Markdown

alwaysmeticulous Bot commented May 28, 2026

🔴 Meticulous spotted visual differences in 9 of 1351 screens tested: view and approve differences detected.

Meticulous evaluated ~10 hours of user flows against your PR.

Last updated for commit edff3da package.json changes. This comment will update as new commits are pushed.

priyabratadas-dh and others added 2 commits May 28, 2026 17:08
…tting

- Revert engines.node from ">=22.0.0" back to ">=18.0.0" so yarn install
  succeeds in the CI lint job (which uses Node 20); the Node 22 requirement
  is a local development convention, not a hard runtime constraint
- Apply prettier formatting across all POM and spec files (quote style,
  trailing commas, whitespace normalisation)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@priyabratadas-dh priyabratadas-dh merged commit 8739770 into master May 28, 2026
40 of 41 checks passed
@priyabratadas-dh priyabratadas-dh deleted the playwright/lint-rules-addition branch May 28, 2026 15:38
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.

3 participants