forked from baron/baron-sso
테넌트 crud 테스트 코드 추가
This commit is contained in:
@@ -44,18 +44,18 @@ describe("tenantTree utility", () => {
|
||||
|
||||
it("calculates recursive member counts correctly", () => {
|
||||
const { currentBase } = buildTenantFullTree(mockTenants, "root-1");
|
||||
|
||||
|
||||
expect(currentBase).not.toBeNull();
|
||||
if (currentBase) {
|
||||
// Direct: 10, Child: 5, Grandchild: 2 -> Total: 17
|
||||
expect(currentBase.recursiveMemberCount).toBe(17);
|
||||
expect(currentBase.children).toHaveLength(1);
|
||||
|
||||
|
||||
const child = currentBase.children[0];
|
||||
// Direct: 5, Grandchild: 2 -> Total: 7
|
||||
expect(child.recursiveMemberCount).toBe(7);
|
||||
expect(child.children).toHaveLength(1);
|
||||
|
||||
|
||||
const grandchild = child.children[0];
|
||||
// Direct: 2 -> Total: 2
|
||||
expect(grandchild.recursiveMemberCount).toBe(2);
|
||||
@@ -84,10 +84,10 @@ describe("tenantTree utility", () => {
|
||||
updatedAt: "",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
const { subTree } = buildTenantFullTree(multiRootTenants);
|
||||
expect(subTree).toHaveLength(2);
|
||||
expect(subTree.map(n => n.id)).toContain("root-1");
|
||||
expect(subTree.map(n => n.id)).toContain("root-2");
|
||||
expect(subTree.map((n) => n.id)).toContain("root-1");
|
||||
expect(subTree.map((n) => n.id)).toContain("root-2");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ test.describe("Authentication", () => {
|
||||
|
||||
// Should be on the dashboard/overview
|
||||
await expect(page.locator("aside")).toBeVisible();
|
||||
await expect(page.locator("h1")).toContainText("Admin Control");
|
||||
await expect(page.locator("h1")).toContainText(/Admin Control|운영 도구/);
|
||||
});
|
||||
|
||||
test("should logout and redirect to login page", async ({ page }) => {
|
||||
|
||||
@@ -170,31 +170,45 @@ test.describe("Tenants Management", () => {
|
||||
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 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("전체")
|
||||
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|소속/ });
|
||||
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();
|
||||
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 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