Initial commit

This commit is contained in:
Rafael Dias Martins
2026-08-31 14:10:20 -03:00
commit 8fcb5aac66
454 changed files with 60207 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
import { test, expect } from '@playwright/test';
test.describe('Cadastro', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/auth/register');
});
test('deve mostrar o formulário de cadastro', async ({ page }) => {
await expect(page.locator('h1, h2')).toContainText(/cadastro|registro/i);
await expect(page.getByLabel(/nome completo/i)).toBeVisible();
await expect(page.getByLabel(/email/i)).toBeVisible();
await expect(page.getByLabel(/senha/i)).toBeVisible();
await expect(page.getByLabel(/confirmar senha/i)).toBeVisible();
await expect(page.getByRole('button', { name: /cadastrar|registrar/i })).toBeVisible();
});
test('deve mostrar erro com senhas que não conferem', async ({ page }) => {
await page.getByLabel(/nome completo/i).fill('Usuário Teste');
await page.getByLabel(/email/i).fill(`teste${Date.now()}@teste.com`);
await page.getByLabel(/senha/i).fill('123456');
await page.getByLabel(/confirmar senha/i).fill('654321');
await page.getByRole('button', { name: /cadastrar|registrar/i }).click();
await expect(page.getByText(/senhas não conferem|senha não confere/i)).toBeVisible();
});
test('deve mostrar erro com senha muito curta', async ({ page }) => {
await page.getByLabel(/nome completo/i).fill('Usuário Teste');
await page.getByLabel(/email/i).fill(`teste${Date.now()}@teste.com`);
await page.getByLabel(/senha/i).fill('123');
await page.getByLabel(/confirmar senha/i).fill('123');
await page.getByRole('button', { name: /cadastrar|registrar/i }).click();
await expect(page.getByText(/mínimo de \d+ caracteres|senha muito curta/i)).toBeVisible();
});
test('deve mostrar erro com email inválido', async ({ page }) => {
await page.getByLabel(/nome completo/i).fill('Usuário Teste');
await page.getByLabel(/email/i).fill('email-invalido');
await page.getByLabel(/senha/i).fill('123456');
await page.getByLabel(/confirmar senha/i).fill('123456');
await page.getByRole('button', { name: /cadastrar|registrar/i }).click();
await expect(page.getByText(/email inválido/i)).toBeVisible();
});
test('deve mostrar erro com campos obrigatórios vazios', async ({ page }) => {
await page.getByRole('button', { name: /cadastrar|registrar/i }).click();
await expect(page.getByText(/nome.*obrigatório/i)).toBeVisible();
});
test('deve cadastrar com dados válidos e redirecionar para login', async ({ page }) => {
const timestamp = Date.now();
await page.getByLabel(/nome completo/i).fill(`Usuário Teste ${timestamp}`);
await page.getByLabel(/email/i).fill(`teste${timestamp}@teste.com`);
await page.getByLabel(/senha/i).fill('123456');
await page.getByLabel(/confirmar senha/i).fill('123456');
await page.getByRole('button', { name: /cadastrar|registrar/i }).click();
// Deve redirecionar para login ou mostrar mensagem de sucesso
await expect(page).toHaveURL(/\/auth\/login/, { timeout: 10000 });
});
});
test.describe('Seleção de Role', () => {
test('deve mostrar opções quando usuário tem múltiplos roles', async ({ page }) => {
// TODO: Fazer login com usuário que tem múltiplos roles
await page.goto('/dispatcher');
// Deve mostrar o dispatcher
await expect(page.locator('h1, h2')).toContainText(/escolha.*destino|selecione.*papel/i);
});
test('admin: redireciona para /admin/dashboard', async ({ page }) => {
// TODO: Fazer login como admin
// await page.goto('/dispatcher');
// await page.getByRole('button', { name: /administrador|admin/i }).click();
// await expect(page).toHaveURL(/\/admin\/dashboard/);
});
test('professor: redireciona para /dashboard/teacher', async ({ page }) => {
// TODO: Fazer login como professor
// await page.goto('/dispatcher');
// await page.getByRole('button', { name: /professor/i }).click();
// await expect(page).toHaveURL(/\/dashboard\/teacher/);
});
test('aluno: redireciona para /dashboard/student', async ({ page }) => {
// TODO: Fazer login como aluno
// await page.goto('/dispatcher');
// await page.getByRole('button', { name: /aluno/i }).click();
// await expect(page).toHaveURL(/\/dashboard\/student/);
});
test('responsável: redireciona para /dashboard/guardian', async ({ page }) => {
// TODO: Fazer login como responsável
// await page.goto('/dispatcher');
// await page.getByRole('button', { name: /responsável|guardian/i }).click();
// await expect(page).toHaveURL(/\/dashboard\/guardian/);
});
});