From e715b5720d0978f4fa411697c0755c525818b361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Thu, 29 Oct 2026 19:24:05 +0100 Subject: [PATCH] Reference smoke tests never test another project's server; skills refreshed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - reference/playwright.config.ts: reuseExistingServer only with E2E_REUSE_SERVER=1. Playwright starts the built site itself on E2E_BASE_URL's port (default 3100) and fails when the port is taken — before, a dev server of another project on 3100 (intecion.com's) was tested instead. CI is unchanged: it starts nothing before test:e2e. README's production check follows. - reference/.agents/skills refreshed after the seed-exit-guard merge (ipal-form and ipal-site seed templates, ipal-reference); INDEX.md regenerated. Co-Authored-By: Claude Opus 5.5 --- docs/agent/reference-site/INDEX.md | 8 ++++++-- .../skills/ipal-form/resources/seed-form.template.ts | 4 +++- reference/.agents/skills/ipal-reference/SKILL.md | 2 +- reference/.agents/skills/ipal-reference/resources/api.md | 3 ++- .../skills/ipal-site/resources/seed-content.template.ts | 5 ++++- reference/README.md | 5 +++-- reference/playwright.config.ts | 8 ++++++-- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/docs/agent/reference-site/INDEX.md b/docs/agent/reference-site/INDEX.md index eb1167e..2531ca0 100644 --- a/docs/agent/reference-site/INDEX.md +++ b/docs/agent/reference-site/INDEX.md @@ -92,7 +92,11 @@ try { // no .env (CI) } -/** Smoke tests against a built, seeded site: pnpm build && pnpm seed && pnpm payload run e2e/create-test-admin.ts. */ +/** + * Smoke tests against a built, seeded site: pnpm build && pnpm seed && pnpm payload run e2e/create-test-admin.ts. + * E2E_BASE_URL picks the port (default 3100). Playwright starts its own server there and fails when the port is + * taken, so another project's dev server is never tested by mistake; E2E_REUSE_SERVER=1 uses a server you started. + */ const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3100' export default defineConfig({ @@ -105,7 +109,7 @@ export default defineConfig({ webServer: { command: 'pnpm start', env: { PORT: new URL(baseURL).port || '3000' }, - reuseExistingServer: true, + reuseExistingServer: process.env.E2E_REUSE_SERVER === '1', url: `${baseURL}/api/health`, }, workers: 1, diff --git a/reference/.agents/skills/ipal-form/resources/seed-form.template.ts b/reference/.agents/skills/ipal-form/resources/seed-form.template.ts index d842f54..9b9c4ea 100644 --- a/reference/.agents/skills/ipal-form/resources/seed-form.template.ts +++ b/reference/.agents/skills/ipal-form/resources/seed-form.template.ts @@ -25,7 +25,7 @@ * `email` field (no extra recipients, no header injection). */ import config from '@payload-config' -import { createSeeder } from '@intecion/ipal-kit/seed' +import { createSeeder, guardSeedExit } from '@intecion/ipal-kit/seed' import { getPayload } from 'payload' // ─── fill from the brief ──────────────────────────────────────────────────── @@ -104,6 +104,8 @@ function richText(text: string) { } } +// An early exit (Payload never up, the run cut short) fails with exit 1 instead of a silent 0 (docs/seeding.md). +guardSeedExit({ label: '[seed-form]' }) const payload = await getPayload({ config }) // Options (docs/seeding.md § Turn off, override, extend) — env vars work without editing this file. // A form seed touches exactly one record — this form (matched by its title). After launch that stays true: diff --git a/reference/.agents/skills/ipal-reference/SKILL.md b/reference/.agents/skills/ipal-reference/SKILL.md index f35ba4c..78d5554 100644 --- a/reference/.agents/skills/ipal-reference/SKILL.md +++ b/reference/.agents/skills/ipal-reference/SKILL.md @@ -248,7 +248,7 @@ Details: env.md, deployment.md, PROGRAMISTA §3. **DNS** (A/AAAA, www, CAA, Search Console TXT, Bing, SPF/DKIM/DMARC for the From domain, R2 domain): the plugin sets nothing — list of records to check with `dig`: `deployment.md` §6, summary in **ipal-setup** stage 11. -**Seeding** (content in pages, forms, globals) — **VERY IMPORTANT: after launch never re-seed everything; named records only** (`only` / `SEED_ONLY`; a full run of a live database needs the owner's OK and `IPAL_SEED_ALLOW_FULL=1`). Create-only, matched by a natural key, never delete, never seed users or secrets, dry run → backup → real run; updates on production only for untouched records and only with `IPAL_SEED_ALLOW_PROD_UPDATE=1`. Helper: `createSeeder` from `@intecion/ipal-kit/seed` (resources/api.md → Seeding). Templates: `ipal-site/resources/seed-content.template.ts`, `ipal-form/resources/seed-form.template.ts`. Rules and Coolify steps: `node_modules/@intecion/ipal-kit/docs/seeding.md`. +**Seeding** (content in pages, forms, globals) — **VERY IMPORTANT: after launch never re-seed everything; named records only** (`only` / `SEED_ONLY`; a full run of a live database needs the owner's OK and `IPAL_SEED_ALLOW_FULL=1`). Create-only, matched by a natural key, never delete, never seed users or secrets, dry run → backup → real run; updates on production only for untouched records and only with `IPAL_SEED_ALLOW_PROD_UPDATE=1`. Helper: `createSeeder` from `@intecion/ipal-kit/seed` (resources/api.md → Seeding), with `guardSeedExit()` called first (an early exit → exit 1 with the reason, never a silent 0). Templates: `ipal-site/resources/seed-content.template.ts`, `ipal-form/resources/seed-form.template.ts`. Rules and Coolify steps: `node_modules/@intecion/ipal-kit/docs/seeding.md`. | Seed env var (run time) | Effect | |---|---| diff --git a/reference/.agents/skills/ipal-reference/resources/api.md b/reference/.agents/skills/ipal-reference/resources/api.md index c789cd2..cc83792 100644 --- a/reference/.agents/skills/ipal-reference/resources/api.md +++ b/reference/.agents/skills/ipal-reference/resources/api.md @@ -562,13 +562,14 @@ Server only (`pnpm payload run`); never import it from client code, the Payload | `upsertBy(collection, key, data)` | (method) | Matches by other keys, e.g. a form by `{ title }`. | | `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global — a choice (select, radio, checkbox, number, date) still at its `defaultValue` counts as empty, text never does; a field already holding the seeded value is skipped (all seeded fields with `update` when untouched). | | `summary()` | (method) | Prints and returns `{ created, skipped, updated, skippedEdited, errors }`; exit 1 when `errors`. | +| `guardSeedExit({ label?, log?, process? })`, `activeSeedExitGuard()` | `@intecion/ipal-kit/seed` | Call first in a seed script: a run that ends before Payload initializes or before `summary()` (Node exiting through an empty event loop under `payload run`) prints `[seed] ended before …` and exits 1 instead of a silent 0. `createSeeder` / `summary()` report to it; `dispose()` stops it. | | `isLocalDatabase(url, { localHosts? })` | `@intecion/ipal-kit/seed` | `true` for SQLite files, Unix sockets, localhost / 127.0.0.1 / ::1 (+ `SEED_LOCAL_HOSTS`). | | `writeLocales(payload, target, data, { context?, draft? })` | `@intecion/ipal-kit/seed` | Writes seed values (`{ pl, en }` per field) to `{ collection, id }` or `{ global }`: default locale first, then every other locale with `fallbackLocale: false` onto the same row ids. | | `seedHash(value)` | `@intecion/ipal-kit/seed` | Stable hash for the hidden `seedHash` field (key order, row ids, nulls ignored). | | `projectOnto(seed, current)` | `@intecion/ipal-kit/seed` | Current values at the keys the seed writes — hash them to compare with the stored hash. | | `editedSinceSeed({ doc, currentHash?, hashField?, untouchedSeconds? })` | `@intecion/ipal-kit/seed` | `null` = untouched; otherwise the reason (stored hash differs / `updatedAt` too late after `createdAt`). | -**Types:** `Seeder`, `SeederOptions`, `SeedResult`, `SeedStatus`, `SeedSummary`, `UpsertOptions` — the seeder, its options and results; `SeedValue`, `SeedTarget`, `WriteLocalesOptions`, `EditedSinceSeedArgs` — building-block inputs (all `/seed`). +**Types:** `SeedExitGuard`, `SeedExitGuardOptions`, `SeedExitProcess` — the early-exit guard; `Seeder`, `SeederOptions`, `SeedResult`, `SeedStatus`, `SeedSummary`, `UpsertOptions` — the seeder, its options and results; `SeedValue`, `SeedTarget`, `WriteLocalesOptions`, `EditedSinceSeedArgs` — building-block inputs (all `/seed`). ## Security (`security`) — details: `node_modules/@intecion/ipal-kit/docs/security.md` diff --git a/reference/.agents/skills/ipal-site/resources/seed-content.template.ts b/reference/.agents/skills/ipal-site/resources/seed-content.template.ts index 17553f3..1287aac 100644 --- a/reference/.agents/skills/ipal-site/resources/seed-content.template.ts +++ b/reference/.agents/skills/ipal-site/resources/seed-content.template.ts @@ -32,7 +32,7 @@ */ import config from '@payload-config' import { libraryBlockSlugs } from '@intecion/ipal-kit/blocks' -import { createSeeder } from '@intecion/ipal-kit/seed' +import { createSeeder, guardSeedExit } from '@intecion/ipal-kit/seed' import { pageTemplates } from '@intecion/ipal-kit/templates' import { getPayload } from 'payload' @@ -67,6 +67,9 @@ const COLLECTION = 'pages' const ONLY: string[] | undefined = undefined // ----------------------------------------------------------------- /CONTENT -- +// An early exit (Payload never up, the run cut short) fails with exit 1 instead of a silent 0 (docs/seeding.md). +guardSeedExit() + // Options (docs/seeding.md § Turn off, override, extend) — env vars work without editing this file: // createSeeder(payload, { editCheck: { hashField: false }, guard: { localHosts: ['db'] }, context: { … } }) const seed = createSeeder(await getPayload({ config }), { only: ONLY, pagesCollection: COLLECTION }) diff --git a/reference/README.md b/reference/README.md index 5820b9e..80f3560 100644 --- a/reference/README.md +++ b/reference/README.md @@ -17,8 +17,9 @@ cp .env.example .env # then fill PAYLOAD_SECRET; DATABASE pnpm seed # demo + base content, every language pnpm dev # http://localhost:3000/pl ``` -Production check: `pnpm build && ALLOW_LOCAL_MEDIA=1 PORT=3100 pnpm start`, then -`pnpm payload run e2e/create-test-admin.ts && pnpm test:e2e`. +Production check: `pnpm build && pnpm payload run e2e/create-test-admin.ts && ALLOW_LOCAL_MEDIA=1 pnpm test:e2e` +(Playwright starts the built site on port 3100 itself; another port: `E2E_BASE_URL=http://localhost:3200`, built with +the same `NEXT_PUBLIC_SERVER_URL`; a server you started yourself: `E2E_REUSE_SERVER=1`). ## What is where | Convention | Files | diff --git a/reference/playwright.config.ts b/reference/playwright.config.ts index ad4b932..2aebe4f 100644 --- a/reference/playwright.config.ts +++ b/reference/playwright.config.ts @@ -7,7 +7,11 @@ try { // no .env (CI) } -/** Smoke tests against a built, seeded site: pnpm build && pnpm seed && pnpm payload run e2e/create-test-admin.ts. */ +/** + * Smoke tests against a built, seeded site: pnpm build && pnpm seed && pnpm payload run e2e/create-test-admin.ts. + * E2E_BASE_URL picks the port (default 3100). Playwright starts its own server there and fails when the port is + * taken, so another project's dev server is never tested by mistake; E2E_REUSE_SERVER=1 uses a server you started. + */ const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3100' export default defineConfig({ @@ -20,7 +24,7 @@ export default defineConfig({ webServer: { command: 'pnpm start', env: { PORT: new URL(baseURL).port || '3000' }, - reuseExistingServer: true, + reuseExistingServer: process.env.E2E_REUSE_SERVER === '1', url: `${baseURL}/api/health`, }, workers: 1,