const { chromium } = require(process.env.REVIEW_PLAYWRIGHT); const assert = require('node:assert/strict'); (async () => { const browser = await chromium.launch({ headless: true }); try { const page = await browser.newPage(); let mode = 'ready'; await page.route('**/api/**', route => { if (route.request().url().endsWith('/auth/me')) return route.fulfill({ json: { username: 'Tester', role: 'user' } }); if (route.request().url().endsWith('/site/info')) return route.fulfill({ status: mode === 'unauthorized' ? 401 : 200, json: { mediaServerUrl: mode === 'missing' ? null : 'https://watch.example.com/' } }); return route.fulfill({ json: {} }); }); for (const width of [1440, 390]) { await page.setViewportSize({ width, height: 900 }); await page.goto('http://127.0.0.1:3103/welcome'); await page.getByRole('link', { name: /Go to GrizzlyFlix/ }).waitFor(); assert.equal(await page.getByRole('link', { name: /Go to GrizzlyFlix/ }).getAttribute('href'), 'https://watch.example.com/'); assert.equal(await page.getByRole('link', { name: /Manage your account/ }).getAttribute('href'), '/'); assert.equal(await page.locator('.header').count(), 0); assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)); await page.goto('http://127.0.0.1:3103/how-it-works'); await page.getByText('Understand the six progress steps').click(); await page.getByText('Your request has been received.').waitFor(); assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)); } mode = 'missing'; await page.goto('http://127.0.0.1:3103/welcome'); await page.getByText(/watch link hasn’t been set up/).waitFor(); mode = 'unauthorized'; await page.goto('http://127.0.0.1:3103/welcome'); await page.waitForURL('**/login'); console.log('Welcome and guide checks passed: desktop, mobile, links, disclosure, missing URL, auth redirect.'); } finally { await browser.close(); } })().catch(error => { console.error(error); process.exit(1); });