Skip to content

fix(e2e): make the MCP registration test-owned, and name the working directory - #510

Merged
senamakel merged 6 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/484-followup-mcp-agent-test-ownership
Aug 8, 2026
Merged

fix(e2e): make the MCP registration test-owned, and name the working directory#510
senamakel merged 6 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/484-followup-mcp-agent-test-ownership

Conversation

@M3gA-Mind

@M3gA-Mind M3gA-Mind commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #484 (issue #467), which merged at 83bd8ba while these two fixes
were still in flight. Both come from CodeRabbit's review of that PR, and both
are real; neither reached main.

The MCP registration in mcp-agent.spec.ts was not test-owned (CodeRabbit,
Major). The server name was fixed and a 409 already exists was accepted as
successful setup, so a leftover registration from an earlier run — pointing at
any endpoint at all — would be adopted, passed against, and then deleted by a
test that never created it. The spec would go green having validated nothing
about MCP_SERVER. The name is unique per run now and a 409 is a setup
failure.

Cleanup is checked as well, but only when the body got that far: an
assertion thrown out of a finally replaces the real failure with a complaint
about cleanup, which is the harder of the two to debug. That is a deliberate
narrowing of the suggested fix, and the reason is in the comment.

The README's live-lane recipe did not say where to stand (CodeRabbit,
Minor). It runs cargo build from the repository root and npm run e2e:live
from frontend/; only CI knew that, through working-directory: frontend.

API Or Behavior Changes

None. Test-fixture ownership and one documentation line.

Tests

  • cargo fmt --all -- --check — N/A - full local build matrix is prohibited on this machine; verified in CI. (No Rust in this diff.)
  • cargo clippy --all-targets -- -D warnings — N/A - full local build matrix is prohibited on this machine; verified in CI.
  • cargo build --all-targets — N/A - full local build matrix is prohibited on this machine; verified in CI.
  • cargo test — N/A - full local build matrix is prohibited on this machine; verified in CI.

npm run typecheck:e2e clean. The spec itself runs in Console E2E (live brain), which this PR's own CI run exercises — that lane is where the change
is observable, and it is green on main as of #484.

No new test accompanies this: the change is a test's correctness, and the
property it fixes (a stale registration cannot be adopted) is asserted by the
spec's own expect(added.ok()) on every run.

Documentation

frontend/README.md — the live-lane recipe now names the working directory.

Summary by CodeRabbit

  • Documentation

    • Updated live end-to-end test setup instructions to include changing into the frontend directory before running tests.
  • Tests

    • Improved MCP agent test isolation by generating unique server names for each run.
    • Strengthened registration and cleanup checks to better detect failures.
    • Ensured mock tool calls use the server created during the current test.
    • Improved cleanup handling when test execution encounters transport failures.

…directory

Both from CodeRabbit on tinyhumansai#484, both real.

A fixed server name plus a tolerated 409 let this spec adopt a leftover
registration from an earlier run — pointing anywhere at all — pass against
it, and then delete a server it never created. The name is unique per run
now and 409 is a failure. The cleanup is checked too, but only when the body
got that far: an assertion thrown out of a `finally` replaces the real
failure with a complaint about cleanup.

The README's live-lane recipe ran `cargo build` from the repository root and
`npm run e2e:live` from wherever you happened to be.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@M3gA-Mind

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7549d717-0a85-4189-ab1c-8fadc036dfcb

📥 Commits

Reviewing files that changed from the base of the PR and between 591bcc0 and 7018833.

📒 Files selected for processing (1)
  • frontend/test/e2e/mcp-agent.spec.ts
📝 Walkthrough

Walkthrough

The live E2E command now targets the frontend directory. The MCP agent test uses unique server names, requires successful registration, passes the generated name to tool calls, and conditionally validates cleanup.

Changes

Live E2E MCP testing

Layer / File(s) Summary
Live E2E setup and MCP test lifecycle
frontend/README.md, frontend/test/e2e/mcp-agent.spec.ts
The setup command targets frontend. The test generates a unique MCP server name, requires successful registration, uses that name for tool calls, and reports cleanup failures only after successful test execution.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit names each server bright,
Then sends the right tool call in flight.
Registration must succeed,
Cleanup follows every deed.
Frontend tests now run just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main MCP E2E test changes and the README command update.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/README.md`:
- Around line 208-210: Update the live E2E command in the README to run from the
repository root without changing directories, while preserving the frontend
package context through the npm invocation. Remove the standalone “cd frontend”
step and keep the existing live E2E behavior unchanged.

In `@frontend/test/e2e/mcp-agent.spec.ts`:
- Around line 86-91: Update the test setup around the server and marker
generation to import and call node:crypto.randomUUID() once per attempt, then
reuse that UUID in both server and marker values. Remove reliance on Date.now()
and preserve the existing per-run uniqueness and cleanup behavior.
- Around line 149-161: Update the cleanup in the finally block around
page.request.delete for server so transport rejections are caught; rethrow the
cleanup error only when bodyPassed is true, and otherwise record it without
replacing the original body failure. Preserve the existing removed.ok assertion
for successful delete responses.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1c426b69-590f-4e57-90b6-02b8a4e521b9

📥 Commits

Reviewing files that changed from the base of the PR and between 4c17304 and 975b86e.

📒 Files selected for processing (2)
  • frontend/README.md
  • frontend/test/e2e/mcp-agent.spec.ts

Comment thread frontend/README.md Outdated
Comment thread frontend/test/e2e/mcp-agent.spec.ts Outdated
Comment thread frontend/test/e2e/mcp-agent.spec.ts
…after

Two more from CodeRabbit on tinyhumansai#510.

The first is a hole in the reasoning of the commit it reviews. I guarded
the cleanup ASSERTION behind `bodyPassed` so it could not replace a real
failure, and left the `page.request.delete` that precedes it unguarded —
and that call REJECTS on a transport failure rather than returning a
response to inspect. So the exact substitution the guard exists to prevent
was still reachable, by the other of the two paths. Both are inside the
guard now.

The second: run both commands from the repository root. The recipe said
`cd frontend`, which contradicts this repo's own rule, so
`npm --prefix frontend` instead.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@M3gA-Mind

Copy link
Copy Markdown
Collaborator Author

Two of the three fixed in 591bcc0; declining the third with a reason.

Preserve the original body failure when cleanup transport fails (Major) — fixed, and a good catch. It is a hole in the reasoning of the commit it reviews: I guarded the cleanup assertion behind bodyPassed so it could not replace a real failure, and left the page.request.delete in front of it unguarded — and that call rejects on a transport failure rather than returning a response to inspect. The exact substitution the guard exists to prevent was still reachable, by the other of the two paths. Both are inside the guard now.

Run from the repository root (Minor) — fixed. npm --prefix frontend run e2e:live. The repo rule is right and cd frontend contradicted it.

randomUUID() for server and marker (Minor) — declining. The collision this protects against cannot occur here, and the change would make this spec diverge from its neighbour for no gain:

  • the suite is workers: 1, fullyParallel: false, so no two tests in a run are ever in flight together;
  • two concurrent CI runs never share a host — host.sh gives each run its own binary, bind and data root under target/e2e, so a same-millisecond Date.now() in two runs registers two servers in two different secret stores;
  • mcp.spec.ts — merged, adjacent, doing the same job on the default lane — names its runtime server pw-mcp-${Date.now()}. Matching that idiom is worth more here than removing a collision that has no path to happening.

Happy to switch if either of the first two stops being true.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

git show --stat --oneline 591bcc0
git diff 591bcc0^ 591bcc0 -- frontend/README.md frontend/test/e2e/mcp-agent.spec.ts

printf '\n--- Candidate files ---\n'
fd -i 'mcp.spec.ts' .
fd -i 'playwright*.{ts,js,mjs,cjs}' . || true
fd -i 'host.sh' .

printf '\n--- mcp-agent test outline ---\n'
ast-grep outline frontend/test/e2e/mcp-agent.spec.ts --items all || true

printf '\n--- Relevant implementation and configuration references ---\n'
rg -n -C 4 --glob '!*node_modules*' \
  '(workers\s*:|fullyParallel\s*:|pw-mcp-\$\{Date\.now\(\)\}|target/e2e|data root|dataRoot|bind|page\.request\.delete|bodyPassed)' \
  frontend .github scripts . 2>/dev/null || true

Length of output: 191593


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- MCP agent test ---'
sed -n '80,185p' frontend/test/e2e/mcp-agent.spec.ts

printf '%s\n' '--- Playwright host selection ---'
sed -n '1,170p' frontend/playwright.config.ts

printf '%s\n' '--- Adjacent MCP test naming and cleanup ---'
sed -n '55,125p' frontend/test/e2e/mcp.spec.ts

printf '%s\n' '--- External-host documentation and references ---'
rg -n -C 3 --glob 'frontend/**/*.{ts,md,sh}' \
  '(PW_BASE_URL|managesHost|reuseExistingServer|PW_HOST_DATA_DIR)' frontend

Length of output: 28043


@M3gA-Mind The two accepted fixes are correct.

  • The README now runs the command from the repository root.
  • Cleanup transport failures can no longer replace a failure from the test body.

I accept the Date.now() pattern for the managed-host CI path. However, I cannot withdraw the minor finding.

PW_BASE_URL supports a host managed outside Playwright. Two independent Playwright invocations can target that same host. workers: 1 and fullyParallel: false do not serialize those invocations. If both calls to Date.now() occur in the same millisecond, registration still returns 409.

Use randomUUID() for server and marker, or document and enforce single-invocation access to an externally managed host.

🐇🔍

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@M3gA-Mind

Copy link
Copy Markdown
Collaborator Author

CI note, and I am going to stop re-running it. The four other jobs are green on this commit; Console E2E (live brain) has now been cancelled on three consecutive attempts, and the job records say why it is not a code signal:

attempt started completed runner steps recorded
1 skipped (its needs was cancelled)
2 17:47:11 18:04:49 none none
3 18:19:22 18:50:30 "" (empty) none

An empty runner_name with zero steps after 31 minutes means no runner ever picked the job up — it queued and was evicted, rather than running and failing. Nothing executed, so there is nothing in the diff for it to have tripped over.

For comparison, the same lane on the same spec content ran fine twice earlier today: run 31113374341 (8m15s, 90 passed / 6 skipped, mcp-agent.spec.ts green) and run 31110082447 on #484 (4m6s). The only change since is 591bcc0, two frontend files.

This lane is last in the dependency chain (needs: rust-gated, ~18 minutes), so it queues at the point where the org's runners are busiest — which is a real cost of the shape #467 chose and worth knowing about, but it is a capacity question rather than a defect. Re-running while the queue is saturated just moves the eviction later, so I have stopped.

@senamakel senamakel self-assigned this Aug 8, 2026
senamakel and others added 4 commits August 8, 2026 16:21
Checkpoint of work in progress, touching frontend/test/e2e/mcp-agent.spec.ts.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching frontend/test/e2e/mcp-agent.spec.ts.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching frontend/test/e2e/mcp-agent.spec.ts.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel merged commit c5ce1a7 into tinyhumansai:main Aug 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants