Repository navigation
test(e2e): run the suite offline, against a throwaway Postgres and local emulators of every outside service - #328
Conversation
…cal emulators of every outside service Each e2e run, local or CI, starts its own Postgres 17 (embedded-postgres) and MSW emulators of Bunny, Stripe, Algolia, Resend and Anthropic, holding their state in memory for the run. A network guard fails any request that leaves the machine, in the app server, the Playwright processes and the browser. The library video is a 3 second fixture. .env.e2e is committed with placeholder keys, so the e2e workflow needs no secret, and runs of different branches no longer wait for each other. The app reads its Bunny pull zones as full origins and takes optional origins for each outside API, defaulting to the real hosts. Closes #320 Closes #292
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 Startup JS · ✅ No heavierBrotli · 33 routes · against main at
What moved
Caution Far from the goal. 🟩 is the goal, each 🟥 one more goal’s worth.
📋 Every route
🤖 Agent briefWhat this measures. The Brotli size of each JS file the server-rendered page of a route modulepreloads, read from the TanStack Start manifest of Rules. Budgets live in Reproduce pnpm run build:e2e
gh run download 46307394879 --name bundle-size --dir /tmp/main-bundle-size
git show origin/main:bundle-budget.json > /tmp/main-budget.json
pnpm run bundle-size --base /tmp/main-bundle-size/report.json --base-budget /tmp/main-budget.json
pnpm run build:analyzeData {
"verdict": "pass",
"base": {
"commit": "874fd37",
"runId": "46307394879"
},
"violations": [],
"raisedBudgets": [],
"routeChanges": [
{
"name": "/admin/downloader",
"beforeBytes": 374926,
"afterBytes": 374813
},
{
"name": "/admin/categories",
"beforeBytes": 407560,
"afterBytes": 407448
}
],
"chunkChanges": [
{
"chunk": "algolia-insights",
"deltaBytes": 125,
"loadedBy": [
"/reels",
"/",
"/dmca",
"/mentions-legales",
"/privacy",
"/terms-of-use",
"/verify-email",
"/memes/$memeId",
"/app",
"/checkout/success",
"/memes/ai-search",
"/password/create-new",
"/password/reset",
"/memes/$memeId/studio",
"/memes/bookmarks",
"/faq",
"/pricing",
"/settings",
"/submit",
"/memes/category/$slug"
],
"isRegression": false
},
{
"chunk": "app-hooks",
"deltaBytes": -107,
"loadedBy": [
"every route"
],
"isRegression": false
}
]
} |
…leave the machine WebKit reads a video through blob: URLs, whose empty hostname the guard took for a request to the outside, and aborted.
…ck before hydration sent it away A submit before hydration posts the form natively, which drops the token from the address. The faster suite meets that window more often.
…f the page Once the app's service worker controls a WebKit page, the page's requests go through it and skip Playwright's routing: they lost the per-test x-real-ip, so every WebKit export counted against one shared "unknown" IP and hit the download rate limit, and the browser network guard could not see them. No scenario relies on the service worker.
…t's routing The per-test x-real-ip only rides on routed calls. When a call skips the routing, as WebKit's did through the service worker, every scenario shares one IP and the rate limits fail tests far from the cause. The fixture now names such calls at the end of the scenario. With service workers allowed, 11 of the 12 WebKit Meme files scenarios go red on it.
The e2e video now has a sound, and a phone browser may start it muted, as Safari on an iPhone does. The scenario checks that the tap leaves the sound alone, whichever way the browser started it.
In CI, WebKit plays video through GStreamer in a container with no audio output: with a sound track, playback sometimes stalled before its first frame, so the player never counted as started and kept its controls hidden. Ten repeats of the WebKit player scenarios failed 3 times out of 161 with the sound and never without it. The sound export is built from silence, the way production builds it for a video without sound.
Summary
Each e2e run now owns its outside world, started by Playwright before the app and gone with the run:
flowchart LR PW[Playwright] -->|1. starts| OUT["Outside services<br/>(e2e/emulators)"] PW -->|2. builds, starts| APP[App server] OUT --- PG[(Postgres 17<br/>embedded, empty)] OUT --- EM["MSW emulators, in memory<br/>Bunny · Stripe · Algolia · Resend · Anthropic"] APP --> PG APP --> EM Browser --> APP Browser --> EM Guard{{"network guard: fails any non-loopback request"}} Guard -.-> APP Guard -.-> PW Guard -.-> Browsersatisfies Stripe.Subscription, Algolia'sSearchResponse…), and Bunny's with the app's own response schemas, moved tosrc/constants/bunny-api.ts. An unknown call is refused by name.VITE_BUNNY_ORIGIN,VITE_BUNNY_IMAGES_ORIGIN) and takes optional origins for each outside API, defaulting to the real hosts.mainnever cancels another.src/constants/algolia.ts, read byscripts/setup-algolia-indices.tsand the emulator.Closes #320
Closes #292
Evidence
main(874fd37): 305 passed in 10.2 min, Studio 40 s, seed 35 s, checkout 33 s, one shared Neon branch, one run at a time.After: local, offline, build included:
pnpm run test:e2e→ 304 passed in 2.7 min, Studio 3.8 s, checkout ~3 s.[network guard]and[emulator]errors in the run and server logs: 0. (304: the remote "Bunny Storage holds every file" setup check is gone, the files ship with the fixture.)pnpm run check,pnpm run bundle-size: green.Merge Danger
Door: two-way
Revertable in one commit. The Neon
testbranch and the Bunny, Algolia and Stripe e2e resources stay untouched until deleted by hand after the merge.Blast Radius: deployment
VITE_BUNNY_HOSTNAMEandVITE_BUNNY_IMAGES_HOSTNAMEbecomeVITE_BUNNY_ORIGINandVITE_BUNNY_IMAGES_ORIGIN, withhttps://. Vercel needs them before the merge, or the build fails env validation. The preview of this PR fails the same way until then.