Skip to content

Add nix build target for e2e tests#507

Merged
mtlynch merged 5 commits into
masterfrom
e2e-nix
Jun 20, 2026
Merged

Add nix build target for e2e tests#507
mtlynch merged 5 commits into
masterfrom
e2e-nix

Conversation

@mtlynch

@mtlynch mtlynch commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Switch e2e tests to use a mock TMDB server instead of hitting the real thing.

mtlynch and others added 4 commits June 19, 2026 23:10
Port the reference go-app-starter e2e test packaging pattern to this repo so `nix build .#e2e-tests` builds the dev backend, installs JavaScript dependencies from a fixed-output pnpm store, and runs Playwright with Nix-provided browsers and fonts.

Use pnpm 10.25.0 instead of pnpm 11.5.3 so the flake can use the same `pnpm.fetchDeps` and `pnpm.configHook` flow as go-app-starter. This avoids custom pnpm store extraction logic and keeps the Nix target close to the reference implementation. CircleCI and package.json now pin the same pnpm version.

Add `metadata_prod.go` and `metadata_dev.go` to keep the e2e target hermetic. Production builds still construct the real TMDB metadata finder and require `SJ_TMDB_API`. Dev builds continue to use the real TMDB client by default, but if `SJ_TMDB_API=dummy`, they use deterministic in-process fake metadata for the titles that the Playwright suite searches for. The Nix e2e target sets that dummy value so it does not require a secret TMDB key or network access during `nix build`.
Replace the metadata_dev.go/metadata_prod.go build-tag split (which injected
an in-process fake MetadataFinder when SJ_TMDB_API=dummy) with a mock TMDB HTTP
server run by the Playwright e2e harness.

TMDB is called server-side, so Playwright's page.route() can't intercept it
directly. Instead, make the TMDB client's base URL configurable via
SJ_TMDB_API_BASE_URL (defaulting to the production API) and have the e2e fixtures
start an in-process mock TMDB server, pointing the spawned backend at it. Poster
requests to image.tmdb.org are stubbed via page.route so no browser request
escapes to the Internet. This keeps `nix build .#e2e-tests` hermetic without
baking fake data into the production binary.

Verified: go build (prod + dev), go test, gofmt, go vet, and a hermetic
`nix build .#e2e-tests` (46/46 Playwright tests pass, no network).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts:
#	metadata/tmdb/tmdb.go
# Conflicts:
#	flake.lock
#	flake.nix
@mtlynch mtlynch enabled auto-merge (squash) June 20, 2026 00:24
@mtlynch mtlynch merged commit 6158021 into master Jun 20, 2026
9 checks passed
@mtlynch mtlynch deleted the e2e-nix branch June 20, 2026 00:24
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant