Builder E2E still takes too long. The goal is all 145 cases under 3 minutes end to end, with exactly ten shards and the same UI, MCP, and generated Preview checks. This PR has not met that goal. ### Measured results - Initial green CI run: 9m43s from build start to the last shard; slowest test step 439s. - Best green run after replacing repeated UI project setup: about 5m35s; slowest test step 250s. - Best green run (393e51c): about 4m59s; slowest test step 201s. The two-file rebalance reduced the prior green run by about 50s. The 3-minute goal remains unmet. - Latest green run (de2f4ed): about 5m56s; slowest test step 257s. All ten shards and required workflows passed. The preceding green run took about 6m09s, showing substantial run-to-run variation. - The 119 content-mode project setup calls fell from 599s to 23.5s of aggregate worker time by using the app's dev login and project creation API. The sum of shard test steps fell from 2,178s to 1,721s in the first run with this change. Per-shard wall time still varies substantially between runs. - The shared build takes about 85s, including roughly 30s of setup and 51s of Builder compilation. During tests, the four-CPU shard runners showed 27–52% CPU scheduling pressure and 0% memory pressure; peak memory was unavailable. ### Changes - Cache the test schema and share one Builder build artifact across ten shards. Shard setup overlaps the build; each shard still starts an isolated database. - Keep real MCP and browser sessions alive for repeated Preview submissions, and reuse generated Previews where checks can share one. - Give independent cases separate projects and run them within the existing shard workers. Keep exactly ten shards. - Create content-mode fixture projects through the app's normal login and project API, using its CSRF token. Dedicated UI project creation remains in the Builder project fixture. - Capture managed Form responses before fast redirects discard their bodies. Fix drag targeting and unique drag fixture IDs. - Report CPU and memory pressure for every shard. Allow the MCP browser startup enough time under CI load. An earlier shard rebalance worsened the run and was reverted; a measured two-file rebalance improved the slowest shard without changing test logic. ### Verification and remaining work Focused local runs passed for a single project, three projects sharing one session, a paid-plan MCP project, and the MCP Preview form case. Builder and Vision typechecks, lint, formatting, the ten-shard matrix check, and Vision regression tests passed. All required workflows passed onde2f4ed. The latest review fix also passed all 63 Vision tests, Vision typecheck, lint, and formatting locally. - [x] Profile the full suite and measure complete ten-shard CI runs. - [x] Remove repeated UI project setup from the shared fixture. - [x] Measure CPU and memory pressure in CI. - [ ] Reduce Builder interactions, generated Preview work, and build time enough to finish under 3 minutes. - [x] Resolve five review threads and verify the affected paths. - [x] Check authoritative Builder documentation; these test harness and capture fixes do not change user-facing behavior or documentation. CI still checks out and installs dependencies, builds Builder, uploads and downloads its artifact, starts a database for each shard, and runs real browsers and generated production Previews. Warm caches remove downloads and schema generation, but do not remove setup, compilation, browser work, or cache transfers. No product behavior or authoritative documentation changed.
Builder E2E tests
Builder E2E workflows run with Playwright Test. The Playwright setup project waits for PostgREST, resets the disposable database, and warms the login route before Chromium runs the selected tests.
Run the suite
Use the full command for CI-like validation:
pnpm e2e:builder
The local command builds Builder and the generated React Router components used by Preview tests.
The first run after migrations change applies the regular migration pipeline
and writes an ignored schema cache under .cache/builder-e2e. Refresh it
explicitly with:
pnpm e2e:builder:refresh-schema-cache
The regular E2E suite uses lightweight PostgreSQL containers. Verify that the complete migration chain also applies to the pinned Supabase PostgreSQL image with:
pnpm e2e:builder:check-supabase-migrations
Pass normal Playwright Test arguments after --. For example:
pnpm e2e:builder -- --grep "Builder can copy, duplicate, and delete a page"
pnpm e2e:builder -- 'apps/builder/e2e/tests/pages-actions.[shard-3].e2e.ts'
pnpm e2e:builder -- --debug --grep "Builder can copy"
A lightweight Playwright discovery pass validates the selection before Docker, database migrations, browser installation, or the Builder build starts. A filter that matches no tests therefore fails without starting the test environment.
Fast local reruns
Keep the E2E backend and Builder development server running to avoid rebuilding Builder and restarting Docker for each edit.
Terminal 1:
pnpm e2e:builder:dev:backend
Terminal 2:
pnpm dev
Terminal 3:
pnpm e2e:builder:dev -- --grep "Builder can copy, duplicate, and delete a page"
pnpm e2e:builder:dev defaults to
E2E_BUILDER_URL=https://127.0.0.1:3000. Override it when the development
server uses another port. Chromium maps wstd.dev and its project subdomains
to loopback for local Builder URLs, so host-file changes are unnecessary.
The development backend uses E2E_DB_BOOTSTRAP=if-empty and keeps Docker
containers running. The Playwright setup project still resets test data before
each invocation.
Test organization
- Put workflows in
e2e/tests/*.e2e.tsand importtestfrome2e/test.ts. - Use Playwright's
pagefixture for the workflow under test. Playwright gives each test an isolated context and closes it automatically. - Use Playwright's
contextfixture when setup should share authentication with the workflow page. - Use
withBrowserContext(browser, callback)for isolated setup or setup that runs inbeforeAll. If cookies must survive frombeforeAllinto the tests, create an explicit context withnewBrowserContext(browser)and close it inafterAll. - Use
newIsolatedPage(browser)for identities that must not share cookies. - Keep tests in a file independent even though Playwright runs them in declaration order by default.
CI discovers isolated Playwright shards from filename tags. Each shard uses two workers, except shard 5 uses one to avoid overlapping MCP browser launches. Files are assigned by measured CI duration to keep the slowest job short:
pages-actions.[shard-3].e2e.ts
Every E2E filename must contain at least one unique shard tag. CI derives its matrix from those tags, so adding or removing a shard does not require editing the workflow. Files with multiple tags are partitioned across those shards. All files selected by a shard must use the same set of tags. Rebalance by changing filename tags when measured job durations drift. Suites may opt into parallel mode only when every worker creates uniquely named setup data and the tests do not depend on each other's mutations.
Backend organization
Development, E2E, schema-cache, and Supabase compatibility commands share the
backend definition in apps/builder/backend. compose.yaml defines the common
services, and compose.<mode>.yaml defines only the differences for a named
mode. Backend commands resolve these files by convention; callers do not pass
Compose filenames.
The schema-cache fingerprint discovers migration sources and non-test backend files automatically. Adding a database image, initialization script, Compose override, or migration therefore invalidates the cache without updating a filename registry.
Failures
Failed shard jobs upload the Playwright HTML report, traces, screenshots, videos, and backend service logs.
When you need a completely clean backend locally:
E2E_SKIP_CLEANUP=false pnpm e2e:builder