diff --git a/e2e/checks/phone-overflow.cjs b/e2e/checks/phone-overflow.cjs new file mode 100644 index 000000000..60e3dfd30 --- /dev/null +++ b/e2e/checks/phone-overflow.cjs @@ -0,0 +1,61 @@ +// 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'); + +module.exports = async ({ page, go, shot, fail, settled }) => { + 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'); + } +}; diff --git a/ui/src/accounts/PersonalTokensCard.vue b/ui/src/accounts/PersonalTokensCard.vue index fdaf64032..111bed26a 100644 --- a/ui/src/accounts/PersonalTokensCard.vue +++ b/ui/src/accounts/PersonalTokensCard.vue @@ -75,8 +75,8 @@ onMounted(load);