forked from baron/baron-sso
org chart 연동기능 추가
This commit is contained in:
@@ -114,24 +114,100 @@ test.describe("Tenants Management", () => {
|
||||
await expect(page).toHaveURL(/.*\/tenants$/, { timeout: 15000 });
|
||||
});
|
||||
|
||||
test("should clarify organization import creates org tenants and users together", async ({
|
||||
test("should export and import tenant CSV without organization/user combined import", async ({
|
||||
page,
|
||||
}) => {
|
||||
let exportRequested = false;
|
||||
let importRequested = false;
|
||||
let importBody = "";
|
||||
|
||||
await page.route("**/api/v1/admin/tenants**", async (route) => {
|
||||
const url = route.request().url();
|
||||
const method = route.request().method();
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
|
||||
if (url.includes("/export")) {
|
||||
exportRequested = true;
|
||||
return route.fulfill({
|
||||
body: "tenant_id,name,type,parent_tenant_id,slug,memo,email_domain\n",
|
||||
contentType: "text/csv",
|
||||
headers: {
|
||||
...headers,
|
||||
"Content-Disposition": 'attachment; filename="tenants.csv"',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (url.includes("/import")) {
|
||||
importRequested = true;
|
||||
importBody = route.request().postData() ?? "";
|
||||
return route.fulfill({
|
||||
json: { created: 0, updated: 1, failed: 0, errors: [] },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (method === "GET") {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
items: [
|
||||
{
|
||||
id: "tenant-alpha-id",
|
||||
name: "Tenant Alpha",
|
||||
slug: "tenant-alpha",
|
||||
status: "active",
|
||||
type: "COMPANY",
|
||||
domains: [],
|
||||
memberCount: 0,
|
||||
updatedAt: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
limit: 1000,
|
||||
offset: 0,
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
return route.continue();
|
||||
});
|
||||
|
||||
await page.goto("/tenants");
|
||||
await expect(page.locator("h2").last()).toContainText(
|
||||
/테넌트 목록|Tenants/i,
|
||||
{ timeout: 20000 },
|
||||
);
|
||||
|
||||
await page
|
||||
.locator("button")
|
||||
.filter({ hasText: /임포트|Import/i })
|
||||
.first()
|
||||
.click();
|
||||
await expect(page.getByText(/조직\/사용자 통합/)).toHaveCount(0);
|
||||
await expect(page.getByTestId("tenant-template-btn")).toBeVisible();
|
||||
await expect(page.getByTestId("tenant-export-btn")).toBeVisible();
|
||||
await expect(page.getByTestId("tenant-import-btn")).toBeVisible();
|
||||
|
||||
await expect(page.getByRole("dialog")).toContainText(
|
||||
/조직\/사용자 통합 일괄 등록|organization and user batch registration/i,
|
||||
const download = page.waitForEvent("download");
|
||||
await page.getByTestId("tenant-export-btn").click();
|
||||
await download;
|
||||
expect(exportRequested).toBe(true);
|
||||
|
||||
await page.getByTestId("tenant-import-input").setInputFiles({
|
||||
name: "tenants.csv",
|
||||
mimeType: "text/csv",
|
||||
buffer: Buffer.from(
|
||||
"tenant_id,name,type,parent_tenant_id,slug,memo,email_domain\n,Tenant Alpha,COMPANY,,tenant-alpha-copy,Imported memo,imported.example.com\n",
|
||||
),
|
||||
});
|
||||
|
||||
await expect(page.getByRole("dialog")).toContainText("CSV 가져오기 확인");
|
||||
await expect(page.getByTestId("tenant-import-candidate")).toContainText(
|
||||
"Tenant Alpha",
|
||||
);
|
||||
await page.getByTestId("tenant-import-confirm-btn").click();
|
||||
|
||||
await expect(page.getByTestId("tenant-import-result")).toContainText(
|
||||
/갱신 1|Updated 1/i,
|
||||
);
|
||||
expect(importRequested).toBe(true);
|
||||
expect(importBody).toContain("tenant-alpha-id");
|
||||
});
|
||||
|
||||
test("should show validation error on empty name", async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user