From 3ed4b10ecd83a79bc6716fcb0b0f5b4fb35e441f Mon Sep 17 00:00:00 2001 From: peptiderepo <273788462+peptiderepo@users.noreply.github.com> Date: Tue, 9 Jun 2026 22:20:39 +0700 Subject: [PATCH] test(smoke): fix remaining 6 failures (#8) - 02 search: target the visible .hero-search instance; the old .first() selector matched the hidden header search-overlay (instance 1). - 01 calculator: it auto-computes from the peptide preset; select the peptide and assert #prc-results, scoped to .prc-calculator (the old broad button[type=submit] selector clicked the PSA search button). - 03 admin: 'const nav' had been swallowed into a comment (ReferenceError). - 04 rest-api: PSA /search returns {results:[]} with no 'status' key; drop it. Auth fixed separately via a dedicated staging CI admin (ci-smoke) + corrected STAGING_WP_ADMIN_* secrets; the global.setup failure was cascading into these. Agent-Session: cto smoke-green Co-authored-by: peptiderepo --- tests/01-reconstitution-calculator.spec.ts | 37 ++++++---------------- tests/02-peptide-search.spec.ts | 8 ++--- tests/03-admin-plugins.spec.ts | 3 +- tests/04-rest-api.spec.ts | 1 - 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/tests/01-reconstitution-calculator.spec.ts b/tests/01-reconstitution-calculator.spec.ts index ea84c0f..e967e02 100755 --- a/tests/01-reconstitution-calculator.spec.ts +++ b/tests/01-reconstitution-calculator.spec.ts @@ -39,31 +39,14 @@ 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 }) => { - // 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 - }); + 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 }); + }); }); diff --git a/tests/02-peptide-search.spec.ts b/tests/02-peptide-search.spec.ts index 7f6bd6b..e062d10 100755 --- a/tests/02-peptide-search.spec.ts +++ b/tests/02-peptide-search.spec.ts @@ -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( - '.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input' + '.hero-search .psa-search-input' ).first(); await expect(searchInput).toBeVisible({ timeout: 10_000 }); }); test('searching for a known peptide returns results', async ({ page }) => { const searchInput = page.locator( - '.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input' + '.hero-search .psa-search-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('.psa-results, .psa-search-results, [data-psa-results]').first(); + const results = page.locator('.hero-search .psa-search-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( - '.psa-search-form input, input[name*="peptide"], input[placeholder*="peptide" i], [data-psa] input' + '.hero-search .psa-search-input' ).first(); await searchInput.fill('TB-500'); await searchInput.press('Enter'); diff --git a/tests/03-admin-plugins.spec.ts b/tests/03-admin-plugins.spec.ts index a75f026..a0c97bf 100755 --- a/tests/03-admin-plugins.spec.ts +++ b/tests/03-admin-plugins.spec.ts @@ -97,7 +97,8 @@ test.describe('WP Admin — PRAutoBlogger settings page', () => { 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(); // "Peptides" top-level menu item is registered by the peptide CPT await expect(nav.locator('text=Peptides')).toBeVisible({ timeout: 10_000 }); diff --git a/tests/04-rest-api.spec.ts b/tests/04-rest-api.spec.ts index ed8bbe3..0a94627 100755 --- a/tests/04-rest-api.spec.ts +++ b/tests/04-rest-api.spec.ts @@ -38,7 +38,6 @@ 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'); } });