forked from baron/baron-sso
Playwright 테스트 오류 수정
This commit is contained in:
@@ -5,8 +5,10 @@ test.describe("Tenants Management", () => {
|
||||
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}`;
|
||||
@@ -21,19 +23,28 @@ test.describe("Tenants Management", () => {
|
||||
|
||||
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-user", name: "Admin", role: "super_admin", manageableTenants: [] },
|
||||
headers
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin",
|
||||
role: "super_admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
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({
|
||||
json: { items: [], total: 0, limit: 100, offset: 0 },
|
||||
headers
|
||||
headers,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -50,10 +61,21 @@ test.describe("Tenants Management", () => {
|
||||
if (route.request().method() === "GET") {
|
||||
await route.fulfill({
|
||||
json: {
|
||||
items: [{ id: "1", name: "Tenant A", slug: "tenant-a", status: "active", type: "COMPANY", updatedAt: new Date().toISOString() }],
|
||||
total: 1, limit: 1000, offset: 0,
|
||||
items: [
|
||||
{
|
||||
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 {
|
||||
await route.continue();
|
||||
@@ -61,67 +83,119 @@ test.describe("Tenants Management", () => {
|
||||
});
|
||||
|
||||
await page.goto("/tenants");
|
||||
await expect(page.locator("h2").last()).toContainText(/테넌트 목록|Tenants/i, { timeout: 20000 });
|
||||
await expect(page.locator("table")).toContainText("Tenant A", { timeout: 10000 });
|
||||
await expect(page.locator("h2").last()).toContainText(
|
||||
/테넌트 목록|Tenants/i,
|
||||
{ timeout: 20000 },
|
||||
);
|
||||
await expect(page.locator("table")).toContainText("Tenant A", {
|
||||
timeout: 10000,
|
||||
});
|
||||
});
|
||||
|
||||
test("should create a new tenant", async ({ page }) => {
|
||||
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();
|
||||
await nameInput.fill("New Tenant");
|
||||
|
||||
|
||||
const slugInput = page.locator('input[name="slug"]').first();
|
||||
await slugInput.fill("new-tenant");
|
||||
|
||||
|
||||
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 expect(page).toHaveURL(/.*\/tenants$/, { timeout: 15000 });
|
||||
});
|
||||
|
||||
test("should show validation error on empty name", async ({ page }) => {
|
||||
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 page.locator('input[name="name"]').first().fill("Valid Name");
|
||||
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 = [
|
||||
{ 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) => {
|
||||
const url = route.request().url();
|
||||
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")) {
|
||||
await route.fulfill({ json: mockTenants[0], headers: { 'Access-Control-Allow-Origin': '*' } });
|
||||
await route.fulfill({
|
||||
json: mockTenants[0],
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
});
|
||||
} else {
|
||||
await route.fulfill({
|
||||
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 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();
|
||||
await expect(parentRow).toContainText("5");
|
||||
const parentRow = page
|
||||
.locator("tr")
|
||||
.filter({ hasText: "Parent Org" })
|
||||
.first();
|
||||
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 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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user