Repository navigation
test(e2e): deflake mock-LLM profile activation helper - #1580
Conversation
activateProfileViaUI is the shared setup step every mock-LLM spec runs via
ensureMockLLMProfile, and it was the common failure point of the intermittent
mock-llm-e2e timeouts seen across unrelated PRs.
Three compounding problems:
- The poll called page.goto("/settings/llm") on every tick, but the "Active"
badge is reactive (the activate mutation invalidates the profiles query, so
active_profile refetches and the row re-renders). The reload was unnecessary
and burned the 15s budget in 2-3 navigations.
- The inner waitForTestId carried its default 30s timeout inside the 15s poll,
so one slow render could consume the whole budget in a single tick.
- createProfileViaUI returns as soon as the editor closes, not when the new row
renders. If the row was not yet in the DOM, the activation gesture was skipped
entirely and the poll then waited for a badge that was never set.
Wait for the row to be visible, retry the open-menu -> "Set active" gesture with
expect().toPass(), and assert the badge appears reactively (no reload). Reset any
menu left open between attempts with Escape, since the trigger toggles.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@OpenHands /codereview-roasted and post feedback on the PR |
|
I'm on it! enyst can track my progress at all-hands.dev |
enyst
left a comment
There was a problem hiding this comment.
🟡 Taste Rating: Acceptable
The core shape is right: wait for the row, retry activation, and stop doing expensive reloads. I found one real reliability gap that keeps the new retry loop from fully doing what it says.
[RISK ASSESSMENT]
- [Overall PR]
⚠️ Risk Assessment: 🟢 LOW
Test-helper-only change; CI and both mock-LLM suites are green. The risk is localized to E2E setup flake behavior, not product/runtime behavior.
VERDICT:
❌ Needs small rework: fix the nested default timeout so the retry loop can actually retry on a missing menu/dropped click.
KEY INSIGHT:
The new algorithm is simpler, but one old 30s wait remains inside the 30s retry budget.
This review was created by an AI agent (OpenHands) on behalf of @OpenHands.
Improve this review? If any feedback above seems incorrect or irrelevant to this repository, you can teach the reviewer to do better:
- Add a
.agents/skills/custom-codereview-guide.mdfile to your branch (or edit it if one already exists) with the/codereviewtrigger and the context the reviewer is missing (e.g., "Security concerns about X do not apply here because Y"). See the customization docs for the required frontmatter format.- Re-request a review - the reviewer reads guidelines from the PR branch, so your changes take effect immediately.
- When your PR is merged, the guideline file goes through normal code review by repository maintainers.
Resolve with AI? Install the iterate skill in your agent and run
/iterateto automatically drive this PR through CI, review, and QA until it's merge-ready.Was this review helpful? React with 👍 or 👎 to give feedback.
This comment was marked as duplicate.
This comment was marked as duplicate.
The open-menu gesture inside `activateProfileViaUI`'s `.toPass` block used `waitForTestId`'s 30s default (equal to the whole `.toPass` budget) and an unbounded `click` actionTimeout. A menu that failed to open — the exact flake the retry is meant to self-heal — would consume the entire 30s window in one tick, so the loop never got a second attempt. Cap the menu wait and both clicks at 5s each so a failed tick fails fast and `.toPass` retries. Also short-circuit on badge visibility rather than DOM attachment for consistency with the success assertion.
…m-profile-activation # Conflicts: # tests/e2e/mock-llm/utils/mock-llm-helpers.ts
|
@enyst :-) |
…m-profile-activation # Conflicts: # tests/e2e/mock-llm/utils/mock-llm-helpers.ts
✅ Mock-LLM E2E Tests60/60 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
✅ Mock-LLM Docker E2E Test Results60/60 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
|
🚀 Released in v1.2.0. |
HUMAN:
Fixing a flaky test.
AGENT:
Automated validation (Claude), run against the same stack CI uses — mock-LLM Python server on
openhands-sdk==1.29.3, the full agent-canvas binary viabin/agent-canvas.mjswithopenhands-automation==1.0.0a13, pre-built frontend, Playwright Chromium:activateProfileViaUI(the code changed here) passed on every run. I ranmock-llm-preset-automation.spec.tswith--repeat-each=5(10 executions) against one server: the profile create+activate setup succeeded 10/10, and the:151test that was flaking in CI (activateProfileViaUItimeout at the oldmock-llm-helpers.ts:553) passed 5/5. The old badge-poll timeout did not recur once across ~14 total executions of the helper.mock-llm-preset-automation.spec.ts+mock-llm-files-and-git.spec.tstogether; thefiles-and-git"step 1: ensure mock LLM profile is configured" step (which calls this helper) passed.:248—waitForNonUserMessageTextwaiting for the mock agent's streamed reply (helpers.ts:179, 45s) and achat-inputrender-timing miss. Those are a separate helper, downstream of activation, and reproduce locally only because this machine is running a second full agent-canvas instance concurrently (load avg ~5), which slows the agent-server runtime's replies. They do not involveactivateProfileViaUI.npm run typecheckpasses.Authoritative gate:
tests/e2e/mock-llm/utils/mock-llm-helpers.tsis a shared helper, soresolve-affected-tests.mjsreturns__ALL__and themock-llm-e2eCI job runs the full suite against this branch — that run (on a clean, uncontended runner) is the real end-to-end check.Why
The
mock-llm-e2ejob flakes intermittently across unrelated PRs. Every mock-LLM spec begins withensureMockLLMProfile→activateProfileViaUI(tests/e2e/mock-llm/utils/mock-llm-helpers.ts), and the failures all land on that shared setup step (e.g.files-and-git.spec.ts:101 "step 1: ensure mock LLM profile is configured",mock-llm-acp-agent.spec.ts:93,mock-llm-preset-automation.spec.ts:151), timing out withTimeout 15000ms exceeded while waiting on the predicate.Three compounding problems in the old
activateProfileViaUI:page.goto("/settings/llm")on every iteration. But the "Active" badge is reactive —useActivateLlmProfileinvalidates the profiles query on success, which refetchesactive_profileand re-renders the row. Reloading each tick (navigation + hydration + profiles refetch, ~2–5s on a loaded runner) meant the 15s budget only bought ~2–3 real attempts.waitForTestId(..., "add-llm-profile")carried its default 30s timeout, so one slow render could consume the whole poll budget in a single tick.createProfileViaUIreturns as soon as the editor closes — it does not wait for the new row to render in the list. If the row wasn't in the DOM yet,if ((await row.count()) > 0)was false, the "Set active" gesture was never attempted, and the poll then waited 15s for a badge that would never appear. The poll only re-checked the badge; it never retried the click.Summary
activateProfileViaUIto wait for the profile row to be visible before acting on it (fixes the skipped-activation race).expect(...).toPass()so a dropped click or a not-yet-loaded menu self-heals, and assert the badge appears reactively — no per-tick page reload.Escapeat the start of each retry, since the menu trigger toggles.Issue Number
No dedicated tracking issue — this is a test-infra reliability fix.
How to Test
Video/Screenshots
No UI change — this is a test-helper change. Evidence is the passing e2e runs in the AGENT section above.
Type
Notes
tests/e2e/mock-llm/utils/mock-llm-helpers.tsis a shared helper, soresolve-affected-tests.mjsreturns__ALL__and CI runs the full mock-LLM suite on this PR. The change is stricter than before — it now verifies the "Active" badge appears without a reload, exercising the reactive update path directly.🐳 Docker images for this PR
• GHCR package: https://github.com/OpenHands/agent-canvas/pkgs/container/agent-canvas
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.33.0-pythonopenhands-automation==1.1.4ad80e5372c7dc0fad585fa973ef220e98efff04dPull (multi-arch manifest)
# Multi-arch manifest — Docker automatically pulls the correct architecture docker pull ghcr.io/openhands/agent-canvas:sha-ad80e53Run
All tags pushed for this build
About Multi-Architecture Support
sha-ad80e53) is a multi-arch manifest supporting both amd64 and arm64sha-ad80e53-amd64) are also available if needed