forked from baron/baron-sso
동기화 기초구조 마련
This commit is contained in:
@@ -110,6 +110,9 @@ test.describe("Tenants Management", () => {
|
||||
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, {
|
||||
timeout: 20000,
|
||||
});
|
||||
await page
|
||||
.getByRole("button", { name: "최상위 테넌트로 생성" })
|
||||
.click();
|
||||
|
||||
const nameInput = page.locator('input[name="name"]').first();
|
||||
await nameInput.fill("New Tenant");
|
||||
@@ -119,14 +122,221 @@ test.describe("Tenants Management", () => {
|
||||
|
||||
await page.locator("textarea").first().fill("Description");
|
||||
|
||||
const submitBtn = page
|
||||
.locator("button")
|
||||
.filter({ hasText: /생성|Create/i })
|
||||
.first();
|
||||
const submitBtn = page.getByRole("button", { name: /^생성$/ });
|
||||
await submitBtn.click();
|
||||
await expect(page).toHaveURL(/.*\/tenants$/, { timeout: 15000 });
|
||||
});
|
||||
|
||||
test("should ask for parent tenant before tenant details", async ({
|
||||
page,
|
||||
}) => {
|
||||
const tenants = [
|
||||
{
|
||||
id: "family-1",
|
||||
name: "한맥가족",
|
||||
slug: "hanmac-family",
|
||||
status: "active",
|
||||
type: "COMPANY_GROUP",
|
||||
memberCount: 0,
|
||||
parentId: null,
|
||||
},
|
||||
{
|
||||
id: "company-1",
|
||||
name: "삼안",
|
||||
slug: "saman",
|
||||
status: "active",
|
||||
type: "COMPANY",
|
||||
memberCount: 0,
|
||||
parentId: "family-1",
|
||||
},
|
||||
{
|
||||
id: "outside-1",
|
||||
name: "외부회사",
|
||||
slug: "outside",
|
||||
status: "active",
|
||||
type: "COMPANY",
|
||||
memberCount: 0,
|
||||
parentId: null,
|
||||
},
|
||||
];
|
||||
|
||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
return route.fulfill({
|
||||
json: { items: tenants, total: tenants.length, limit: 1000, offset: 0 },
|
||||
headers,
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/tenants/new");
|
||||
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, {
|
||||
timeout: 20000,
|
||||
});
|
||||
await expect(
|
||||
page.getByRole("button", { name: "한맥가족에서 선택" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "다른 테넌트 선택" }),
|
||||
).toBeVisible();
|
||||
const parentLabelTop = await page
|
||||
.getByText(/상위 테넌트/)
|
||||
.first()
|
||||
.evaluate((element) => element.getBoundingClientRect().top);
|
||||
const rootButtonTop = await page
|
||||
.getByRole("button", { name: "최상위 테넌트로 생성" })
|
||||
.evaluate((element) => element.getBoundingClientRect().top);
|
||||
expect(Math.abs(parentLabelTop - rootButtonTop)).toBeLessThan(10);
|
||||
await expect(page.locator('input[name="name"]')).toHaveCount(0);
|
||||
|
||||
await page.getByRole("button", { name: "다른 테넌트 선택" }).click();
|
||||
await expect(page.getByRole("dialog")).toBeVisible();
|
||||
await page.getByPlaceholder("테넌트 이름 또는 슬러그 검색").fill("outside");
|
||||
await page.getByRole("button", { name: /외부회사/ }).click();
|
||||
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("tenant-parent-picker-slot")
|
||||
.getByText("outside · COMPANY"),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("일반 하위 테넌트")).toBeVisible();
|
||||
await expect(page.locator('input[name="name"]')).toBeVisible();
|
||||
await expect(page.getByLabel("조직 세부타입")).toHaveCount(0);
|
||||
await expect(page.getByLabel("공개 범위")).toHaveCount(0);
|
||||
|
||||
await page
|
||||
.getByTestId("tenant-parent-picker-slot")
|
||||
.getByRole("button", { name: "한맥가족에서 선택" })
|
||||
.click();
|
||||
await expect(page.getByRole("dialog")).toBeVisible();
|
||||
await page.evaluate(() => {
|
||||
window.postMessage(
|
||||
{
|
||||
type: "orgfront:picker:confirm",
|
||||
payload: {
|
||||
selections: [
|
||||
{ type: "tenant", id: "family-1", name: "한맥가족" },
|
||||
],
|
||||
},
|
||||
},
|
||||
window.location.origin,
|
||||
);
|
||||
});
|
||||
|
||||
await expect(page.getByText("hanmac-family · COMPANY_GROUP")).toBeVisible();
|
||||
await expect(page.getByText("한맥가족 하위 테넌트")).toBeVisible();
|
||||
await expect(page.locator('input[name="name"]')).toBeVisible();
|
||||
await expect(page.getByLabel("조직 세부타입")).toBeVisible();
|
||||
await expect(page.getByLabel("공개 범위")).toBeVisible();
|
||||
});
|
||||
|
||||
test("should create a hanmac-family child tenant with org config", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
let createBody = "";
|
||||
const tenants = [
|
||||
{
|
||||
id: "family-1",
|
||||
name: "한맥가족",
|
||||
slug: "hanmac-family",
|
||||
status: "active",
|
||||
type: "COMPANY_GROUP",
|
||||
memberCount: 0,
|
||||
parentId: null,
|
||||
},
|
||||
{
|
||||
id: "company-1",
|
||||
name: "삼안",
|
||||
slug: "saman",
|
||||
status: "active",
|
||||
type: "COMPANY",
|
||||
memberCount: 0,
|
||||
parentId: "family-1",
|
||||
},
|
||||
];
|
||||
|
||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||
const method = route.request().method();
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
if (method === "GET") {
|
||||
return route.fulfill({
|
||||
json: { items: tenants, total: tenants.length, limit: 1000, offset: 0 },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
if (method === "POST") {
|
||||
createBody = route.request().postData() ?? "";
|
||||
return route.fulfill({
|
||||
json: { id: "created-tenant-id", name: "신규 센터" },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
return route.fulfill({ json: {}, headers });
|
||||
});
|
||||
|
||||
await page.goto("/tenants/new");
|
||||
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, {
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
await page.getByRole("button", { name: "한맥가족에서 선택" }).click();
|
||||
await expect(page.getByRole("dialog")).toBeVisible();
|
||||
await page.evaluate(() => {
|
||||
window.postMessage(
|
||||
{
|
||||
type: "orgfront:picker:confirm",
|
||||
payload: {
|
||||
selections: [
|
||||
{ type: "tenant", id: "family-1", name: "한맥가족" },
|
||||
],
|
||||
},
|
||||
},
|
||||
window.location.origin,
|
||||
);
|
||||
});
|
||||
|
||||
await expect(page.getByText("hanmac-family · COMPANY_GROUP")).toBeVisible();
|
||||
await expect(page.getByLabel("조직 세부타입")).toBeVisible();
|
||||
await expect(page.getByLabel("공개 범위")).toBeVisible();
|
||||
|
||||
const layout = page.getByTestId("tenant-parent-org-config-layout");
|
||||
const parentWidth = await page
|
||||
.getByTestId("tenant-parent-picker-slot")
|
||||
.evaluate((element) => element.getBoundingClientRect().width);
|
||||
const orgUnitWidth = await page
|
||||
.getByTestId("tenant-org-unit-type-slot")
|
||||
.evaluate((element) => element.getBoundingClientRect().width);
|
||||
const visibilityWidth = await page
|
||||
.getByTestId("tenant-visibility-slot")
|
||||
.evaluate((element) => element.getBoundingClientRect().width);
|
||||
const columns = await layout.evaluate((element) =>
|
||||
window.getComputedStyle(element).gridTemplateColumns,
|
||||
);
|
||||
expect(columns.split(" ").length).toBe(4);
|
||||
expect(parentWidth).toBeGreaterThan(orgUnitWidth * 1.7);
|
||||
expect(parentWidth).toBeLessThan(orgUnitWidth * 2.3);
|
||||
expect(Math.abs(orgUnitWidth - visibilityWidth)).toBeLessThan(8);
|
||||
|
||||
await page.locator('input[name="name"]').first().fill("신규 센터");
|
||||
await page.locator('input[name="slug"]').first().fill("new-center");
|
||||
await page.getByLabel("조직 세부타입").selectOption("센터");
|
||||
await page.getByLabel("공개 범위").selectOption("internal");
|
||||
await page
|
||||
.locator("button")
|
||||
.filter({ hasText: /생성|Create/i })
|
||||
.first()
|
||||
.click();
|
||||
|
||||
await expect(page).toHaveURL(/.*\/tenants$/, { timeout: 15000 });
|
||||
expect(JSON.parse(createBody)).toMatchObject({
|
||||
parentId: "family-1",
|
||||
config: {
|
||||
orgUnitType: "센터",
|
||||
visibility: "internal",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("should export and import tenant CSV without organization/user combined import", async ({
|
||||
page,
|
||||
browserName,
|
||||
@@ -320,11 +530,11 @@ test.describe("Tenants Management", () => {
|
||||
expect(importBody).not.toContain("local-parent-id");
|
||||
expect(importBody).not.toContain("local-child-id");
|
||||
const parentMatch = importBody.match(
|
||||
/([0-9a-f-]{36}),Parent Tenant,COMPANY,,parent-created/,
|
||||
/([0-9a-f-]{36}),Parent Tenant,COMPANY,,,parent-created/,
|
||||
);
|
||||
expect(parentMatch?.[1]).toBeTruthy();
|
||||
expect(importBody).toContain(
|
||||
`,Child Tenant,USER_GROUP,${parentMatch?.[1]},child-created`,
|
||||
`,Child Tenant,USER_GROUP,${parentMatch?.[1]},parent-created,child-created`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -333,11 +543,11 @@ test.describe("Tenants Management", () => {
|
||||
await expect(page.locator("h2").last()).toContainText(/추가|Create/i, {
|
||||
timeout: 20000,
|
||||
});
|
||||
await page
|
||||
.getByRole("button", { name: "최상위 테넌트로 생성" })
|
||||
.click();
|
||||
|
||||
const submitBtn = page
|
||||
.locator("button")
|
||||
.filter({ hasText: /생성|Create/i })
|
||||
.first();
|
||||
const submitBtn = page.getByRole("button", { name: /^생성$/ });
|
||||
await expect(submitBtn).toBeDisabled();
|
||||
|
||||
await page.locator('input[name="name"]').first().fill("Valid Name");
|
||||
@@ -408,4 +618,120 @@ test.describe("Tenants Management", () => {
|
||||
.first(),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("should show tenant UUID at the top of tenant detail profile", async ({
|
||||
page,
|
||||
}) => {
|
||||
const tenantUuid = "11111111-2222-4333-8444-555555555555";
|
||||
const tenant = {
|
||||
id: tenantUuid,
|
||||
name: "Tenant With UUID",
|
||||
slug: "tenant-with-uuid",
|
||||
status: "active",
|
||||
type: "COMPANY",
|
||||
memberCount: 0,
|
||||
parentId: null,
|
||||
config: {},
|
||||
domains: [],
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||
const url = route.request().url();
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
if (url.includes(`/admin/tenants/${tenantUuid}`)) {
|
||||
return route.fulfill({ json: tenant, headers });
|
||||
}
|
||||
return route.fulfill({
|
||||
json: { items: [tenant], total: 1, limit: 1000, offset: 0 },
|
||||
headers,
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto(`/tenants/${tenantUuid}`);
|
||||
|
||||
const titleRow = page.getByTestId("tenant-detail-title-row");
|
||||
await expect(titleRow).toBeVisible({ timeout: 20000 });
|
||||
await expect(titleRow).toContainText("Tenant With UUID");
|
||||
await expect(titleRow).toContainText(tenantUuid);
|
||||
await expect(titleRow).not.toContainText("Tenant UUID");
|
||||
await expect(page.getByTestId("tenant-detail-copy-uuid")).toBeVisible();
|
||||
});
|
||||
|
||||
test("should place hanmac org config beside parent tenant picker", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
const tenants = [
|
||||
{
|
||||
id: "family-1",
|
||||
name: "한맥가족",
|
||||
slug: "hanmac-family",
|
||||
status: "active",
|
||||
type: "COMPANY_GROUP",
|
||||
memberCount: 0,
|
||||
parentId: null,
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: "company-1",
|
||||
name: "삼안",
|
||||
slug: "saman",
|
||||
status: "active",
|
||||
type: "COMPANY",
|
||||
memberCount: 0,
|
||||
parentId: "family-1",
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: "team-1",
|
||||
name: "기획팀",
|
||||
slug: "planning",
|
||||
status: "active",
|
||||
type: "USER_GROUP",
|
||||
memberCount: 0,
|
||||
parentId: "company-1",
|
||||
config: { orgUnitType: "팀", visibility: "internal" },
|
||||
},
|
||||
];
|
||||
|
||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||
const url = route.request().url();
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
if (url.includes("/admin/tenants/team-1")) {
|
||||
return route.fulfill({ json: tenants[2], headers });
|
||||
}
|
||||
return route.fulfill({
|
||||
json: { items: tenants, total: tenants.length, limit: 1000, offset: 0 },
|
||||
headers,
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/tenants/team-1");
|
||||
|
||||
const layout = page.getByTestId("tenant-parent-org-config-layout");
|
||||
await expect(layout).toBeVisible({ timeout: 20000 });
|
||||
await expect(layout).toContainText("상위 테넌트");
|
||||
await expect(layout).toContainText("조직 세부타입");
|
||||
await expect(layout).toContainText("공개 범위");
|
||||
|
||||
const columns = await layout.evaluate((element) =>
|
||||
window.getComputedStyle(element).gridTemplateColumns,
|
||||
);
|
||||
expect(columns.split(" ").length).toBe(4);
|
||||
|
||||
const parentWidth = await page
|
||||
.getByTestId("tenant-parent-picker-slot")
|
||||
.evaluate((element) => element.getBoundingClientRect().width);
|
||||
const orgUnitWidth = await page
|
||||
.getByTestId("tenant-org-unit-type-slot")
|
||||
.evaluate((element) => element.getBoundingClientRect().width);
|
||||
const visibilityWidth = await page
|
||||
.getByTestId("tenant-visibility-slot")
|
||||
.evaluate((element) => element.getBoundingClientRect().width);
|
||||
|
||||
expect(parentWidth).toBeGreaterThan(orgUnitWidth * 1.7);
|
||||
expect(parentWidth).toBeLessThan(orgUnitWidth * 2.3);
|
||||
expect(Math.abs(orgUnitWidth - visibilityWidth)).toBeLessThan(8);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user