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

test.describe('Login Flow', () => {
  test('login page is accessible', async ({ page }) => {
    await page.goto('/login');
    
    // Verify login page content
    await expect(page.getByText('Sign in required')).toBeVisible();
    await expect(page.getByText('Continue to login')).toBeVisible();
  });

  test('redirects to home after login', async ({ page }) => {
    await page.goto('/login');
    
    // Click login button
    await page.getByText('Continue to login').click();
    
    // Should redirect to OAuth provider (this is a simplified check)
    // In real tests, you'd mock the OAuth flow or use test credentials
    await expect(page).toHaveURL(/.*authentik.*/);
  });
});

test.describe('Protected Routes', () => {
  test('redirects unauthenticated users to login', async ({ page }) => {
    await page.goto('/projects');
    
    // Should be redirected to login page
    await expect(page).toHaveURL(/.*login.*/);
    await expect(page.getByText('Sign in required')).toBeVisible();
  });
});
