#!/usr/bin/env node /** Screenshot public HTTPS doors after signing in (staff IAM + customer portal). */ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import puppeteer from 'puppeteer-core'; const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); const SHOTS = path.join(ROOT, 'screenshots', 'live'); const CHROME = process.env.CHROME_PATH || '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; fs.mkdirSync(SHOTS, { recursive: true }); const wait = (ms) => new Promise((r) => setTimeout(r, ms)); const browser = await puppeteer.launch({ executablePath: CHROME, headless: 'new', args: ['--no-sandbox', '--window-size=1280,800', '--disable-dev-shm-usage'], defaultViewport: { width: 1280, height: 800 }, }); async function goto(page, url) { try { await page.goto(url, { waitUntil: 'networkidle2', timeout: 25000 }); } catch { await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 15000 }).catch(() => {}); } await wait(700); } async function shot(page, file) { const dest = path.join(SHOTS, file); await page.screenshot({ path: dest, fullPage: false }); process.stdout.write(`wrote ${dest}\n`); } try { const page = await browser.newPage(); await goto(page, 'https://iam.zapier.georgelambert.org/login'); await page.waitForSelector('#username', { timeout: 15000 }); await page.type('#username', 'admin'); await page.type('#password', 'admin-dev-key'); await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 20000 }).catch(() => {}), page.click('button[type="submit"]'), ]); await wait(1200); await shot(page, 'iam.png'); for (const [file, url] of [ ['fleet.png', 'https://fleet.zapier.georgelambert.org/'], ['cs.png', 'https://cs.zapier.georgelambert.org/'], ['sales.png', 'https://sales.zapier.georgelambert.org/'], ['acct.png', 'https://acct.zapier.georgelambert.org/'], ['staff.png', 'https://staff.zapier.georgelambert.org/'], ['login.png', 'https://login.zapier.georgelambert.org/'], ]) { await goto(page, url); await wait(800); await shot(page, file); } for (const [file, url] of [ ['api.png', 'https://api.zapier.georgelambert.org/health'], ['leaf.png', 'https://leaf.zapier.georgelambert.org/health'], ['zap.png', 'https://zap.zapier.georgelambert.org/health'], ['mw.png', 'https://mw.zapier.georgelambert.org/health'], ['git.png', 'https://git.georgelambert.org/'], ]) { await goto(page, url); await shot(page, file); } await goto(page, 'https://portal.zapier.georgelambert.org/portal/'); const toggle = await page.$('#auth-toggle'); if (toggle) await toggle.click(); await wait(300); const name = await page.$('#auth-name'); if (name) { const email = `docs-capture-${Date.now()}@example.com`; await page.type('#auth-name', 'Docs Capture'); await page.type('#auth-email', email); await page.type('#auth-password', 'DocsCapture-dev-1!'); await page.click('#auth-submit'); await page.waitForSelector('#shell.on', { timeout: 20000 }).catch(() => {}); await wait(1200); } await shot(page, 'portal.png'); await goto(page, 'https://zapier.georgelambert.org/'); await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); await wait(400); await shot(page, 'docs.png'); await page.close(); } finally { await browser.close(); }