SPB Git

Repository Public

studio-phone.spec.ts 2.6 KB 42 lines typescript

1import { expect, test } from "@playwright/test";23/** The studio on a phone-sized touch screen, with the session of the studio journey. */4test.use({ storageState: "e2e/.auth.json" });5const noOverflow = async (p: import("@playwright/test").Page) => expect(await p.evaluate(() => document.documentElement.scrollWidth - window.innerWidth)).toBeLessThanOrEqual(1);67test("dashboard, creation form, media, templates and settings fit a 390 px screen", async ({ page }) => {8  for (const path of ["/admin", "/admin/sheets/new", "/admin/assets", "/admin/templates", "/admin/settings", "/admin/revisions"]) {9    await page.goto(path);10    await expect(page.getByRole("heading", { level: 1 })).toBeVisible();11    await page.waitForLoadState("networkidle");12    await noOverflow(page);13    await page.screenshot({ path: `e2e/screenshots/phone-${path.replace(/\W+/g, "-")}.png` });14  }15  // The bottom tab bar is there and its targets are thumb-sized.16  const nav = page.getByRole("navigation").last();17  for (const link of await nav.getByRole("link").all()) expect((await link.boundingBox())!.height).toBeGreaterThanOrEqual(44);18});1920test("the editor on a phone: canvas full width, action bar, drawers", async ({ page }) => {21  await page.goto("/admin");22  await page.waitForLoadState("networkidle");23  await page.locator('a[href*="/edit"]').first().click();24  await expect(page).toHaveURL(/\/edit/);25  await expect(page.locator(".sheet h1")).toBeVisible();26  await noOverflow(page);27  for (const name of ["Enregistrer", "Aperçu", "Publier"]) { const b = page.getByRole("button", { name, exact: true }).last(); await expect(b).toBeVisible(); expect((await b.boundingBox())!.height).toBeGreaterThanOrEqual(36); }28  // One-column layout: every block spans the sheet's width.29  const widths = await page.locator(".sheet .sh-grid > .sh-block").evaluateAll((els) => els.map((e) => Math.round(e.getBoundingClientRect().width)));30  expect(new Set(widths).size).toBe(1);31  await page.locator('[data-block-id="intro"]').tap();32  await page.getByRole("button", { name: "Propriétés", exact: true }).last().tap();33  const drawer = page.getByRole("dialog");34  await expect(drawer.locator("textarea").first()).toBeVisible();35  await page.screenshot({ path: "e2e/screenshots/phone-editor-drawer.png" });36  await drawer.getByRole("button", { name: "Claude" }).tap();37  await expect(drawer.locator("#ai-instruction")).toBeVisible();38  await drawer.getByRole("button", { name: "Blocs" }).tap();39  await expect(drawer.getByRole("button").nth(3)).toBeVisible();40  await page.screenshot({ path: "e2e/screenshots/phone-editor-blocks.png" });41});42
Files main
Menu

Theme