Files
peptide-e2e/tests/00-homepage.spec.ts
peptiderepo d46a1e4680 feat: initial Playwright smoke suite
20 tests across 5 files covering all plugin surfaces on staging:
- Homepage load and PHP fatal detection
- Reconstitution Calculator shortcode + math
- Peptide Search AI widget + AJAX response
- Admin: all plugins active, PSA + PRAutoBlogger settings pages
- REST API: prc/v1/presets, peptides/v1/search, compounds, CPT types

Staging shortcode pages:
  /reconstitution-calculator/ - [prc_calculator]
  /search-peptides/           - [peptide_search]
  /peptide-directory/         - [peptide_directory]

GHA workflow: smoke.yml supports manual dispatch + workflow_call
for use as a deploy gate from plugin repos.
2026-04-26 04:39:13 +00:00

41 lines
1.4 KiB
TypeScript
Executable File

/**
* 00-homepage.spec.ts
*
* What: Verifies the site root loads with no fatal PHP errors and basic
* theme elements are present. Catches theme activation failures,
* white screens, and missing plugin-provided content.
* Who triggers it: Playwright chromium project (post-auth setup).
* Dependencies: peptide-starter-theme, PR Core active.
*/
import { test, expect } from '@playwright/test';
test.describe('Homepage', () => {
test('loads with HTTP 200 and no fatal error', async ({ page }) => {
const response = await page.goto('/');
expect(response?.status()).toBe(200);
});
test('has no PHP fatal error or white screen', async ({ page }) => {
await page.goto('/');
const body = await page.textContent('body');
// PHP fatals produce these strings in non-production WP configs
expect(body).not.toContain('Fatal error');
expect(body).not.toContain('Parse error');
expect(body).not.toContain('Warning: ');
// White-screen: body is empty or nearly empty
expect((body ?? '').trim().length).toBeGreaterThan(200);
});
test('renders site name in page title', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/peptiderepo/i);
});
test('wp-admin bar present (logged-in session)', async ({ page }) => {
await page.goto('/');
// The auth state from global.setup means we should see the admin bar
await expect(page.locator('#wpadminbar')).toBeVisible();
});
});