import { test, expect } from "@playwright/test"; test.describe("Authentication", () => { test("should show login page", async ({ page }) => { await page.goto("/login"); await expect(page.locator("h1")).toContainText("로그인"); await expect(page.locator('input[name="username"]')).toBeVisible(); await expect(page.locator('input[name="password"]')).toBeVisible(); await expect(page.locator('button[type="submit"]')).toBeVisible(); }); test("should show error on invalid login", async ({ page }) => { await page.goto("/login"); await page.fill('input[name="username"]', "invaliduser"); await page.fill('input[name="password"]', "invalidpassword"); await page.click('button[type="submit"]'); // Wait for error message await expect(page.locator(".text-red-700, .text-red-600")).toBeVisible({ timeout: 5000, }); }); test("should redirect to login when accessing protected page", async ({ page, }) => { await page.goto("/portfolio"); // Should redirect to login await expect(page).toHaveURL(/\/login/); }); });