Outside-in tests (IAWL ideas 33, 34): closed doors on the built site as anonymous, customer and editor; every public route judged
- reference/e2e/closed-doors.ts + closed-doors.spec.ts: one table of doors, asked by pnpm e2e:built in both bundlers; doors still open while the owner decides are asserted open (test.fail) with their question - listPublicRoutes / listNextRouteFiles / compareRouteSnapshot / updateRouteSnapshot (main entry), runRouteCheck (/doctor) - reference/e2e/routes.ts + routes.snapshot.json (395 routes, one reason each); pnpm routes:check [--update], first step of e2e:built - create-test-admin.ts makes an editor test account - docs: security.md sections, AGENT.md 8a, iapl-audit templates, iapl-upgrade 1.17.1, changelog draft Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
498b3dbf38
commit
2468390538
@@ -8,7 +8,9 @@
|
||||
* once with Turbopack:
|
||||
* 1. production build with the late-staff fixture (E2E_LATE_STAFF=1, reference/e2e/late-staff-fixture.ts);
|
||||
* 2. no package manifest under .next/static (checked on disk, before anything is started);
|
||||
* 3. Playwright against `next start`: e2e/late-staff.spec.ts, e2e/mail-relay.spec.ts (the mail service: the confirm
|
||||
* 0. (once, before the builds) every public route is judged: `pnpm routes:check` (reference/e2e/routes.snapshot.json);
|
||||
* 3. Playwright against `next start`: e2e/closed-doors.spec.ts (every door of e2e/closed-doors.ts asked as an anonymous
|
||||
* visitor, a customer and an editor), e2e/late-staff.spec.ts, e2e/mail-relay.spec.ts (the mail service: the confirm
|
||||
* route under Next, the state block in the panel's production bundle) and the smoke tests "no package.json is published",
|
||||
* "client hints" (Payload's colour-scheme headers on the admin only; a public page is requested once) and every
|
||||
* "consent" test (banner at first paint, Global Privacy Control, equal prominence, withdrawal, the consent log).
|
||||
@@ -53,6 +55,9 @@ if (!args.includes('--skip-plugin-build')) {
|
||||
run('build the plugin', 'pnpm', ['build'], root)
|
||||
run('refresh the plugin copy in the reference site', 'pnpm', ['install', '--ignore-workspace'], site)
|
||||
}
|
||||
// Every public route judged (IAWL idea 34): from the config only, without the test fixtures, before any build.
|
||||
run('every public route of the reference site is judged (pnpm routes:check)', 'node', ['scripts/routes-check.mjs'], root)
|
||||
|
||||
// The run starts Payload with the fixture's collections, and Payload rewrites the site's generated types then. The
|
||||
// tree must be as it was after a required release step: the file is put back at the end — also when a step fails.
|
||||
const generated = ['src/payload-types.ts', 'src/app/(payload)/admin/importMap.js'].map((rel) => path.join(site, rel)).filter((file) => existsSync(file)).map((file) => ({ before: readFileSync(file), file }))
|
||||
@@ -83,7 +88,7 @@ for (const bundler of bundlers) {
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`[e2e:built] ✓ ${bundler}: no package manifest among ${files.length} public files`)
|
||||
run(`${bundler}: the built site — late-staff spec, the mail service, the published-files check, the client hints and consent`, 'pnpm', ['exec', 'playwright', 'test', 'late-staff', 'mail-relay', 'smoke', '--grep', 'late staff collection|the mail service|no package.json is published|client hints|consent'], site, { ALLOW_LOCAL_MEDIA: process.env.ALLOW_LOCAL_MEDIA ?? '1', E2E_LATE_STAFF: '1' })
|
||||
run(`${bundler}: the built site — late-staff spec, the mail service, closed doors, the published-files check, the client hints and consent`, 'pnpm', ['exec', 'playwright', 'test', 'late-staff', 'mail-relay', 'closed-doors', 'smoke', '--grep', 'late staff collection|the mail service|closed doors|no package.json is published|client hints|consent'], site, { ALLOW_LOCAL_MEDIA: process.env.ALLOW_LOCAL_MEDIA ?? '1', E2E_LATE_STAFF: '1' })
|
||||
passed.push(bundler)
|
||||
}
|
||||
console.log(`\n[e2e:built] passed: ${passed.join(' and ')}. (The reference site's .next now holds the ${passed.at(-1)} build WITH the fixture: rebuild with \`pnpm build\` there before other checks.)`)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* pnpm routes:check — every public route of the reference site (REST, GraphQL, Next route files) against the judged
|
||||
* list reference/e2e/routes.snapshot.json (docs/security.md "Routes nobody has judged"). Fails on a route nobody
|
||||
* has judged and on an entry without a reason; reads the config only, never the database.
|
||||
* pnpm routes:check the check (also the first step of pnpm e2e:built)
|
||||
* pnpm routes:check --update after a Payload or plugin upgrade: new routes are added with an EMPTY reason (the
|
||||
* check fails until somebody writes one), gone ones dropped; review the diff
|
||||
* Needs the reference site installed (pnpm install --ignore-workspace in reference/) with a current plugin copy
|
||||
* (pnpm build first), and reference/.env (the config reads it; nothing connects).
|
||||
* The test fixtures (E2E_LATE_STAFF, E2E_MAIL_RELAY_URL) are switched off: the list is the site's, not the tests'.
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const site = path.join(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'), 'reference')
|
||||
const update = process.argv.slice(2).includes('--update')
|
||||
const env = { ...process.env }
|
||||
for (const fixture of ['E2E_LATE_STAFF', 'E2E_MAIL_RELAY_URL', 'E2E_DEVELOPMENT_HOSTS']) {delete env[fixture]}
|
||||
// `payload run` drops --flags (minimist), so the script takes the word `update`
|
||||
const result = spawnSync('pnpm', ['payload', 'run', 'e2e/routes.ts', ...(update ? ['update'] : [])], { cwd: site, env, stdio: 'inherit' })
|
||||
process.exit(result.status ?? 1)
|
||||
Reference in New Issue
Block a user