forked from baron/baron-sso
adminfront 태넌트 화면 기능 누락 복구
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Worksmobile tenant management", () => {
|
||||
@@ -558,4 +559,163 @@ test.describe("Worksmobile tenant management", () => {
|
||||
immutableRow.getByRole("button", { name: /비밀번호 관리/ }),
|
||||
).toBeDisabled();
|
||||
});
|
||||
|
||||
test("downloads initial password CSV and enqueues WORKS admin jobs", async ({
|
||||
page,
|
||||
}) => {
|
||||
const requests: string[] = [];
|
||||
const headers = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Expose-Headers": "Content-Disposition",
|
||||
};
|
||||
|
||||
await page.route("**/api/v1/**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const method = route.request().method();
|
||||
|
||||
if (url.pathname.endsWith("/user/me")) {
|
||||
return route.fulfill({
|
||||
json: { id: "admin-user", name: "Admin", role: "super_admin" },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith("/admin/tenants/hanmac-family-id/worksmobile") &&
|
||||
method === "GET"
|
||||
) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
tenant: {
|
||||
id: "hanmac-family-id",
|
||||
name: "한맥 가족",
|
||||
slug: "hanmac-family",
|
||||
parentId: null,
|
||||
},
|
||||
config: {
|
||||
enabled: true,
|
||||
tokenConfigured: true,
|
||||
adminTenantId: "works-tenant-1",
|
||||
},
|
||||
recentJobs: [
|
||||
{
|
||||
id: "job-retry",
|
||||
resourceType: "USER",
|
||||
resourceId: "user-failed",
|
||||
action: "sync",
|
||||
status: "failed",
|
||||
retryCount: 1,
|
||||
createdAt: "2026-05-01T00:00:00Z",
|
||||
updatedAt: "2026-05-01T00:00:00Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/comparison",
|
||||
) &&
|
||||
method === "GET"
|
||||
) {
|
||||
return route.fulfill({
|
||||
json: { users: [], groups: [] },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/initial-passwords.csv",
|
||||
) &&
|
||||
method === "GET"
|
||||
) {
|
||||
requests.push("download-passwords");
|
||||
return route.fulfill({
|
||||
body: "email,password\nuser@example.com,Secret123!\n",
|
||||
contentType: "text/csv",
|
||||
headers: {
|
||||
...headers,
|
||||
"Content-Disposition":
|
||||
'attachment; filename="worksmobile-passwords.csv"',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/backfill/dry-run",
|
||||
) &&
|
||||
method === "POST"
|
||||
) {
|
||||
requests.push("dry-run");
|
||||
return route.fulfill({ json: { id: "job-dry-run" }, headers });
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/orgunits/org-1/sync",
|
||||
) &&
|
||||
method === "POST"
|
||||
) {
|
||||
requests.push("org-sync");
|
||||
return route.fulfill({ json: { id: "job-org-sync" }, headers });
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/users/user-1/sync",
|
||||
) &&
|
||||
method === "POST"
|
||||
) {
|
||||
requests.push("user-sync");
|
||||
return route.fulfill({ json: { id: "job-user-sync" }, headers });
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/jobs/job-retry/retry",
|
||||
) &&
|
||||
method === "POST"
|
||||
) {
|
||||
requests.push("retry");
|
||||
return route.fulfill({ json: { id: "job-retry-next" }, headers });
|
||||
}
|
||||
|
||||
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
||||
});
|
||||
|
||||
await page.goto("/tenants/hanmac-family-id/worksmobile");
|
||||
await expect(page.getByText("Worksmobile 연동")).toBeVisible();
|
||||
|
||||
const download = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: "초기 비밀번호 CSV" }).click();
|
||||
const passwordCsv = await download;
|
||||
expect(passwordCsv.suggestedFilename()).toBe("worksmobile-passwords.csv");
|
||||
const passwordCsvPath = await passwordCsv.path();
|
||||
expect(passwordCsvPath).toBeTruthy();
|
||||
expect(await readFile(passwordCsvPath ?? "", "utf8")).toContain(
|
||||
"user@example.com,Secret123!",
|
||||
);
|
||||
|
||||
await page.getByRole("button", { name: "Backfill Dry-run" }).click();
|
||||
await expect.poll(() => requests).toContain("dry-run");
|
||||
|
||||
await page.getByPlaceholder("orgUnit tenant UUID").fill("org-1");
|
||||
await page.getByRole("button", { name: "조직 Sync" }).click();
|
||||
await expect.poll(() => requests).toContain("org-sync");
|
||||
|
||||
await page.getByPlaceholder("Kratos user UUID").fill("user-1");
|
||||
await page.getByRole("button", { name: "구성원 Sync" }).click();
|
||||
await expect.poll(() => requests).toContain("user-sync");
|
||||
|
||||
await page
|
||||
.getByRole("row", { name: /USER:user-failed/ })
|
||||
.getByRole("button")
|
||||
.click();
|
||||
await expect.poll(() => requests).toContain("retry");
|
||||
expect(requests).toContain("download-passwords");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user