SPB Git

Repository Public

mobile.spec.ts 3.3 KB 52 lines typescript

1import { expect, test } from "@playwright/test";2import { PREVIEW, PROD, S01, expectNoAccountPrompt } from "./helpers";34/** 375 px wide, touch. Nothing may overflow sideways; the menu, the player and the quiz must be usable. */5const noOverflow = async (page: import("@playwright/test").Page, label: string) =>6  expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth), `débordement horizontal : ${label}`).toBeLessThanOrEqual(0);78test("menu mobile et navigation", async ({ page }) => {9  await page.goto(PROD + "/");10  await expect(page.getByRole("navigation", { name: "Navigation principale", exact: true })).toBeHidden();11  const toggle = page.getByRole("button", { name: "Ouvrir le menu" });12  await expect(toggle).toHaveAttribute("aria-expanded", "false");13  await toggle.tap();14  const menu = page.getByRole("navigation", { name: "Navigation principale (mobile)" });15  await expect(menu).toBeVisible();16  await page.keyboard.press("Escape");17  await expect(menu).toBeHidden();18  await page.getByRole("button", { name: "Ouvrir le menu" }).tap();19  await menu.getByRole("link", { name: "Programme" }).tap();20  await expect(page).toHaveURL(/\/programme$/);21  await expect(menu).toBeHidden(); // closes on navigation22  await noOverflow(page, "/programme");23});2425test("aucun débordement à 375 px, en aperçu comme en production", async ({ page }) => {26  const routes = ["/", "/programme", S01, `${S01}/regarder`, "/parcours", "/laboratoires", "/ressources", "/glossaire", "/recherche?q=jeton", "/confidentialite", "/accessibilite"];27  for (const path of routes) { await page.goto(PROD + path, { waitUntil: "networkidle" }); await noOverflow(page, `production ${path}`); }28  for (const path of [...routes, "/apercu", "/schemas", "/schemas/attention", "/schemas/terminal-shell", "/schemas/flux-git", "/schemas/hebergement-modeles", "/schemas/carte-mcp", "/schemas/evaluation-agents"]) {29    await page.goto(PREVIEW + path, { waitUntil: "networkidle" }); await noOverflow(page, `aperçu ${path}`);30    await expectNoAccountPrompt(page);31  }32});3334test("lecteur et quiz utilisables au doigt", async ({ page }) => {35  await page.goto(`${PREVIEW}${S01}/regarder`);36  await expect(page.getByTestId("player")).toHaveAttribute("data-status", "pret", { timeout: 20_000 });37  await page.getByTestId("big-play").tap();38  await expect.poll(() => page.getByTestId("video").evaluate((v: HTMLVideoElement) => v.currentTime), { timeout: 15_000 }).toBeGreaterThan(0.5);39  // Controls are large enough to tap (at least 40 px)40  for (const id of ["play-toggle", "captions-toggle", "help-toggle"]) { const box = await page.getByTestId(id).boundingBox(); expect(Math.min(box!.width, box!.height), id).toBeGreaterThanOrEqual(40); }41  await page.getByRole("tab", { name: /Chapitres/ }).tap();42  await page.getByTestId("chapter").nth(1).tap();43  await expect.poll(() => page.getByTestId("video").evaluate((v: HTMLVideoElement) => v.currentTime)).toBeGreaterThanOrEqual(30);44  await noOverflow(page, "lecteur");45  await page.goto(PREVIEW + S01 + "#quiz");46  const q1 = page.locator('[data-question="S01-Q01"]');47  await q1.getByText("mais pas de l'apprentissage automatique").tap();48  await q1.getByRole("button", { name: "Vérifier ma réponse" }).tap();49  await expect(q1.getByTestId("feedback")).toContainText("Bonne réponse");50  await noOverflow(page, "quiz corrigé");51});52
Files main
Menu

Theme