SPB Git

Repository Public

responsive.spec.ts 3.8 KB 92 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : agentilab-web8 * File             : tests/e2e/responsive.spec.ts9 * Module           : Tests10 * Repository       : https://git.spboucher.ai/agentilab-web11 * Project Website  : Not specified12 * Created          : 2026-12-0513 * Last Modified    : 2026-12-0514 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : Proprietary34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import { expect, test } from '@playwright/test';44import { pages } from './helpers';4546const WIDTHS = [320, 390, 768, 1024, 1440, 1920];4748for (const { path } of pages) {49  test(`${path} : aucun débordement horizontal de 320 à 1920 px`, async ({ page }) => {50    for (const width of WIDTHS) {51      await page.setViewportSize({ width, height: 900 });52      await page.goto(path);53      const overflow = await page.evaluate(() => {54        const limit = document.documentElement.clientWidth;55        const culprits = [...document.querySelectorAll('body *')]56          .filter((el) => {57            const rect = el.getBoundingClientRect();58            return rect.width > 0 && (rect.right > limit + 1 || rect.left < -1) && !el.closest('.sr-only, .skip-link');59          })60          .slice(0, 3)61          .map((el) => `${el.tagName}.${el.className}`);62        return { scroll: document.documentElement.scrollWidth - limit, culprits };63      });64      expect(overflow, `${path} à ${width}px`).toEqual({ scroll: 0, culprits: [] });65    }66  });67}6869test('zoom 200 % : le contenu reste lisible sans défilement horizontal', async ({ page }) => {70  // Un zoom de 200 % sur 1280 px équivaut à une fenêtre CSS de 640 px.71  await page.setViewportSize({ width: 640, height: 450 });72  await page.goto('/');73  expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBe(0);74  await expect(page.getByRole('heading', { level: 1 })).toBeVisible();75});7677test('prefers-reduced-motion : aucune animation', async ({ page }) => {78  await page.emulateMedia({ reducedMotion: 'reduce' });79  await page.goto('/');80  const animated = await page.evaluate(() => [...document.querySelectorAll('*')].filter((el) => getComputedStyle(el).animationName !== 'none').length);81  expect(animated).toBe(0);82});8384test('boutons et liens d’action : au moins 44 px de haut', async ({ page }) => {85  await page.setViewportSize({ width: 390, height: 844 });86  await page.goto('/ecosysteme');87  for (const el of await page.locator('.btn, .filter, .lang, .mnav > summary').all()) {88    if (!(await el.isVisible())) continue;89    expect((await el.boundingBox())?.height ?? 0).toBeGreaterThanOrEqual(44);90  }91});92
Files main
Menu

Theme