Compare commits

..

3 Commits

Author SHA1 Message Date
peptiderepo
0c5c30196b merge: resolve main conflict — conserve board smoke (PR #13) + dossier smoke (PR #14)
Conflict: CHANGELOG.md (add/add) and package.json (v1.1.0 vs v1.2.0).

Resolution:
- CHANGELOG.md: keep both entries, v1.2.0 above v1.1.0 (chronological order).
  Updated v1.2.0 description to reference v0.19.2 / v0.19.3 (hotfix context).
- package.json: use version 1.2.0 (PR #14 head; dossier smoke is the newer addition).
- tests/03-admin-plugins.spec.ts: auto-merged by git — board describe block (PR #13)
  at line 97, dossier describe block (PR #14) at line 158. Both conserved.

Dossier smoke selector #prab-dossier verified against v0.19.3 template
(templates/admin/dossier-page.php line 62/86) — registration parent change
does not affect markup.

Agent-Session: dossier-403-hotfix-20260612
2026-06-12 11:20:30 +00:00
Engineer PRAutoBlogger
fd2d0823d6 test(smoke): dossier page smoke guard — assert HTTP 200 + #prab-dossier + no fatal (v1.2.0)
Adds dossier smoke test to 03-admin-plugins.spec.ts (describe block:
'WP Admin — PRAutoBlogger Article Dossier').

Guards:
- Menu-ordering regression: wrong hookname -> wp_die 404 (same class as v0.19.1 board bug)
- PHP fatal on dossier load
- Missing #prab-dossier container (template regression)
- Stage-section regression (conditional on run data existing)

Defensive strategy:
- Tries canonical staging posts 925/930 via REST API first
- Falls back to most recent post via /wp-json/wp/v2/posts
- Falls back to post_id=0 (graceful empty state) with loud test.info() annotation
- Stage-section assertions conditional: if stages present they must render; if absent
  the pre-substrate graceful state is expected (no failure)

npx playwright test --list shows 24 tests (was 23).
New test at 03-admin-plugins.spec.ts:185.
TypeScript compiles without errors.

Part of PRAutoBlogger v0.19.2 M2 milestone. Companion PR: peptiderepo/prautoblogger#158.

Agent-Session: claude-sonnet-4-6
2026-06-12 10:40:49 +00:00
peptiderepo
113bb17e43 test(smoke): board page smoke guard — assert HTTP 200 + #prab-board (v1.1.0)
Add board page smoke test to 03-admin-plugins.spec.ts under the
'WP Admin — PRAutoBlogger board page' describe block.

The test navigates to /wp-admin/admin.php?page=prautoblogger-board and
asserts:
  1. HTTP 200 (not wp_die 404)
  2. #wpbody visible (authenticated admin session confirmed)
  3. body does NOT contain 'Invalid plugin page' (the wp_die string)
  4. #prab-board container visible (selector from templates/admin/board-page.php)

This guards against the v0.19.1 regression class: PRAutoBlogger_Board_Page
was registered at admin_menu priority 10, before the parent top-level menu
(also 10). WordPress computed the wrong hookname (admin_page_*) at
add_submenu_page() time; at request time it recomputed prautoblogger_page_*,
found nothing, and called wp_die() — 404. The board was un-navigable since
v0.19.0 shipped. With this test in the deploy gate, this failure class is
now un-shippable.

Spec compiles and lists cleanly (npx playwright test --list: 23 tests).
Cannot be validated against prod until v0.19.1 deploys; stated in spec comment.

Agent-Session: board-404-hotfix-20260612
2026-06-12 08:32:08 +00:00
5 changed files with 26 additions and 252 deletions

View File

@@ -2,39 +2,6 @@
All notable changes to the peptide-e2e smoke suite will be documented here.
## [1.4.0] - 2026-06-12
### Added
- **Dossier edit + re-run smoke (M3, skip-if-absent)** (`05-dossier-edit.spec.ts`).
Opens a discovered post's dossier and exercises the v0.20.0 edit surface READ-ONLY:
opens/closes the first edit panel (asserts textareas, Save/Re-run buttons, the
fork-preserved + queued-execution copy), asserts every disabled edit affordance
carries a visible reason, and checks the M3 sidebar cards (Run Spend, Models &
Prompts). NEVER clicks Save or any Re-run button (those fork inputs / queue paid
LLM jobs). SKIPS with a loud annotation when `.prab-stage-rerun-footer` is absent
(plugin v0.20.0 not yet deployed) so this PR can merge before prautoblogger PR #161
per the M3 merge-order binding. 25 tests total (was 24), delta = 1.
## [1.3.0] - 2026-06-12
### Fixed
- **Auth setup survives `ERR_ABORTED` on wp-login.php** (`global.setup.ts`).
When Hostinger's LiteSpeed throttles a GitHub runner IP, `page.goto` can
throw `net::ERR_ABORTED` rather than a `TimeoutError`. Playwright marks the
browser context closed internally on abort, so the existing
`context.close()` call in the catch block threw
`"browserContext.close: Target page, context or browser has been closed"`,
which propagated out of catch and killed setup before the remaining retries
ran. Two production deploys were blocked by this flake on 2026-06-12.
Fix: introduced `safeClose()` helper that swallows the already-closed
error, so an aborted context never terminates the retry loop. Max attempts
raised from 3 → 5; backoff is now exponential (5 s / 10 s / 20 s / 40 s)
instead of a flat 15 s, giving the throttle window more time to clear.
Worst-case timing: 5 × 90 s navigation + 75 s backoff = ~525 s, well under
the 900 s (15 min) job timeout. Final-failure message explicitly names the
LiteSpeed throttle hypothesis so future CI logs self-diagnose.
## [1.2.0] - 2026-06-12
### Added

View File

@@ -8,25 +8,10 @@
* The saved auth state (playwright/.auth/admin.json) is reused by the
* "chromium" project so individual tests don't each incur a login round-trip.
*
* Retry hardening (2026-06-12 v1): Hostinger rate-limits GitHub runner IPs on
* Retry hardening (2026-06-12): Hostinger rate-limits GitHub runner IPs on
* wp-login.php, causing TimeoutError on page.goto. The login attempt is now
* retried up to MAX_ATTEMPTS times with a fresh browser context per attempt
* and BACKOFF_MS delay between attempts so transient throttle windows clear.
*
* Retry hardening (2026-06-12 v2 — ERR_ABORTED fix): When Hostinger aborts
* the connection (net::ERR_ABORTED), Playwright marks the context as closed
* internally. A subsequent context.close() call throws
* "browserContext.close: Target page, context or browser has been closed",
* which propagated out of the catch block and crashed setup without consuming
* remaining retries. Fix: context.close() is now guarded in its own
* try/catch so an already-closed context never aborts the retry loop.
* MAX_ATTEMPTS raised to 5; backoff doubled each time (5s/10s/20s/40s) so the
* LiteSpeed throttle window has time to clear before each retry.
*
* Timing math (job timeout-minutes: 15 = 900 s):
* 5 attempts × NAV_TIMEOUT (90 s) = 450 s navigation ceiling
* 4 inter-attempt waits (5+10+20+40 s) = 75 s backoff ceiling
* Total worst-case: ~525 s — well under the 900 s job timeout.
*/
import { test as setup, expect } from '@playwright/test';
@@ -35,22 +20,9 @@ import * as fs from 'fs';
const AUTH_FILE = path.join(__dirname, 'playwright/.auth/admin.json');
const MAX_ATTEMPTS = 5;
const NAV_TIMEOUT = 90_000; // 90 s per navigation attempt
/** Exponential backoff delays (ms) between attempts: 5 s, 10 s, 20 s, 40 s */
function backoffMs(attempt: number): number {
return 5_000 * Math.pow(2, attempt - 1);
}
/** Safely close a context that Playwright may have already closed internally. */
async function safeClose(context: import('@playwright/test').BrowserContext): Promise<void> {
try {
await context.close();
} catch {
// Ignored: context was already closed (e.g. after ERR_ABORTED or crash).
}
}
const MAX_ATTEMPTS = 3;
const BACKOFF_MS = 15_000; // 15 s between attempts
const NAV_TIMEOUT = 90_000; // raised from 30 s → 90 s per attempt
setup('authenticate as WP admin', async ({ browser }) => {
const user = process.env.WP_ADMIN_USER;
@@ -103,7 +75,7 @@ setup('authenticate as WP admin', async ({ browser }) => {
await page.context().storageState({ path: AUTH_FILE });
console.log(`[setup] Login succeeded on attempt ${attempt}/${MAX_ATTEMPTS}`);
await safeClose(context);
await context.close();
return; // success — exit setup
} catch (err) {
lastError = err;
@@ -112,20 +84,11 @@ setup('authenticate as WP admin', async ({ browser }) => {
`[setup] Login attempt ${attempt}/${MAX_ATTEMPTS} FAILED: ${message}`
);
// IMPORTANT: use safeClose — if Playwright received ERR_ABORTED it marks
// the context closed internally, so a plain context.close() throws
// "Target page, context or browser has been closed". Without this guard
// that secondary throw propagated out of catch and killed setup before
// the remaining retries ran.
await safeClose(context);
await context.close();
if (attempt < MAX_ATTEMPTS) {
const wait = backoffMs(attempt);
console.log(
`[setup] Waiting ${wait / 1000}s before retry ` +
`(LiteSpeed throttle cool-down — attempt ${attempt + 1}/${MAX_ATTEMPTS}) ...`
);
await new Promise((resolve) => setTimeout(resolve, wait));
console.log(`[setup] Waiting ${BACKOFF_MS / 1000}s before retry ...`);
await new Promise((resolve) => setTimeout(resolve, BACKOFF_MS));
}
}
}
@@ -134,8 +97,7 @@ setup('authenticate as WP admin', async ({ browser }) => {
throw new Error(
`[setup] All ${MAX_ATTEMPTS} login attempts failed. ` +
`Last error: ${lastError instanceof Error ? lastError.message : String(lastError)}\n` +
`Hypothesis: Hostinger LiteSpeed is throttling GitHub runner IPs on wp-login.php — ` +
`connections abort (ERR_ABORTED) or time out in bursts. ` +
`Re-run the workflow once the throttle window clears, or increase MAX_ATTEMPTS / backoffMs().`
`Hint: Hostinger may still be throttling GitHub runner IPs. ` +
`Re-run the workflow once the throttle window clears, or increase BACKOFF_MS / MAX_ATTEMPTS.`
);
});

44
package-lock.json generated
View File

@@ -1,28 +1,25 @@
{
"name": "peptide-e2e",
"version": "1.4.0",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "peptide-e2e",
"version": "1.4.0",
"dependencies": {
"typescript": "^6.0.3"
},
"version": "1.0.0",
"devDependencies": {
"@playwright/test": "^1.60.0",
"@playwright/test": "^1.43.0",
"dotenv": "^16.4.5"
}
},
"node_modules/@playwright/test": {
"version": "1.60.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.60.0.tgz",
"integrity": "sha512-O71yZIbAh/PxDMNGns37GHBIfrVkEVyn+AXyIa5dOTfb4/xNvRWV+Vv/NMbNCtODB/pO7vLlF2OTmMVLhmr7Ag==",
"version": "1.59.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.1.tgz",
"integrity": "sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.60.0"
"playwright": "1.59.1"
},
"bin": {
"playwright": "cli.js"
@@ -60,13 +57,13 @@
}
},
"node_modules/playwright": {
"version": "1.60.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0.tgz",
"integrity": "sha512-hheHdokM8cdqCb0lcE3s+zT4t4W+vvjpGxsZlDnikarzx8tSzMebh3UiFtgqwFwnTnjYQcsyMF8ei2mCO/tpeA==",
"version": "1.59.1",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.1.tgz",
"integrity": "sha512-C8oWjPR3F81yljW9o5OxcWzfh6avkVwDD2VYdwIGqTkl+OGFISgypqzfu7dOe4QNLL2aqcWBmI3PMtLIK233lw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.60.0"
"playwright-core": "1.59.1"
},
"bin": {
"playwright": "cli.js"
@@ -79,9 +76,9 @@
}
},
"node_modules/playwright-core": {
"version": "1.60.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0.tgz",
"integrity": "sha512-9bW6zvX/m0lEbgTKJ6YppOKx8H3VOPBMOCFh2irXFOT4BbHgrx5hPjwJYLT40Lu+4qtD36qKc/Hn56StUW57IA==",
"version": "1.59.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.1.tgz",
"integrity": "sha512-HBV/RJg81z5BiiZ9yPzIiClYV/QMsDCKUyogwH9p3MCP6IYjUFu/MActgYAvK0oWyV9NlwM3GLBjADyWgydVyg==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@@ -90,19 +87,6 @@
"engines": {
"node": ">=18"
}
},
"node_modules/typescript": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "peptide-e2e",
"version": "1.4.0",
"version": "1.2.0",
"description": "Playwright smoke tests for peptiderepo.com (staging + production)",
"private": true,
"scripts": {
@@ -11,10 +11,7 @@
"report": "playwright show-report"
},
"devDependencies": {
"@playwright/test": "^1.60.0",
"@playwright/test": "^1.43.0",
"dotenv": "^16.4.5"
},
"dependencies": {
"typescript": "^6.0.3"
}
}

View File

@@ -1,136 +0,0 @@
/**
* 05-dossier-edit.spec.ts
*
* What: Smoke for the PRAutoBlogger dossier EDIT + RE-RUN surface
* (plugin v0.20.0, Phase 2 admin M3). Read-only: opens/closes the
* edit panel and asserts structure — it NEVER clicks Save or any
* Re-run button (those fork inputs / queue paid LLM jobs).
* Who triggers it: Playwright chromium project (post-auth setup).
* Dependencies: wp-admin authenticated session (from global.setup.ts).
*
* SKIP-IF-ABSENT (M3 binding): this spec targets a surface that may not
* be deployed yet. When the M3 markup (.prab-stage-rerun-footer) is
* absent from the dossier, the test SKIPS with a loud annotation so this
* PR can merge before the plugin PR ships. Once v0.20.0 is live, the
* skip path goes dead and the assertions gate as usual.
*
* Selectors sourced from prautoblogger v0.20.0:
* templates/admin/dossier-stage-section.php (.prab-stage-rerun-footer,
* .prab-edit-toggle, .prab-edit-unavailable, .prab-rerun-from)
* templates/admin/dossier-edit-panel.php (.prab-edit-panel,
* .prab-edit-textarea, .prab-edit-save, .prab-edit-rerun)
* templates/admin/dossier-sidebar-cards.php (.prab-run-spend,
* .prab-models-card)
*
* @see prautoblogger PR #161 (v0.20.0) — the surface under test.
*/
import { test, expect } from '@playwright/test';
const ADMIN = '/wp-admin';
const CANDIDATE_POST_IDS = [925, 930]; // canonical staging posts
test.describe('WP Admin — PRAutoBlogger dossier edit + re-run (M3)', () => {
test('edit affordances render structurally (no mutations)', async ({ page, request }) => {
// ── Post discovery (same defensive strategy as the dossier smoke) ──
let targetPostId: number | null = null;
for (const pid of CANDIDATE_POST_IDS) {
const apiRes = await request.get(`/wp-json/wp/v2/posts/${pid}`);
if (apiRes.ok()) {
targetPostId = pid;
break;
}
}
if (targetPostId === null) {
const listRes = await request.get('/wp-json/wp/v2/posts?per_page=5&orderby=date&order=desc');
if (listRes.ok()) {
const posts: Array<{ id: number }> = await listRes.json();
if (posts.length > 0) {
targetPostId = posts[0].id;
}
}
}
if (targetPostId === null) {
test.info().annotations.push({
type: 'warning',
description:
'[dossier-edit smoke] No post found on this environment — ' +
'cannot exercise the edit surface. Skipping.',
});
test.skip();
return;
}
const res = await page.goto(`${ADMIN}/admin.php?page=prautoblogger-dossier&post_id=${targetPostId}`);
expect(res?.status()).toBe(200);
await expect(page.locator('#wpbody')).toBeVisible();
const body = await page.textContent('body');
expect(body).not.toContain('Fatal error');
expect(body).not.toContain('Invalid plugin page');
// ── SKIP-IF-ABSENT gate: M3 markup not deployed yet ────────────────
const footers = page.locator('.prab-stage-rerun-footer');
const footerCount = await footers.count();
if (footerCount === 0) {
test.info().annotations.push({
type: 'warning',
description:
'[dossier-edit smoke] .prab-stage-rerun-footer absent — the M3 ' +
'edit+rerun surface (plugin v0.20.0) is not deployed on this ' +
'environment, or this post has no stage sections. Skipping per ' +
'the merge-early binding.',
});
test.skip();
return;
}
console.log(`[dossier-edit smoke] Found ${footerCount} stage rerun footers on post id=${targetPostId}`);
// ── Disabled affordances must explain themselves ───────────────────
const unavailable = page.locator('.prab-edit-unavailable');
const unavailableCount = await unavailable.count();
for (let i = 0; i < unavailableCount; i++) {
const reason = (await unavailable.nth(i).textContent())?.trim() ?? '';
expect(reason.length, 'disabled edit affordances must carry a visible reason').toBeGreaterThan(10);
}
// ── Edit panel open/close (read-only — NEVER click save/rerun) ─────
const toggles = page.locator('.prab-edit-toggle');
const toggleCount = await toggles.count();
if (toggleCount === 0) {
test.info().annotations.push({
type: 'info',
description:
'[dossier-edit smoke] No editable stage on this post (no recorded ' +
'request_json yet, or post is published/frozen). Disabled-state ' +
'reasons were asserted; panel interaction not exercisable.',
});
return;
}
const firstToggle = toggles.first();
const panelId = await firstToggle.getAttribute('aria-controls');
expect(panelId).toBeTruthy();
const panel = page.locator(`#${panelId}`);
await firstToggle.click();
await expect(panel).toBeVisible();
await expect(firstToggle).toHaveAttribute('aria-expanded', 'true');
// Panel structure: textareas + save + rerun buttons + fork/queue copy.
expect(await panel.locator('.prab-edit-textarea').count()).toBeGreaterThan(0);
await expect(panel.locator('.prab-edit-save')).toBeVisible();
await expect(panel.locator('.prab-edit-rerun')).toBeVisible();
const copy = (await panel.textContent()) ?? '';
expect(copy).toContain('original is preserved'); // fork copy (guardrail 1)
expect(copy.toLowerCase()).toContain('queued'); // chained-cron copy
// Close it again — leave the page exactly as found.
await firstToggle.click();
await expect(panel).toBeHidden();
// ── M3 sidebar cards present when run data exists ──────────────────
await expect(page.locator('.prab-run-spend')).toBeVisible();
await expect(page.locator('.prab-models-card')).toBeVisible();
});
});