Files
mkvtool/web/e2e/01-auth.spec.ts
T

34 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {expect, test} from "@playwright/test";
import {login} from "./helpers";
test("la connexion refuse un mauvais mot de passe", async ({page}) => {
await page.goto("/");
await page.getByLabel("Nom d’utilisateur").fill("admin");
await page.getByLabel("Mot de passe").fill("faux");
await page.getByRole("button", {name: "Se connecter"}).click();
await expect(page.getByText("Identifiants incorrects")).toBeVisible();
await expect(page.getByRole("button", {name: "Se connecter"})).toBeVisible();
});
test("la connexion réussie mène au tableau de bord, la déconnexion revient au login", async ({
page,
}) => {
await login(page);
await expect(page.getByRole("button", {name: "Tableau de bord"})).toBeVisible();
// Menu utilisateur: theme + déconnexion.
await page.getByRole("button", {name: "Menu utilisateur"}).click();
await page.getByRole("menuitem", {name: "Déconnexion"}).click();
await expect(page.getByRole("button", {name: "Se connecter"})).toBeVisible();
});
test("le basculement de thème persiste", async ({page}) => {
await login(page);
await page.getByRole("button", {name: "Menu utilisateur"}).click();
await page.getByRole("menuitem", {name: "Passer en thème clair"}).click();
await expect(page.locator("html")).toHaveAttribute("data-theme", "light");
await page.reload();
await expect(page.locator("html")).toHaveAttribute("data-theme", "light");
});