Compare commits
2 Commits
claude/e2e
...
claude/har
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
027b078915 | ||
|
|
07d23b420b |
5
.github/workflows/deploy-app.yml
vendored
5
.github/workflows/deploy-app.yml
vendored
@@ -79,10 +79,7 @@ jobs:
|
|||||||
|
|
||||||
deploy-production:
|
deploy-production:
|
||||||
name: Deploy to Production
|
name: Deploy to Production
|
||||||
# Smoke is now a GATE: a smoke FAILURE blocks production. A deliberately
|
needs: [deploy-staging]
|
||||||
# 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' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: production
|
environment: production
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
18
.github/workflows/deploy-health.yml
vendored
18
.github/workflows/deploy-health.yml
vendored
@@ -45,23 +45,7 @@ jobs:
|
|||||||
if (sts.length) prodState = sts[0].state;
|
if (sts.length) prodState = sts[0].state;
|
||||||
}
|
}
|
||||||
if (runConc === 'failure') problems.push(`**${repo}**: latest deploy run failed (\`${short(runSha)}\`)`);
|
if (runConc === 'failure') problems.push(`**${repo}**: latest deploy run failed (\`${short(runSha)}\`)`);
|
||||||
if (prodSha && prodSha !== main) {
|
if (prodSha && prodSha !== main) problems.push(`**${repo}**: prod behind main — prod=\`${short(prodSha)}\` vs main=\`${short(main)}\` (undeployed commits)`);
|
||||||
// Only real drift if undeployed commits touch DEPLOYABLE files
|
|
||||||
// (ignore .github/, tests/, and docs/build files the deploy excludes).
|
|
||||||
try {
|
|
||||||
const cmp = (await github.rest.repos.compareCommits({owner, repo, base: prodSha, head: main})).data;
|
|
||||||
const deployable = (cmp.files || []).some(f => {
|
|
||||||
const x = f.filename;
|
|
||||||
if (x.startsWith('.github/') || x.startsWith('tests/')) return false;
|
|
||||||
if (/^(ARCHITECTURE|CONVENTIONS|CHANGELOG|README)\.md$/.test(x)) return false;
|
|
||||||
if (/^(composer\.(json|lock)|phpunit\.xml(\.dist)?|\.?phpcs\.xml\.dist)$/.test(x)) return false;
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
if (deployable) problems.push(`**${repo}**: prod behind main — prod=\`${short(prodSha)}\` vs main=\`${short(main)}\` (undeployed code changes)`);
|
|
||||||
} catch (e) {
|
|
||||||
problems.push(`**${repo}**: prod sha != main sha (could not diff: ${e.message})`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (prodSha && prodState !== 'success') problems.push(`**${repo}**: last production deployment state is \`${prodState}\``);
|
if (prodSha && prodState !== 'success') problems.push(`**${repo}**: last production deployment state is \`${prodState}\``);
|
||||||
core.info(`${repo}: main=${short(main)} lastRun=${runConc} prodDeploy=${short(prodSha)}/${prodState}`);
|
core.info(`${repo}: main=${short(main)} lastRun=${runConc} prodDeploy=${short(prodSha)}/${prodState}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -7,11 +7,6 @@
|
|||||||
*
|
*
|
||||||
* The saved auth state (playwright/.auth/admin.json) is reused by the
|
* 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.
|
* "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';
|
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 AUTH_FILE = path.join(__dirname, 'playwright/.auth/admin.json');
|
||||||
|
|
||||||
const MAX_ATTEMPTS = 3;
|
setup('authenticate as WP admin', async ({ page }) => {
|
||||||
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;
|
const user = process.env.WP_ADMIN_USER;
|
||||||
const password = process.env.WP_ADMIN_PASSWORD;
|
const password = process.env.WP_ADMIN_PASSWORD;
|
||||||
const baseURL = process.env.BASE_URL ?? 'https://staging.peptiderepo.com';
|
|
||||||
|
|
||||||
if (!user || !password) {
|
if (!user || !password) {
|
||||||
throw new Error(
|
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 });
|
fs.mkdirSync(path.dirname(AUTH_FILE), { recursive: true });
|
||||||
|
|
||||||
let lastError: unknown;
|
await page.goto('/wp-login.php');
|
||||||
|
|
||||||
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
||||||
console.log(
|
|
||||||
`[setup] Login attempt ${attempt}/${MAX_ATTEMPTS} — navigating to wp-login.php ...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// Fresh context per attempt so stale cookies / throttle state don't carry over.
|
|
||||||
const context = await browser.newContext({ baseURL });
|
|
||||||
const page = await context.newPage();
|
|
||||||
|
|
||||||
try {
|
|
||||||
await page.goto('/wp-login.php', { timeout: NAV_TIMEOUT });
|
|
||||||
await page.fill('#user_login', user);
|
await page.fill('#user_login', user);
|
||||||
await page.fill('#user_pass', password);
|
await page.fill('#user_pass', password);
|
||||||
await page.click('#wp-submit');
|
await page.click('#wp-submit');
|
||||||
|
|
||||||
// Wait for any post-login navigation. The site may redirect successful
|
// Wait for any post-login navigation. The site may redirect successful logins
|
||||||
// logins to the homepage (via a login_redirect filter) rather than to
|
// to the homepage (via a login_redirect filter) rather than to wp-admin —
|
||||||
// wp-admin — staging does this. So we don't assert the post-submit URL;
|
// staging does this. So we don't assert the post-submit URL; instead, we
|
||||||
// instead, we verify we're no longer ON wp-login.php (which would
|
// verify we're no longer ON wp-login.php (which would indicate a credential
|
||||||
// indicate a credential rejection or 2FA prompt) and then navigate
|
// rejection or 2FA prompt) and then navigate explicitly to wp-admin.
|
||||||
// explicitly to wp-admin.
|
await page.waitForURL((url) => !url.pathname.includes('/wp-login.php'), {
|
||||||
await page.waitForURL(
|
timeout: 20_000,
|
||||||
(url) => !url.pathname.includes('/wp-login.php'),
|
});
|
||||||
{ timeout: NAV_TIMEOUT }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Navigate explicitly into wp-admin to capture the authenticated admin session.
|
// Navigate explicitly into wp-admin to capture the authenticated admin session.
|
||||||
await page.goto('/wp-admin/', { timeout: NAV_TIMEOUT });
|
await page.goto('/wp-admin/');
|
||||||
await expect(page).toHaveURL(/\/wp-admin\//, { timeout: 20_000 });
|
await expect(page).toHaveURL(/\/wp-admin\//, { timeout: 20_000 });
|
||||||
await expect(page.locator('#wpadminbar')).toBeVisible({ timeout: 20_000 });
|
await expect(page.locator('#wpadminbar')).toBeVisible();
|
||||||
|
|
||||||
// Persist session cookies + localStorage to disk
|
// Persist session cookies + localStorage to disk
|
||||||
await page.context().storageState({ path: AUTH_FILE });
|
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.`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,13 +40,30 @@ test.describe('Reconstitution Calculator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('fills inputs and gets a numeric result', async ({ page }) => {
|
test('fills inputs and gets a numeric result', async ({ page }) => {
|
||||||
const calc = page.locator('.prc-calculator');
|
// Select BPC-157 or the first non-placeholder option
|
||||||
// The calculator auto-computes once a peptide preset is chosen (the preset
|
const select = page.locator('select').first();
|
||||||
// supplies vial size, recommended water volume and a default dose).
|
const firstPeptide = select.locator('option').nth(1);
|
||||||
await calc.locator('#prc-peptide-select').selectOption({ index: 1 });
|
const firstValue = await firstPeptide.getAttribute('value');
|
||||||
// Results panel unhides and renders numeric result cards.
|
await select.selectOption(firstValue ?? '');
|
||||||
const results = page.locator('#prc-results');
|
|
||||||
await expect(results).toBeVisible({ timeout: 10_000 });
|
// Fill reconstitution volume (mL) — use a known valid value
|
||||||
await expect(page.locator('.prc-result-card__value').first()).toHaveText(/\d/, { timeout: 5_000 });
|
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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ test.describe('Peptide Search AI', () => {
|
|||||||
test('search input widget is present on page', async ({ page }) => {
|
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
|
// PSA renders a form with class .psa-search-form or input with data-psa attr
|
||||||
const searchInput = page.locator(
|
const searchInput = page.locator(
|
||||||
'.hero-search .psa-search-input'
|
'.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input'
|
||||||
).first();
|
).first();
|
||||||
await expect(searchInput).toBeVisible({ timeout: 10_000 });
|
await expect(searchInput).toBeVisible({ timeout: 10_000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('searching for a known peptide returns results', async ({ page }) => {
|
test('searching for a known peptide returns results', async ({ page }) => {
|
||||||
const searchInput = page.locator(
|
const searchInput = page.locator(
|
||||||
'.hero-search .psa-search-input'
|
'.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input'
|
||||||
).first();
|
).first();
|
||||||
await expect(searchInput).toBeVisible();
|
await expect(searchInput).toBeVisible();
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ test.describe('Peptide Search AI', () => {
|
|||||||
await searchInput.press('Enter');
|
await searchInput.press('Enter');
|
||||||
|
|
||||||
// Results container should appear and contain something
|
// 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 });
|
await expect(results).toBeVisible({ timeout: 15_000 });
|
||||||
const text = await results.textContent();
|
const text = await results.textContent();
|
||||||
expect((text ?? '').trim().length).toBeGreaterThan(0);
|
expect((text ?? '').trim().length).toBeGreaterThan(0);
|
||||||
@@ -57,7 +57,7 @@ test.describe('Peptide Search AI', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const searchInput = page.locator(
|
const searchInput = page.locator(
|
||||||
'.hero-search .psa-search-input'
|
'.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input'
|
||||||
).first();
|
).first();
|
||||||
await searchInput.fill('TB-500');
|
await searchInput.fill('TB-500');
|
||||||
await searchInput.press('Enter');
|
await searchInput.press('Enter');
|
||||||
|
|||||||
@@ -97,11 +97,10 @@ test.describe('WP Admin — PRAutoBlogger settings page', () => {
|
|||||||
test.describe('WP Admin — Peptide Repo Core admin', () => {
|
test.describe('WP Admin — Peptide Repo Core admin', () => {
|
||||||
test('PR Core menu item exists in wp-admin', async ({ page }) => {
|
test('PR Core menu item exists in wp-admin', async ({ page }) => {
|
||||||
await page.goto(`${ADMIN}/`);
|
await page.goto(`${ADMIN}/`);
|
||||||
// PR Core registers the peptide CPT which creates a "Peptides" menu item
|
// PR Core registers the peptide CPT which creates a "Peptides" menu item const nav = page.locator('#adminmenu');
|
||||||
const nav = page.locator('#adminmenu');
|
|
||||||
await expect(nav).toBeVisible();
|
await expect(nav).toBeVisible();
|
||||||
// PR Core registers the peptide CPT, which adds a post_type=peptide admin menu/submenu (label-agnostic).
|
// "Peptides" top-level menu item is registered by the peptide CPT
|
||||||
await expect(nav.locator('a[href*="post_type=peptide"]').first()).toBeAttached({ timeout: 10_000 });
|
await expect(nav.locator('text=Peptides')).toBeVisible({ timeout: 10_000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('PR Core Settings page loads', async ({ page }) => {
|
test('PR Core Settings page loads', async ({ page }) => {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ test.describe('REST API — Peptide Search AI', () => {
|
|||||||
expect([200, 404]).toContain(res.status());
|
expect([200, 404]).toContain(res.status());
|
||||||
if (res.status() === 200) {
|
if (res.status() === 200) {
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
|
expect(body).toHaveProperty('status');
|
||||||
expect(body).toHaveProperty('results');
|
expect(body).toHaveProperty('results');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user