Repository navigation
Playwright guardrails (4/N): burn down positional locators in e2e/Features/Glossary - #31029
ShaileshParmar11 wants to merge 23 commits into
Conversation
Adds the CommonJS eslint-rules plugin skeleton (rules: {}) that later
tasks register rules into, wires it into eslint.config.mjs under the
om-playwright namespace, and adds a node --test based unit test target.
Also adds an eslint.config.mjs block scoping the plugin's own .js files
to CommonJS globals/no-require-imports:off, and switches the
test:eslint-rules script to a glob instead of a bare directory path --
both needed because `node --test <dir>` does not recurse into an
explicit directory argument on this repo's pinned Node (22.17.0),
confirmed against the .nvmrc version, not just the locally active one.
…d fix 16 races Registers a listener promise before the triggering action instead of awaiting waitForResponse() after it, which races an already-fired response and hangs until timeout. Zero suppressions — all 16 pre-existing violations fixed by hand.
…n, not as a weaker loader wait Review found the explore.ts fix from the prior commit substituted a strictly weaker wait (toHaveCount(0) is a no-op if the loader hasn't mounted yet) with an inaccurate comment. selectDataAssetFilter has exactly one call site, so the listener moves to EntitySummaryPanel.spec.ts's single beforeEach, before the sidebarClick that actually triggers the query.
…test objects - beforeEach runs on the triggering test's own timeout slot (verified against playwright@1.57.0 worker/workerMain.js), so test.slow() there has the same blast radius as a describe-scope call; the previous heuristic treated it as legal. beforeAll/afterAll/afterEach each get their own slot and correctly remain legal. - Widen detection to aliased test objects (e.g. base.slow() inside base.describe(), where base = test.extend(...)) via a dynamic test-object-identifier signal, while excluding variables bound directly to the describe function itself (const d = test.describe;) from being misclassified as per-test callbacks. - Add RuleTester cases pinning beforeEach, beforeAll, afterEach, test.step, aliased test objects, and the describe-alias edge case. - Re-snapshot: 89 violations (79 + 9 beforeEach + 1 aliased describe), suppressions total 94 (unchanged, 4 promoted rules) + 89 = 183.
Flags e2e tests whose body only performs page/locator interactions
(clicks, fills, navigation) with no expect() reference anywhere and no
call to anything beyond the test's own Playwright fixtures - i.e. tests
that are provably assertion-free.
The rule intentionally does not flag delegation to a helper or
page-object method (entity.descriptionUpdate(page), addUser(...),
verifyAuthenticated(...)), since those may assert internally and
proving otherwise needs interprocedural analysis this rule doesn't do.
An earlier text-scan-only design flagged 474 tests, but hand-verifying
samples showed most delegate to helpers that do assert - a large,
confirmed false-positive rate. Scoping the rule to only what it can
prove (no expect text + every call rooted at a page fixture) drops
that to a single, high-confidence violation:
playwright/e2e/nightly/ServiceIngestion.spec.ts's "Default Pagination
size should be 15" test, which waits on two network patterns and
clicks once but never asserts a status, body, or visible count.
Registered as om-playwright/require-assertion-per-test, scoped to
playwright/e2e/**/*.spec.{js,jsx,ts,tsx} only (utils/support files
contain no tests). Snapshot suppresses the one existing violation via
--suppress-rule; the four already-promoted playwright/* suppressions
(94) and om-playwright/no-blanket-test-slow (89) are untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…e-assertion-per-test test.slow(true), test.setTimeout(...), and test.step(...) were being treated as ordinary non-page calls, so any test opening with one of them (89 suppressed sites use test.slow()) was silently exempted no matter how purely it clicked afterward - none of them can assert. A call rooted at the `test` identifier is now filtered out before the "every remaining call is page/locator-only" check, instead of counting either way. test.step's own nested calls are unaffected: they're separate CallExpression nodes checked on their own merits, since the callback is inline and fully visible, not a delegated helper. Corpus impact: still exactly 1 violation, same site (ServiceIngestion.spec.ts:189) - no re-snapshot needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…row helper defaults
Widen no-positional-locator to flag Identifier/MemberExpression receivers
(hoisted-variable and property-stored locators), not just inline call-chain
tails - 185 previously-missed sites, closing the cheapest evasion path
(hoist into a variable). Discriminate genuine Playwright .first()/.last()/
.nth() calls from same-named non-Locator calls (e.g. lodash) by argument
arity instead.
Fix scopedLocators helpers: getRowByName defaulted to a CSS attribute
selector that never matches implicit ARIA roles (Ant Design <tr> rows),
and expectRowFor never forwarded rowSelector. Default to page.getByRole('row')
and thread rowSelector through both helpers; document the hasText
substring-collision failure mode.
Re-snapshot: no-positional-locator suppressions 1068 -> 1253 via
--suppress-rule (never --suppress-all/--prune-suppressions); the three
pre-existing suppression groups are byte-identical.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…e escape hatch
Add no-unscoped-count-assertion and require-unique-entity-name (heuristic,
expect false positives) plus justified-rule-disable, the escape hatch that
lets a developer document why a heuristic misfire is being suppressed.
require-unique-entity-name is implemented, tested, and registered in the
plugin but deliberately not enabled: a raw pass found 1625 violations, and
a 25-sample hand review found 0/25 true positives (matches were almost
entirely Playwright's own getByRole(..., { name }) option and static
config keys, not entity creation). Snapshotting that baseline would ratchet
near-total noise; left for a follow-up to narrow the heuristic. The other
two rules were sanity-checked, found to carry real signal, and are
snapshotted normally (+73, +9 violations; suppressions total 1437 -> 1519).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…e-entity-name
Both were reviewed against their full/near-full population, not just the
sanity-check samples from the initial implementation:
- require-unique-entity-name: confirmed ~3/1625 (0.18%) true-positive
rate. The heuristic can't distinguish assigning a name to a new entity
from using one to look an existing element up — 59% of hits are
Playwright's own getByRole/getByLabel(role, { name }) accessible-name
option, where adding uuid() would break the locator. 43/51 files under
playwright/support/entity/ already call uuid() internally, so
uniqueness is solved one layer down from where this rule looked.
Never enabled, so no suppressions to remove.
- no-unscoped-count-assertion: full classification of all 73 sites found
~77% false positives (17 true / 56 false), dominated by the rule
flagging locators already scoped through a variable per its own
recommended fix (const c = loc.filter({ hasText }); expect(c)...) —
failing code for following its own advice. Suppressions pruned via a
full-corpus --prune-suppressions run; total 1519 -> 1446.
justified-rule-disable is untouched (its count of 9 was independently
re-verified) and now registers as the fifth rule in the plugin.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ate guidance Docs previously listed a hand-written, stale error/warn split for the Playwright ESLint rules that no longer matched eslint.config.mjs (every rule now runs at error). Generate the rule table from the config instead, so the docs can't drift from what CI actually enforces, and consolidate the overlapping rules file and skills onto the generated table and the real lint:playwright:suppressions gate.
Adds a corpus meta-test that fails if eslint-suppressions.json's total grows (ceiling 1446, the current baseline), and wires a full-corpus CI step running the rule unit tests, the suppressions-aware lint with pruning, and the generated rule-table freshness check. The step is unconditional rather than changed-files-scoped because --prune-suppressions against a partial file set would delete valid suppressions for files the PR didn't touch. Until this lands, all 18 Playwright guardrail rules only ran locally. Also updates skills/playwright-validation/SKILL.md's stale three-rule/warn-tier description to reflect that every rule is now error-level with no warn tier.
…wright guardrail step --prune-suppressions writes eslint-suppressions.json in place when it drops a stale entry, and the step never restored it — a later step in the same job (lint_core_components) runs a repo-wide git status check that could then misattribute this failure to itself. Restore the file unconditionally on both the pass and fail paths. Also guard the failure-detail grep with `|| true`: under GitHub's default `bash -eo pipefail` shell, a grep with no matches exits non-zero and would abort the script before the GITHUB_OUTPUT writes, leaving the PR summary comment blank.
Playwright already runs with retries: 1 and the JSON reporter is already enabled, so flaky/failed data is produced and discarded on every CI run. Add a small aggregator that turns results.json into a flake-report.json summary per shard, uploaded as an artifact. Purely additive: no new test runtime, no changes to any existing step or job outcome.
…load Four fixes from final branch review: - ui-checkstyle: run the non-pruning yarn lint:playwright:full so a fixed violation fails CI until its stale suppression is pruned and committed, instead of silently discarding the rewrite; drop the now-dead git checkout restore; update the failure-reason text accordingly. - justified-rule-disable rule + CI grep guard: a bare eslint-disable (no rule list) or a disable of the rule itself previously bypassed all 18 guardrail rules undetected; the rule now reports blanket disables and a CI-level grep guard catches the self-referential case the rule cannot see. - playwright-postgresql-e2e: add continue-on-error/overwrite/if-no-files-found to the flake-report upload so artifact-name collisions on job re-run don't fail an otherwise-passing 40-minute shard. - docs: point developer-facing lint instructions at yarn lint:playwright:suppressions to match the new CI command split. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CI's changed-files checkstyle runs prettier, which the guardrail work did not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| const hasValidResponse = | ||
| (await badMessage | ||
| .first() | ||
| .isVisible({ timeout: 10000 }) | ||
| .catch(() => false)) || | ||
| (await errorState | ||
| .first() | ||
| .isVisible({ timeout: 2000 }) | ||
| .catch(() => false)) || | ||
| (await badMessage.count().catch(() => 0)) > 0 || | ||
| (await errorState.count().catch(() => 0)) > 0 || |
There was a problem hiding this comment.
⚠️ Edge Case: count() snapshot drops the wait for error-text to render
In both non-existent glossary/term tests the checks were changed from badMessage.first().isVisible({ timeout: 10000 }) / errorState.first().isVisible({ timeout: 3000 }) to (await badMessage.count().catch(() => 0)) > 0. Locator.count() is an instantaneous snapshot that does not retry/wait, whereas the old .isVisible({ timeout }) polled for up to 10s. When the app's response is the error text itself (and none of the other OR branches — no-data-placeholder, header, add-glossary, sidebar — render), count() can observe 0 before the message paints, making hasValidResponse false and failing the assertion intermittently. This undercuts the PR's anti-flake goal for the error-text path. Prefer a web-first assertion that waits: combine the acceptable locators with .or() and assert on it, or use expect(locator).not.toHaveCount(0) (which retries) instead of the synchronous .count().
Use a combined locator with a retrying web-first assertion so the error text is still awaited.:
const anyValidState = badMessage
.or(errorState)
.or(noDataPlaceholder)
.or(glossaryHeader)
.or(addGlossaryButton)
.or(glossarySidebar);
// not.toHaveCount(0) retries until the timeout, unlike a bare count()
await expect(anyValidState).not.toHaveCount(0, { timeout: 10000 });
Was this helpful? React with 👍 / 👎
| const parentRow = page.locator( | ||
| `[data-row-key="${parentTerm.responseData.fullyQualifiedName}"]` | ||
| ); |
There was a problem hiding this comment.
💡 Edge Case: Exact data-row-key selector breaks on FQNs with quotes/dots
The substring-collision fix replaces [data-row-key*="${name}"] with [data-row-key="${fullyQualifiedName}"]. OpenMetadata FQNs quote segments that contain reserved characters (e.g. a term named a.b yields an FQN like Glossary."a.b"), and embedding such a value inside a double-quoted CSS attribute selector produces a malformed selector that will not match. This is fine for the current tests (generated names avoid dots), but is a latent trap if these helpers are reused with names containing dots/quotes. Consider escaping via page.locator('[data-row-key]').filter(...) or CSS.escape-style handling if names may contain special characters.
Was this helpful? React with 👍 / 👎
| if MATCHES=$(grep -rnE 'eslint-disable(-next-line|-line)?\s*(\*/|$)|eslint-disable[^\n]*om-playwright/justified-rule-disable' \ | ||
| playwright/ --include='*.ts' --include='*.tsx'); then | ||
| echo "$MATCHES" | ||
| echo "::error::Found a blanket 'eslint-disable' (no rule list) or a disable of om-playwright/justified-rule-disable itself. Both bypass the Playwright lint guardrails entirely and are never allowed, justified or not. Disable individual rules instead, each with a justification, e.g. // eslint-disable-next-line om-playwright/no-positional-locator -- <why>." | ||
| echo "changed_files<<EOF" >> "$GITHUB_OUTPUT" | ||
| echo "$MATCHES" >> "$GITHUB_OUTPUT" | ||
| echo "EOF" >> "$GITHUB_OUTPUT" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
💡 Bug: CI blanket-disable grep can false-positive on wrapped block comments
The guard regex alternative eslint-disable(-next-line|-line)?\s*(\*/|$) is line-based. A valid multi-line block directive where the rule list is on a following line — e.g. /* eslint-disable om-playwright/no-positional-locator */ — matches on the first line (eslint-disable followed by end-of-line), so the guard would wrongly reject it as a blanket disable and fail CI. Single-line directives (the common case) are unaffected. If wrapped block directives are a concern, match the full comment rather than a single line, or document that disable directives must stay on one line.
Was this helpful? React with 👍 / 👎
CodeQL flagged the separate guardrail step as a high-severity cache-poisoning risk: it executes PR-authored code (the eslint config and the local rule plugin) in a pull_request_target job with a privileged checkout. The file already documents the convention - every `run:` executing PR code in this job is a poisonable step, so a separate step adds one more for no gain in isolation. Folding the guardrail commands into the existing playwright step removes the new alert without weakening the gate. The checks now run before --fix/--write so they judge what the contributor actually wrote, and the changed-files matcher is widened to eslint.config.mjs and eslint-suppressions.json so a config-only change still triggers the gate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…sary (81 sites)
Suppressions 1446 -> 1377; no-positional-locator 1265 -> 1184.
Includes fixing a real substring-collision class properly rather than
disabling it: [data-row-key*="${name}"] matched descendant FQNs, and
getByText('Term_1') also matched Term_10, Term_11 and so on. Both now use
exact matching.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
4b6592a to
e644da6
Compare
|
🔴 Playwright Results — workflow failedValidated commit ✅ 814 passed · ❌ 8 failed · 🟡 1 flaky · ⏭️ 15 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 57m 8s ⏱️ Max setup 3m 21s · max shard execution 19m 12s · max shard-job elapsed before upload 22m 48s · reporting 8s 🌐 190.47 requests/attempt · 2.40 app boots/UI scenario · 9.20% common-shard skew Optimization targets still in progress:
Genuine Failures (failed on all attempts)❌
|
|
Closing until the 2.0 release is out — parking this rather than abandoning it. Will reopen once the release lands. State when closed: ready for review. The branch
On reopen, in this order:
Note these sibling PRs all touch |
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source



Describe your changes:
Burns down
om-playwright/no-positional-locatoracrossplaywright/e2e/Features/Glossary/.Positional locators (
.first(),.last(),.nth()) are called "not recommended" by Playwright's own docs — when the page changes, Playwright may act on an element you did not intend.81 sites across 13 files. Suppressions 1,446 → 1,377.
Type of change:
High-level design:
Four conversion patterns, in priority order:
.filter({ hasText }),getByRole(role, { name }), a specificdata-testid, orgetRowByName()fromscopedLocators.ts.expect(loc).not.toHaveCount(0).eslint-disable— last resort, each carrying a-- <why>justification that thejustified-rule-disablerule enforces aterror.The notable fix here is a real substring-collision bug, resolved properly rather than disabled. Two patterns were silently selecting the wrong row:
[data-row-key*="${name}"]uses a substring match, so a parent term's key also matched its descendants' fully-qualified names.getByText('Term_1')also matchesTerm_10,Term_11,Term_12…Both now use exact matching. An earlier pass had disabled these sites with a justification that "preserved the existing imprecision"; review flagged that as the wrong call, and they were converted.
The corpus meta-test's suppression ceiling ratchets from 1,446 to 1,377 — the count may only ever go down.
Tests:
Use cases covered
.first()are now count assertions, which cannot select a wrong element at allUnit tests
yarn test:eslint-rules(7/7) still passes, including the ratcheted ceiling.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
yarn lint:playwright:full→ exit 0yarn test:eslint-rules→ 7/7yarn tsc:playwright→ 162 errors, no rise over the base branch, zeroTS2304--report-unused-disable-directivescorpus-wide → zero orphaned directives--checkon all 13 changed files → cleanUI screen recording / screenshots:
Not applicable — no application UI changes.
Checklist:
Fixes <issue-number>: <short explanation>— no issue linked yetFixes #<issue-number>above — outstandingMerge order
This PR and its siblings all modify
eslint-suppressions.json, so they can be reviewed in parallel but must merge sequentially, each rebasing and re-running the full-corpus prune after the previous lands.🤖 Generated with Claude Code