Testing

The Landing (swapps-campaigns) site is covered by Playwright end-to-end tests in e2e/, plus a TypeScript type-check. There is no separate unit-test runner.

Test layout

File Covers
e2e/forms.spec.ts Every landing form, in both locales, submitted to a successful state.
e2e/i18n.spec.ts Localized routing: EN at root, ES under /es/, correct <html lang>, hreflang alternates, and the language selector linking to the counterpart URL.
e2e/helpers.ts Test helpers: stubRecaptchaAndLeads, fillLeadForm, fillDiagnostic, openModal.
playwright.config.ts Playwright config (see below).
scripts/form-e2e-manual.mjs The manual, headed walkthrough that hits the real worker.

The automatic suite stubs reCAPTCHA and mocks the lead endpoint (in e2e/helpers.ts), so it runs with no captcha, no human interaction, and never creates a real Pipedrive lead.

Configuration

playwright.config.ts:

  • testDir: "./e2e", fully parallel, project chromium (Desktop Chrome).
  • baseURL: "http://localhost:3100".
  • webServer boots npm run dev automatically (reuseExistingServer outside CI, 120s timeout).
  • In CI: forbidOnly, one retry, the github reporter, and trace: on-first-retry.

Running

Command What it does
npm run test:e2e Automatic suite. Stubs reCAPTCHA, mocks the lead endpoint; boots the dev server automatically. Covers every form (EN + ES) submitting to success, plus locale routing / lang / hreflang / selector.
npm run test:e2e:ui Same suite in Playwright's UI mode.
npm test type-check + test:e2e.
npm run test:e2e:manual Manual walkthrough (scripts/form-e2e-manual.mjs): opens a headed browser, auto-fills each form, and parks at the reCAPTCHA for you to solve and submit.

First-time setup downloads the browser binary once:

npx playwright install chromium

The manual suite hits the real worker

npm run test:e2e:manual submits to the real swapps-worker, creating real Pipedrive leads (tagged as tests). Use it only to verify the live integration. Narrow it with the SLUGS= and BASE= env vars, e.g. SLUGS=website-support BASE=https://go.swapps.com npm run test:e2e:manual.

Pre-push gate

A hook at .githooks/pre-push runs type-check + test:e2e and blocks the push on failure. It is wired via git config core.hooksPath .githooks, set automatically by the prepare script on npm install — so run npm install once after pulling the repo.

Bypass it in an emergency with:

git push --no-verify