forked from baron/baron-sso
Playwright 테스트 오류 수정
This commit is contained in:
@@ -5,8 +5,10 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.setItem("locale", "ko");
|
||||
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 client_id = "adminfront";
|
||||
const key = `oidc.user:${authority}:${client_id}`;
|
||||
@@ -22,24 +24,43 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
// Capture ALL API calls to our mock host
|
||||
await page.route("**/api/v1/**", async (route) => {
|
||||
const url = route.request().url();
|
||||
const headers = { 'Access-Control-Allow-Origin': '*' };
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
|
||||
if (url.includes("/user/me")) {
|
||||
return route.fulfill({
|
||||
json: { id: "admin", role: "super_admin", name: "Admin", manageableTenants: [] },
|
||||
headers
|
||||
json: {
|
||||
id: "admin",
|
||||
role: "super_admin",
|
||||
name: "Admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (url.includes("/admin/users")) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
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,
|
||||
},
|
||||
headers
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (url.includes("/organization")) {
|
||||
@@ -48,22 +69,31 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
{ id: "g-1", name: "Engineering", slug: "eng", tenantId: "t-1" },
|
||||
{ id: "g-2", name: "Sales", slug: "sales", tenantId: "t-1" },
|
||||
],
|
||||
headers
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (url.includes("/admin/tenants/t-1")) {
|
||||
return route.fulfill({
|
||||
json: { id: "t-1", name: "Main Tenant", slug: "main", status: "active", type: "COMPANY" },
|
||||
headers
|
||||
json: {
|
||||
id: "t-1",
|
||||
name: "Main Tenant",
|
||||
slug: "main",
|
||||
status: "active",
|
||||
type: "COMPANY",
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (url.includes("/admin/tenants")) {
|
||||
return route.fulfill({
|
||||
json: { items: [{ id: "t-1", name: "Main Tenant", slug: "main" }], total: 1 },
|
||||
headers
|
||||
json: {
|
||||
items: [{ id: "t-1", name: "Main Tenant", slug: "main" }],
|
||||
total: 1,
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
||||
});
|
||||
|
||||
@@ -72,12 +102,14 @@ 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");
|
||||
// 로딩바 대기 대신 실제 데이터 텍스트 대기
|
||||
const table = page.locator("table");
|
||||
await expect(table).toContainText("User One", { timeout: 20000 });
|
||||
|
||||
|
||||
// 첫 번째 데이터의 체크박스 선택
|
||||
const userCheckbox = page.locator('table input[type="checkbox"]').nth(1);
|
||||
await userCheckbox.click();
|
||||
@@ -85,7 +117,7 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
// 일괄 작업 바 확인
|
||||
const selectionBar = page.getByTestId("bulk-action-bar");
|
||||
await expect(selectionBar).toBeVisible({ timeout: 15000 });
|
||||
|
||||
|
||||
// 활성화 버튼 확인
|
||||
const activeBtn = page.getByTestId("bulk-active-btn");
|
||||
await expect(activeBtn).toBeVisible({ timeout: 10000 });
|
||||
@@ -97,25 +129,38 @@ test.describe("Bulk Actions and Tree Search", () => {
|
||||
// 선택 해제 버튼
|
||||
const closeBtn = page.getByTestId("bulk-close-btn");
|
||||
await closeBtn.click();
|
||||
|
||||
|
||||
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 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();
|
||||
|
||||
// 트리 검색 입력창 대기 (더 유연한 셀렉터)
|
||||
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 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).toHaveClass(/bg-primary/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user