2024-DEV-BUT3/__tests__/pages/authenticated/Register.test.jsx
2024-05-12 18:34:12 +02:00

37 lines
1.7 KiB
JavaScript

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");
});