Skip to content

fix(tests): playground role-select selectors, apiBase pre-nav bug, mark 5 flaky tests retry-eligible - #5896

Merged
mmabrouk merged 2 commits into
release/v0.112.0from
test-fix/playground-xpath-apibase
Aug 10, 2026
Merged

fix(tests): playground role-select selectors, apiBase pre-nav bug, mark 5 flaky tests retry-eligible#5896
mmabrouk merged 2 commits into
release/v0.112.0from
test-fix/playground-xpath-apibase

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

Summary

Three independent fixes to the web acceptance suite, continuing the repair from #5854/#5855.

1. Playground prompt-message XPath fragility (confirmed real)

playground/index.ts:178 ("Should update the prompt and save the changes") and :219
("should save the current changes as a new variant") both failed at
scrollIntoViewIfNeeded timing out on addNewPrompt()'s 5-hop
xpath=ancestor::.../locator('..') chain, which no longer matches the current DOM (the
prompt editor now renders through PromptSchemaControl, shared with the evaluator
DrillInView, not the structure the chain assumed).

Fix: replaced the chain with a scoped, index-correlated lookup:

  • Added data-testid="prompt-schema-control" to PromptSchemaControl.tsx's root — this
    ships in fix(frontend): dropdown menus never unmount after close (scroll-fade vs Radix Presence) #5895, not here (see Dependency below).
  • addNewPrompt() now scopes the "Message" button and .message-user-select role
    buttons to that testid, and pairs the Nth role button with the Nth
    .editor-input[role="textbox"] — each ChatMessageItem renders exactly one of each,
    in message order, so no ancestor traversal is needed.

A second, real bug surfaced during investigation (live-debugged against
144.76.237.122:8180, not a test artifact): selecting a role from the dropdown updated
the value correctly but its Radix portal never unmounted — data-state flipped to
"closed" but the node stayed mounted and interactive forever, permanently
aria-hiding the rest of the page (confirmed via getComputedStyle + manual repro).
Root cause: DropdownMenuContent's overflow-y-auto class collides with globals.css's
scroll-fade animation, which Radix's Presence waits on before unmounting — a
scroll-timeline animation never fires the animationend it's waiting for. Fixed with a
one-class animate-none override, verified via isolated CSS-specificity test. This
fix also ships in #5895
, and is a prerequisite for these two tests to pass — a selector
rewrite alone can't work around a permanently-open, aria-hiding overlay.

Verified live: both tests pass (16.0s and 14.0s) against 144.76.237.122:8180 once
#5895's changes were live on that stack.

2. apiBase() about:blank bug (confirmed real, fixed)

agent-chat/attach-send-render-reload.spec.ts failed in ~300ms:
seedAgentChatApp() calls apiBase(page) before the test navigates anywhere, so
page.url() is still "about:blank" — a non-empty string that defeats
page.url() || fallback, and whose .origin serializes to the literal string "null"
(a bogus /null/api/... request).

Fix: treat about:blank explicitly as "no real page yet" and fall back to
AGENTA_WEB_URL, matching the test config's own baseURL.

Verified live: the test now runs past seeding and into navigateToAgentPlayground()
(60s+ instead of ~300ms). It then fails on a separate, real, downstream issue
expectPath times out waiting for /apps/<id>/playground; the seeded is_agent app's
playground URL instead resolves to a bare /playground path with no /apps/<id>
segment, suggesting agent-type workflows have moved under a different route in the
current IA. Not chased, per scope — flagging as a follow-up.

3. Mark 5 nondeterministic tests retry-eligible (not skipped)

Per Mahmoud's call: three low-confidence timeouts (two evaluator-area: a toHaveValue
race in openAutoEvaluationRunFromList, and a waitForEvaluatorsQuery timeout; one
human-annotation predicate timeout) and two observability trace-indexing tests are
read-only or use uniquely-named fixtures, so a retry is safe — never skipped.

Implementation: each test wrapped in its own nested test.describe(...) with
test.describe.configure({retries: 2}) — the narrowest scope covering exactly one test,
leaving every sibling test in the same file at the suite's global default (0 retries
locally, 2 in CI; playwright.config.ts has no per-project override, confirmed no
existing retry pattern in the suite to conflict with).

  • auto-evaluation/index.ts: "should run a single evaluation"
  • evaluators/index.ts: "should navigate to the evaluators page and display both
    automatic and human evaluator tabs"
  • human-annotation/index.ts: "should create a new evaluator inline and annotate a
    scenario from the annotate tab"
  • observability/index.ts: "view traces" and "should open a span and drill into its
    attributes"

Verified live: --list collects all 80 tests with no errors; the evaluators test
passes cleanly under the new describe scope; the auto-evaluation test genuinely retried
twice (3 total attempts visible in the run log) before failing on unrelated flakiness,
confirming configure({retries: 2}) is wired up correctly and doesn't break test
loading. Pass/fail of these five stays nondeterministic by design.

Dependency

Requires #5895 to merge first. This branch's playground selectors use the
data-testid="prompt-schema-control" that PR adds, and rely on its animate-none fix
for the role dropdown to close at all. Verification above was run against the live dev
stack after #5895's changes were applied there directly (not yet merged) — CI here won't
go green until #5895 lands on release/v0.112.0.

Test plan

  • Playground: both tests pass live (16.0s, 14.0s) against 144.76.237.122:8180
  • apiBase: confirmed past the about:blank/null bug; downstream /apps/<id>
    routing failure reported separately, not fixed here
  • Retry-marking: --list clean (80 tests, 21 files); one test passed under the new
    scope, one genuinely retried twice as configured
  • pnpm turbo run lint --filter=@agenta/oss — clean (pre-existing warnings only,
    unrelated files)
  • prettier --write on all touched files

…fix apiBase pre-navigation bug

- playground/tests.ts addNewPrompt(): replace the 5-hop ancestor::/locator('..') XPath
  chain with a scoped, index-correlated lookup (data-testid="prompt-schema-control",
  added to PromptSchemaControl.tsx in PR #5895, scopes the "Message" button and role
  selectors; the Nth .message-user-select role button and Nth .editor-input[role="textbox"]
  always belong to the same message row, since ChatMessageList renders one of each per
  message in array order). Fixes "Should update the prompt and save the changes" and
  "should save the current changes as a new variant", both confirmed passing live against
  144.76.237.122:8180. Depends on PR #5895 (dropdown-menu.tsx animate-none fix) for the
  data-testid and for the role dropdown to actually close after a selection.

- agent-chat/tests.ts apiBase(): seedAgentChatApp() runs before the test navigates
  anywhere, so page.url() is still "about:blank" -- a non-empty string that defeats
  `page.url() || fallback`, and whose .origin serializes to the literal string "null"
  (a bogus /null/api/... request that 404s in ~300ms). Treat about:blank as "no real
  page yet" and fall back to AGENTA_WEB_URL, matching the test config's own baseURL.
  Confirmed live: the test now gets past seeding and into navigateToAgentPlayground()
  (60s+ runtime instead of ~300ms), then fails downstream on a real, separate issue --
  waitForPath times out because the seeded is_agent app's playground URL resolves to a
  bare /playground path without the /apps/<id> segment, suggesting agent-type workflows
  have moved under a different route in the current IA. Not chased; flagging for
  a follow-up.
…ahmoud's call

Wraps each test in its own nested test.describe(...) with
test.describe.configure({retries: 2}) -- the narrowest scope that covers exactly one
test, leaving every sibling test in the same file at the suite's global default
(0 retries locally, 2 in CI; playwright.config.ts has no per-project override).

These five were identified (PR #5854) as low-confidence timeouts/races, not stale
selectors, and are read-only or use uniquely-named (Date.now()-suffixed) fixtures, so a
retry never collides with or destroys prior data:

- auto-evaluation/index.ts: "should run a single evaluation" -- openAutoEvaluationRunFromList's
  search-input toHaveValue race.
- evaluators/index.ts: "should navigate to the evaluators page and display both automatic
  and human evaluator tabs" -- waitForEvaluatorsQuery timeout.
- human-annotation/index.ts: "should create a new evaluator inline and annotate a scenario
  from the annotate tab" -- annotateCurrentHumanScenario's annotation-form predicate timeout.
- observability/index.ts: "view traces" and "should open a span and drill into its
  attributes" -- both can lag past the polling window on async trace indexing.

Verified live against 144.76.237.122:8180: `--list` collects all 80 tests with no
errors, "should navigate to..." passes cleanly under the new describe scope, and
"should run a single evaluation" genuinely retried twice (3 total attempts) before
failing, confirming the configure({retries: 2}) is wired up and does not break test
loading. Pass/fail of these five stays nondeterministic by design -- nothing here was
skipped.
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Aug 10, 2026
@vercel

vercel Bot commented Aug 10, 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 10, 2026 10:00am

Request Review

@dosubot dosubot Bot added the tests label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of uninitialized pages during acceptance test setup, preventing invalid API origins.
    • Made playground prompt interactions more reliable by scoping controls and waiting for dropdowns to close.
  • Tests

    • Added automatic retries to evaluation, evaluator navigation, human annotation, and observability acceptance tests.
    • Preserved existing workflows and assertions while improving resilience against transient delays.

Walkthrough

The Playwright acceptance tests now resolve API URLs safely from blank pages, retry selected suites up to two times, and use scoped prompt selectors with dropdown readiness synchronization.

Changes

Playwright acceptance test resilience

Layer / File(s) Summary
Blank-page API URL fallback
web/oss/tests/playwright/acceptance/agent-chat/tests.ts
apiBase falls back to AGENTA_WEB_URL or localhost when the page URL is about:blank.
Retry-enabled acceptance suites
web/oss/tests/playwright/acceptance/auto-evaluation/index.ts, web/oss/tests/playwright/acceptance/evaluators/index.ts, web/oss/tests/playwright/acceptance/human-annotation/index.ts, web/oss/tests/playwright/acceptance/observability/index.ts
Selected acceptance suites allow up to two retries. Existing workflows and assertions remain unchanged.
Scoped playground prompt controls
web/oss/tests/playwright/acceptance/playground/tests.ts
Prompt controls use schema-scoped selectors, shared indexes for new roles and editors, and a wait for dropdown portal removal.

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

Possibly related issues

Possibly related PRs

  • Agenta-AI/agenta#4308 — Modifies overlapping auto-evaluation and human-annotation Playwright tests for UI resilience.
  • Agenta-AI/agenta#4458 — Targets Playwright acceptance-test flakiness, including observability retry and timeout behavior.
  • Agenta-AI/agenta#5177 — Overlaps with the agent-chat acceptance infrastructure and agent-chat/tests.ts.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the three main changes: playground selectors, the apiBase pre-navigation fix, and retry configuration for five tests.
Description check ✅ Passed The description directly explains all three changes, their dependency, verification results, and the remaining downstream routing issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-fix/playground-xpath-apibase

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: a2ee04f9-ffc1-487d-9fab-2827b5b57bd8

📥 Commits

Reviewing files that changed from the base of the PR and between b7dcfe3 and 619d6a3.

📒 Files selected for processing (6)
  • web/oss/tests/playwright/acceptance/agent-chat/tests.ts
  • web/oss/tests/playwright/acceptance/auto-evaluation/index.ts
  • web/oss/tests/playwright/acceptance/evaluators/index.ts
  • web/oss/tests/playwright/acceptance/human-annotation/index.ts
  • web/oss/tests/playwright/acceptance/observability/index.ts
  • web/oss/tests/playwright/acceptance/playground/tests.ts

Comment thread web/oss/tests/playwright/acceptance/auto-evaluation/index.ts
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-08-10T10:20:53.522Z

@mmabrouk
mmabrouk merged commit 9187721 into release/v0.112.0 Aug 10, 2026
61 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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