import { test, expect } from '@playwright/test' test.describe('Authentication', () => { test.beforeEach(async ({ page }) => { await page.goto('/login') }) test('should display login form', async ({ page }) => { await expect(page.getByRole('heading', { name: /tabatafit admin/i })).toBeVisible() await expect(page.getByLabel(/email/i)).toBeVisible() await expect(page.getByLabel(/password/i)).toBeVisible() await expect(page.getByRole('button', { name: /sign in/i })).toBeVisible() }) test('should show validation errors', async ({ page }) => { await page.getByRole('button', { name: /sign in/i }).click() // Check HTML5 validation const emailInput = page.getByLabel(/email/i) await expect(emailInput).toHaveAttribute('required', '') }) test('should redirect unauthenticated users to login', async ({ page }) => { await page.goto('/') await expect(page).toHaveURL(/.*login/) }) test('should redirect authenticated users away from login', async ({ page }) => { // This test would need actual auth setup // For now, just verify the route protection exists await page.goto('/login') await expect(page.getByRole('heading', { name: /tabatafit admin/i })).toBeVisible() }) }) test.describe('Dashboard', () => { test('should display dashboard stats', async ({ page }) => { // Navigate to dashboard (will redirect to login if not authenticated) await page.goto('/') // If authenticated, should show dashboard // If not, should redirect to login await expect(page.getByRole('heading', { name: /dashboard|tabatafit admin/i })).toBeVisible() }) test('should have working navigation', async ({ page }) => { await page.goto('/') // Check if we can see the sidebar navigation const sidebar = page.locator('aside, nav').first() await expect(sidebar).toBeVisible() // Check for navigation links await expect(page.getByRole('link', { name: /workouts/i })).toBeVisible() await expect(page.getByRole('link', { name: /trainers/i })).toBeVisible() }) }) test.describe('Navigation', () => { test('should navigate between pages', async ({ page }) => { await page.goto('/') // Try to navigate to workouts await page.getByRole('link', { name: /workouts/i }).click() await expect(page).toHaveURL(/.*workouts/) // Navigate to trainers await page.getByRole('link', { name: /trainers/i }).click() await expect(page).toHaveURL(/.*trainers/) }) })