import puppeteer from "puppeteer"; const targetUrl = process.env.TEST_URL || "http://localhost:3000"; const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || "secret"; // Use ENV or default async function main() { console.log(`\n๐Ÿš€ Starting E2E Form Submission Check for: ${targetUrl}`); const browser = await puppeteer.launch({ headless: true, args: ["--no-sandbox", "--disable-setuid-sandbox"], }); const page = await browser.newPage(); try { console.log(`\n๐Ÿ›ก๏ธ Authenticating through Gatekeeper...`); await page.goto(targetUrl, { waitUntil: "networkidle0" }); const isGatekeeperPage = await page.$('input[name="password"]'); if (isGatekeeperPage) { await page.type('input[name="password"]', gatekeeperPassword); await Promise.all([ page.waitForNavigation({ waitUntil: "networkidle2" }), page.click('button[type="submit"]'), ]); console.log(`โœ… Gatekeeper authentication successful!`); } 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 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"); } } catch (err: any) { console.error(`โŒ Test Failed: ${err.message}`); process.exit(1); } finally { await browser.close(); } } main();