diff --git a/__tests__/pages/authenticated/Register.test.jsx b/__tests__/pages/authenticated/Register.test.jsx new file mode 100644 index 0000000..3145fae --- /dev/null +++ b/__tests__/pages/authenticated/Register.test.jsx @@ -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"); +});