123 lines
5.1 KiB
JavaScript
123 lines
5.1 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Wards - Alunos Vinculados a Responsáveis', () => {
|
|
// TODO: Fazer login como responsável antes de cada teste
|
|
// test.beforeEach(async ({ page }) => {
|
|
// await page.goto('/auth/login');
|
|
// await page.getByLabel(/email/i).fill('[email protected]');
|
|
// await page.getByLabel(/senha/i).fill('123456');
|
|
// await page.getByRole('button', { name: /entrar/i }).click();
|
|
// await page.waitForURL(/\/dashboard\/guardian/);
|
|
// });
|
|
|
|
test.describe('Dashboard do Responsável', () => {
|
|
test('deve mostrar lista de alunos vinculados', async ({ page }) => {
|
|
// TODO: Implementar após login
|
|
await page.goto('/dashboard/guardian');
|
|
|
|
await expect(page.getByText(/alunos|wards|meus alunos/i)).toBeVisible();
|
|
});
|
|
|
|
test('cada aluno deve ter link para detalhes', async ({ page }) => {
|
|
await page.goto('/dashboard/guardian');
|
|
|
|
// TODO: Verificar se há cards de alunos com links
|
|
// const studentCard = page.locator('[data-testid="student-card"]').first();
|
|
// await expect(studentCard.getByRole('link')).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('Cadastro de Ward', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/dashboard/guardian/register-student');
|
|
});
|
|
|
|
test('deve mostrar formulário de cadastro de aluno', async ({ page }) => {
|
|
await expect(page.getByLabel(/nome do aluno|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|salvar/i })).toBeVisible();
|
|
});
|
|
|
|
test('deve validar campos obrigatórios', async ({ page }) => {
|
|
await page.getByRole('button', { name: /cadastrar|salvar/i }).click();
|
|
|
|
await expect(page.getByText(/nome.*obrigatório/i)).toBeVisible();
|
|
});
|
|
|
|
test('deve mostrar erro com email já existente', async ({ page }) => {
|
|
await page.getByLabel(/nome do aluno/i).fill('Aluno Teste');
|
|
await page.getByLabel(/email/i).fill('[email protected]'); // Email que já existe
|
|
await page.getByLabel(/senha/i).fill('123456');
|
|
await page.getByLabel(/confirmar senha/i).fill('123456');
|
|
|
|
await page.getByRole('button', { name: /cadastrar|salvar/i }).click();
|
|
|
|
await expect(page.getByText(/email já cadastrado|já existe/i)).toBeVisible();
|
|
});
|
|
|
|
test('deve mostrar erro com senhas diferentes', async ({ page }) => {
|
|
await page.getByLabel(/nome do aluno/i).fill('Aluno Teste');
|
|
await page.getByLabel(/email/i).fill(`novoaluno${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|salvar/i }).click();
|
|
|
|
await expect(page.getByText(/senhas não conferem/i)).toBeVisible();
|
|
});
|
|
|
|
test('deve cadastrar ward com sucesso', async ({ page }) => {
|
|
const timestamp = Date.now();
|
|
await page.getByLabel(/nome do aluno/i).fill(`Aluno Ward ${timestamp}`);
|
|
await page.getByLabel(/email/i).fill(`ward${timestamp}@teste.com`);
|
|
await page.getByLabel(/senha/i).fill('123456');
|
|
await page.getByLabel(/confirmar senha/i).fill('123456');
|
|
|
|
await page.getByRole('button', { name: /cadastrar|salvar/i }).click();
|
|
|
|
// Deve mostrar mensagem de sucesso ou redirecionar
|
|
await expect(page.getByText(/aluno cadastrado|sucesso/i)).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('novo ward deve aparecer na lista do responsável', async ({ page }) => {
|
|
// 1. Cadastrar novo ward
|
|
const timestamp = Date.now();
|
|
const wardName = `Aluno Ward ${timestamp}`;
|
|
const wardEmail = `ward${timestamp}@teste.com`;
|
|
|
|
await page.goto('/dashboard/guardian/register-student');
|
|
await page.getByLabel(/nome do aluno/i).fill(wardName);
|
|
await page.getByLabel(/email/i).fill(wardEmail);
|
|
await page.getByLabel(/senha/i).fill('123456');
|
|
await page.getByLabel(/confirmar senha/i).fill('123456');
|
|
await page.getByRole('button', { name: /cadastrar|salvar/i }).click();
|
|
|
|
// 2. Voltar para dashboard e verificar se aparece
|
|
await page.goto('/dashboard/guardian');
|
|
await expect(page.getByText(wardName)).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe('Detalhes do Ward', () => {
|
|
test('deve mostrar turmas do aluno', async ({ page }) => {
|
|
// TODO: Implementar
|
|
// await page.goto('/dashboard/guardian/ward-id');
|
|
// await expect(page.getByText(/turmas|classes/i)).toBeVisible();
|
|
});
|
|
|
|
test('deve mostrar pagamentos do aluno', async ({ page }) => {
|
|
// TODO: Implementar
|
|
// await page.goto('/dashboard/guardian/ward-id/payments');
|
|
// await expect(page.getByText(/pagamentos|mensalidades/i)).toBeVisible();
|
|
});
|
|
|
|
test('deve mostrar notas do aluno', async ({ page }) => {
|
|
// TODO: Implementar
|
|
// await page.goto('/dashboard/guardian/ward-id/grades');
|
|
// await expect(page.getByText(/notas|provas/i)).toBeVisible();
|
|
});
|
|
});
|
|
});
|