forked from baron/baron-sso
계층 표시 테스트 코드 추가
This commit is contained in:
@@ -94,4 +94,107 @@ test.describe("Tenants Management", () => {
|
||||
await page.fill("input >> nth=0", "Valid Name");
|
||||
await expect(submitBtn).not.toBeDisabled();
|
||||
});
|
||||
|
||||
test("should show organization hierarchy and member list distinction", async ({
|
||||
page,
|
||||
}) => {
|
||||
// Mock parent tenant and its children
|
||||
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",
|
||||
},
|
||||
];
|
||||
|
||||
await page.route("**/api/v1/admin/tenants*", async (route) => {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
items: mockTenants,
|
||||
total: 2,
|
||||
limit: 1000,
|
||||
offset: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// Mock members for parent and child
|
||||
await page.route(
|
||||
"**/api/v1/admin/users?*companyCode=parent-slug*",
|
||||
async (route) => {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
items: [{ id: "u1", name: "User One", email: "u1@parent.com" }],
|
||||
total: 1,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
await page.route(
|
||||
"**/api/v1/admin/users?*companyCode=child-slug*",
|
||||
async (route) => {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
items: [{ id: "u2", name: "User Two", email: "u2@child.com" }],
|
||||
total: 1,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
await page.goto("/tenants/parent-1/organization");
|
||||
|
||||
// Wait for the table to appear
|
||||
await expect(page.locator("table")).toBeVisible();
|
||||
|
||||
// Check if hierarchy shows correctly
|
||||
await expect(page.locator("table")).toContainText("Parent Org");
|
||||
await expect(page.locator("table")).toContainText("Child Team");
|
||||
|
||||
// Check if member counts (Direct/Total) are displayed
|
||||
// Parent should have Direct 5, Total 8
|
||||
const parentRow = page.locator("tr", { hasText: "Parent Org" });
|
||||
await expect(parentRow).toContainText("5"); // Direct
|
||||
await expect(parentRow).toContainText("8"); // Total (5 + 3)
|
||||
|
||||
// Check for either English or Korean labels
|
||||
const hasDirectLabel = await parentRow.evaluate(el =>
|
||||
el.textContent?.includes("Direct") || el.textContent?.includes("소속")
|
||||
);
|
||||
const hasTotalLabel = await parentRow.evaluate(el =>
|
||||
el.textContent?.includes("Total") || el.textContent?.includes("전체")
|
||||
);
|
||||
expect(hasDirectLabel).toBe(true);
|
||||
expect(hasTotalLabel).toBe(true);
|
||||
|
||||
// Open Member List Dialog - Click the members count button
|
||||
const memberButton = parentRow.getByRole("button").filter({ hasText: /Direct|소속/ });
|
||||
await memberButton.click();
|
||||
|
||||
// Check Tabs in Member List Dialog
|
||||
// Use regex to match either language, ignoring the count suffix
|
||||
await expect(page.locator('button[role="tab"]').filter({ hasText: /소속 멤버|Direct Members/ })).toBeVisible();
|
||||
await expect(page.locator('button[role="tab"]').filter({ hasText: /하위 조직 멤버|Descendant Members/ })).toBeVisible();
|
||||
|
||||
// Direct Members Tab should show parent's user
|
||||
await expect(page.locator("role=dialog")).toContainText("u1@parent.com");
|
||||
|
||||
// Switch to Descendant Members Tab
|
||||
await page.click('button[role="tab"]:has-text("하위 조직 멤버"), button[role="tab"]:has-text("Descendant Members")');
|
||||
await expect(page.locator("role=dialog")).toContainText("u2@child.com");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user