Skip to content

Playwright guardrails (4/N): burn down positional locators in e2e/Features/Glossary - #31029

Closed
ShaileshParmar11 wants to merge 23 commits into
mainfrom
claude/playwright-positional-glossary
Closed

ShaileshParmar11 wants to merge 23 commits into
mainfrom
claude/playwright-positional-glossary

Conversation

@ShaileshParmar11

Copy link
Copy Markdown
Contributor

Describe your changes:

No linked issue yet — needs Fixes #<issue-number> before merge.
Depends on #31026 (the guardrail gate). Merge that first.

Burns down om-playwright/no-positional-locator across playwright/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:

  • Improvement

High-level design:

Four conversion patterns, in priority order:

  1. Delete the positional call where the locator was already unique — most were defensive. Where one genuinely matches several elements, Playwright strict mode now fails loudly, which is the desired signal rather than a silent wrong-element click.
  2. Scope by a test-owned identifier — .filter({ hasText }), getByRole(role, { name }), a specific data-testid, or getRowByName() from scopedLocators.ts.
  3. Convert to a count assertion — existence checks became expect(loc).not.toHaveCount(0).
  4. Justified eslint-disable — last resort, each carrying a -- <why> justification that the justified-rule-disable rule enforces at error.

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 matches Term_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

  • Glossary term/row lookups now resolve by exact identity rather than position or substring
  • Existence checks that used .first() are now count assertions, which cannot select a wrong element at all

Unit tests

  • Not applicable — no new logic; yarn test:eslint-rules (7/7) still passes, including the ratcheted ceiling.

Backend integration tests

  • Not applicable.

Ingestion integration tests

  • Not applicable.

Playwright (UI) tests

  • Not applicable as new tests — this modifies existing specs. CI is the verification: a locator that no longer resolves uniquely fails loudly under strict mode rather than passing vacuously.

Manual testing performed

  1. yarn lint:playwright:full → exit 0
  2. yarn test:eslint-rules → 7/7
  3. yarn tsc:playwright → 162 errors, no rise over the base branch, zero TS2304
  4. --report-unused-disable-directives corpus-wide → zero orphaned directives
  5. Prettier --check on all 13 changed files → clean
  6. Suppression arithmetic verified: the drop equals the sites fixed; no other rule's counts moved

UI screen recording / screenshots:

Not applicable — no application UI changes.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation> — no issue linked yet
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above — outstanding
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable.
  • For UI changes: not applicable.
  • Tests listed above.

Merge 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

ShaileshParmar11 and others added 21 commits August 4, 2026 11:59
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>
Copilot AI review requested due to automatic review settings August 5, 2026 12:03
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Aug 5, 2026
Comment on lines 805 to +807
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 ||

@gitar-bot gitar-bot Bot Aug 5, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ 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 👍 / 👎

Comment on lines +389 to +391
const parentRow = page.locator(
`[data-row-key="${parentTerm.responseData.fullyQualifiedName}"]`
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 👍 / 👎

Comment on lines +301 to +309
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 👍 / 👎

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 65%
66.01% (77627/117595) 49.97% (46837/93726) 51.15% (14081/27526)

…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>
@ShaileshParmar11
ShaileshParmar11 force-pushed the claude/playwright-positional-glossary branch from 4b6592a to e644da6 Compare August 5, 2026 12:18
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🔴 Playwright Results — workflow failed

Validated commit e644da6ebcf3651e3358bcc0aac2ae9ffb9cea38 in Playwright run 31005072377, attempt 1.

✅ 814 passed · ❌ 8 failed · 🟡 1 flaky · ⏭️ 15 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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:

  • Application boot ratio was 2.4 per UI scenario (2066 boots / 862 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 152 0 0 0 0 0
🔴 Shard chromium-02 155 2 1 14 0 0
🔴 Shard chromium-03 161 1 0 0 0 0
🔴 Shard chromium-04 195 5 0 1 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 10 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

Genuine Failures (failed on all attempts)

❌ Features/Glossary/GlossaryStatusFilterNestedTerms.spec.ts › filter by parent status shows parent and allows expansion to see children (shard chromium-02)
Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed  Locator: [data-row-key=""PW%'d822c41a.Lively99689d41".BasicParent"] Expected: visible Error: Unexpected token "" while parsing css selector "[data-row-key=""PW%'d822c41a.Lively99689d41".BasicParent"]". Did you mean to CSS.escape it?  Call log: �[2m  - Expect "toBeVisible" with timeout 15000ms�[22m �[2m  - waiting for [data-row-key=""PW%'d822c41a.Lively99689d41".BasicParent"]�[22m 
❌ Features/Glossary/GlossaryWorkflow.spec.ts › should delete parent term and cascade delete children (shard chromium-02)
Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed  Locator: locator('tbody > tr[data-row-key*="ParentToDelete"]:visible') Expected: visible Error: strict mode violation: locator('tbody > tr[data-row-key*="ParentToDelete"]:visible') resolved to 2 elements:     1) <tr role="row" data-rac="" tabindex="-1" data-level="1" draggable="true" id="react-aria6555994361-:r4e:" data-collection="react-aria6555994361-:r32:" data-key=""PW%'d428fb6d.Noble1401ff5b".ParentToDelete" data-row-key=""PW%'d428fb6d.Noble1401ff5b".ParentToDelete" aria-labelledby="react-aria6555994361-:r34:-"PW%'d428fb6d.Noble1401ff5b".ParentToDelete-name" class="tw:relative tw:outline-focus-ring tw:after:pointer-events-none tw:focus-visible:outline-2 tw:focus-visible:-outline-offset-2 tw:h-14 tw:s…>…</tr> aka getByRole('row', { name: 'Move the term ParentToDelete' })     2) <tr role="row" data-rac="" tabindex="-1" data-level="1" draggable="true" id="react-aria6555994361-:r51:" data-collec
❌ Features/Glossary/GlossaryP3Tests.spec.ts › should handle slow network gracefully (shard chromium-03)
Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed  Locator: locator('[data-testid="add-glossary"], [data-testid="glossary-left-panel"]') Expected: visible Error: strict mode violation: locator('[data-testid="add-glossary"], [data-testid="glossary-left-panel"]') resolved to 3 elements:     1) <div class="h-full" data-testid="glossary-left-panel">…</div> aka getByTestId('glossary-left-panel').first()     2) <button type="button" data-testid="add-glossary" class="ant-btn ant-btn-default ant-btn-block text-primary">…</button> aka getByTestId('add-glossary')     3) <ul dir="ltr" role="menu" tabindex="0" data-menu-list="true" data-testid="glossary-left-panel" class="ant-menu ant-menu-root ant-menu-inline ant-menu-light custom-menu">…</ul> aka getByText('PW % 74ae6209 Lazy129c0daePW')  Call log: �[2m  - Expect "toBeVisible" with timeout 10000ms�[22m �[2m  - waiting for locator('[data-testid="add-glossary"], [data-testid="glossary-left-panel"]')�[22m 
❌ Features/Glossary/GlossaryCRUDOperations.spec.ts › should delete parent term and cascade delete children (shard chromium-04)
Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed  Locator: [data-row-key=""PW%'9658b032.Noble0afdcc31".CascadeParent"] Expected: visible Error: Unexpected token "" while parsing css selector "[data-row-key=""PW%'9658b032.Noble0afdcc31".CascadeParent"]". Did you mean to CSS.escape it?  Call log: �[2m  - Expect "toBeVisible" with timeout 15000ms�[22m �[2m  - waiting for [data-row-key=""PW%'9658b032.Noble0afdcc31".CascadeParent"]�[22m 
❌ Features/Glossary/GlossaryCRUDOperations.spec.ts › should display parent term with children for drag operation (shard chromium-04)
Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed  Locator: [data-row-key=""PW%'9c4e2f0d.Bravec9c9b796".DragParent"] Expected: visible Error: Unexpected token "" while parsing css selector "[data-row-key=""PW%'9c4e2f0d.Bravec9c9b796".DragParent"]". Did you mean to CSS.escape it?  Call log: �[2m  - Expect "toBeVisible" with timeout 15000ms�[22m �[2m  - waiting for [data-row-key=""PW%'9c4e2f0d.Bravec9c9b796".DragParent"]�[22m 
❌ Features/Glossary/GlossaryCRUDOperations.spec.ts › should navigate between tabs on term page (shard chromium-04)
Error: locator.click: Unexpected token "" while parsing css selector "[data-row-key=""PW%'4e011fec.Merryf8a65451"."PW.c0477565%Bear281c5be2""]". Did you mean to CSS.escape it? Call log: �[2m  - waiting for [data-row-key=""PW%'4e011fec.Merryf8a65451"."PW.c0477565%Bear281c5be2""]�[22m 
❌ Features/Glossary/GlossaryCRUDOperations.spec.ts › should create child term via row action button (shard chromium-04)
Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed  Locator: [data-row-key=""PW%'a914d6fc.Quickdc6dbf6f".ParentForRowAction"] Expected: visible Error: Unexpected token "" while parsing css selector "[data-row-key=""PW%'a914d6fc.Quickdc6dbf6f".ParentForRowAction"]". Did you mean to CSS.escape it?  Call log: �[2m  - Expect "toBeVisible" with timeout 15000ms�[22m �[2m  - waiting for [data-row-key=""PW%'a914d6fc.Quickdc6dbf6f".ParentForRowAction"]�[22m 
❌ Features/Glossary/GlossaryCRUDOperations.spec.ts › should remove synonym from term (shard chromium-04)
Error: locator.click: Unexpected token "" while parsing css selector "[data-row-key=""PW%'fd8e800b.Lazye1671e8e".TermWithSynonym"]". Did you mean to CSS.escape it? Call log: �[2m  - waiting for [data-row-key=""PW%'fd8e800b.Lazye1671e8e".TermWithSynonym"]�[22m 
🟡 1 flaky test(s) (passed on retry)
  • Pages/Entity.spec.ts › Domain Propagation (shard chromium-02, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@ShaileshParmar11

Copy link
Copy Markdown
Contributor Author

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 claude/playwright-positional-glossary is preserved at e644da6ebc; nothing here is lost by closing.

On reopen, in this order:

  1. Reopen and merge Fixes 31036: Playwright guardrails — enforce test anti-patterns in CI via ESLint + suppressions ratchet #31026 (the gate) first — this PR is branched from it and is meaningless without it.
  2. Rebase this branch onto main.
  3. Re-run the full-corpus prune (yarn lint:playwright:suppressions in openmetadata-ui/src/main/resources/ui) and commit the pruned eslint-suppressions.json.
  4. Update PW_SUPPRESSION_CEILING in playwright/eslint-rules/tests/corpus.test.js to the new total.

Note these sibling PRs all touch eslint-suppressions.json, so they can be reviewed in parallel but must merge sequentially, each rebasing and re-pruning after the previous.

@gitar-bot

gitar-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 0 resolved / 3 findings

Removes positional locators across 81 Glossary e2e test sites and tightens selector matching, but changes to count assertions drop error-text rendering waits and exact row-key selectors break on fully qualified names with quotes or dots.

⚠️ Edge Case: count() snapshot drops the wait for error-text to render

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryP3Tests.spec.ts:805-807 📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryP3Tests.spec.ts:856-858

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 });
💡 Edge Case: Exact data-row-key selector breaks on FQNs with quotes/dots

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryCRUDOperations.spec.ts:389-391 📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryCRUDOperations.spec.ts:454-462 📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryStatusFilterNestedTerms.spec.ts:154-155

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.

💡 Bug: CI blanket-disable grep can false-positive on wrapped block comments

📄 .github/workflows/ui-checkstyle.yml:301-309

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.

🤖 Prompt for agents
Code Review: Removes positional locators across 81 Glossary e2e test sites and tightens selector matching, but changes to count assertions drop error-text rendering waits and exact row-key selectors break on fully qualified names with quotes or dots.

1. ⚠️ Edge Case: count() snapshot drops the wait for error-text to render
   Files: openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryP3Tests.spec.ts:805-807, openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryP3Tests.spec.ts:856-858

   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()`.

   Fix (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 });

2. 💡 Edge Case: Exact data-row-key selector breaks on FQNs with quotes/dots
   Files: openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryCRUDOperations.spec.ts:389-391, openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryCRUDOperations.spec.ts:454-462, openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Glossary/GlossaryStatusFilterNestedTerms.spec.ts:154-155

   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.

3. 💡 Bug: CI blanket-disable grep can false-positive on wrapped block comments
   Files: .github/workflows/ui-checkstyle.yml:301-309

   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.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants