Skip to content

Test the deployed examples site on every PR - #956

Merged
vvo merged 6 commits into
mainfrom
vincentvoyer/e2e-deployed-examples
Aug 30, 2026
Merged

Test the deployed examples site on every PR#956
vvo merged 6 commits into
mainfrom
vincentvoyer/e2e-deployed-examples

Conversation

@vvo

@vvo vvo commented Aug 30, 2026

Copy link
Copy Markdown
Owner

tl;dr; the live examples site has been returning 500s on every login since v9, and nothing would have caught it, so we test the real Vercel deployment on every PR.

Problem

  • Every example on get-iron-session.vercel.app answered an empty 500 the moment you logged in, since v9.
  • v9 started reading the example passwords from the environment, and nobody set them on the Vercel project. The password is read per request, so builds stayed green the whole time.
  • The Playwright suite only tests a fixture app on localhost, and CI never even built the examples app.
  • Logging in on the pages-router redirect example landed you on a blank page. That one has been broken since docs(Examples): Add examples for Pages Router聽#631.

Solution

  • Vercel now runs the visitor flows against the deployment for the commit, so a preview is checked before merge and the live site again after.
  • The passwords are set on the Vercel project and production is fixed. Verified by hand: login, counter, reload, logout, the protected pages and both magic-link paths.
Implementation details
  • e2e/examples.spec.ts runs against BASE_URL via playwright.deployed.config.ts, chromium only, since the fixture suite already covers Firefox and WebKit.
  • .github/workflows/e2e-deployed.yaml keys on deployment_status, taking the URL from environment_url. A pull_request run starts before the preview exists, and polling the Vercel API would need a token.
  • Previews are behind Vercel Authentication, so the run passes the project's Protection Bypass for Automation secret as a header. Previews stay private.
  • The SWR examples render their login form in the server HTML and submit through a React onSubmit, so a click before hydration posts to the page URL. openExample waits for the client's session GET first.
  • They also pass optimisticData, so the logged-in UI appears before the cookie exists. login waits for the cookie and the counter waits for its PATCH.
  • The redirect fix is res.redirect(303, url). res.status(303).redirect(url) answers 307, which keeps the method, so the browser re-POSTed to the page and got a 405.
  • The new check reports separately from the test aggregator, so it needs adding to branch protection to block merges.

vvo added 3 commits August 30, 2026 23:56
`res.status(303).redirect(url)` does not produce a 303. Passing only a URL to
`redirect()` makes Next answer 307 and ignore the status set before it, and 307
preserves the method, so the browser re-POSTed to the page and got a blank 405.
Logging in through this example has been landing on an empty page.

Broken since #631. The new deployed e2e suite is what caught it.
The existing Playwright suite asserts library behaviour against a fixture on
localhost. Nothing checked the site the README sends people to.

That gap is why v9 shipped with every example returning an empty 500:
`examples/next/src/passwords.ts` started reading the session passwords from the
environment, nothing set them on the Vercel project, and because the password is
read per request the build stayed green throughout.

So this suite runs the visitor flows against a deployed URL given by
`BASE_URL`: login, a session write, persistence across a reload, logout, the
proxy redirect, the protected pages, and both magic-link paths.

Two things it has to work around, both of which cost real debugging time:

- The SWR examples render their login form in the server HTML and submit it
  through a React `onSubmit` that calls `preventDefault()`. Clicking before
  hydration posts to the page URL instead of the session route, so `openExample`
  waits for the client's session GET first.
- They also pass `optimisticData`, so the logged-in UI appears before the POST
  that sets the cookie has answered. Asserting the rendered state proves
  nothing, so `login` waits for the cookie and the counter waits for its PATCH.
Vercel's git integration fires `deployment_status` when a deployment finishes,
with the URL in `environment_url`. A separate workflow keyed on that event is
the simplest way to test the real preview: it does not exist yet when a
`pull_request` run starts, and waiting for it inside ci.yaml would mean polling
the Vercel API with a token.

It runs for previews and for production, so a PR is checked before merge and the
live site is checked again after.

Also builds the examples app in the quality job. Nothing in CI built it, so a
break in it only surfaced as a failed deploy after merge.
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
iron-session Ready Ready Preview Aug 30, 2026 10:20pm

Request Review

Every preview is behind Vercel Authentication, so the whole suite failed on the
first run: each request answered 302 to vercel.com/sso-api, including the home
page. Previews stay private and CI passes the project's Protection Bypass for
Automation secret as a header instead.

The magic-link test now clears cookies on its own context rather than opening a
new one. `browser.newContext()` does not inherit the config's `use` options, so
the fresh context did not carry the bypass header.
The deployed suite needs BASE_URL and, on a preview, the bypass secret. Neither
is guessable. The two waits it depends on look like flakiness, so they are
written down before someone removes them.
@vvo
vvo marked this pull request as ready for review August 30, 2026 22:20
@vvo
vvo merged commit 36e78de into main Aug 30, 2026
12 checks passed
@vvo
vvo deleted the vincentvoyer/e2e-deployed-examples branch August 30, 2026 22:22
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