From b7dac5d46305114fdea7bf1eb3101465b3c48b23 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Mon, 2 Mar 2026 15:58:51 +0100 Subject: [PATCH] fix(ci): rewrite check-forms with KLZ pattern (executablePath, networkidle2, 60s timeout) --- apps/web/scripts/check-forms.ts | 34 +++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/apps/web/scripts/check-forms.ts b/apps/web/scripts/check-forms.ts index 999054f..993ce2d 100644 --- a/apps/web/scripts/check-forms.ts +++ b/apps/web/scripts/check-forms.ts @@ -1,49 +1,63 @@ import puppeteer from "puppeteer"; const targetUrl = process.env.TEST_URL || "http://localhost:3000"; -const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || "secret"; // Use ENV or default +const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || "secret"; async function main() { console.log(`\n๐Ÿš€ Starting E2E Form Submission Check for: ${targetUrl}`); + // Launch browser with KLZ pattern: use system chromium via env const browser = await puppeteer.launch({ headless: true, - args: ["--no-sandbox", "--disable-setuid-sandbox"], + executablePath: + process.env.PUPPETEER_EXECUTABLE_PATH || + process.env.CHROME_PATH || + undefined, + args: [ + "--no-sandbox", + "--disable-setuid-sandbox", + "--disable-dev-shm-usage", + ], }); const page = await browser.newPage(); try { + // Authenticate through Gatekeeper console.log(`\n๐Ÿ›ก๏ธ Authenticating through Gatekeeper...`); - await page.goto(targetUrl, { waitUntil: "networkidle0" }); + await page.goto(targetUrl, { waitUntil: "networkidle2", timeout: 60000 }); const isGatekeeperPage = await page.$('input[name="password"]'); if (isGatekeeperPage) { await page.type('input[name="password"]', gatekeeperPassword); await Promise.all([ - page.waitForNavigation({ waitUntil: "networkidle2" }), + page.waitForNavigation({ waitUntil: "networkidle2", timeout: 60000 }), page.click('button[type="submit"]'), ]); console.log(`โœ… Gatekeeper authentication successful!`); + } else { + console.log(`โœ… Already authenticated (no Gatekeeper gate detected).`); } - console.log(`\n๐Ÿงช Testing Contact Form submission...`); - // Note: This needs to be adapted to the actual selectors on mintel.me - // For now, we perform a simple smoke test of the home page + // Basic smoke test + console.log(`\n๐Ÿงช Testing page load...`); const title = await page.title(); console.log(`โœ… Page Title: ${title}`); if (title.toLowerCase().includes("mintel")) { console.log(`โœ… Basic smoke test passed!`); } else { - throw new Error("Page title mismatch"); + throw new Error(`Page title mismatch: "${title}"`); } } catch (err: any) { console.error(`โŒ Test Failed: ${err.message}`); - process.exit(1); - } finally { await browser.close(); + process.exit(1); } + + await browser.close(); + console.log(`\n๐ŸŽ‰ SUCCESS: E2E smoke test passed!`); + process.exit(0); } main();