Skip to content

fix(tests): stop swallowing strict-mode violations across the acceptance suite - #5855

Merged
mmabrouk merged 5 commits into
release/v0.112.0from
test-fix/swallowed-exceptions
Aug 9, 2026
Merged

fix(tests): stop swallowing strict-mode violations across the acceptance suite#5855
mmabrouk merged 5 commits into
release/v0.112.0from
test-fix/swallowed-exceptions

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

PR 5824 fixed four sites where LOCATOR.isX().catch(() => false) silently turned a Playwright strict-mode violation (a locator matching more than one element) into a permanent false. A poll loop built on that pattern can't tell "not ready yet" from "the selector itself is broken" — it just times out with a message that names no real cause (e.g. "page never reached a stable ready state"), and someone spends hours looking in the wrong place. That PR added pollLocatorState (web/tests/utils/index.ts) as the fix and the pattern to copy.

105 more sites used the raw pattern (102 literal matches of .catch(() => false) across 16 files; one of those matches was a comment mention, not real code — 101 real sites). This converts all but one of them.

What changed, and what didn't

Converted 101 sites across 16 files to pollLocatorState, in 5 reviewable commits:

  1. global-setup.ts (27 sites)
  2. Shared fixtures — apiHelpers, providerHelpers, authHelpers (13 sites)
  3. Evaluation acceptance tests — human-annotation, auto-evaluation, evaluators (40 sites)
  4. Remaining OSS acceptance tests — playground, observability, app, deployment, use-api, settings/model-hub (16 sites)
  5. EE members (3 sites)

Left exactly one site unconverted, with a comment explaining why: human-annotation/tests.ts's ensureSingleHumanEvaluatorSelection calls .evaluateAll(...) on a locator, not .isVisible()/.isEnabled()/etc. evaluateAll runs over every element the locator currently matches, regardless of count — it can never throw a strict-mode violation, so pollLocatorState would be a no-op there. I checked every other site individually for a similar "deliberate swallow" case; this was the only one.

Verification — before/after against a real failure

A passing suite doesn't prove the messages improved (that's the whole point PR 5824 made). I reproduced a real strict-mode violation live against the deployed EE dev stack (not a fabricated error string) and ran both patterns against it.

The originally-documented duplicate ("Add endpoint" rendered twice — header + empty state, per providerHelpers/index.ts's existing comment) no longer reproduces on the account I had a live session for (it already has a custom provider configured from an earlier run, so the empty-state row isn't showing). I demonstrated the identical mechanism against a locator that's genuinely ambiguous on that same live page today: the Model Hub's "Configure now" button, which renders once per standard provider row (13 real matches: OpenAI, Mistral, Cohere, Anthropic, ...).

Before (LOCATOR.isEnabled().catch(() => false)):

Result reported to the poll: false

The caller sees only false. A poll loop built on this reports something like "Models page never reached a stable ready state" — naming no real cause, exactly the failure mode PR 5824 described.

After (pollLocatorState(() => LOCATOR.isEnabled())):

Threw through cleanly. Actual error surfaced to the test:
locator.isEnabled: Error: strict mode violation: getByRole('button', { name: 'Configure now' }) resolved to 13 elements:
    1) <button type="button" class="ant-btn ...">…</button> aka getByRole('button', { name: 'Configure now' }).first()
    2) <button type="button" class="ant-btn ...">…</button> aka getByRole('button', { name: 'Configure now' }).nth(1)
    ...

The real Playwright error — naming the ambiguous selector and listing the matched elements — reaches the test instead of being swallowed.

Test plan

  • eslint --fix on all 16 touched files — no new errors (verified every reported error pre-exists on an untouched line via git diff)
  • playwright test --list loads all 80 OSS + 67 EE acceptance tests with the converted code (no import/syntax breakage)
  • Live before/after reproduction of a real strict-mode violation, shown above

global-setup.ts's 27 isVisible/isEditable/isChecked/getAttribute readiness
checks all used the raw `.catch(() => false)` pattern PR 5824 identified:
a strict-mode violation (a locator matching more than one element) gets
silently turned into a permanent `false` instead of failing loudly, so a
broken selector reports as a generic auth-flow timeout instead of naming
the real cause.

Switch every site to pollLocatorState (web/tests/utils/index.ts, added in
PR 5824), which still swallows ordinary "not there yet" failures but
rethrows a strict-mode violation.
Same conversion as global-setup.ts for the three base/user fixture helper
modules (apiHelpers, providerHelpers, authHelpers): 13 more
`.catch(() => false)` readiness checks now use pollLocatorState so a
locator that starts matching more than one element fails with its real
strict-mode message instead of a generic "page never reached a stable
ready state" timeout.

providerHelpers/index.ts already imported pollLocatorState from PR 5824;
this converts the 4 sites in that file the earlier pass left behind.
…ptance tests

Converts the remaining 40 `.catch(() => false)` readiness checks in the
human-annotation, auto-evaluation, and evaluators acceptance suites to
pollLocatorState, same as PR 5824's four sites: ordinary "not there yet"
failures still poll normally, but a strict-mode violation now surfaces
with its real message instead of a misleading readiness timeout.

Left one site unconverted in human-annotation/tests.ts
(ensureSingleHumanEvaluatorSelection's evaluateAll check): evaluateAll
runs over every matched row regardless of count, so it can never throw a
strict-mode violation, and a one-line comment says so.
…cceptance tests

Same pollLocatorState conversion for the playground, observability, app
creation, deployment, use-api, and settings/model-hub acceptance suites
(16 sites total). deployment/index.ts and use-api/index.ts already
imported pollLocatorState from PR 5824's deployVariantToEnv fix; this
converts the one remaining site in each of those two files.
Converts the last 3 sites (openInviteMembersModal x2,
dismissInvitedUserLinkDialog) to pollLocatorState.
@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Blocked Blocked Aug 9, 2026 9:57pm

Request Review

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. tests labels Aug 9, 2026
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 167481a7-3271-4cd2-a16c-c26e942ae476

📥 Commits

Reviewing files that changed from the base of the PR and between cd13ca3 and 606769f.

📒 Files selected for processing (16)
  • web/ee/tests/playwright/acceptance/members/index.ts
  • web/oss/tests/playwright/acceptance/app/test.ts
  • web/oss/tests/playwright/acceptance/auto-evaluation/index.ts
  • web/oss/tests/playwright/acceptance/auto-evaluation/tests.ts
  • web/oss/tests/playwright/acceptance/deployment/index.ts
  • web/oss/tests/playwright/acceptance/evaluators/index.ts
  • web/oss/tests/playwright/acceptance/evaluators/tests.ts
  • web/oss/tests/playwright/acceptance/human-annotation/tests.ts
  • web/oss/tests/playwright/acceptance/observability/index.ts
  • web/oss/tests/playwright/acceptance/playground/tests.ts
  • web/oss/tests/playwright/acceptance/settings/model-hub.ts
  • web/oss/tests/playwright/acceptance/use-api/index.ts
  • web/tests/playwright/global-setup.ts
  • web/tests/tests/fixtures/base.fixture/apiHelpers/index.ts
  • web/tests/tests/fixtures/base.fixture/providerHelpers/index.ts
  • web/tests/tests/fixtures/user.fixture/authHelpers/index.ts

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Improved automated end-to-end test reliability by polling UI states consistently across authentication, invitations, evaluations, deployments, annotations, observability, playground, settings, and other workflows.
    • Preserved existing retry behavior while allowing unexpected UI errors to surface during test execution.
    • Strengthened checks for visibility, enabled states, and selected controls across browser-based tests.

Walkthrough

The change replaces direct Playwright visibility and checked-state checks with pollLocatorState across acceptance tests, global setup, and shared fixtures. Existing retry behavior, timeouts, and boolean handling remain where specified.

Changes

Playwright acceptance flows

Layer / File(s) Summary
Core acceptance-flow polling
web/ee/tests/playwright/acceptance/members/index.ts, web/oss/tests/playwright/acceptance/{app,auto-evaluation,deployment,evaluators}/...
Core acceptance flows now poll locator visibility and checked state through pollLocatorState.
UI acceptance-flow polling
web/oss/tests/playwright/acceptance/{human-annotation,observability,playground,settings,use-api}/...
Additional UI flows now use polling for onboarding, forms, drawers, rows, controls, and readiness checks.
Global setup and authentication polling
web/tests/playwright/global-setup.ts
Survey, signup, authentication, OTP, Turnstile, and feedback detection now use shared locator polling.
Shared fixture readiness polling
web/tests/tests/fixtures/base.fixture/..., web/tests/tests/fixtures/user.fixture/...
API, provider, and authentication fixtures now use pollLocatorState for readiness and control detection.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: exposing Playwright strict-mode violations across the acceptance suite.
Description check ✅ Passed The description directly explains the conversion to pollLocatorState, the retained exception, and the verification performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-fix/swallowed-exceptions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mmabrouk
mmabrouk merged commit 613368b into release/v0.112.0 Aug 9, 2026
41 of 43 checks passed
@mmabrouk mmabrouk added the lgtm This PR has been approved by a maintainer label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant