Files
voiceon-character-admin/tests/e2e/auth.spec.ts
2026-07-27 15:04:03 +09:00

44 lines
1.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
const apiBaseUrl = "https://test-character-admin.sodalive.net";
test("completes login, navigation, and logout using only the keyboard", async ({ page }) => {
await page.route(`${apiBaseUrl}/admin/member/login`, async (route) => {
await route.fulfill({
contentType: "application/json",
json: { success: true, message: null, data: { token: "admin-token", role: "ADMIN" }, errorProperty: null },
});
});
await page.route(`${apiBaseUrl}/api/v2/admin/ai-characters?page=0&size=20`, async (route) => {
await route.fulfill({
contentType: "application/json",
json: { success: true, message: null, data: null, errorProperty: null },
});
});
await page.route(`${apiBaseUrl}/member/logout`, async (route) => {
await route.fulfill({
contentType: "application/json",
json: { success: true, message: null, data: {}, errorProperty: null },
});
});
await page.goto("/login");
await page.getByLabel("이메일").focus();
await page.keyboard.type("admin@test.com");
await page.getByLabel("비밀번호").focus();
await page.keyboard.type("password");
await page.getByRole("button", { name: "로그인" }).focus();
await page.keyboard.press("Enter");
await expect(page).toHaveURL(/\/ai-characters$/);
await expect(page.getByRole("heading", { name: "AI 캐릭터", exact: true })).toBeVisible();
const logoutButton = page.getByRole("button", { name: "로그아웃" });
await logoutButton.focus();
await expect(logoutButton).toBeFocused();
await page.keyboard.press("Enter");
await expect(page).toHaveURL(/\/login$/);
await expect(page.getByRole("heading", { name: "관리자 로그인" })).toBeVisible();
});