Files
Portfolio/tests/browser/media-policy.spec.ts

29 lines
1.3 KiB
TypeScript

import { expect, test } from '../helpers/serve-dist';
test('pending approval renders a complete text-first portfolio without media requests or broken placeholders', async ({ page, distUrl }) => {
const mediaRequests: string[] = [];
page.on('request', (request) => {
if (/\.(?:avif|jpe?g|png|webp|mp4|webm)(?:$|\?)/iu.test(request.url())) mediaRequests.push(request.url());
});
await page.goto(distUrl, { waitUntil: 'networkidle' });
await expect(page.locator('main > section')).toHaveCount(8);
await expect(page.locator('#selected-builds article')).toHaveCount(3);
await expect(page.locator('#additional-work article')).toHaveCount(4);
await expect(page.locator('[data-project-media]')).toHaveCount(0);
await expect(page.locator('.journey-poster')).not.toHaveAttribute('src', /.+/u);
expect(mediaRequests).toEqual([]);
});
test('reduced motion does not introduce automatic project media payloads', async ({ page, distUrl }) => {
const videoRequests: string[] = [];
page.on('request', (request) => {
if (/\.(?:mp4|webm)(?:$|\?)/iu.test(request.url())) videoRequests.push(request.url());
});
await page.emulateMedia({ reducedMotion: 'reduce' });
await page.goto(distUrl, { waitUntil: 'networkidle' });
await expect(page.locator('video[src], video source[src]')).toHaveCount(0);
expect(videoRequests).toEqual([]);
});