1
0
forked from baron/baron-sso

feat: improve Worksmobile tenant sync handling

This commit is contained in:
2026-06-02 18:05:36 +09:00
parent d6d39ca300
commit d32ca69eee
58 changed files with 4035 additions and 1400 deletions

View File

@@ -38,6 +38,11 @@ test.describe("Worksmobile tenant management", () => {
const url = new URL(route.request().url());
const method = route.request().method();
const headers = { "Access-Control-Allow-Origin": "*" };
const isWorksmobileTenantPath = (suffix: string) =>
url.pathname.endsWith(`/admin/tenants/hanmac-family-id${suffix}`) ||
url.pathname.endsWith(
`/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a${suffix}`,
);
if (url.pathname.endsWith("/user/me")) {
return route.fulfill({
@@ -45,7 +50,14 @@ test.describe("Worksmobile tenant management", () => {
id: "admin-user",
name: "Admin",
role: "super_admin",
manageableTenants: [],
manageableTenants: [
{
id: "038326b6-954a-48a7-a85f-efd83f62b82a",
name: "한맥 가족",
slug: "hanmac-family",
type: "COMPANY_GROUP",
},
],
},
headers,
});
@@ -68,10 +80,7 @@ test.describe("Worksmobile tenant management", () => {
});
}
if (
url.pathname.endsWith("/admin/tenants/hanmac-family-id/worksmobile") &&
method === "GET"
) {
if (isWorksmobileTenantPath("/worksmobile") && method === "GET") {
return route.fulfill({
json: {
tenant: {
@@ -95,18 +104,14 @@ test.describe("Worksmobile tenant management", () => {
}
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/credential-batches",
) &&
isWorksmobileTenantPath("/worksmobile/credential-batches") &&
method === "GET"
) {
return route.fulfill({ json: [], headers });
}
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/comparison",
) &&
isWorksmobileTenantPath("/worksmobile/comparison") &&
method === "GET"
) {
const includeMatched =
@@ -210,9 +215,7 @@ test.describe("Worksmobile tenant management", () => {
}
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/users/user-missing/sync",
) &&
isWorksmobileTenantPath("/worksmobile/users/user-missing/sync") &&
method === "POST"
) {
syncRequests.push("user-missing");
@@ -225,24 +228,51 @@ test.describe("Worksmobile tenant management", () => {
return route.fulfill({ json: { items: [], total: 0 }, headers });
});
await page.goto("/tenants/hanmac-family-id");
await page.getByRole("link", { name: "Worksmobile" }).click();
await page.goto("/");
await expect(
page.getByRole("link", { name: "Worksmobile" }),
).toHaveAttribute("href", "/worksmobile");
await page.goto("/worksmobile");
await expect(page).toHaveURL(/\/tenants\/hanmac-family-id\/worksmobile$/);
await expect(page.getByText("Baron / Works 비교")).toBeVisible();
await expect(page).toHaveURL(/\/worksmobile$/);
await expect(page.getByRole("tab", { name: "이력" })).toBeVisible();
await expect(page.getByRole("tab", { name: "사용자" })).toBeVisible();
await expect(page.getByRole("tab", { name: "조직" })).toBeVisible();
await expect(page.getByText("비밀번호 파일 히스토리")).toBeVisible();
await expect(page.getByText("domainMappings")).not.toBeVisible();
await expect(page.getByText("SCIM token")).not.toBeVisible();
await page.getByRole("tab", { name: "사용자" }).click();
await expect(page.getByText("사용자 단건 동기화")).toBeVisible();
await expect(page.getByPlaceholder("Kratos user UUID")).toBeVisible();
const userSyncCard = page.getByTestId("worksmobile-users-single-sync");
const userComparisonTable = page.getByTestId(
"worksmobile-구성원-virtual-body",
);
await expect(userComparisonTable).toBeVisible();
await expect(userSyncCard).toBeVisible();
expect(
await page.evaluate(() => {
const table = document.querySelector(
'[data-testid="worksmobile-구성원-virtual-body"]',
);
const sync = document.querySelector(
'[data-testid="worksmobile-users-single-sync"]',
);
return Boolean(
table &&
sync &&
table.compareDocumentPosition(sync) &
Node.DOCUMENT_POSITION_FOLLOWING,
);
}),
).toBe(true);
await expect(page.getByText("김누락")).toBeVisible();
await expect(page.getByText("박웍스")).toBeVisible();
await expect(page.getByText("숨김 SU")).not.toBeVisible();
await expect(page.getByText("숨김 CYHAN1")).not.toBeVisible();
await expect(page.getByText("su-@samaneng.com")).not.toBeVisible();
await expect(page.getByText("cyhan1@hanmaceng.co.kr")).not.toBeVisible();
await expect(page.getByText("WORKS 전용 조직")).toBeVisible();
await expect(page.getByText("기술본부", { exact: true })).toBeVisible();
await expect(page.getByText("parent-tech", { exact: true })).toBeVisible();
await expect(page.getByText("WORKS 기술본부")).toBeVisible();
await expect(page.getByText("works-parent-tech")).toBeVisible();
await expect(page.getByText("WORKS 전용 조직")).not.toBeVisible();
await expect(page.getByText("홍길동")).not.toBeVisible();
expect(comparisonRequests[0]).toBe(true);
@@ -321,6 +351,37 @@ test.describe("Worksmobile tenant management", () => {
.getByRole("button", { name: "선택 구성원 WORKS에 생성" })
.click();
await expect.poll(() => syncRequests).toEqual(["user-missing"]);
await page.getByRole("tab", { name: "조직" }).click();
await expect(page.getByText("조직 단건 동기화")).toBeVisible();
await expect(page.getByPlaceholder("orgUnit tenant UUID")).toBeVisible();
const groupSyncCard = page.getByTestId("worksmobile-groups-single-sync");
const groupComparisonTable = page.getByTestId(
"worksmobile-조직/그룹-virtual-body",
);
await expect(groupComparisonTable).toBeVisible();
await expect(groupSyncCard).toBeVisible();
expect(
await page.evaluate(() => {
const table = document.querySelector(
'[data-testid="worksmobile-조직/그룹-virtual-body"]',
);
const sync = document.querySelector(
'[data-testid="worksmobile-groups-single-sync"]',
);
return Boolean(
table &&
sync &&
table.compareDocumentPosition(sync) &
Node.DOCUMENT_POSITION_FOLLOWING,
);
}),
).toBe(true);
await expect(page.getByText("WORKS 전용 조직")).toBeVisible();
await expect(page.getByText("기술본부", { exact: true })).toBeVisible();
await expect(page.getByText("parent-tech", { exact: true })).toBeVisible();
await expect(page.getByText("WORKS 기술본부")).toBeVisible();
await expect(page.getByText("works-parent-tech")).toBeVisible();
});
test("shows a toast when selected WORKS creation fails", async ({ page }) => {
@@ -352,7 +413,9 @@ test.describe("Worksmobile tenant management", () => {
}
if (
url.pathname.endsWith("/admin/tenants/hanmac-family-id/worksmobile") &&
url.pathname.endsWith(
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile",
) &&
method === "GET"
) {
return route.fulfill({
@@ -372,7 +435,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/credential-batches",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/credential-batches",
) &&
method === "GET"
) {
@@ -381,7 +444,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/comparison",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/comparison",
) &&
method === "GET"
) {
@@ -403,7 +466,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/users/user-fail/sync",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/users/user-fail/sync",
) &&
method === "POST"
) {
@@ -417,7 +480,8 @@ test.describe("Worksmobile tenant management", () => {
return route.fulfill({ json: { items: [], total: 0 }, headers });
});
await page.goto("/tenants/hanmac-family-id/worksmobile");
await page.goto("/worksmobile");
await page.getByRole("tab", { name: "사용자" }).click();
await page
.getByRole("row", { name: /실패 사용자/ })
.getByRole("checkbox")
@@ -465,7 +529,9 @@ test.describe("Worksmobile tenant management", () => {
}
if (
url.pathname.endsWith("/admin/tenants/hanmac-family-id/worksmobile") &&
url.pathname.endsWith(
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile",
) &&
method === "GET"
) {
return route.fulfill({
@@ -487,7 +553,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/credential-batches",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/credential-batches",
) &&
method === "GET"
) {
@@ -496,7 +562,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/comparison",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/comparison",
) &&
method === "GET"
) {
@@ -537,7 +603,8 @@ test.describe("Worksmobile tenant management", () => {
return route.fulfill({ json: { items: [], total: 0 }, headers });
});
await page.goto("/tenants/hanmac-family-id/worksmobile");
await page.goto("/worksmobile");
await page.getByRole("tab", { name: "사용자" }).click();
await expect(page.getByText("긴 WORKS 사용자")).toBeVisible();
const userColumnButton = page
@@ -608,7 +675,9 @@ test.describe("Worksmobile tenant management", () => {
}
if (
url.pathname.endsWith("/admin/tenants/hanmac-family-id/worksmobile") &&
url.pathname.endsWith(
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile",
) &&
method === "GET"
) {
return route.fulfill({
@@ -664,6 +733,24 @@ test.describe("Worksmobile tenant management", () => {
},
},
},
{
id: "job-pending",
resourceType: "ORGUNIT",
resourceId: "org-pending",
action: "UPSERT",
status: "pending",
retryCount: 0,
createdAt: "2026-05-01T00:00:00Z",
updatedAt: "2026-05-01T00:01:00Z",
payload: {
matchLocalPart: "halla-site",
requestSummary: {
orgUnitName: "한라 현장",
email: "halla-site@hallasanup.com",
orgUnitExternalKey: "org-pending",
},
},
},
],
},
headers,
@@ -672,7 +759,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/credential-batches",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/credential-batches",
) &&
method === "GET"
) {
@@ -696,7 +783,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/comparison",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/comparison",
) &&
method === "GET"
) {
@@ -708,7 +795,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/initial-passwords.csv",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/initial-passwords.csv",
) &&
method === "GET"
) {
@@ -726,7 +813,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/backfill/dry-run",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/backfill/dry-run",
) &&
method === "POST"
) {
@@ -736,7 +823,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/orgunits/org-1/sync",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/orgunits/org-1/sync",
) &&
method === "POST"
) {
@@ -746,7 +833,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/users/user-1/sync",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/users/user-1/sync",
) &&
method === "POST"
) {
@@ -756,7 +843,7 @@ test.describe("Worksmobile tenant management", () => {
if (
url.pathname.endsWith(
"/admin/tenants/hanmac-family-id/worksmobile/jobs/job-retry/retry",
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/jobs/job-retry/retry",
) &&
method === "POST"
) {
@@ -764,10 +851,20 @@ test.describe("Worksmobile tenant management", () => {
return route.fulfill({ json: { id: "job-retry-next" }, headers });
}
if (
url.pathname.endsWith(
"/admin/tenants/038326b6-954a-48a7-a85f-efd83f62b82a/worksmobile/jobs/pending",
) &&
method === "DELETE"
) {
requests.push("delete-pending");
return route.fulfill({ json: { deletedCount: 1 }, headers });
}
return route.fulfill({ json: { items: [], total: 0 }, headers });
});
await page.goto("/tenants/hanmac-family-id/worksmobile");
await page.goto("/worksmobile");
await expect(page.getByText("Worksmobile 연동")).toBeVisible();
const download = page.waitForEvent("download");
@@ -785,27 +882,41 @@ test.describe("Worksmobile tenant management", () => {
await page.getByRole("button", { name: "Backfill Dry-run" }).click();
await expect.poll(() => requests).toContain("dry-run");
await page.getByRole("tab", { name: "조직" }).click();
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.getByRole("tab", { name: "사용자" }).click();
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("tab", { name: "이력" }).click();
await expect(page.getByRole("row", { name: /변경 사용자/ })).toContainText(
"changed-user@example.com",
);
await expect(
page.getByRole("row", { name: /ORGUNIT:people-growth/ }),
).toContainText("people-growth@example.com");
await expect(page.getByText("externalKey:parent-org")).toBeVisible();
await expect(
page
.getByRole("row", { name: /ORGUNIT:people-growth/ })
.getByText("externalKey:parent-org")
.first(),
).toBeVisible();
const failedJobRow = page.getByRole("row", { name: /변경 사용자/ });
await failedJobRow.getByText("payload").click();
await expect(
failedJobRow.getByText('"loginEmail": "changed-user@example.com"'),
).toBeVisible();
await page
.getByRole("row", { name: /변경 사용자/ })
.getByRole("button")
.click();
await failedJobRow.getByRole("button").click();
await expect.poll(() => requests).toContain("retry");
page.once("dialog", (dialog) => dialog.accept());
await page.getByRole("button", { name: /대기중 payload 삭제/ }).click();
await expect.poll(() => requests).toContain("delete-pending");
expect(requests).toContain("download-passwords");
});
});