diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e57d37..712635b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## [1.7.0] - 2026-06-17 + +### Added +- **Peptide News admin smoke (07)** (`07-peptide-news-admin.spec.ts`). + Covers the Peptide News Plugin admin surfaces: dashboard (HTTP 200, no fatal, + h1 "Peptide News Analytics" heading, `.pn-summary-cards`, `.pn-date-filter`), + settings (form present), articles, and LLM costs sub-pages. Skip-if-absent guard + on all tests using the standard 05/06 merge-early binding pattern. Slugs sourced + from `admin/class-pn-admin-menu.php`. + +- **PR Vision admin smoke (08)** (`08-pr-vision-admin.spec.ts`). + Covers the PR Vision plugin admin surfaces: dashboard (HTTP 200, no fatal, + h1 "PR Vision" visible), Settings page (API-key-manager card `#prv-key-card` + present, status badge `#prv-key-source-badge` visible), write-only security + invariant (`#prv_api_key` value="" + full HTML must not contain "sk-or-"), + Costs sub-page (`pr-vision-costs`), and Call Log sub-page (`pr-vision-calls`). + Skip-if-absent at two levels: plugin absent (loud annotation + skip), and + `#prv-key-card` absent (Settings v0.2.0 not yet deployed on environment). + Selectors sourced from `class-prv-admin-page.php`, `class-prv-key-manager-renderer.php`. + + All notable changes to the peptide-e2e smoke suite will be documented here. ## [1.6.0] - 2026-06-16 diff --git a/package.json b/package.json index 21bbf9c..95ae492 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "peptide-e2e", - "version": "1.5.0", + "version": "1.7.0", "description": "Playwright smoke tests for peptiderepo.com (staging + production)", "private": true, "scripts": { diff --git a/tests/07-peptide-news-admin.spec.ts b/tests/07-peptide-news-admin.spec.ts new file mode 100644 index 0000000..612cbe6 --- /dev/null +++ b/tests/07-peptide-news-admin.spec.ts @@ -0,0 +1,144 @@ +/** + * 07-peptide-news-admin.spec.ts + * + * What: Smoke tests for the Peptide News Plugin admin surfaces. + * Verifies the dashboard, settings, articles, and cost sub-pages + * load without PHP fatals and checks expected UI elements. + * Guards against activation failures, missing menu registration, or + * PHP fatals introduced by a bad deploy. + * + * Who triggers it: Playwright chromium project (post-auth setup). + * Dependencies: wp-admin authenticated session (from global.setup.ts). + * + * SKIP-IF-ABSENT: When the Peptide News Plugin is not installed/activated on + * this environment, each test detects the absent menu page and skips with a + * loud annotation — consistent with the 05/06 merge-early binding pattern. + * + * Admin menu slugs (sourced from admin/class-pn-admin-menu.php): + * Dashboard -> admin.php?page=peptide-news-dashboard + * Settings -> admin.php?page=peptide-news-settings + * Articles -> admin.php?page=peptide-news-articles + * LLM Costs -> admin.php?page=peptide-news-costs + * + * Selectors sourced from admin/partials/dashboard.php: + * h1 "Peptide News Analytics" - page heading (text match) + * .pn-summary-cards - summary card row + * .pn-date-filter - date range filter form + * + * @see peptiderepo/peptide-news-plugin admin/class-pn-admin-menu.php + * @see peptiderepo/peptide-news-plugin admin/partials/dashboard.php + */ + +import { test, expect } from '@playwright/test'; + +const ADMIN = '/wp-admin'; + +/** + * Detect the "page not registered" condition WordPress returns when a plugin + * menu slug is unknown. Returns true when the plugin is absent. + * + * WordPress either: + * (a) Shows "You do not have sufficient permissions to access this page." + * (b) Shows a notice that the page cannot be found + * (c) Redirects back to /wp-admin/ stripping the ?page= param + */ +function isPluginAbsent(body: string, url: string): boolean { + return ( + body.includes('Invalid plugin page') || + body.includes('do not have sufficient permissions') || + body.includes('The page you are looking for') || + ( url.includes('/wp-admin/') && ! url.includes('page=peptide-news') ) + ); +} + +/** Push a loud skip annotation and call test.skip(). */ +function skipMissing(): void { + test.info().annotations.push({ + type: 'skip', + description: + '[peptide-news smoke] Peptide News Plugin is not installed or activated ' + + 'on this environment. Skipping per the merge-early binding.', + }); + test.skip(); +} + +test.describe('WP Admin - Peptide News Plugin dashboard', () => { + test('dashboard page loads (HTTP 200, no PHP fatal)', async ({ page }) => { + const res = await page.goto(`${ADMIN}/admin.php?page=peptide-news-dashboard`); + expect(res?.status()).toBe(200); + + await expect(page.locator('#wpbody')).toBeVisible(); + + const body = (await page.textContent('body')) ?? ''; + expect(body).not.toContain('Fatal error'); + + if (isPluginAbsent(body, page.url())) { skipMissing(); return; } + }); + + test('dashboard renders analytics heading, summary cards, and date filter', async ({ page }) => { + await page.goto(`${ADMIN}/admin.php?page=peptide-news-dashboard`); + + await expect(page.locator('#wpbody')).toBeVisible(); + const body = (await page.textContent('body')) ?? ''; + expect(body).not.toContain('Fatal error'); + + if (isPluginAbsent(body, page.url())) { skipMissing(); return; } + + // Heading from admin/partials/dashboard.php: