Files
archie/e2e/checks/audit-phone.cjs
T

43 lines
1.6 KiB
JavaScript

// The audit page at phone width: secondary columns collapse, and the list,
// an expanded row and the filters dialog fit without horizontal overflow.
const assert = require('node:assert/strict');
const { trackAudit } = require('./helpers/audit-helpers.cjs');
module.exports = async ({ page, go, shot, fail, settled }) => {
trackAudit(page);
await page.setViewportSize({ width: 390, height: 844 });
await go('/settings/audit');
const assertNoOverflow = async (label) => {
const { scrollWidth, innerWidth } = await page.evaluate(() => ({
scrollWidth: document.documentElement.scrollWidth,
innerWidth,
}));
if (scrollWidth > innerWidth) {
fail(`${label} overflows 390px: documentElement.scrollWidth=${scrollWidth} > innerWidth=${innerWidth}`);
}
};
await page.locator('[data-row-key]').first().waitFor();
await assertNoOverflow('audit list');
assert.equal(
await page.locator('thead th', { hasText: 'Target' }).first().evaluate((el) => getComputedStyle(el).display),
'none',
'secondary columns are still rendered on the phone',
);
await shot('list');
const phoneRow = page.locator('[data-row-key]').first();
await phoneRow.focus();
await page.keyboard.press('Enter');
await settled();
assert.equal(await phoneRow.getAttribute('aria-expanded'), 'true', 'phone row did not expand');
await assertNoOverflow('expanded change set');
await shot('expanded');
await page.getByRole('button', { name: 'Filters', exact: true }).click();
await page.getByRole('dialog').first().waitFor();
await settled();
await assertNoOverflow('advanced filters');
await shot('filters');
};