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

test.describe("Authentication", () => {
  test("shows login page", async ({ page }) => {
    await page.goto("/login");
    await expect(page.locator("h1, h2").first()).toContainText(/log in|sign in/i);
  });

  test("shows validation errors for empty form", async ({ page }) => {
    await page.goto("/login");
    await page.click('button[type="submit"]');
    await expect(page.locator('[role="alert"]').first()).toBeVisible();
  });

  test("shows register page", async ({ page }) => {
    await page.goto("/register");
    await expect(page.locator("h1, h2").first()).toContainText(/register|sign up|create account/i);
  });

  test("navigates from login to register", async ({ page }) => {
    await page.goto("/login");
    await page.click('a[href="/register"]');
    await expect(page).toHaveURL("/register");
  });

  test("navigates from login to forgot password", async ({ page }) => {
    await page.goto("/login");
    await page.click('a[href="/forgot-password"]');
    await expect(page).toHaveURL("/forgot-password");
  });
});
