sokko-g/e2e/production/onboarding.spec.js
Shinuwa 27a6c90c25
Some checks failed
Validate Sokko G / validate (push) Failing after 12m44s
Stabilize E2E persistence checks before reloads
2026-10-23 19:59:45 +02:00

44 lines
2.5 KiB
JavaScript

// Rôle : vérifie la visibilité de la prise en main sur le vrai build après création et suppression persistées.
import { test, expect } from "@playwright/test";
import { readFile } from "node:fs/promises";
import { readStoredSnapshot } from "../helpers/storage.js";
const site = JSON.parse(await readFile("website/public/data/site.json", "utf8"));
test("production home hides onboarding after creation and restores it after deleting the last toolbox", async ({ page }) => {
const errors = [];
page.on("pageerror", (error) => errors.push(error.message));
await page.goto("/");
const onboarding = page.getByRole("region", { name: site.home.onboarding.title, exact: true });
await expect(onboarding).toBeVisible();
await expect(page.locator('script[type="module"][src^="/assets/"]')).toHaveCount(1);
await expect(page.locator('script[src*="/@vite/client"]')).toHaveCount(0);
await onboarding.getByRole("button", { name: site.home.onboarding.primaryAction, exact: true }).click();
const dialog = page.getByRole("dialog");
await dialog.getByRole("textbox", { name: "Nom", exact: true }).fill("Production toolbox");
await dialog.getByRole("button", { name: "Créer", exact: true }).click();
await expect(page).toHaveURL(/#\/toolbox\//);
await expect(page.locator('[data-module-type="memos"]')).toBeVisible();
await expect(page.locator('[data-module-type="links"]')).toBeVisible();
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.some((toolbox) => toolbox.name === "Production toolbox")).toBe(true);
await page.goto("/#/");
await expect(page.getByRole("heading", { name: site.home.hero.title, exact: true })).toBeVisible();
await expect(onboarding).toHaveCount(0);
await page.reload();
await expect(page.getByRole("heading", { name: site.home.hero.title, exact: true })).toBeVisible();
await expect(onboarding).toHaveCount(0);
await page.goto("/#/about");
await expect(onboarding).toBeVisible();
await page.goto("/#/toolboxes");
await page.getByRole("button", { name: "Supprimer Production toolbox", exact: true }).click();
await page.getByRole("dialog").getByRole("button", { name: "Supprimer", exact: true }).click();
await expect(page.locator(".toolbox-card")).toHaveCount(0);
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.length).toBe(0);
await page.goto("/#/");
await expect(onboarding).toBeVisible();
await page.reload();
await expect(onboarding).toBeVisible();
expect(errors).toEqual([]);
});