English | Português (Brasil)
A Playwright + TypeScript test suite for a Next.js 16 / Payload CMS website, running against the production build and a brand-new Postgres database on every e2e CI job. The application is the official Payload Website Template, kept frozen: known issues are reported and, where possible, pinned by tests, not patched.
This is a personal portfolio project, not client work.
| What | Result | Evidence |
|---|---|---|
Tests on main |
66, all as expected | HTML report (latest run on main) |
| Pipeline | 6 jobs behind one required ci-passed gate, 3m 11s |
Run at 3db055c, workflow, ruleset |
| Known issues in the app | 9 with a test asserting the correct behavior, 1 without | Known issues |
| Second CI platform | The same e2e job on GitLab.com, 62 of 62 at 6636fd0 |
Job log, green pipeline, .gitlab-ci.yml |
| Stack | Playwright 1.65, Next.js 16.4, Payload 3.93, Postgres 18 | package.json, compose.yaml |
About "66 green": the 9 known issue tests use test.fail(), so the report counts them as passed while the issue exists. If one gets fixed, its test starts failing and asks for the marker to be removed.
| Area | Tests | Where |
|---|---|---|
| REST API contract | 22 | tests/api/ |
| Accessibility and keyboard | 23 | accessibility.spec.ts, keyboard.spec.ts |
| Homepage: desktop, mobile, reduced motion | 13 | homepage.spec.ts, .mobile, .reduced-motion |
| Contact form | 1 | contact-form.spec.ts |
| CMS journey, admin panel to frontend | 2 | cms.admin.spec.ts |
| Specs that came with the template | 4 | admin.e2e.spec.ts, frontend.e2e.spec.ts |
| Admin login setup | 1 | auth.setup.ts |
Screenshot from the 63-test run at 9e7e146, with KI-1 to KI-8: production build, fresh database.
| A client usually asks for | What is here | Evidence |
|---|---|---|
| User journeys tested in a real browser | An editor changes a page in the admin panel, and an anonymous visitor sees the published result | cms.admin.spec.ts |
| API tests that catch breaking changes | Response schemas for /api/pages, /api/posts and /api/forms, plus anonymous and authenticated permissions |
cms-contract.ts, tests/api/ |
| Accessibility checks | axe scans up to WCAG 2.2 AA in both color themes, and keyboard-only navigation | axe.ts, accessibility.spec.ts, keyboard.spec.ts |
| Tests that can be trusted | Each test written here was seen failing, before its support code existed or by mutation; the commits record how | Commits db83780, ad6e89f, 025581d |
| A repeatable test environment | Each e2e job gets a new Postgres, migrations, seed data and its own generated secrets |
ci.yml, scripts/seed.ts |
| CI that blocks bad merges | Types, lint, dependency audit, secret scan, workflow audit, integration tests and E2E behind one gate | Ruleset, pull request held back by a failing probe commit |
| GitHub Actions or GitLab CI | Both ran for real; GitHub is the source of truth, GitLab runs the e2e job |
GitHub run, GitLab pipeline |
| Readable reports when something breaks | A public HTML report from main, and the report attached to any run whose tests fail |
Report, deliberately failing GitLab pipeline |
| Issues reported clearly | Observed, expected, cause and impact for each one | Known issues |
All are in the generated app or its Payload dependency, and each one links to its full report. They are not all functional failures: KI-3 and KI-4 are accessibility findings from axe, and KI-5 is the cost of a deliberate rule against a flash of the wrong theme. One more defect is intermittent, so it has no test; it is described at the end of the report.
| Id | Issue | Impact |
|---|---|---|
| KI-1 | Homepage title repeats the site name | Low |
| KI-2 | Unmatched nested URLs show the default Next.js 404 page | Moderate |
| KI-3 | Code block line numbers have insufficient contrast | Low |
| KI-4 | Open theme selector leaves focusable content inside aria-hidden regions | Low |
| KI-5 | Pages are blank when JavaScript is unavailable | Moderate |
| KI-6 | A newly published post is missing from the posts listing | Moderate |
| KI-7 | REST validation errors lose their field details once the admin panel has loaded first | Low |
| KI-8 | A malformed email shows the generic required-field message | Low |
| KI-9 | A form that has submissions cannot be deleted | Moderate |
- Browsers: Chromium only. The
mobileproject emulates a Pixel 7 on Chromium at 375x812; there is no Firefox, WebKit or real-device run. - Test types: no load, visual regression or security testing of the app.
- Accessibility: automated scans and keyboard paths, not an audit with assistive technology.
- The application: no existing file under
src/changed since the first commit (comparison), and only generated migrations were added. Commit51c76a2updatednextandsharpfor security fixes and corrected one template spec. - GitLab: the mirror is updated by hand and runs only the
e2ejob.
Prerequisites: Docker, the Node.js version in .node-version (pnpm install fails on an older one or another major), and pnpm 11, installed with npm: npm install --global pnpm@latest-11 (pnpm 11 installation; pnpm then runs the exact version pinned in packageManager). Node 25 and later no longer ship Corepack, so corepack enable does not work there. The seed downloads its images from GitHub, so it needs internet access.
pnpm install --frozen-lockfile
cp .env.example .env # local-only values that match compose.yaml
pnpm db:up # starts Postgres and waits until it is healthy
pnpm db:migrate # validates the environment and applies the migrations
pnpm db:seed # replaces all content and media with the demo content
pnpm build
pnpm startOpen http://localhost:3000. The admin panel is at http://localhost:3000/admin, and the seed creates a demo login: demo-author@example.com / password.
- Keep this order. Static pages are generated during the build, so seeding after it leaves
/postsempty for up to 10 minutes. - Keep this database in production mode. Anything else that connects to it (
pnpm dev, including the template's Development steps) makes the Postgres adapter push the schema and mark the database as dev. The nextpnpm db:migratethen stops at a data-loss prompt instead of migrating. To recover, runpnpm db:downand start again frompnpm db:up. - If the seed fails, do not build yet. A failed seed can leave the database half cleared. Run
pnpm db:seedagain first. If you already built, remove.nextbefore building again:.next/cacheis shared between builds and keeps the empty header, even after a good seed. - Start over:
pnpm db:downdeletes the database, then repeat frompnpm db:up.
After the steps above, up to pnpm build:
pnpm exec playwright install chromium # once, and after every Playwright update
pnpm test:e2e # starts `pnpm start`, or reuses a running server
pnpm exec playwright show-report # opens the HTML reportpnpm test:int runs the template's Vitest integration test against the same database, also in production mode, and pnpm test runs both suites, as CI does.
A reused server keeps the state of whoever used it first. The KI-7 test only holds when the admin initialized Payload first: a fresh server from pnpm test:e2e makes sure of that, but a server that served an /api route first reports that test as "Expected to fail, but passed".
The tests run against the production build, so run pnpm build again after changing the app. Projects: setup (admin login), api (REST contract of /api/pages, /api/posts and /api/forms), admin (journey from the admin panel to the frontend), chromium (desktop), mobile (375x812) and reduced-motion.
The suite logs in with E2E_ADMIN_EMAIL and E2E_ADMIN_PASSWORD. A .env created before they were added to .env.example needs both lines, and the run stops at startup without them.
Defects found in the app are listed in docs/KNOWN_ISSUES.md.
An experiment with Playwright Test Agents, including where they conflict with these rules, is in docs/PLAYWRIGHT_AGENTS_EXPERIMENT.md.
Every pull request runs these jobs, and the ci-passed gate requires all of them:
| Job | What it does |
|---|---|
check |
Types, lint, formatting and the repository sentinels (pnpm check) |
audit |
pnpm audit --prod --audit-level=high; accepted exceptions are listed per advisory in pnpm-workspace.yaml, each with a tracking issue and an expiry date of at most 30 days that pnpm check enforces |
secret-scan |
gitleaks over the commits of each pull request and push |
workflow-audit |
zizmor over the workflows |
integration |
The template's Vitest suite (pnpm test:int) in production mode, after the migrations, with its own Postgres and secrets |
e2e |
Migrate, seed, build, start and test in the official Playwright container, with a new Postgres and secrets per job |
When e2e fails, the HTML report is attached to the run as an artifact, and the server log is in the output of the test step. The report of the latest run on main that reached the tests is published at https://brunoccalmeida.github.io/playwright-nextjs-e2e-ci/.
The e2e job also runs on GitLab.com, from .gitlab-ci.yml: same Playwright image, a Postgres service and the same migrate, seed, build and test sequence, on a Free-tier hosted runner. The container setup differs: it runs as root, without the --init and --ipc=host flags. GitHub stays the source of truth and runs every other gate. The GitLab mirror is updated by hand, so the proof is one pipeline at one commit, not a live status: green pipeline at 6636fd0, and a deliberately failing one that shows the job going red and keeping the report as an artifact.
The original Payload template documentation is kept, unchanged, in docs/PAYLOAD_TEMPLATE_README.md.


