🎉 Ajout des tests d'inscription

This commit is contained in:
Julien C 2024-05-12 18:34:12 +02:00
parent 8b01b19365
commit 1e05ef6abf

View File

@ -0,0 +1,36 @@
import { test, expect } from "@playwright/test";
test("inscription avec nom d'utilisateur déjà existant", async ({ page }) => {
await page.goto("http://localhost:3001/register");
await page.fill('input[placeholder="username"]', "utilisateur_existant");
await page.fill('input[placeholder="password"]', "mot_de_passe_test");
await page.fill('input[placeholder="confirmation"]', "mot_de_passe_test");
await page.click('button[type="submit"]');
await page.waitForLoadState("networkidle");
const errorMessage = await page.textContent(".text-red-500");
expect(errorMessage).toContain("Ce nom d'utilisateur existe déjà");
});
test("inscription avec mots de passe non correspondants", async ({ page }) => {
await page.goto("http://localhost:3001/register");
await page.fill('input[placeholder="username"]', "utilisateur_test");
await page.fill('input[placeholder="password"]', "mot_de_passe_test");
await page.fill(
'input[placeholder="confirmation"]',
"mot_de_passe_incorrect",
);
await page.click('button[type="submit"]');
await page.waitForLoadState("networkidle");
const errorMessage = await page.textContent(".text-red-500");
expect(errorMessage).toContain("Les mots de passe ne correspondent pas");
});
test("inscription sans nom d'utilisateur", async ({ page }) => {
await page.goto("http://localhost:3001/register");
await page.fill('input[placeholder="password"]', "mot_de_passe_test");
await page.fill('input[placeholder="confirmation"]', "mot_de_passe_test");
await page.click('button[type="submit"]');
await page.waitForLoadState("networkidle");
const errorMessage = await page.textContent(".text-red-500");
expect(errorMessage).toContain("Veuillez fournir un nom d'utilisateur");
});