Skip to content

fix(e2e): run the suite against a production build - #319

Merged
KrasimirKralev merged 1 commit into
betafrom
fix/e2e-production-build
Aug 8, 2026
Merged

KrasimirKralev merged 1 commit into
betafrom
fix/e2e-production-build

Conversation

@KrasimirKralev

@KrasimirKralev KrasimirKralev commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Switches the Playwright e2e suite from bun run dev to a real production build, served by the standalone server. This is the Option-B rework: it fixes the class of CI-only e2e failures that never reproduced on-device.

Why

The Turbopack dev server caused two CI-only failures:

A pre-built, minified standalone server has no HMR and no on-demand compile, so both classes disappear.

Verified on the Jetson

Against the prod build: chat-popup (4/4) + terminal-reconnect + 36 specs pass, and e2e JS coverage lands at 48.8% (above the 39% floor — the V8 collector still attributes fine to the hashed chunks).

Details

  • SESSION_SECRET is unset for the test server so middleware auth stays inactive and / renders the desktop (production sets it via production-server.js; e2e drives the UI, not the auth gate). The WebSocket specs mock window.WebSocket in-browser, so the bare standalone server needs no gateway/terminal proxy.
  • Drops the now-obsolete global-setup warmup (a dev-Turbopack workaround).
  • Re-enables terminal-reconnect (passes against prod).

Still open (does NOT close #114)

The five DOM-interaction specs (browser-vnc, desktop-selection, installed-app-settings, mascot-context, clawkeep-interactions) stay fixme'd: they fail on GitHub Actions and against the prod build on the Jetson, so they're a distinct per-spec issue — not the dev-server class this PR fixes. Tracked in #114.

Unblocks

#315 (the dep-security refresh) rebases on this and its chat-popup goes green — landing all 48 runtime CVEs.

Summary by CodeRabbit

  • Tests
    • End-to-end testing now runs against the standalone production build, improving coverage of real-world behavior.
    • Removed development-server preloading from the test process.
    • Updated test tracking notes to clarify known failures across CI, production builds, and Jetson environments.
    • Preserved existing test server reuse and application URL settings while allowing additional startup time for production builds.

Switch the Playwright webServer from `bun run dev` to a real production build
served by the standalone server. The Turbopack dev server was the root of two
CI-only e2e failures that never reproduced on-device:

- cold on-demand route compile under `workers:1` could outlast the 15s expect
  timeout (the #114 flake), and
- on next 16.2 its HMR websocket crashed hydration under Bun (broke chat-popup
  + terminal-reconnect on the dep-refresh PR).

A pre-built, minified standalone server has no HMR and no on-demand compile, so
both classes disappear. Verified on the Jetson: chat-popup + terminal-reconnect
+ 36 specs pass against the prod build, and e2e JS coverage lands at 48.8%
(above the 39% floor — the collector's V8 ranges still attribute fine).

SESSION_SECRET is unset for the test server so middleware auth stays inactive
and `/` renders the desktop (production sets it via production-server.js; e2e
drives the UI, not the auth gate). The WebSocket specs mock `window.WebSocket`
in-browser, so the bare standalone server needs no gateway/terminal proxy.

Drops the now-obsolete global-setup warmup (a dev-Turbopack workaround).

Re-enables terminal-reconnect (passes against prod). The five DOM-interaction
specs stay fixme'd: they fail on GitHub Actions AND against the prod build on
the Jetson, so they're a distinct per-spec issue, still tracked in #114.
@KrasimirKralev
KrasimirKralev requested a review from a team as a code owner August 8, 2026 18:49
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Playwright now builds and starts the standalone production server for E2E tests. The global setup warm-up is removed. Five affected specs update FIXME comments to describe failures during their first DOM interaction.

Changes

Production E2E execution

Layer / File(s) Summary
Production server and failure diagnostics
playwright.config.ts, e2e/*
Playwright replaces bun run dev with a production build and standalone server, sets production environment values, disables SESSION_SECRET, and allows up to 10 minutes for startup. Five FIXME comments describe failures in GitHub Actions and production builds. The E2E global setup warm-up is removed.

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

Sequence Diagram(s)

sequenceDiagram
  participant Playwright
  participant NextBuild
  participant NextServer
  participant E2ESpecs
  Playwright->>NextBuild: Build production application
  Playwright->>NextServer: Start standalone server
  E2ESpecs->>NextServer: Run browser interactions
Loading

Possibly related PRs

Suggested labels: run-full-e2e, area: ci-e2e

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: running the end-to-end suite against a production build.
Description check ✅ Passed The description clearly covers the change, rationale, test results, remaining fixmes, and linked issues, but omits several template sections.
Linked Issues check ✅ Passed The changes implement the production-build investigation path from #114, re-enable terminal-reconnect, and retain the five unresolved specs as fixmes.
Out of Scope Changes check ✅ Passed All changes support the production-build e2e configuration, removal of dev-server warmup, or documentation of the remaining affected specs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e2e-production-build

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.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

🦀 ClawReview

Claws waving — here's what this change is about.

Switches the Playwright e2e suite to run against a real production build (bun run build + standalone server) instead of bun run dev, eliminating two classes of CI-only failures: Turbopack's on-demand route compilation could outlast the 15 s test timeout, and next 16.2's HMR websocket crashed hydration under Bun. The now-obsolete global-setup.ts warmup file is deleted, and FIXME comments on five specs are updated to clarify they fail against the production build on the Jetson too — narrowing #114 to a per-spec issue rather than a dev-server one.

At a glance

  • 🔧 Fix · touches Playwright e2e config + test suite infrastructure
  • Base branch: beta · +14 source / +20 tests across 7 files
  • ✅ base beta matches the beta-first convention
  • ✅ conventional PR title

Good to know

  • 🟡 CI e2e runs now open with a full bun run build step before any test starts — the 10-minute webServer timeout reflects this; cold CI runs will take noticeably longer.
  • ℹ️ SESSION_SECRET is intentionally unset for the test server so middleware auth stays inactive and / renders the desktop directly without a login gate.
  • ℹ️ Five specs remain fixme'd and are confirmed to fail against the production build on the Jetson too — their root cause is distinct from what this PR fixes and is still open in e2e: 6 tests fail only on GitHub Actions despite passing locally #114.

— ClawReview 🦀. I set the scene; CodeRabbit reviews the code; you decide. Conventions: docs.

@github-actions github-actions Bot added the area: ci-e2e Auto-triage area label Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

CI Summary

✅ Tests

  • Result: passed
  • View run
  • Coverage: statements 70.78%, branches 61.07%, functions 66.6%, lines 72.7%

✅ E2E

✅ E2E Install

@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

🤖 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 `@playwright.config.ts`:
- Line 54: Update the Playwright webServer command to launch the application
through production-server.js instead of directly invoking
.next/standalone/server.js, preserving the existing environment variables and
build step so E2E tests exercise the production upgrade proxy, TLS, and
WebSocket paths.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8dc89d4c-a11d-4d9f-a6fd-422763258b3e

📥 Commits

Reviewing files that changed from the base of the PR and between cce2026 and 67bb073.

📒 Files selected for processing (7)
  • e2e/browser-vnc.spec.ts
  • e2e/clawkeep-interactions.spec.ts
  • e2e/desktop-selection.spec.ts
  • e2e/global-setup.ts
  • e2e/installed-app-settings.spec.ts
  • e2e/mascot-context.spec.ts
  • playwright.config.ts
💤 Files with no reviewable changes (1)
  • e2e/global-setup.ts

Comment thread playwright.config.ts
// via production-server.js; e2e drives the UI, not the auth gate). The
// WebSocket-backed specs mock `window.WebSocket` in-browser, so the bare
// standalone server (no gateway/terminal proxy) is enough.
command: `bun run build && env -u SESSION_SECRET PORT=${port} HOSTNAME=127.0.0.1 NODE_ENV=production node .next/standalone/server.js`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 10 'production-server|Server\.prototype\.listen|upgrade|WebSocket|SESSION_SECRET|terminal|gateway|novnc' \
  package.json production-server.js playwright.config.ts

Repository: ID-Robots/clawbox

Length of output: 20735


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== playwright config =="
sed -n '1,90p' playwright.config.ts

echo
echo "== production-server startup tail =="
sed -n '230,263p' production-server.js

echo
echo "== terminal reconnect tests and websocket handling =="
rg -n -C 8 'terminal-reconnect|terminal-ws|WebSocket|window\.WebSocket|test\.skip|new WebSocket|connect.*terminal' playwright tests src -S

Repository: ID-Robots/clawbox

Length of output: 50373


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== e2e files =="
git ls-files 'e2e/**' | sed -n '1,120p'

echo
echo "== terminal reconnect occurrences in e2e =="
rg -n -C 10 'terminal|connect|reconnect|WebSocket|skip|disable|mock' e2e -S || true

echo
echo "== deterministic check: production-server monkey patch path =="
python3 - <<'PY'
from pathlib import Path
text = Path('production-server.js').read_text()
checks = {
    'monkey_patches_http_server_listen': 'http.Server.prototype.listen = function (...args)' in text,
    'production_branch_polls_upgrade': '"upgrade"' in text and 'if (IS_DEV) {' in text and 'const poll = setInterval' in text,
    'attaches_terminal_proxy': 'prefix: "/terminal-ws"' in text and 'TERMINAL_WS_PORT' in text,
    'removes_upgrade_listeners_before_proxy': 'removeAllListeners("upgrade")' in text and 'attachUpgradeProxy(this)' in text,
    'starts_https': 'startHttpsServer(this)' in text,
    'starts_next_server': 'require("./.next/standalone/server.js")' in text,
}
for k, v in checks.items():
    print(f'{k}: {v}')
print('direct_standard_server_command:' in open('playwright.config.ts').read().replace('\n', ' ').replace('  ', ' '))
PY

Repository: ID-Robots/clawbox

Length of output: 36892


Run E2E through the same production entrypoint.

production-server.js monkey-patches http.Server.prototype.listen, then in production polls until Next attaches upgrade handlers, strips those handlers, calls attachUpgradeProxy, starts HTTPS/WSS, and finally requires .next/standalone/server.js. Directly starting the standalone server skips the production upgrade proxy and TLS path, including the terminal WebSocket route that terminal-reconnect covers. Use node production‑server.js here, or document why bypassing this entrypoint is safe for all production behavior.

🤖 Prompt for 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.

In `@playwright.config.ts` at line 54, Update the Playwright webServer command to
launch the application through production-server.js instead of directly invoking
.next/standalone/server.js, preserving the existing environment variables and
build step so E2E tests exercise the production upgrade proxy, TLS, and
WebSocket paths.

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

Labels

area: ci-e2e Auto-triage area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant