Files
mkvtool/web/e2e/02-config.spec.ts
T

74 lines
3.0 KiB
TypeScript

import {expect, test} from "@playwright/test";
import {fermerNotifications, login} from "./helpers";
test("au premier lancement sans config: avertissements ciblés, scan désactivé", async ({page}) => {
await login(page);
// Avertissement Radarr (obligatoire) + info qBittorrent (optionnel).
await expect(
page.locator(".notification.warning", {hasText: /Connexion Radarr non configurée/}),
).toBeVisible();
await expect(
page.locator(".notification.info", {hasText: /qBittorrent non configuré/}),
).toBeVisible();
// Le scan est impossible sans Radarr.
await expect(page.getByRole("button", {name: "Scanner maintenant"})).toBeDisabled();
// Badges orange "non configuré".
await page.getByRole("button", {name: "Configuration"}).click();
await expect(
page.locator(".status.st-detected", {hasText: "Radarr non configuré"}),
).toBeVisible();
await expect(
page.locator(".status.st-detected", {hasText: "qBittorrent non configuré"}),
).toBeVisible();
});
test("enregistrement et test de connexion: échec explicite en badge rouge", async ({page}) => {
await login(page);
await page.getByRole("button", {name: "Configuration"}).click();
// Radarr: on configure une URL (injoignable dans l'environnement de test).
await fermerNotifications(page);
await page.getByLabel("URL Radarr").fill("http://127.0.0.1:59999");
await page.getByLabel("Clé API", {exact: true}).fill("cle-de-test");
await page.getByRole("button", {name: "Enregistrer et tester"}).first().click();
// Le test échoue: notification d'erreur, badge "Test échoué" persistant.
await expect(
page.locator(".notification.error", {hasText: /Connexion Radarr impossible/}),
).toBeVisible();
await expect(page.locator(".status.error", {hasText: "Test échoué"}).first()).toBeVisible();
// Avec Radarr configuré, le scan devient actif (et échoue proprement).
await expect(page.getByRole("button", {name: "Scanner maintenant"})).toBeEnabled();
await page.getByRole("button", {name: "Scanner maintenant"}).click();
await expect(
page.locator(".notification.error", {hasText: /Scan Radarr impossible/}),
).toBeVisible();
});
test("qBittorrent: enregistrement puis échec de test en badge rouge", async ({page}) => {
await login(page);
await page.getByRole("button", {name: "Configuration"}).click();
await fermerNotifications(page);
await page.getByLabel("URL qBittorrent").fill("http://127.0.0.1:59998");
await page.getByLabel("Utilisateur (optionnel)").fill("admin");
await page
.locator("section")
.filter({hasText: "Connexion qBittorrent"})
.getByRole("button", {name: "Enregistrer et tester"})
.click();
await expect(
page.locator(".notification.error", {hasText: /Connexion qBittorrent impossible/}),
).toBeVisible();
// Le badge repasse en rouge "Test échoué" après le rechargement du statut.
await expect(
page.locator(".status.error", {hasText: "Test échoué"}).first(),
).toBeVisible({timeout: 10_000});
});