'use strict'; // Runs in the `mobile` project (Pixel 7): pages must fit the phone width, // with no horizontal page scroll. Wide content (tables, code) scrolls inside // its own box instead. const { test, expect } = require('./fixtures'); const PATHS = ['/', '/ticket/100000001', '/ticket/100000002', '/ticket/create']; for (const path of PATHS) { test(`${path} fits a phone screen`, async ({ page }) => { await page.goto(path); await page.waitForLoadState('networkidle'); const overflow = await page.evaluate(() => { const doc = document.documentElement; const wide = [...document.querySelectorAll('body *')] .filter(el => el.getBoundingClientRect().right > doc.clientWidth + 1 && el.getClientRects().length) .slice(0, 5) .map(el => el.tagName.toLowerCase() + (el.id ? '#' + el.id : '') + (typeof el.className === 'string' && el.className.trim() ? '.' + el.className.trim().split(/\s+/).join('.') : '')); return { scrollWidth: doc.scrollWidth, clientWidth: doc.clientWidth, wide }; }); expect(overflow.scrollWidth, `wider than the screen: ${overflow.wide.join(', ')}`) .toBeLessThanOrEqual(overflow.clientWidth); }); }