Improve the UI and tests

This commit is contained in:
Urtzi Alfaro
2025-11-15 21:21:06 +01:00
parent 86d704b354
commit 54b7a5e080
44 changed files with 2268 additions and 1414 deletions

View File

@@ -1,5 +1,9 @@
import { test as setup, expect } from '@playwright/test';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const authFile = path.join(__dirname, '.auth', 'user.json');
@@ -12,17 +16,27 @@ setup('authenticate', async ({ page }) => {
// Navigate to login page
await page.goto('/login');
// Handle cookie consent dialog if present
const acceptCookiesButton = page.getByRole('button', {
name: /aceptar todas|accept all/i,
});
if (await acceptCookiesButton.isVisible({ timeout: 2000 }).catch(() => false)) {
await acceptCookiesButton.click();
console.log('✅ Cookie consent accepted');
}
// TODO: Update these credentials with your test user
// For now, we'll use environment variables or default test credentials
const testEmail = process.env.TEST_USER_EMAIL || 'test@bakery.com';
const testPassword = process.env.TEST_USER_PASSWORD || 'test-password-123';
const testEmail = process.env.TEST_USER_EMAIL || 'ualfaro@gmail.com';
const testPassword = process.env.TEST_USER_PASSWORD || 'Admin123';
// Fill in login form
await page.getByLabel(/email/i).fill(testEmail);
await page.getByLabel(/password/i).fill(testPassword);
await page.getByLabel(/email|correo/i).fill(testEmail);
// Use getByRole for password to avoid matching the "Show password" button
await page.getByRole('textbox', { name: /password|contraseña/i }).fill(testPassword);
// Click login button
await page.getByRole('button', { name: /log in|sign in|login/i }).click();
await page.getByRole('button', { name: /log in|sign in|login|acceder/i }).click();
// Wait for redirect to dashboard or app
await page.waitForURL(/\/(app|dashboard)/);