✅ Tests Playwright (20 parcours utilisateur) + suite backend renforcee (56) + DOCUMENTATION.md + nettoyage (settings_store, react-router)
This commit is contained in:
1 parent
231a1f2599
commit
adab24ca61
20 files changed
+1315
-88
No files matched your search
@@ -0,0 +1,33 @@
|
||||
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");
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
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});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
|
||||
import {login} from "./helpers";
|
||||
|
||||
test("le tableau de bord affiche les statistiques et l'activité", async ({page}) => {
|
||||
await login(page);
|
||||
await expect(page.locator(".stat", {hasText: "À traiter"})).toContainText("7");
|
||||
await expect(page.locator(".stat", {hasText: "En cours"})).toContainText("0");
|
||||
await expect(page.locator(".stat", {hasText: "Traités"})).toContainText("1");
|
||||
await expect(page.locator(".stat", {hasText: "Erreurs"})).toContainText("2");
|
||||
|
||||
// Colonnes d'activité: aucune conversion en cours, une terminée (Cars).
|
||||
await expect(page.getByText("Aucun traitement en cours.")).toBeVisible();
|
||||
await expect(
|
||||
page.locator(".activity-col", {hasText: "Traitement terminé"}).getByText("Cars"),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("la navigation entre les pages fonctionne", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await expect(page.getByRole("heading", {name: "Films ISO"})).toBeVisible();
|
||||
await page.getByRole("button", {name: "Configuration"}).click();
|
||||
await expect(page.getByRole("heading", {name: "Connexion Radarr"})).toBeVisible();
|
||||
await page.getByRole("button", {name: "Tableau de bord"}).click();
|
||||
await expect(page.getByRole("heading", {name: "Activité"})).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
|
||||
import {ligneFilm, login} from "./helpers";
|
||||
|
||||
test("les onglets affichent les films dans la bonne catégorie", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
|
||||
// Onglet par défaut: les films détectés sémés.
|
||||
await expect(ligneFilm(page, "Pacific Rim")).toBeVisible();
|
||||
await expect(ligneFilm(page, "Film Liste")).toBeVisible();
|
||||
|
||||
// Traités: Cars, avec sa pastille verte.
|
||||
await page.getByRole("button", {name: "Traités"}).click();
|
||||
await expect(ligneFilm(page, "Cars")).toBeVisible();
|
||||
await expect(page.locator(".status.st-completed", {hasText: "Terminé"})).toBeVisible();
|
||||
|
||||
// Erreurs: Film Erreur.
|
||||
await page.getByRole("button", {name: "Erreurs"}).click();
|
||||
await expect(ligneFilm(page, "^Film Erreur$")).toBeVisible();
|
||||
await expect(page.locator(".status.error", {hasText: "Erreur"}).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("la fiche d'un film détecté montre l'état et l'emplacement", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await ligneFilm(page, "Film Liste").click();
|
||||
|
||||
const modal = page.locator(".modal");
|
||||
await expect(modal.getByRole("heading", {name: "Film Liste", level: 2})).toBeVisible();
|
||||
await expect(modal.getByText("Détecté")).toBeVisible();
|
||||
await expect(modal.getByRole("button", {name: "Convertir en MKV"})).toBeEnabled();
|
||||
|
||||
// Fermeture par Échap.
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(modal).toBeHidden();
|
||||
});
|
||||
|
||||
test("la fiche d'un film traité affiche les deux chemins et le bouton de renommage", async ({
|
||||
page,
|
||||
}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await page.getByRole("button", {name: "Traités"}).click();
|
||||
await ligneFilm(page, "Cars").click();
|
||||
|
||||
await expect(page.getByText("MKV lié (dossier du film)")).toBeVisible();
|
||||
await expect(page.getByText("MKV brut (dossier de travail)")).toBeVisible();
|
||||
await expect(page.getByRole("button", {name: "Renommer via Radarr"})).toBeVisible();
|
||||
// Le MKV lié porte bien le nom du film.
|
||||
await expect(page.locator("code", {hasText: "Cars (2006).mkv"}).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("la fiche d'un film en erreur montre l'erreur et le journal", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await page.getByRole("button", {name: "Erreurs"}).click();
|
||||
await ligneFilm(page, "^Film Erreur$").click();
|
||||
|
||||
const modal = page.locator(".modal");
|
||||
await expect(modal.getByText(/MakeMKV a échoué/)).toBeVisible();
|
||||
await expect(modal.getByText("Journal de la dernière conversion")).toBeVisible();
|
||||
await expect(
|
||||
modal.getByRole("button", {name: "Reprendre la conversion en MKV"}),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("l'onglet Traités propose le renommage Radarr groupé", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await page.getByRole("button", {name: "Traités"}).click();
|
||||
|
||||
const bouton = page.getByRole("button", {name: "Renommer les traités via Radarr"});
|
||||
await expect(bouton).toBeVisible();
|
||||
await bouton.click();
|
||||
// Radarr n'est pas joignable dans l'environnement de test: échec signalé.
|
||||
await expect(page.locator(".notification.error")).toContainText(/en échec/);
|
||||
});
|
||||
|
||||
test("la suppression d'une ligne passe par une confirmation", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await ligneFilm(page, "Film Jetable 1").getByRole("button", {name: "Supprimer"}).click();
|
||||
// Le modal de confirmation porte bien le nom du film visé.
|
||||
await expect(
|
||||
page.locator(".modal.confirm").getByRole("heading", {name: "Film Jetable 1", level: 2}),
|
||||
).toBeVisible();
|
||||
await page
|
||||
.locator(".modal.confirm")
|
||||
.getByRole("button", {name: "Supprimer", exact: true})
|
||||
.click();
|
||||
|
||||
await expect(
|
||||
page.locator(".notification", {hasText: /retiré de l'inventaire/}),
|
||||
).toBeVisible();
|
||||
await expect(ligneFilm(page, "Film Jetable 1")).toBeHidden();
|
||||
});
|
||||
|
||||
test("la sélection multiple supprime plusieurs lignes", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await page.getByRole("button", {name: "Sélection multiple"}).click();
|
||||
await ligneFilm(page, "Film Jetable 3").click();
|
||||
await ligneFilm(page, "Film Jetable 4").click();
|
||||
await expect(page.getByText("2 sélectionné(s)")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", {name: "Supprimer la sélection"}).click();
|
||||
await page.locator(".modal.confirm").getByRole("button", {name: "Supprimer", exact: true}).click();
|
||||
await expect(
|
||||
page.locator(".notification", {hasText: /ligne\(s\) retirée\(s\)/}),
|
||||
).toBeVisible();
|
||||
// Les deux lignes jetables ont disparu, les autres films restent.
|
||||
await expect(ligneFilm(page, "Film Jetable 3")).toBeHidden();
|
||||
await expect(ligneFilm(page, "Film Jetable 4")).toBeHidden();
|
||||
await expect(ligneFilm(page, "Film Liste")).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
|
||||
import {ligneFilm, login} from "./helpers";
|
||||
|
||||
test("l'interface reste utilisable sur mobile", async ({page}) => {
|
||||
await page.setViewportSize({width: 375, height: 812});
|
||||
await login(page);
|
||||
|
||||
// Navigation par onglets défilants, tous accessibles.
|
||||
await expect(page.getByRole("button", {name: "Traitements"})).toBeVisible();
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
|
||||
// Les fiches restent lisibles et cliquables: pastille + actions.
|
||||
const ligne = ligneFilm(page, "Pacific Rim");
|
||||
await expect(ligne).toBeVisible();
|
||||
await expect(ligne.locator(".status", {hasText: "Détecté"})).toBeVisible();
|
||||
await ligne.click();
|
||||
await expect(page.locator(".modal").getByRole("heading", {name: "Pacific Rim", level: 2})).toBeVisible();
|
||||
await expect(page.getByRole("button", {name: "Convertir en MKV"})).toBeVisible();
|
||||
});
|
||||
|
||||
test("la fiche reste lisible sur écran étroit", async ({page}) => {
|
||||
await page.setViewportSize({width: 360, height: 740});
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await page.getByRole("button", {name: "Traités"}).click();
|
||||
await ligneFilm(page, "Cars").click();
|
||||
|
||||
// Le tableau de la fiche passe en une colonne, contenu complet visible.
|
||||
await expect(page.getByText("MKV lié (dossier du film)")).toBeVisible();
|
||||
await expect(page.getByText("MKV brut (dossier de travail)")).toBeVisible();
|
||||
await page.locator(".modal").getByRole("button", {name: "Fermer"}).click();
|
||||
await expect(page.locator(".modal")).toBeHidden();
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
|
||||
import {attendreEtat, fermerNotifications, ligneFilm, login} from "./helpers";
|
||||
|
||||
test("conversion complète: détection → validation → traité", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
|
||||
// Lancement depuis la fiche.
|
||||
await ligneFilm(page, "Pacific Rim").click();
|
||||
await page.getByRole("button", {name: "Convertir en MKV"}).click();
|
||||
await expect(
|
||||
page.locator(".notification", {hasText: /mise en file d'attente/}),
|
||||
).toBeVisible();
|
||||
|
||||
// Le statut passe par les états actifs puis "À valider", sans recharger.
|
||||
await attendreEtat(page, "Pacific Rim", "À valider");
|
||||
|
||||
// Fiche: les deux chemins et le bouton de validation.
|
||||
await ligneFilm(page, "Pacific Rim").click();
|
||||
await expect(page.getByText("MKV lié (dossier du film)")).toBeVisible();
|
||||
await expect(page.getByText("MKV brut (dossier de travail)")).toBeVisible();
|
||||
|
||||
// Validation: Radarr est absent dans l'environnement de test, la
|
||||
// validation réussit avec un avertissement.
|
||||
await fermerNotifications(page);
|
||||
await page.getByRole("button", {name: "Valider la conversion"}).click();
|
||||
await expect(page.locator(".notification.warning").last()).toContainText(
|
||||
/mise à jour Radarr impossible/,
|
||||
);
|
||||
|
||||
// La ligne a changé de catégorie toute seule: elle est dans "Traités".
|
||||
await page.getByRole("button", {name: "Traités"}).click();
|
||||
await expect(ligneFilm(page, "Pacific Rim")).toBeVisible();
|
||||
await expect(
|
||||
ligneFilm(page, "Pacific Rim").locator(".status", {hasText: "Terminé"}),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("annulation d'une conversion à valider: retour à détecté", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
|
||||
await ligneFilm(page, "Autre Film").click();
|
||||
await page.getByRole("button", {name: "Convertir en MKV"}).click();
|
||||
await attendreEtat(page, "Autre Film", "À valider");
|
||||
|
||||
await ligneFilm(page, "Autre Film").click();
|
||||
await fermerNotifications(page);
|
||||
await page.getByRole("button", {name: "Annuler"}).click();
|
||||
await expect(
|
||||
page.locator(".notification", {hasText: /annulée/}),
|
||||
).toBeVisible();
|
||||
|
||||
// Retour dans "À traiter" avec l'état détecté, MKV et lien supprimés.
|
||||
await attendreEtat(page, "Autre Film", "Détecté");
|
||||
await page.getByRole("button", {name: "À traiter"}).click();
|
||||
await expect(ligneFilm(page, "Autre Film")).toBeVisible();
|
||||
});
|
||||
|
||||
test("reprise d'une conversion après échec", async ({page}) => {
|
||||
await login(page);
|
||||
await page.getByRole("button", {name: "Traitements"}).click();
|
||||
await page.getByRole("button", {name: "Erreurs"}).click();
|
||||
await ligneFilm(page, "Film Erreur Bis").click();
|
||||
await page.getByRole("button", {name: "Reprendre la conversion en MKV"}).click();
|
||||
await expect(
|
||||
page.locator(".notification", {hasText: /mise en file d'attente/}),
|
||||
).toBeVisible();
|
||||
|
||||
// Pendant la conversion la ligne quitte "Erreurs": on la suit dans
|
||||
// l'onglet "En cours" jusqu'a "À valider".
|
||||
await page.getByRole("button", {name: "En cours"}).click();
|
||||
await attendreEtat(page, "Film Erreur Bis", "À valider");
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
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,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user