Guide

Your AI coder broke checkout: how to catch it before your customers do

You asked for a small change. The AI made it, and somewhere else the Upgrade button stopped working, or sign-up started dead-ending. Nothing errored. You found out from a customer, or from a quiet week of revenue. The fix isn't to stop using AI. It's to check the handful of paths that make you money, automatically, every time the code changes.

Updated 6 min read

Why AI edits break things that used to work

An AI coder sees the part of your code it's working on, not the whole product in its head the way you do. Ask it to make the pricing cards work on phones and it may add a banner that covers the Upgrade button, rename a route your checkout calls, or rewrite a working function from scratch. The Cursor forum is full of threads titled things like "a new functional request is breaking something else". The code still compiles, so nothing tells you.

Google's DORA research has measured the wider pattern across teams. In the 2024 report, more AI adoption was associated with an estimated 7.2% drop in delivery stability (an association in survey data, not proof of cause). The 2025 report adds the part that matters here: without robust control systems, like strong automated testing, more change leads to instability.

So the goal is a small, automatic safety net: a check that a real customer can still do the things that make you money, run before every change goes live.

Step 1: write down the journeys that make you money

Not every page. Three to six paths, written the way a customer would describe them. For a typical SaaS built with AI:

JourneySteps in plain EnglishWhy it matters
Sign upOpen the home page, click Sign up, enter an email and password, land on the dashboard.No sign-ups, no customers.
Log inLog in with a test account, see your own data.Locked-out customers churn.
UpgradeClick Upgrade on the pricing page, reach Stripe Checkout with the right plan.This is the revenue.
Core featureCreate the main thing your app makes (a note, a report, an AI answer) and see it saved.It's why people pay.
Password resetRequest a reset email.Silent breakage here becomes support tickets.

Writing these down already helps: it's the checklist you click through before merging anything your AI touched. The next steps make a browser click through it for you.

Step 2: set up Playwright (ten minutes)

Playwright (opens in a new tab) drives a real browser the way a customer would: it opens pages, types, clicks and checks what's on screen. It's free and open source. In your project folder:

Terminal
npm init playwright@latest
Pick TypeScript, keep the tests folder, say yes to the GitHub Actions workflow and to installing browsers.

That creates playwright.config.ts, a tests/ folder with an example, and optionally .github/workflows/playwright.yml. Point it at your app with a baseURL, so tests can say page.goto('/signup'):

TypeScript
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  retries: process.env.CI ? 2 : 0,
  use: {
    baseURL: process.env.BASE_URL ?? "http://localhost:3000",
    trace: "on-first-retry",
    screenshot: "only-on-failure",
  },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
});
playwright.config.ts. A screenshot and a trace (a step-by-step recording) are saved when a test fails, so you can see what went wrong.

Step 3: record a journey instead of writing it

You don't have to write test code by hand. Start your app, then run:

Terminal
npx playwright codegen http://localhost:3000

A browser opens. Click through the journey exactly as a customer would. Playwright writes the code as you go, preferring locators based on roles and visible text ("the button named Sign up"), which survive design changes better than CSS selectors. Use the toolbar's assert buttons to check that the right text or page appears at the end. Copy the result into a file in tests/ and tidy it up. It will look something like this:

TypeScript
import { test, expect } from "@playwright/test";

test("a new visitor can sign up and reach the dashboard", async ({ page }) => {
  await page.goto("/signup");
  await page.getByLabel("Email").fill(`test+${Date.now()}@example.com`);
  await page.getByLabel("Password").fill("a-long-test-password-123");
  await page.getByRole("button", { name: "Sign up" }).click();

  await expect(page).toHaveURL(/\/dashboard/);
  await expect(page.getByRole("heading", { name: "Dashboard" })).toBeVisible();
});
tests/signup.spec.ts. Use your app's real labels. A unique email per run means the test never collides with yesterday's account.

await expect(...) assertions wait for the page (up to five seconds by default) instead of failing the instant something isn't there yet. That's what keeps these tests from failing at random. Avoid page.waitForTimeout().

Step 4: test checkout without fighting Stripe

Here's the part most tutorials skip. Stripe says its hosted Checkout page has security measures that prevent automated testing. So don't make your test type card numbers into checkout.stripe.com. Test your side of the journey instead: that the button works and Stripe opens with the right plan.

TypeScript
import { test, expect } from "@playwright/test";

test.use({ storageState: "playwright/.auth/user.json" }); // a signed-in test user

test("upgrade sends the customer to Stripe Checkout", async ({ page }) => {
  await page.goto("/pricing");
  await page.getByRole("button", { name: "Upgrade to Pro" }).click();
  await expect(page).toHaveURL(/checkout\.stripe\.com/);
});
This catches the most common AI breakage: a button that's covered, renamed, disabled or pointing at a route that moved.

The other half, what happens after payment, is your webhook. Test it with the Stripe CLI (stripe trigger checkout.session.completed) and one manual run with the 4242 test card. Our Stripe test mode guide has the full checklist.

Logging in once for every test

Playwright's recommended pattern is a setup step that logs in and saves the browser's state to a file, which other tests reuse. Add the folder to .gitignore first: Playwright warns that the file holds cookies that could be used to impersonate your test account.

TypeScript
// tests/auth.setup.ts
import { test as setup, expect } from "@playwright/test";

setup("log in as the test user", async ({ page }) => {
  await page.goto("/login");
  await page.getByLabel("Email").fill(process.env.TEST_USER_EMAIL!);
  await page.getByLabel("Password").fill(process.env.TEST_USER_PASSWORD!);
  await page.getByRole("button", { name: "Log in" }).click();
  await expect(page).toHaveURL(/\/dashboard/);
  await page.context().storageState({ path: "playwright/.auth/user.json" });
});
In playwright.config.ts, add a project { name: "setup", testMatch: /.*\.setup\.ts/ } and give your test project dependencies: ["setup"]. Use a dedicated test account, never a real customer's.

Step 5: run them on every change

Run npx playwright test locally before you merge (--ui gives you a visual runner; npx playwright show-report opens the results). Then make it automatic: the workflow the installer created runs the tests on every push and pull request to main, installs the browsers with npx playwright install --with-deps, and uploads the report.

Testing against localhost in CI is a good start. Testing against the real preview deployment your host builds for each pull request is better, because it uses the real build, env vars and database. Here's how to do that on Vercel.

Keep the tests honest and few

  • Check what a customer sees, a URL, a heading, a confirmation message, not internal details. A test that passes while the page is broken is worse than none.
  • Be careful letting the same AI write the tests and the code. It tends to test what it thinks the app does. Read each test's final assertions and make sure they'd fail if the journey were broken.
  • Five good journeys beat fifty brittle ones. Every test you add is one more thing to keep working.
  • When a test fails, look before you fix. Open the screenshot and trace. Sometimes the test is out of date; often it caught exactly the bug it was written for.

Where Corvis fits

Corvis does this for you on Next.js apps on Vercel. It reads your code and suggests the journeys; you tick the ones that matter. On every preview deployment it runs them in a real browser and puts a pass or fail on the pull request. On a failure you get a screenshot, the reason in plain English, and a fix brief for Cursor or Claude Code, and Corvis retests once the fix lands. Journeys that change data run only on previews, with Stripe test mode; production checks are read-only. Every journey exports as a standard Playwright test you keep in your own repo. After you ship, on paid plans, it also learns how many payments and signups your app normally gets each hour, and when they stop or fall far below that, it tells you, names the deploy it started after, and offers to roll that deploy back.

Sources

Checked against these pages on 24 October 2026. Providers change their dashboards; if a step looks different, the source has the current version.

  1. Playwright: Installation (opens in a new tab)
  2. Playwright: Generating tests (codegen) (opens in a new tab)
  3. Playwright: Locators (opens in a new tab)
  4. Playwright: Best practices (opens in a new tab)
  5. Playwright: Authentication (opens in a new tab)
  6. Playwright: Test use options (opens in a new tab)
  7. Playwright: Setting up CI (opens in a new tab)
  8. Stripe Docs: Automated testing (opens in a new tab)
  9. Google Cloud: Announcing the 2024 DORA report (opens in a new tab)
  10. Google Cloud: Announcing the 2025 DORA report (opens in a new tab)
  11. Cursor forum: "A new functional request is breaking something else" (opens in a new tab)

Is your repo leaking right now?

The free scan checks a public GitHub repo for leaked keys and risky code, and grades it from A to F.

Scan a repo free