24 lines
1.2 KiB
JavaScript
24 lines
1.2 KiB
JavaScript
'use strict';
|
|||
|
|
|
||
|
|
// Runs in the `mobile` project (Pixel 7). Every page must fit the phone width:
|
||
|
|
// no horizontal page scroll, and the heading on screen.
|
||
|
|
const { test, expect } = require('./fixtures');
|
||
|
|
|
||
|
|
const PATHS = ['/', '/workers', '/workflows', '/executions', '/quick', '/scheduler'];
|
||
|
|
|
||
|
|
for (const path of PATHS) {
|
||
|
|
test(`${path} fits a phone screen`, async ({ page }) => {
|
||
|
|
await page.goto(path);
|
||
|
|
await page.waitForLoadState('networkidle');
|
||
|
|
await expect(page.getByRole('heading', { level: 1 })).toBeInViewport();
|
||
|
|
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 : '') + (el.className && typeof el.className === 'string' ? '.' + 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);
|
||
|
|
});
|
||
|
|
}
|