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

test.describe("Authentication Flow", () => {
  test("Guest should see Landing Page", async ({ page }) => {
    await page.goto("/");
    await expect(page).toHaveTitle(/AutoTrade/i);
    await expect(
      page.getByRole("heading", { name: "투자의 미래, 자동화하세요" }),
    ).toBeVisible();
    await expect(
      page.getByRole("link", { name: "로그인" }).first(),
    ).toBeVisible();
  });

  test("Guest trying to access /dashboard should be redirected to /login", async ({
    page,
  }) => {
    await page.goto("/dashboard");
    await expect(page).toHaveURL(/\/login/);
    await expect(page.getByRole("button", { name: "로그인" })).toBeVisible();
  });

  test("Login page should load correctly", async ({ page }) => {
    await page.goto("/login");
    await expect(page.getByLabel("이메일", { exact: true })).toBeVisible();
    await expect(page.getByLabel("비밀번호")).toBeVisible();
    await expect(page.getByRole("button", { name: "로그인" })).toBeVisible();
  });
});
