Skip to content

feat(e2e): in-process fake blob server so tests exercise the real paths#38

Merged
n2p5 merged 1 commit into
mainfrom
fix/e2e-fake-blob
May 21, 2026
Merged

feat(e2e): in-process fake blob server so tests exercise the real paths#38
n2p5 merged 1 commit into
mainfrom
fix/e2e-fake-blob

Conversation

@n2p5
Copy link
Copy Markdown
Contributor

@n2p5 n2p5 commented May 21, 2026

Summary

CI was logging `BLOB_READ_WRITE_TOKEN is not set` on every tripwire-touching test because there's no token in the CI environment. Tests still passed (errors caught by Suspense boundaries or fire-and-forget catches), but the blob code paths weren't actually exercised — so a real regression in the read or write path would have slipped through.

This adds an in-memory HTTP server (`e2e/fake-blob.ts`) that Playwright runs as a second `webServer` alongside `next dev`. The fake honors the subset of the Vercel Blob surface we use: `PUT /`, `GET /`, and `GET /api/blob/?prefix=` for ingest's list call. It seeds `stats/tripwire-aggregates.json` from a fixture so `/x/tripwire` renders real numbers.

Production stays on `@vercel/blob`. A new `src/lib/blob.ts` wrapper routes `put()` to the SDK in prod and to the fake's HTTP PUT when `BLOB_BASE_URL` is set. `aggregates.ts` and `ingest.ts` got one-line overrides on their URL builders.

A new `e2e/x/tripwire/page.spec.ts` loads `/x/tripwire` and asserts the hero numbers match the seeded fixture, proving the read path end-to-end.

Local verification

Previously the CI dev server logged 'BLOB_READ_WRITE_TOKEN is not set'
on every tripwire-touching test because there's no token in the CI
environment. The tests passed only because errors landed inside an
error boundary or a fire-and-forget catch — the blob code paths
weren't actually exercised.

This adds a tiny in-memory HTTP server (e2e/fake-blob.ts) that
Playwright runs as a second webServer alongside `next dev`. The fake
honors the subset of the Vercel Blob surface we actually use: PUT a
pathname, GET it back, and a GET /api/blob/ list endpoint for ingest.
It seeds stats/tripwire-aggregates.json from a fixture so /x/tripwire
renders real numbers.

Production code stays on @vercel/blob. A new src/lib/blob.ts wrapper
routes put() to the SDK in prod and to the fake's HTTP PUT when
BLOB_BASE_URL is set. aggregates.ts and ingest.ts gain one-line
overrides on the URL builders.

A new e2e/x/tripwire/page.spec.ts loads /x/tripwire and asserts the
hero numbers match the seeded fixture, proving the read path end-to-
end.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
func-lol Ready Ready Preview, Comment May 21, 2026 1:09pm

Request Review

@n2p5 n2p5 merged commit 826eb5e into main May 21, 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.

1 participant