import { test, expect } from '@playwright/test';

test.describe('Authentication E2E Tests', () => {
  test('should display login page', async ({ page }) => {
    await page.goto('/login');
    
    // Check that login form is visible
    await expect(page.getByRole('heading', { name: /login/i })).toBeVisible();
    await expect(page.getByLabel(/email/i)).toBeVisible();
    await expect(page.getByLabel(/password/i)).toBeVisible();
    await expect(page.getByRole('button', { name: /login/i })).toBeVisible();
  });

  test('should display register page', async ({ page }) => {
    await page.goto('/register');
    
    // Check that register form is visible
    await expect(page.getByRole('heading', { name: /register/i })).toBeVisible();
    await expect(page.getByLabel(/full name/i)).toBeVisible();
    await expect(page.getByLabel(/email/i)).toBeVisible();
    await expect(page.getByLabel(/password/i)).toBeVisible();
    await expect(page.getByRole('button', { name: /register/i })).toBeVisible();
  });

  test('should navigate from login to register', async ({ page }) => {
    await page.goto('/login');
    
    // Click on register link
    await page.getByRole('link', { name: /register/i }).click();
    
    // Should be on register page
    await expect(page).toHaveURL(/.*register/);
    await expect(page.getByRole('heading', { name: /register/i })).toBeVisible();
  });
});

test.describe('Event List E2E Tests', () => {
  test('should display events page', async ({ page }) => {
    await page.goto('/events');
    
    // Check that events list is visible
    await expect(page.getByRole('heading', { name: /events/i })).toBeVisible();
    
    // Check for filters
    await expect(page.getByRole('combobox').first()).toBeVisible();
  });
});

test.describe('Navigation E2E Tests', () => {
  test('should navigate through main pages', async ({ page }) => {
    // Start at home
    await page.goto('/');
    
    // Navigate to events
    await page.getByRole('link', { name: /events/i }).first().click();
    await expect(page).toHaveURL(/.*events/);
    
    // Navigate to login
    await page.getByRole('link', { name: /login/i }).click();
    await expect(page).toHaveURL(/.*login/);
  });
});
