forked from baron/baron-sso
Playwright 테스트 오류 수정
This commit is contained in:
@@ -46,12 +46,15 @@ function AppLayout() {
|
|||||||
enabled:
|
enabled:
|
||||||
(auth.isAuthenticated && !auth.isLoading) ||
|
(auth.isAuthenticated && !auth.isLoading) ||
|
||||||
import.meta.env.MODE === "development" ||
|
import.meta.env.MODE === "development" ||
|
||||||
(window as any)._IS_TEST_MODE === true,
|
(window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean })
|
||||||
|
._IS_TEST_MODE === true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const navItems = React.useMemo(() => {
|
const navItems = React.useMemo(() => {
|
||||||
const items = [...staticNavItems];
|
const items = [...staticNavItems];
|
||||||
const isTest = (window as any)._IS_TEST_MODE === true;
|
const isTest =
|
||||||
|
(window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean })
|
||||||
|
._IS_TEST_MODE === true;
|
||||||
|
|
||||||
// 테스트 모드이면 profile이 없어도 super_admin으로 간주하여 모든 메뉴 렌더링
|
// 테스트 모드이면 profile이 없어도 super_admin으로 간주하여 모든 메뉴 렌더링
|
||||||
const isSuperAdmin = isTest || profile?.role === "super_admin";
|
const isSuperAdmin = isTest || profile?.role === "super_admin";
|
||||||
|
|||||||
@@ -109,7 +109,10 @@ function TenantCreatePage() {
|
|||||||
name="name"
|
name="name"
|
||||||
value={name}
|
value={name}
|
||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => setName(e.target.value)}
|
||||||
placeholder={t("ui.admin.tenants.create.form.name_placeholder", "테넌트 이름을 입력하세요")}
|
placeholder={t(
|
||||||
|
"ui.admin.tenants.create.form.name_placeholder",
|
||||||
|
"테넌트 이름을 입력하세요",
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
@@ -183,7 +186,10 @@ function TenantCreatePage() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="tenant-description" className="text-sm font-semibold">
|
<Label
|
||||||
|
htmlFor="tenant-description"
|
||||||
|
className="text-sm font-semibold"
|
||||||
|
>
|
||||||
{t("ui.admin.tenants.create.form.description", "설명")}
|
{t("ui.admin.tenants.create.form.description", "설명")}
|
||||||
</Label>
|
</Label>
|
||||||
<Textarea
|
<Textarea
|
||||||
|
|||||||
@@ -111,7 +111,11 @@ ${example}`,
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button variant="outline" className="gap-2" data-testid="bulk-import-btn">
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="gap-2"
|
||||||
|
data-testid="bulk-import-btn"
|
||||||
|
>
|
||||||
<Upload size={16} />
|
<Upload size={16} />
|
||||||
{t("ui.admin.users.list.bulk_import", "일괄 등록 (CSV)")}
|
{t("ui.admin.users.list.bulk_import", "일괄 등록 (CSV)")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
const apiClient = axios.create({
|
const apiClient = axios.create({
|
||||||
baseURL: (window as any)._IS_TEST_MODE ? "http://playwright-mock/api" : (import.meta.env.VITE_ADMIN_API_BASE ?? "/api"),
|
baseURL: (window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean })
|
||||||
|
._IS_TEST_MODE
|
||||||
|
? "http://playwright-mock/api"
|
||||||
|
: (import.meta.env.VITE_ADMIN_API_BASE ?? "/api"),
|
||||||
});
|
});
|
||||||
|
|
||||||
apiClient.interceptors.request.use((config) => {
|
apiClient.interceptors.request.use((config) => {
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ test.describe("Authentication", () => {
|
|||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
window.localStorage.setItem("locale", "ko");
|
window.localStorage.setItem("locale", "ko");
|
||||||
window.localStorage.setItem("admin_session", "fake-token");
|
window.localStorage.setItem("admin_session", "fake-token");
|
||||||
(window as any)._IS_TEST_MODE = true;
|
(
|
||||||
|
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||||
|
)._IS_TEST_MODE = true;
|
||||||
|
|
||||||
const authority = "http://localhost:5000/oidc";
|
const authority = "http://localhost:5000/oidc";
|
||||||
const client_id = "adminfront";
|
const client_id = "adminfront";
|
||||||
@@ -14,7 +16,12 @@ test.describe("Authentication", () => {
|
|||||||
const authData = {
|
const authData = {
|
||||||
access_token: "fake-token",
|
access_token: "fake-token",
|
||||||
token_type: "Bearer",
|
token_type: "Bearer",
|
||||||
profile: { sub: "admin-user", name: "Admin", email: "admin@test.com", role: "super_admin" },
|
profile: {
|
||||||
|
sub: "admin-user",
|
||||||
|
name: "Admin",
|
||||||
|
email: "admin@test.com",
|
||||||
|
role: "super_admin",
|
||||||
|
},
|
||||||
expires_at: Math.floor(Date.now() / 1000) + 36000,
|
expires_at: Math.floor(Date.now() / 1000) + 36000,
|
||||||
};
|
};
|
||||||
window.localStorage.setItem(key, JSON.stringify(authData));
|
window.localStorage.setItem(key, JSON.stringify(authData));
|
||||||
@@ -23,8 +30,13 @@ test.describe("Authentication", () => {
|
|||||||
// 2. High-priority Mocks
|
// 2. High-priority Mocks
|
||||||
await page.route("**/api/v1/user/me", async (route) => {
|
await page.route("**/api/v1/user/me", async (route) => {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
json: { id: "admin-user", name: "Admin", role: "super_admin", manageableTenants: [] },
|
json: {
|
||||||
headers: { 'Access-Control-Allow-Origin': '*' }
|
id: "admin-user",
|
||||||
|
name: "Admin",
|
||||||
|
role: "super_admin",
|
||||||
|
manageableTenants: [],
|
||||||
|
},
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -40,15 +52,19 @@ test.describe("Authentication", () => {
|
|||||||
userinfo_endpoint: "http://localhost:5000/oidc/userinfo",
|
userinfo_endpoint: "http://localhost:5000/oidc/userinfo",
|
||||||
end_session_endpoint: "http://localhost:5000/oidc/session/end",
|
end_session_endpoint: "http://localhost:5000/oidc/session/end",
|
||||||
},
|
},
|
||||||
headers: { 'Access-Control-Allow-Origin': '*' }
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
});
|
});
|
||||||
} else if (url.includes("/jwks")) {
|
} else if (url.includes("/jwks")) {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
json: { keys: [] },
|
json: { keys: [] },
|
||||||
headers: { 'Access-Control-Allow-Origin': '*' }
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await route.fulfill({ status: 200, body: "ok", headers: { 'Access-Control-Allow-Origin': '*' } });
|
await route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
body: "ok",
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -65,23 +81,33 @@ test.describe("Authentication", () => {
|
|||||||
test("should redirect unauthorized users to login page", async ({ page }) => {
|
test("should redirect unauthorized users to login page", async ({ page }) => {
|
||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
(window as any)._IS_TEST_MODE = false;
|
(
|
||||||
|
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||||
|
)._IS_TEST_MODE = false;
|
||||||
});
|
});
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
await expect(page).toHaveURL(/.*\/login.*/, { timeout: 15000 });
|
await expect(page).toHaveURL(/.*\/login.*/, { timeout: 15000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should allow access to dashboard when authenticated", async ({ page }) => {
|
test("should allow access to dashboard when authenticated", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
// strict mode violation 피하기 위해 .last() 사용하거나 더 구체적인 셀렉터 사용
|
// strict mode violation 피하기 위해 .last() 사용하거나 더 구체적인 셀렉터 사용
|
||||||
await expect(page.locator("h1").last()).toContainText(/Admin Control|운영 도구/i, { timeout: 15000 });
|
await expect(page.locator("h1").last()).toContainText(
|
||||||
|
/Admin Control|운영 도구/i,
|
||||||
|
{ timeout: 15000 },
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should logout and redirect to login page", async ({ page }) => {
|
test("should logout and redirect to login page", async ({ page }) => {
|
||||||
await page.goto("/");
|
await page.goto("/");
|
||||||
page.on("dialog", (dialog) => dialog.accept());
|
page.on("dialog", (dialog) => dialog.accept());
|
||||||
const logoutBtn = page.locator('button').filter({ hasText: /Logout|로그아웃/i }).first();
|
const logoutBtn = page
|
||||||
await logoutBtn.waitFor({ state: 'visible' });
|
.locator("button")
|
||||||
|
.filter({ hasText: /Logout|로그아웃/i })
|
||||||
|
.first();
|
||||||
|
await logoutBtn.waitFor({ state: "visible" });
|
||||||
await logoutBtn.click();
|
await logoutBtn.click();
|
||||||
await expect(page).toHaveURL(/.*\/login.*/, { timeout: 15000 });
|
await expect(page).toHaveURL(/.*\/login.*/, { timeout: 15000 });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ test.describe("Bulk Actions and Tree Search", () => {
|
|||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
window.localStorage.setItem("locale", "ko");
|
window.localStorage.setItem("locale", "ko");
|
||||||
window.localStorage.setItem("admin_session", "fake-token");
|
window.localStorage.setItem("admin_session", "fake-token");
|
||||||
(window as any)._IS_TEST_MODE = true;
|
(
|
||||||
|
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||||
|
)._IS_TEST_MODE = true;
|
||||||
|
|
||||||
const authority = "http://localhost:5000/oidc";
|
const authority = "http://localhost:5000/oidc";
|
||||||
const client_id = "adminfront";
|
const client_id = "adminfront";
|
||||||
@@ -22,24 +24,43 @@ test.describe("Bulk Actions and Tree Search", () => {
|
|||||||
// Capture ALL API calls to our mock host
|
// Capture ALL API calls to our mock host
|
||||||
await page.route("**/api/v1/**", async (route) => {
|
await page.route("**/api/v1/**", async (route) => {
|
||||||
const url = route.request().url();
|
const url = route.request().url();
|
||||||
const headers = { 'Access-Control-Allow-Origin': '*' };
|
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||||
|
|
||||||
if (url.includes("/user/me")) {
|
if (url.includes("/user/me")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: { id: "admin", role: "super_admin", name: "Admin", manageableTenants: [] },
|
json: {
|
||||||
headers
|
id: "admin",
|
||||||
|
role: "super_admin",
|
||||||
|
name: "Admin",
|
||||||
|
manageableTenants: [],
|
||||||
|
},
|
||||||
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (url.includes("/admin/users")) {
|
if (url.includes("/admin/users")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: {
|
json: {
|
||||||
items: [
|
items: [
|
||||||
{ id: "u-1", name: "User One", email: "u1@test.com", status: "active", role: "user", createdAt: new Date().toISOString() },
|
{
|
||||||
{ id: "u-2", name: "User Two", email: "u2@test.com", status: "active", role: "user", createdAt: new Date().toISOString() },
|
id: "u-1",
|
||||||
|
name: "User One",
|
||||||
|
email: "u1@test.com",
|
||||||
|
status: "active",
|
||||||
|
role: "user",
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "u-2",
|
||||||
|
name: "User Two",
|
||||||
|
email: "u2@test.com",
|
||||||
|
status: "active",
|
||||||
|
role: "user",
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
total: 2,
|
total: 2,
|
||||||
},
|
},
|
||||||
headers
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (url.includes("/organization")) {
|
if (url.includes("/organization")) {
|
||||||
@@ -48,19 +69,28 @@ test.describe("Bulk Actions and Tree Search", () => {
|
|||||||
{ id: "g-1", name: "Engineering", slug: "eng", tenantId: "t-1" },
|
{ id: "g-1", name: "Engineering", slug: "eng", tenantId: "t-1" },
|
||||||
{ id: "g-2", name: "Sales", slug: "sales", tenantId: "t-1" },
|
{ id: "g-2", name: "Sales", slug: "sales", tenantId: "t-1" },
|
||||||
],
|
],
|
||||||
headers
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (url.includes("/admin/tenants/t-1")) {
|
if (url.includes("/admin/tenants/t-1")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: { id: "t-1", name: "Main Tenant", slug: "main", status: "active", type: "COMPANY" },
|
json: {
|
||||||
headers
|
id: "t-1",
|
||||||
|
name: "Main Tenant",
|
||||||
|
slug: "main",
|
||||||
|
status: "active",
|
||||||
|
type: "COMPANY",
|
||||||
|
},
|
||||||
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (url.includes("/admin/tenants")) {
|
if (url.includes("/admin/tenants")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: { items: [{ id: "t-1", name: "Main Tenant", slug: "main" }], total: 1 },
|
json: {
|
||||||
headers
|
items: [{ id: "t-1", name: "Main Tenant", slug: "main" }],
|
||||||
|
total: 1,
|
||||||
|
},
|
||||||
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +102,9 @@ test.describe("Bulk Actions and Tree Search", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should show bulk action bar when users are selected", async ({ page }) => {
|
test("should show bulk action bar when users are selected", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
await page.goto("/users");
|
await page.goto("/users");
|
||||||
// 로딩바 대기 대신 실제 데이터 텍스트 대기
|
// 로딩바 대기 대신 실제 데이터 텍스트 대기
|
||||||
const table = page.locator("table");
|
const table = page.locator("table");
|
||||||
@@ -101,21 +133,34 @@ test.describe("Bulk Actions and Tree Search", () => {
|
|||||||
await expect(selectionBar).not.toBeVisible({ timeout: 10000 });
|
await expect(selectionBar).not.toBeVisible({ timeout: 10000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should filter and highlight nodes in organization tree", async ({ page }) => {
|
test("should filter and highlight nodes in organization tree", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
await page.goto("/tenants/t-1");
|
await page.goto("/tenants/t-1");
|
||||||
// 테넌트 이름이 제목으로 나올 때까지 대기
|
// 테넌트 이름이 제목으로 나올 때까지 대기
|
||||||
await expect(page.locator("h2").last()).toContainText(/Main Tenant|상세|Profile/i, { timeout: 20000 });
|
await expect(page.locator("h2").last()).toContainText(
|
||||||
|
/Main Tenant|상세|Profile/i,
|
||||||
|
{ timeout: 20000 },
|
||||||
|
);
|
||||||
|
|
||||||
const subTenantLink = page.locator('a, button').filter({ hasText: /조직 관리|Organization|Sub-tenant/i }).first();
|
const subTenantLink = page
|
||||||
|
.locator("a, button")
|
||||||
|
.filter({ hasText: /조직 관리|Organization|Sub-tenant/i })
|
||||||
|
.first();
|
||||||
await subTenantLink.click();
|
await subTenantLink.click();
|
||||||
|
|
||||||
// 트리 검색 입력창 대기 (더 유연한 셀렉터)
|
// 트리 검색 입력창 대기 (더 유연한 셀렉터)
|
||||||
const searchInput = page.locator('input[placeholder*="검색"], input[placeholder*="Search"]').first();
|
const searchInput = page
|
||||||
|
.locator('input[placeholder*="검색"], input[placeholder*="Search"]')
|
||||||
|
.first();
|
||||||
await expect(searchInput).toBeVisible({ timeout: 15000 });
|
await expect(searchInput).toBeVisible({ timeout: 15000 });
|
||||||
|
|
||||||
await searchInput.fill("Eng");
|
await searchInput.fill("Eng");
|
||||||
|
|
||||||
const engRow = page.locator('tr').filter({ hasText: "Engineering" }).first();
|
const engRow = page
|
||||||
|
.locator("tr")
|
||||||
|
.filter({ hasText: "Engineering" })
|
||||||
|
.first();
|
||||||
await expect(engRow).toBeVisible();
|
await expect(engRow).toBeVisible();
|
||||||
await expect(engRow).toHaveClass(/bg-primary/);
|
await expect(engRow).toHaveClass(/bg-primary/);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ test.describe("Tenant Owners Management", () => {
|
|||||||
window.localStorage.setItem(key, JSON.stringify(authData));
|
window.localStorage.setItem(key, JSON.stringify(authData));
|
||||||
window.localStorage.setItem("admin_session", "fake-token");
|
window.localStorage.setItem("admin_session", "fake-token");
|
||||||
window.localStorage.setItem("locale", "ko");
|
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) => {
|
await page.route("**/oidc/**", async (route) => {
|
||||||
@@ -29,7 +31,8 @@ test.describe("Tenant Owners Management", () => {
|
|||||||
|
|
||||||
await page.route(/.*\/api\/v1\/.*/, async (route) => {
|
await page.route(/.*\/api\/v1\/.*/, async (route) => {
|
||||||
const url = route.request().url();
|
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({
|
return route.fulfill({
|
||||||
json: {
|
json: {
|
||||||
id: "admin-user",
|
id: "admin-user",
|
||||||
@@ -85,27 +88,39 @@ test.describe("Tenant Owners Management", () => {
|
|||||||
|
|
||||||
await expect(page.getByText(/테넌트 소유자|Tenant Owners/)).toBeVisible();
|
await expect(page.getByText(/테넌트 소유자|Tenant Owners/)).toBeVisible();
|
||||||
await expect(page.locator("table").first()).toContainText("Owner One");
|
await expect(page.locator("table").first()).toContainText("Owner One");
|
||||||
await expect(page.locator("table").first()).toContainText("owner1@example.com");
|
await expect(page.locator("table").first()).toContainText(
|
||||||
|
"owner1@example.com",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should add a new owner", async ({ page }) => {
|
test("should add a new owner", async ({ page }) => {
|
||||||
// Specific override for this test
|
// Specific override for this test
|
||||||
await page.route("**/api/v1/admin/tenants/tenant-1/owners", async (route) => {
|
await page.route(
|
||||||
if (route.request().method() === "GET") {
|
"**/api/v1/admin/tenants/tenant-1/owners",
|
||||||
await route.fulfill({ json: [] });
|
async (route) => {
|
||||||
} else {
|
if (route.request().method() === "GET") {
|
||||||
await route.fulfill({ status: 200, json: {} });
|
await route.fulfill({ json: [] });
|
||||||
}
|
} else {
|
||||||
});
|
await route.fulfill({ status: 200, json: {} });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
await page.goto("/tenants/tenant-1/permissions");
|
await page.goto("/tenants/tenant-1/permissions");
|
||||||
await page.waitForLoadState("networkidle");
|
await page.waitForLoadState("networkidle");
|
||||||
await expect(page.locator(".animate-spin").first()).not.toBeVisible();
|
await expect(page.locator(".animate-spin").first()).not.toBeVisible();
|
||||||
|
|
||||||
await page.click('button:has-text("소유자 추가"), button:has-text("Add Owner")');
|
await page.click(
|
||||||
await page.fill('input[placeholder*="사용자 검색"], input[placeholder*="Search users"]', "User Two");
|
'button:has-text("소유자 추가"), button:has-text("Add Owner")',
|
||||||
|
);
|
||||||
|
await page.fill(
|
||||||
|
'input[placeholder*="사용자 검색"], input[placeholder*="Search users"]',
|
||||||
|
"User Two",
|
||||||
|
);
|
||||||
|
|
||||||
const addButton = page.locator("role=dialog").getByRole("button", { name: /추가|Add/ });
|
const addButton = page
|
||||||
|
.locator("role=dialog")
|
||||||
|
.getByRole("button", { name: /추가|Add/ });
|
||||||
await addButton.click();
|
await addButton.click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ test.describe("Tenants Management", () => {
|
|||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
window.localStorage.setItem("locale", "ko");
|
window.localStorage.setItem("locale", "ko");
|
||||||
window.localStorage.setItem("admin_session", "fake-token");
|
window.localStorage.setItem("admin_session", "fake-token");
|
||||||
(window as any)._IS_TEST_MODE = true;
|
(
|
||||||
|
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||||
|
)._IS_TEST_MODE = true;
|
||||||
|
|
||||||
const authority = "http://localhost:5000/oidc";
|
const authority = "http://localhost:5000/oidc";
|
||||||
const client_id = "adminfront";
|
const client_id = "adminfront";
|
||||||
@@ -21,19 +23,28 @@ test.describe("Tenants Management", () => {
|
|||||||
|
|
||||||
await page.route("**/api/v1/**", async (route) => {
|
await page.route("**/api/v1/**", async (route) => {
|
||||||
const url = route.request().url();
|
const url = route.request().url();
|
||||||
const headers = { 'Access-Control-Allow-Origin': '*' };
|
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||||
|
|
||||||
if (url.includes("/user/me")) {
|
if (url.includes("/user/me")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: { id: "admin-user", name: "Admin", role: "super_admin", manageableTenants: [] },
|
json: {
|
||||||
headers
|
id: "admin-user",
|
||||||
|
name: "Admin",
|
||||||
|
role: "super_admin",
|
||||||
|
manageableTenants: [],
|
||||||
|
},
|
||||||
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (url.includes("/admin/tenants")) {
|
if (url.includes("/admin/tenants")) {
|
||||||
if (route.request().method() === "GET" && !url.includes("/parent-1") && !url.includes("/organization")) {
|
if (
|
||||||
|
route.request().method() === "GET" &&
|
||||||
|
!url.includes("/parent-1") &&
|
||||||
|
!url.includes("/organization")
|
||||||
|
) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: { items: [], total: 0, limit: 100, offset: 0 },
|
json: { items: [], total: 0, limit: 100, offset: 0 },
|
||||||
headers
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,10 +61,21 @@ test.describe("Tenants Management", () => {
|
|||||||
if (route.request().method() === "GET") {
|
if (route.request().method() === "GET") {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
json: {
|
json: {
|
||||||
items: [{ id: "1", name: "Tenant A", slug: "tenant-a", status: "active", type: "COMPANY", updatedAt: new Date().toISOString() }],
|
items: [
|
||||||
total: 1, limit: 1000, offset: 0,
|
{
|
||||||
|
id: "1",
|
||||||
|
name: "Tenant A",
|
||||||
|
slug: "tenant-a",
|
||||||
|
status: "active",
|
||||||
|
type: "COMPANY",
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
total: 1,
|
||||||
|
limit: 1000,
|
||||||
|
offset: 0,
|
||||||
},
|
},
|
||||||
headers: { 'Access-Control-Allow-Origin': '*' }
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await route.continue();
|
await route.continue();
|
||||||
@@ -61,13 +83,20 @@ test.describe("Tenants Management", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await page.goto("/tenants");
|
await page.goto("/tenants");
|
||||||
await expect(page.locator("h2").last()).toContainText(/테넌트 목록|Tenants/i, { timeout: 20000 });
|
await expect(page.locator("h2").last()).toContainText(
|
||||||
await expect(page.locator("table")).toContainText("Tenant A", { timeout: 10000 });
|
/테넌트 목록|Tenants/i,
|
||||||
|
{ timeout: 20000 },
|
||||||
|
);
|
||||||
|
await expect(page.locator("table")).toContainText("Tenant A", {
|
||||||
|
timeout: 10000,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should create a new tenant", async ({ page }) => {
|
test("should create a new tenant", async ({ page }) => {
|
||||||
await page.goto("/tenants/new");
|
await page.goto("/tenants/new");
|
||||||
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, { timeout: 20000 });
|
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, {
|
||||||
|
timeout: 20000,
|
||||||
|
});
|
||||||
|
|
||||||
const nameInput = page.locator('input[name="name"]').first();
|
const nameInput = page.locator('input[name="name"]').first();
|
||||||
await nameInput.fill("New Tenant");
|
await nameInput.fill("New Tenant");
|
||||||
@@ -77,51 +106,96 @@ test.describe("Tenants Management", () => {
|
|||||||
|
|
||||||
await page.locator("textarea").first().fill("Description");
|
await page.locator("textarea").first().fill("Description");
|
||||||
|
|
||||||
const submitBtn = page.locator('button').filter({ hasText: /생성|Create/i }).first();
|
const submitBtn = page
|
||||||
|
.locator("button")
|
||||||
|
.filter({ hasText: /생성|Create/i })
|
||||||
|
.first();
|
||||||
await submitBtn.click();
|
await submitBtn.click();
|
||||||
await expect(page).toHaveURL(/.*\/tenants$/, { timeout: 15000 });
|
await expect(page).toHaveURL(/.*\/tenants$/, { timeout: 15000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should show validation error on empty name", async ({ page }) => {
|
test("should show validation error on empty name", async ({ page }) => {
|
||||||
await page.goto("/tenants/new");
|
await page.goto("/tenants/new");
|
||||||
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, { timeout: 20000 });
|
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, {
|
||||||
|
timeout: 20000,
|
||||||
|
});
|
||||||
|
|
||||||
const submitBtn = page.locator('button').filter({ hasText: /생성|Create/i }).first();
|
const submitBtn = page
|
||||||
|
.locator("button")
|
||||||
|
.filter({ hasText: /생성|Create/i })
|
||||||
|
.first();
|
||||||
await expect(submitBtn).toBeDisabled();
|
await expect(submitBtn).toBeDisabled();
|
||||||
|
|
||||||
await page.locator('input[name="name"]').first().fill("Valid Name");
|
await page.locator('input[name="name"]').first().fill("Valid Name");
|
||||||
await expect(submitBtn).not.toBeDisabled();
|
await expect(submitBtn).not.toBeDisabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should show organization hierarchy and member list distinction", async ({ page }) => {
|
test("should show organization hierarchy and member list distinction", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
const mockTenants = [
|
const mockTenants = [
|
||||||
{ id: "parent-1", name: "Parent Org", slug: "parent-slug", status: "active", type: "COMPANY", memberCount: 5, parentId: null },
|
{
|
||||||
{ id: "child-1", name: "Child Team", slug: "child-slug", status: "active", type: "USER_GROUP", memberCount: 3, parentId: "parent-1" },
|
id: "parent-1",
|
||||||
|
name: "Parent Org",
|
||||||
|
slug: "parent-slug",
|
||||||
|
status: "active",
|
||||||
|
type: "COMPANY",
|
||||||
|
memberCount: 5,
|
||||||
|
parentId: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "child-1",
|
||||||
|
name: "Child Team",
|
||||||
|
slug: "child-slug",
|
||||||
|
status: "active",
|
||||||
|
type: "USER_GROUP",
|
||||||
|
memberCount: 3,
|
||||||
|
parentId: "parent-1",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||||
const url = route.request().url();
|
const url = route.request().url();
|
||||||
if (url.includes("/organization")) {
|
if (url.includes("/organization")) {
|
||||||
await route.fulfill({ json: mockTenants, headers: { 'Access-Control-Allow-Origin': '*' } });
|
await route.fulfill({
|
||||||
|
json: mockTenants,
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
|
});
|
||||||
} else if (url.includes("/parent-1")) {
|
} else if (url.includes("/parent-1")) {
|
||||||
await route.fulfill({ json: mockTenants[0], headers: { 'Access-Control-Allow-Origin': '*' } });
|
await route.fulfill({
|
||||||
|
json: mockTenants[0],
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
json: { items: mockTenants, total: 2, limit: 1000, offset: 0 },
|
json: { items: mockTenants, total: 2, limit: 1000, offset: 0 },
|
||||||
headers: { 'Access-Control-Allow-Origin': '*' }
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.goto("/tenants/parent-1/organization");
|
await page.goto("/tenants/parent-1/organization");
|
||||||
await expect(page.locator("table")).toContainText("Parent Org", { timeout: 20000 });
|
await expect(page.locator("table")).toContainText("Parent Org", {
|
||||||
|
timeout: 20000,
|
||||||
|
});
|
||||||
|
|
||||||
const parentRow = page.locator('tr').filter({ hasText: "Parent Org" }).first();
|
const parentRow = page
|
||||||
|
.locator("tr")
|
||||||
|
.filter({ hasText: "Parent Org" })
|
||||||
|
.first();
|
||||||
await expect(parentRow).toContainText("5");
|
await expect(parentRow).toContainText("5");
|
||||||
|
|
||||||
const memberButton = parentRow.getByRole("button").filter({ hasText: /Direct|소속|직속/ }).first();
|
const memberButton = parentRow
|
||||||
|
.getByRole("button")
|
||||||
|
.filter({ hasText: /Direct|소속|직속/ })
|
||||||
|
.first();
|
||||||
await memberButton.click();
|
await memberButton.click();
|
||||||
|
|
||||||
await expect(page.locator('button[role="tab"]').filter({ hasText: /소속 멤버|Direct Members/i }).first()).toBeVisible();
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('button[role="tab"]')
|
||||||
|
.filter({ hasText: /소속 멤버|Direct Members/i })
|
||||||
|
.first(),
|
||||||
|
).toBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ test.describe("Users Bulk Upload", () => {
|
|||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
window.localStorage.setItem("locale", "ko");
|
window.localStorage.setItem("locale", "ko");
|
||||||
window.localStorage.setItem("admin_session", "fake-token");
|
window.localStorage.setItem("admin_session", "fake-token");
|
||||||
(window as any)._IS_TEST_MODE = true;
|
(
|
||||||
|
window as Window & typeof globalThis & { _IS_TEST_MODE?: boolean }
|
||||||
|
)._IS_TEST_MODE = true;
|
||||||
|
|
||||||
const authority = "http://localhost:5000/oidc";
|
const authority = "http://localhost:5000/oidc";
|
||||||
const client_id = "adminfront";
|
const client_id = "adminfront";
|
||||||
@@ -21,21 +23,32 @@ test.describe("Users Bulk Upload", () => {
|
|||||||
|
|
||||||
await page.route("**/api/v1/**", async (route) => {
|
await page.route("**/api/v1/**", async (route) => {
|
||||||
const url = route.request().url();
|
const url = route.request().url();
|
||||||
const headers = { 'Access-Control-Allow-Origin': '*' };
|
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||||
|
|
||||||
if (url.includes("/user/me")) {
|
if (url.includes("/user/me")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: { id: "admin-user", name: "Admin", role: "super_admin", manageableTenants: [] },
|
json: {
|
||||||
headers
|
id: "admin-user",
|
||||||
|
name: "Admin",
|
||||||
|
role: "super_admin",
|
||||||
|
manageableTenants: [],
|
||||||
|
},
|
||||||
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (url.includes("/admin/users")) {
|
if (url.includes("/admin/users")) {
|
||||||
if (!url.includes("/bulk")) {
|
if (!url.includes("/bulk")) {
|
||||||
return route.fulfill({ json: { items: [], total: 0, limit: 50, offset: 0 }, headers });
|
return route.fulfill({
|
||||||
|
json: { items: [], total: 0, limit: 50, offset: 0 },
|
||||||
|
headers,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (url.includes("/admin/tenants")) {
|
if (url.includes("/admin/tenants")) {
|
||||||
return route.fulfill({ json: { items: [], total: 0, limit: 100, offset: 0 }, headers });
|
return route.fulfill({
|
||||||
|
json: { items: [], total: 0, limit: 100, offset: 0 },
|
||||||
|
headers,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
||||||
});
|
});
|
||||||
@@ -48,13 +61,21 @@ test.describe("Users Bulk Upload", () => {
|
|||||||
test("should open bulk upload modal and show preview", async ({ page }) => {
|
test("should open bulk upload modal and show preview", async ({ page }) => {
|
||||||
await page.goto("/users");
|
await page.goto("/users");
|
||||||
// 헤더 타이틀이 뜰 때까지 대기
|
// 헤더 타이틀이 뜰 때까지 대기
|
||||||
await expect(page.getByTestId("page-title")).toContainText(/사용자|Users/i, { timeout: 20000 });
|
await expect(page.getByTestId("page-title")).toContainText(
|
||||||
|
/사용자|Users/i,
|
||||||
|
{ timeout: 20000 },
|
||||||
|
);
|
||||||
|
|
||||||
const bulkBtn = page.getByTestId("bulk-import-btn");
|
const bulkBtn = page.getByTestId("bulk-import-btn");
|
||||||
await bulkBtn.click();
|
await bulkBtn.click();
|
||||||
|
|
||||||
await expect(page.getByTestId("bulk-upload-title")).toBeVisible({ timeout: 10000 });
|
await expect(page.getByTestId("bulk-upload-title")).toBeVisible({
|
||||||
const downloadBtn = page.locator('button').filter({ hasText: /템플릿 다운로드|템플릿 받기|Download Template/ }).first();
|
timeout: 10000,
|
||||||
|
});
|
||||||
|
const downloadBtn = page
|
||||||
|
.locator("button")
|
||||||
|
.filter({ hasText: /템플릿 다운로드|템플릿 받기|Download Template/ })
|
||||||
|
.first();
|
||||||
await expect(downloadBtn).toBeVisible();
|
await expect(downloadBtn).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -65,10 +86,14 @@ test.describe("Users Bulk Upload", () => {
|
|||||||
json: {
|
json: {
|
||||||
results: [
|
results: [
|
||||||
{ email: "success@test.com", success: true, userId: "u-1" },
|
{ email: "success@test.com", success: true, userId: "u-1" },
|
||||||
{ email: "fail@test.com", success: false, message: "Invalid format" },
|
{
|
||||||
|
email: "fail@test.com",
|
||||||
|
success: false,
|
||||||
|
message: "Invalid format",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
headers: { 'Access-Control-Allow-Origin': '*' }
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await route.continue();
|
await route.continue();
|
||||||
@@ -76,7 +101,10 @@ test.describe("Users Bulk Upload", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await page.goto("/users");
|
await page.goto("/users");
|
||||||
await expect(page.getByTestId("page-title")).toContainText(/사용자|Users/i, { timeout: 20000 });
|
await expect(page.getByTestId("page-title")).toContainText(
|
||||||
|
/사용자|Users/i,
|
||||||
|
{ timeout: 20000 },
|
||||||
|
);
|
||||||
|
|
||||||
const bulkBtn = page.getByTestId("bulk-import-btn");
|
const bulkBtn = page.getByTestId("bulk-import-btn");
|
||||||
await bulkBtn.click();
|
await bulkBtn.click();
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ test.describe("User Schema Dynamic Form", () => {
|
|||||||
window.localStorage.setItem(key, JSON.stringify(authData));
|
window.localStorage.setItem(key, JSON.stringify(authData));
|
||||||
window.localStorage.setItem("admin_session", "fake-token");
|
window.localStorage.setItem("admin_session", "fake-token");
|
||||||
window.localStorage.setItem("locale", "ko");
|
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) => {
|
await page.route("**/oidc/**", async (route) => {
|
||||||
@@ -24,20 +26,38 @@ test.describe("User Schema Dynamic Form", () => {
|
|||||||
|
|
||||||
await page.route(/.*\/api\/v1\/.*/, async (route) => {
|
await page.route(/.*\/api\/v1\/.*/, async (route) => {
|
||||||
const url = route.request().url();
|
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({
|
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")) {
|
if (url.includes("/admin/tenants/t-1")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: {
|
json: {
|
||||||
id: "t-1", name: "Test Tenant", slug: "test-tenant",
|
id: "t-1",
|
||||||
|
name: "Test Tenant",
|
||||||
|
slug: "test-tenant",
|
||||||
config: {
|
config: {
|
||||||
userSchema: [
|
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")) {
|
if (url.includes("/admin/users/u-1")) {
|
||||||
return route.fulfill({
|
return route.fulfill({
|
||||||
json: {
|
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" },
|
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 } },
|
metadata: { "t-1": { emp_id: "E123", salary: 1000 } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -57,7 +82,10 @@ test.describe("User Schema Dynamic Form", () => {
|
|||||||
|
|
||||||
if (url.includes("/admin/tenants")) {
|
if (url.includes("/admin/tenants")) {
|
||||||
return route.fulfill({
|
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,13 +93,17 @@ 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.goto("/users/u-1");
|
||||||
await page.waitForLoadState("networkidle");
|
await page.waitForLoadState("networkidle");
|
||||||
|
|
||||||
// 섹션 헤더 확인
|
// 섹션 헤더 확인
|
||||||
const header = page.getByText(/테넌트별 프로필 관리|Per-tenant Profile/i).first();
|
const header = page
|
||||||
await header.waitFor({ state: 'visible' });
|
.getByText(/테넌트별 프로필 관리|Per-tenant Profile/i)
|
||||||
|
.first();
|
||||||
|
await header.waitFor({ state: "visible" });
|
||||||
|
|
||||||
// 커스텀 필드 레이블 확인
|
// 커스텀 필드 레이블 확인
|
||||||
await expect(page.getByText("Employee ID")).toBeVisible();
|
await expect(page.getByText("Employee ID")).toBeVisible();
|
||||||
@@ -86,19 +118,23 @@ test.describe("User Schema Dynamic Form", () => {
|
|||||||
await expect(page.getByText(/Admin Only/i).first()).toBeVisible();
|
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.goto("/users/u-1");
|
||||||
await page.waitForLoadState("networkidle");
|
await page.waitForLoadState("networkidle");
|
||||||
|
|
||||||
const empIdInput = page.locator('input[id*="emp_id"]');
|
const empIdInput = page.locator('input[id*="emp_id"]');
|
||||||
await empIdInput.waitFor({ state: 'visible' });
|
await empIdInput.waitFor({ state: "visible" });
|
||||||
await empIdInput.fill("invalid");
|
await empIdInput.fill("invalid");
|
||||||
|
|
||||||
// 포커스 해제하여 유효성 검사 트리거
|
// 포커스 해제하여 유효성 검사 트리거
|
||||||
await page.getByLabel(/이름|Name/i).click();
|
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();
|
await expect(errorMsg).toBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ func (h *UserHandler) ListUsers(c *fiber.Ctx) error {
|
|||||||
var requesterRole string
|
var requesterRole string
|
||||||
if profile, ok := c.Locals("user_profile").(*domain.UserProfileResponse); ok {
|
if profile, ok := c.Locals("user_profile").(*domain.UserProfileResponse); ok {
|
||||||
requesterRole = domain.NormalizeRole(profile.Role)
|
requesterRole = domain.NormalizeRole(profile.Role)
|
||||||
requesterCompany = profile.CompanyCode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
limit := c.QueryInt("limit", 50)
|
limit := c.QueryInt("limit", 50)
|
||||||
|
|||||||
@@ -1,34 +1,8 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
|
import { seedAuth } from "./helpers/devfront-fixtures";
|
||||||
|
|
||||||
test("clients page loads correctly", async ({ page }) => {
|
test("clients page loads correctly", async ({ page }) => {
|
||||||
const nowInSeconds = Math.floor(Date.now() / 1000);
|
await seedAuth(page);
|
||||||
|
|
||||||
await page.addInitScript((issuedAt) => {
|
|
||||||
const mockOidcUser = {
|
|
||||||
id_token: "playwright-id-token",
|
|
||||||
session_state: "playwright-session",
|
|
||||||
access_token: "playwright-access-token",
|
|
||||||
refresh_token: "playwright-refresh-token",
|
|
||||||
token_type: "Bearer",
|
|
||||||
scope: "openid profile email",
|
|
||||||
profile: {
|
|
||||||
sub: "playwright-user",
|
|
||||||
email: "playwright@example.com",
|
|
||||||
name: "Playwright User",
|
|
||||||
},
|
|
||||||
expires_at: issuedAt + 3600,
|
|
||||||
};
|
|
||||||
|
|
||||||
// oidc-client-ts storage key format: oidc.user:{authority}:{client_id}
|
|
||||||
window.localStorage.setItem(
|
|
||||||
"oidc.user:http://localhost:5000/oidc:devfront",
|
|
||||||
JSON.stringify(mockOidcUser),
|
|
||||||
);
|
|
||||||
window.localStorage.setItem(
|
|
||||||
"oidc.user:http://localhost:5000/oidc/:devfront",
|
|
||||||
JSON.stringify(mockOidcUser),
|
|
||||||
);
|
|
||||||
}, nowInSeconds);
|
|
||||||
|
|
||||||
await page.route("**/api/v1/dev/clients**", async (route) => {
|
await page.route("**/api/v1/dev/clients**", async (route) => {
|
||||||
if (route.request().method() !== "GET") {
|
if (route.request().method() !== "GET") {
|
||||||
|
|||||||
@@ -103,6 +103,31 @@ export async function seedAuth(page: Page, role?: string) {
|
|||||||
},
|
},
|
||||||
{ issuedAt: nowInSeconds, injectedRole: role ?? "" },
|
{ issuedAt: nowInSeconds, injectedRole: role ?? "" },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await page.route("**/oidc/**", async (route) => {
|
||||||
|
const url = route.request().url();
|
||||||
|
if (url.includes(".well-known/openid-configuration")) {
|
||||||
|
await route.fulfill({
|
||||||
|
json: {
|
||||||
|
issuer: "http://localhost:5000/oidc",
|
||||||
|
authorization_endpoint: "http://localhost:5000/oidc/auth",
|
||||||
|
token_endpoint: "http://localhost:5000/oidc/token",
|
||||||
|
jwks_uri: "http://localhost:5000/oidc/jwks",
|
||||||
|
userinfo_endpoint: "http://localhost:5000/oidc/userinfo",
|
||||||
|
end_session_endpoint: "http://localhost:5000/oidc/session/end",
|
||||||
|
},
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
|
});
|
||||||
|
} else if (url.includes("/jwks")) {
|
||||||
|
await route.fulfill({
|
||||||
|
json: { keys: [] },
|
||||||
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await route.fulfill({ status: 200, body: "ok", headers: { "Access-Control-Allow-Origin": "*" } });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function json(route: Route, payload: unknown, status = 200) {
|
function json(route: Route, payload: unknown, status = 200) {
|
||||||
|
|||||||
Reference in New Issue
Block a user