import { expect, test } from '../helpers/serve-dist'; import { environmentChunkPattern, installSceneInstrumentation, readSceneInstrumentation, } from '../helpers/scene-instrumentation'; test.beforeEach(async ({ page }) => installSceneInstrumentation(page)); test('boots reduced motion without requesting the live scene or automatic media', async ({ page, distUrl }) => { const requests: string[] = []; page.on('request', (request) => requests.push(request.url())); await page.emulateMedia({ reducedMotion: 'reduce' }); await page.goto(distUrl, { waitUntil: 'domcontentloaded' }); await expect(page.locator('.journey-poster')).toHaveCount(1); await expect(page.locator('.journey-canvas')).toHaveCount(0); await expect(page.locator('.journey-hud')).toBeVisible(); await expect(page.locator('nav[aria-label="Portfolio sections"]')).toBeVisible(); await expect(page.locator('#contact a[href^="mailto:"]')).toBeVisible(); await expect(page.getByRole('status')).toContainText('reduced motion requested'); expect(requests.some((url) => environmentChunkPattern.test(url))).toBe(false); await expect(page.locator('video[src], video source[src]')).toHaveCount(0); expect((await readSceneInstrumentation(page)).routeLabelsDrawn).toEqual([]); }); test('requires explicit Enable motion after the system stops requesting reduction', async ({ page, distUrl }) => { const requests: string[] = []; page.on('request', (request) => requests.push(request.url())); await page.emulateMedia({ reducedMotion: 'reduce' }); await page.goto(distUrl, { waitUntil: 'domcontentloaded' }); await page.emulateMedia({ reducedMotion: 'no-preference' }); await expect(page.getByRole('button', { name: 'Enable motion' })).toBeVisible(); expect(requests.some((url) => environmentChunkPattern.test(url))).toBe(false); await page.getByRole('button', { name: 'Enable motion' }).click(); await expect.poll(() => requests.some((url) => environmentChunkPattern.test(url))).toBe(true); });