// The Roster stream in WebKit: as an iPhone (390x844 at 3x, touch) and at // 1280, light and dark. Measures testdata/roster-geometry.js with the // decision card beside its report and with it set aside, and saves a shot // of each when cfg.art names a directory. Prints one JSON object. import { createRequire } from "node:module"; import { readFileSync } from "node:fs"; const require = createRequire(import.meta.url); const { webkit } = require(process.env.EQUIPO_PLAYWRIGHT_CORE); const cfg = JSON.parse(process.env.EQUIPO_ROSTER); const geometry = readFileSync("testdata/roster-geometry.js", "utf8"); const out = {}; const browser = await webkit.launch(); try { for (const width of [390, 1280]) for (const scheme of ["light", "dark"]) { const phone = width === 390; const ctx = await browser.newContext(phone ? { viewport: { width, height: 844 }, deviceScaleFactor: 3, hasTouch: true, isMobile: true, colorScheme: scheme } : { viewport: { width, height: 900 }, colorScheme: scheme }); await ctx.addCookies([{ name: cfg.cookie.name, value: cfg.cookie.value, url: cfg.base }]); const page = await ctx.newPage(); await page.goto(cfg.base + "/conversation"); await page.waitForFunction(() => document.querySelector("[equipo-offline]").hidden && !!document.querySelector("[data-roster-enhanced]")); const measure = phase => page.evaluate(`(${geometry})(${JSON.stringify(phase)}, ${phone})`); const shot = async (name, sel) => { if (!cfg.art) return; if (sel) await page.evaluate(s => document.querySelector(s).scrollIntoView({ block: "center" }), sel); await page.waitForTimeout(150); await page.screenshot({ path: `${cfg.art}/roster-${name}-${width}-${scheme}.png` }); }; const res = {}; await shot("report", "[equipo-roster-report]"); await shot("question", "[equipo-mini-pill]"); res.compact = await measure("compact"); await shot("end"); await page.click('[equipo-card="merge"] [data-set-aside]'); await page.waitForSelector('[equipo-card="merge"] [equipo-aside-stub]'); await page.waitForSelector("[equipo-roster-report] [data-track]"); await shot("full", "[equipo-roster-report]"); res.full = await measure("full"); await page.click('[equipo-card="merge"] [equipo-aside-stub] [data-aside-undo]'); await page.waitForSelector('[equipo-card="merge"] [data-set-aside]'); out[`${width}-${scheme}`] = res; await ctx.close(); } } finally { await browser.close(); } console.log(JSON.stringify(out));