// Phone-width sweep of the views the November audit flagged (#1757): at // 390x844 each must fit without horizontal scroll or clipped controls. The // topbar (with its instance badge) is on every page; /account holds the // token form, /org/agents the agent rows and the grants card, /events the // sources table, the event-type rule editor and the mapping editor dialog. const assert = require('node:assert/strict'); const { staticRoutes } = require('./helpers/routes.cjs'); module.exports = async ({ page, go, shot, fail, settled, tolerate }) => { // The extension catalogue 502 is a stack-environment issue, not this check. tolerate(/extensions\/catalogue/); await page.setViewportSize({ width: 390, height: 844 }); const assertNoOverflow = async (label) => { const { scrollWidth, innerWidth } = await page.evaluate(() => ({ scrollWidth: document.documentElement.scrollWidth, innerWidth: window.innerWidth, })); if (scrollWidth > innerWidth) { fail(`${label} overflows 390px: scrollWidth=${scrollWidth} > innerWidth=${innerWidth}`); } }; const visit = async (path, label, waitFor) => { await go(path); if (waitFor) await settled(waitFor); await assertNoOverflow(label); await shot(label); }; await visit('/account', 'account-tokens', 'text=API tokens'); await visit('/org/agents', 'org-agents', 'text=Credential grants'); await go('/events'); await settled('[role=tab]'); await assertNoOverflow('events'); await shot('events'); // The seeded event type's rule editor (RuleEditor's condition row) opens // from the Edit button on its row. const editType = page.locator('button[aria-label^="Edit "]').first(); if (await editType.count()) { await editType.click(); await page.getByRole('dialog').first().waitFor(); await settled(); await assertNoOverflow('event-type rule editor'); await shot('rule-editor'); await page.keyboard.press('Escape'); await settled(); } // The mappings tab's editor dialog carries the payload tree. await page.getByRole('tab', { name: 'Map' }).click(); await settled('text=New mapping'); await assertNoOverflow('mappings list'); const editMapping = page.locator('button', { hasText: 'Edit' }).first(); if (await editMapping.count()) { await editMapping.click(); await page.getByRole('dialog').first().waitFor(); await settled(); await assertNoOverflow('mapping editor dialog'); await shot('mapping-editor'); } // Every static route fits 390px (#1767): horizontal scroll fails. for (const r of staticRoutes()) { await visit(r, `route ${r}`, null); } };