1
0
forked from baron/baron-sso

Playwright 테스트 오류 수정

This commit is contained in:
2026-03-18 09:05:50 +09:00
parent ec8abf39aa
commit d305398326
13 changed files with 387 additions and 149 deletions

View File

@@ -15,7 +15,9 @@ test.describe("User Schema Dynamic Form", () => {
window.localStorage.setItem(key, JSON.stringify(authData));
window.localStorage.setItem("admin_session", "fake-token");
window.localStorage.setItem("locale", "ko");
(window as any)._IS_TEST_MODE = true;
(
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
)._IS_TEST_MODE = true;
});
await page.route("**/oidc/**", async (route) => {
@@ -24,20 +26,38 @@ test.describe("User Schema Dynamic Form", () => {
await page.route(/.*\/api\/v1\/.*/, async (route) => {
const url = route.request().url();
if (url.includes("/user/me")) { console.log("Mocking ME");
if (url.includes("/user/me")) {
console.log("Mocking ME");
return route.fulfill({
json: { id: "admin-user", name: "Admin", role: "super_admin", manageableTenants: [] },
json: {
id: "admin-user",
name: "Admin",
role: "super_admin",
manageableTenants: [],
},
});
}
if (url.includes("/admin/tenants/t-1")) {
return route.fulfill({
json: {
id: "t-1", name: "Test Tenant", slug: "test-tenant",
id: "t-1",
name: "Test Tenant",
slug: "test-tenant",
config: {
userSchema: [
{ key: "emp_id", label: "Employee ID", required: true, validation: "^E[0-9]{3}$" },
{ key: "salary", label: "Salary", adminOnly: true, type: "number" },
{
key: "emp_id",
label: "Employee ID",
required: true,
validation: "^E[0-9]{3}$",
},
{
key: "salary",
label: "Salary",
adminOnly: true,
type: "number",
},
],
},
},
@@ -47,9 +67,14 @@ test.describe("User Schema Dynamic Form", () => {
if (url.includes("/admin/users/u-1")) {
return route.fulfill({
json: {
id: "u-1", name: "John Doe", email: "john@test.com", companyCode: "test-tenant",
id: "u-1",
name: "John Doe",
email: "john@test.com",
companyCode: "test-tenant",
tenant: { id: "t-1", name: "Test Tenant", slug: "test-tenant" },
joinedTenants: [{ id: "t-1", name: "Test Tenant", slug: "test-tenant" }],
joinedTenants: [
{ id: "t-1", name: "Test Tenant", slug: "test-tenant" },
],
metadata: { "t-1": { emp_id: "E123", salary: 1000 } },
},
});
@@ -57,7 +82,10 @@ test.describe("User Schema Dynamic Form", () => {
if (url.includes("/admin/tenants")) {
return route.fulfill({
json: { items: [{ id: "t-1", slug: "test-tenant", name: "Test Tenant" }], total: 1 },
json: {
items: [{ id: "t-1", slug: "test-tenant", name: "Test Tenant" }],
total: 1,
},
});
}
@@ -65,40 +93,48 @@ test.describe("User Schema Dynamic Form", () => {
});
});
test("should render custom fields from schema in user detail", async ({ page }) => {
test("should render custom fields from schema in user detail", async ({
page,
}) => {
await page.goto("/users/u-1");
await page.waitForLoadState("networkidle");
// 섹션 헤더 확인
const header = page.getByText(/테넌트별 프로필 관리|Per-tenant Profile/i).first();
await header.waitFor({ state: 'visible' });
const header = page
.getByText(/테넌트별 프로필 관리|Per-tenant Profile/i)
.first();
await header.waitFor({ state: "visible" });
// 커스텀 필드 레이블 확인
await expect(page.getByText("Employee ID")).toBeVisible();
// input 값 확인 (id에 t-1.emp_id가 포함됨)
const empIdInput = page.locator('input[id*="emp_id"]');
await expect(empIdInput).toHaveValue("E123");
const salaryInput = page.locator('input[id*="salary"]');
await expect(salaryInput).toHaveValue("1000");
await expect(page.getByText(/Admin Only/i).first()).toBeVisible();
});
test("should show regex validation error for custom field", async ({ page }) => {
test("should show regex validation error for custom field", async ({
page,
}) => {
await page.goto("/users/u-1");
await page.waitForLoadState("networkidle");
const empIdInput = page.locator('input[id*="emp_id"]');
await empIdInput.waitFor({ state: 'visible' });
await empIdInput.waitFor({ state: "visible" });
await empIdInput.fill("invalid");
// 포커스 해제하여 유효성 검사 트리거
await page.getByLabel(/이름|Name/i).click();
// 에러 메시지 확인
const errorMsg = page.locator('form').getByText(/Employee ID|필수|invalid|format/i);
const errorMsg = page
.locator("form")
.getByText(/Employee ID|필수|invalid|format/i);
await expect(errorMsg).toBeVisible();
});
});