Compare commits

..

1 Commits

Author SHA1 Message Date
peptiderepo
b1685d239e ci(monitor): only flag drift when undeployed commits touch deployable files
Compare prod-deployment SHA to main and ignore changes confined to .github/,
tests/, and docs/build files (which the deploy excludes) — so infra-only commits
don't trip a false 'prod behind main' alert every day.

Agent-Session: cto monitor-drift-filter
2026-06-09 07:15:24 +00:00
8 changed files with 57 additions and 153 deletions

View File

@@ -79,10 +79,7 @@ jobs:
deploy-production:
name: Deploy to Production
# Smoke is now a GATE: a smoke FAILURE blocks production. A deliberately
# skipped smoke (run_smoke: false) still allows prod via the if-condition.
needs: [deploy-staging, smoke]
if: ${{ !cancelled() && needs.deploy-staging.result == 'success' && needs.smoke.result != 'failure' }}
needs: [deploy-staging]
runs-on: ubuntu-latest
environment: production
steps:

View File

@@ -1,21 +0,0 @@
# Changelog
All notable changes to the peptide-e2e smoke suite will be documented here.
## [1.1.0] - 2026-06-12
### Added
- **Board page smoke test** (`03-admin-plugins.spec.ts` — `WP Admin — PRAutoBlogger board page`).
Navigates to `/wp-admin/admin.php?page=prautoblogger-board`, asserts HTTP 200,
`#prab-board` container visible, and body does NOT contain "Invalid plugin page".
Guards against the v0.19.1 regression class: Board submenu registered before parent
menu existed (both at admin_menu priority 10) → WordPress fallback hookname →
wp_die 404. Now in the deploy-gate smoke suite so this failure class is un-shippable.
Note: cannot be validated against prod until v0.19.1 of PRAutoBlogger deploys.
Spec compiles and lists cleanly under `npx playwright test --list`.
## [1.0.0] - 2026-06-11
Initial release. 21 tests across 5 specs: homepage, reconstitution calculator,
peptide search, admin plugins, REST API.

View File

@@ -7,11 +7,6 @@
*
* 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): 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.
*/
import { test as setup, expect } from '@playwright/test';
@@ -20,14 +15,9 @@ import * as fs from 'fs';
const AUTH_FILE = path.join(__dirname, 'playwright/.auth/admin.json');
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 }) => {
setup('authenticate as WP admin', async ({ page }) => {
const user = process.env.WP_ADMIN_USER;
const password = process.env.WP_ADMIN_PASSWORD;
const baseURL = process.env.BASE_URL ?? 'https://staging.peptiderepo.com';
if (!user || !password) {
throw new Error(
@@ -35,69 +25,28 @@ setup('authenticate as WP admin', async ({ browser }) => {
);
}
// Ensure auth directory exists
// Ensure directory exists
fs.mkdirSync(path.dirname(AUTH_FILE), { recursive: true });
let lastError: unknown;
await page.goto('/wp-login.php');
await page.fill('#user_login', user);
await page.fill('#user_pass', password);
await page.click('#wp-submit');
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
console.log(
`[setup] Login attempt ${attempt}/${MAX_ATTEMPTS} — navigating to wp-login.php ...`
);
// Wait for any post-login navigation. The site may redirect successful logins
// to the homepage (via a login_redirect filter) rather than to wp-admin —
// staging does this. So we don't assert the post-submit URL; instead, we
// verify we're no longer ON wp-login.php (which would indicate a credential
// rejection or 2FA prompt) and then navigate explicitly to wp-admin.
await page.waitForURL((url) => !url.pathname.includes('/wp-login.php'), {
timeout: 20_000,
});
// Fresh context per attempt so stale cookies / throttle state don't carry over.
const context = await browser.newContext({ baseURL });
const page = await context.newPage();
// Navigate explicitly into wp-admin to capture the authenticated admin session.
await page.goto('/wp-admin/');
await expect(page).toHaveURL(/\/wp-admin\//, { timeout: 20_000 });
await expect(page.locator('#wpadminbar')).toBeVisible();
try {
await page.goto('/wp-login.php', { timeout: NAV_TIMEOUT });
await page.fill('#user_login', user);
await page.fill('#user_pass', password);
await page.click('#wp-submit');
// Wait for any post-login navigation. The site may redirect successful
// logins to the homepage (via a login_redirect filter) rather than to
// wp-admin — staging does this. So we don't assert the post-submit URL;
// instead, we verify we're no longer ON wp-login.php (which would
// indicate a credential rejection or 2FA prompt) and then navigate
// explicitly to wp-admin.
await page.waitForURL(
(url) => !url.pathname.includes('/wp-login.php'),
{ timeout: NAV_TIMEOUT }
);
// Navigate explicitly into wp-admin to capture the authenticated admin session.
await page.goto('/wp-admin/', { timeout: NAV_TIMEOUT });
await expect(page).toHaveURL(/\/wp-admin\//, { timeout: 20_000 });
await expect(page.locator('#wpadminbar')).toBeVisible({ timeout: 20_000 });
// Persist session cookies + localStorage to disk
await page.context().storageState({ path: AUTH_FILE });
console.log(`[setup] Login succeeded on attempt ${attempt}/${MAX_ATTEMPTS}`);
await context.close();
return; // success — exit setup
} catch (err) {
lastError = err;
const message = err instanceof Error ? err.message : String(err);
console.error(
`[setup] Login attempt ${attempt}/${MAX_ATTEMPTS} FAILED: ${message}`
);
await context.close();
if (attempt < MAX_ATTEMPTS) {
console.log(`[setup] Waiting ${BACKOFF_MS / 1000}s before retry ...`);
await new Promise((resolve) => setTimeout(resolve, BACKOFF_MS));
}
}
}
// All attempts exhausted — surface the last error with a clear diagnostic.
throw new Error(
`[setup] All ${MAX_ATTEMPTS} login attempts failed. ` +
`Last error: ${lastError instanceof Error ? lastError.message : String(lastError)}\n` +
`Hint: Hostinger may still be throttling GitHub runner IPs. ` +
`Re-run the workflow once the throttle window clears, or increase BACKOFF_MS / MAX_ATTEMPTS.`
);
// Persist session cookies + localStorage to disk
await page.context().storageState({ path: AUTH_FILE });
});

View File

@@ -1,6 +1,6 @@
{
"name": "peptide-e2e",
"version": "1.1.0",
"version": "1.0.0",
"description": "Playwright smoke tests for peptiderepo.com (staging + production)",
"private": true,
"scripts": {

View File

@@ -39,14 +39,31 @@ test.describe('Reconstitution Calculator', () => {
expect(options).toBeGreaterThan(1); // >1 means at least one peptide beyond placeholder
});
test('fills inputs and gets a numeric result', async ({ page }) => {
const calc = page.locator('.prc-calculator');
// The calculator auto-computes once a peptide preset is chosen (the preset
// supplies vial size, recommended water volume and a default dose).
await calc.locator('#prc-peptide-select').selectOption({ index: 1 });
// Results panel unhides and renders numeric result cards.
const results = page.locator('#prc-results');
await expect(results).toBeVisible({ timeout: 10_000 });
await expect(page.locator('.prc-result-card__value').first()).toHaveText(/\d/, { timeout: 5_000 });
});
test('fills inputs and gets a numeric result', async ({ page }) => {
// Select BPC-157 or the first non-placeholder option
const select = page.locator('select').first();
const firstPeptide = select.locator('option').nth(1);
const firstValue = await firstPeptide.getAttribute('value');
await select.selectOption(firstValue ?? '');
// Fill reconstitution volume (mL) — use a known valid value
const volInput = page.locator('input[name*="recon"], input[placeholder*="mL"], input[type="number"]').first();
await volInput.fill('2');
// Fill desired dose
const doseInput = page.locator('input[name*="dose"], input[placeholder*="dose"], input[type="number"]').nth(1);
await doseInput.fill('250');
// Trigger calculation (button or auto-calculate on input)
const calcButton = page.locator('button[type="submit"], button:has-text("Calculate")');
if (await calcButton.count() > 0) {
await calcButton.first().click();
}
// Results container should show a non-zero concentration or injection volume
const results = page.locator('.prc-results, .calculator-results, [data-prc-result]').first();
await expect(results).toBeVisible({ timeout: 5_000 });
const resultText = await results.textContent();
expect(resultText).toMatch(/\d+(\.\d+)?/); // contains at least one number
});
});

View File

@@ -25,14 +25,14 @@ test.describe('Peptide Search AI', () => {
test('search input widget is present on page', async ({ page }) => {
// PSA renders a form with class .psa-search-form or input with data-psa attr
const searchInput = page.locator(
'.hero-search .psa-search-input'
'.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input'
).first();
await expect(searchInput).toBeVisible({ timeout: 10_000 });
});
test('searching for a known peptide returns results', async ({ page }) => {
const searchInput = page.locator(
'.hero-search .psa-search-input'
'.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input'
).first();
await expect(searchInput).toBeVisible();
@@ -41,7 +41,7 @@ test.describe('Peptide Search AI', () => {
await searchInput.press('Enter');
// Results container should appear and contain something
const results = page.locator('.hero-search .psa-search-results').first();
const results = page.locator('.psa-results, .psa-search-results, [data-psa-results]').first();
await expect(results).toBeVisible({ timeout: 15_000 });
const text = await results.textContent();
expect((text ?? '').trim().length).toBeGreaterThan(0);
@@ -57,7 +57,7 @@ test.describe('Peptide Search AI', () => {
);
const searchInput = page.locator(
'.hero-search .psa-search-input'
'.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input'
).first();
await searchInput.fill('TB-500');
await searchInput.press('Enter');

View File

@@ -94,52 +94,13 @@ test.describe('WP Admin — PRAutoBlogger settings page', () => {
});
});
test.describe('WP Admin — PRAutoBlogger board page', () => {
/**
* Smoke test: Board submenu page must load without 404 or "Invalid plugin page".
*
* This test guards against the v0.19.1 regression class: Board submenu was
* registered before the parent top-level menu page existed (both at admin_menu
* priority 10), causing WordPress to fall back to the `admin_page_*` hookname.
* At request time WP recomputed the hookname, found nothing, and called
* wp_die("Invalid plugin page"). The fix (v0.19.1) moves the board hook to
* priority 11 so the parent menu slot is populated first.
*
* Selector sourced from templates/admin/board-page.php: `<div id="prab-board" ...>`.
*
* NOTE: This test cannot be validated against prod until v0.19.1 is deployed.
* It is included in the deploy-gate smoke suite so the bug class becomes
* un-shippable in future. The spec compiles and lists cleanly; the test will
* run correctly once the fix is live.
*/
test('board page loads and board container is present', async ({ page }) => {
// Navigate to the Board submenu page.
const res = await page.goto(`${ADMIN}/admin.php?page=prautoblogger-board`);
// Must be HTTP 200 — not wp_die 404.
expect(res?.status()).toBe(200);
// wp-admin chrome must render (confirms we're authenticated and in admin).
await expect(page.locator('#wpbody')).toBeVisible();
// Body must NOT contain the wp_die "Invalid plugin page" error string.
const body = await page.textContent('body');
expect(body).not.toContain('Invalid plugin page');
// Board container div must be present (from templates/admin/board-page.php).
// selector: <div id="prab-board" class="prab-board" ...>
await expect(page.locator('#prab-board')).toBeVisible({ timeout: 10_000 });
});
});
test.describe('WP Admin — Peptide Repo Core admin', () => {
test('PR Core menu item exists in wp-admin', async ({ page }) => {
await page.goto(`${ADMIN}/`);
// PR Core registers the peptide CPT which creates a "Peptides" menu item
const nav = page.locator('#adminmenu');
// PR Core registers the peptide CPT which creates a "Peptides" menu item const nav = page.locator('#adminmenu');
await expect(nav).toBeVisible();
// PR Core registers the peptide CPT, which adds a post_type=peptide admin menu/submenu (label-agnostic).
await expect(nav.locator('a[href*="post_type=peptide"]').first()).toBeAttached({ timeout: 10_000 });
// "Peptides" top-level menu item is registered by the peptide CPT
await expect(nav.locator('text=Peptides')).toBeVisible({ timeout: 10_000 });
});
test('PR Core Settings page loads', async ({ page }) => {

View File

@@ -38,6 +38,7 @@ test.describe('REST API — Peptide Search AI', () => {
expect([200, 404]).toContain(res.status());
if (res.status() === 200) {
const body = await res.json();
expect(body).toHaveProperty('status');
expect(body).toHaveProperty('results');
}
});