Files
mkvtool/web/e2e/helpers.ts
T

38 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 type {Page} from "@playwright/test";
import {expect} from "@playwright/test";
/** Connexion au compte seme par le serveur d'integration. */
export async function login(page: Page) {
await page.goto("/");
await page.getByLabel("Nom d’utilisateur").fill("admin");
await page.getByLabel("Mot de passe").fill("mot-de-passe-123");
await page.getByRole("button", {name: "Se connecter"}).click();
await expect(page.getByRole("button", {name: "Scanner maintenant"})).toBeVisible();
}
/** Ligne d'un film dans la liste: l'article portant le titre en en-tete. */
export function ligneFilm(page: Page, titre: string) {
return page
.locator("article")
.filter({has: page.getByRole("heading", {name: new RegExp(titre)})});
}
/** Referme les notifications empilees en bas a droite.
* Elles couvrent les boutons d'action des formulaires et des fiches: on les
* degage avant d'interagir.
*/
export async function fermerNotifications(page: Page) {
const boutons = page.getByRole("button", {name: "Supprimer la notification"});
for (let i = (await boutons.count()) - 1; i >= 0; i--) {
await boutons.nth(i).click();
}
}
/** Attend que la pastille du film atteigne l'etat voulu (polling de 3 s). */
export async function attendreEtat(page: Page, titre: string, etat: string) {
await expect(ligneFilm(page, titre).locator(".status", {hasText: etat})).toBeVisible({
timeout: 20_000,
});
}