forked from baron/baron-sso
worksmobile 연동 & ory stack 26.2.0으로 업그레이드
This commit is contained in:
@@ -703,6 +703,7 @@ test.describe("User Management", () => {
|
||||
tenantId: "03dbe16b-e47b-4f72-927b-782807d67a35",
|
||||
tenantSlug: "tech-planning",
|
||||
tenantName: "기술기획",
|
||||
isPrimary: true,
|
||||
isOwner: true,
|
||||
jobTitle: "플랫폼 운영",
|
||||
position: "책임",
|
||||
@@ -724,12 +725,115 @@ test.describe("User Management", () => {
|
||||
await expect(page.getByTestId("detail-appointment-row-0")).toBeVisible();
|
||||
await expect(
|
||||
page.getByTestId("detail-appointment-tenant-owner-line-0"),
|
||||
).toContainText(/기술기획|조직장/);
|
||||
).toContainText(/기술기획|대표 조직|조직장/);
|
||||
await expect(
|
||||
page.getByTestId("detail-appointment-row-0").getByRole("switch", {
|
||||
name: /대표 조직/i,
|
||||
}),
|
||||
).toBeChecked();
|
||||
await expect(
|
||||
page.getByTestId("detail-appointment-row-0").getByRole("switch", {
|
||||
name: /대표 조직/i,
|
||||
}),
|
||||
).toBeDisabled();
|
||||
await expect(
|
||||
page.getByTestId("detail-appointment-position-line-0"),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("should save selected Hanmac representative appointment from user detail", async ({
|
||||
page,
|
||||
}) => {
|
||||
let updatePayload: Record<string, unknown> | undefined;
|
||||
|
||||
await page.route(/\/admin\/users\/u-1$/, async (route) => {
|
||||
if (route.request().method() === "GET") {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
id: "u-1",
|
||||
name: "Family User",
|
||||
email: "family@test.com",
|
||||
phone: "010-1111-2222",
|
||||
loginId: "familyuser",
|
||||
role: "user",
|
||||
status: "active",
|
||||
createdAt: "2026-04-01T00:00:00Z",
|
||||
updatedAt: "2026-04-01T00:00:00Z",
|
||||
metadata: {
|
||||
hanmacFamily: true,
|
||||
additionalAppointments: [
|
||||
{
|
||||
tenantId: "03dbe16b-e47b-4f72-927b-782807d67a35",
|
||||
tenantSlug: "tech-planning",
|
||||
tenantName: "기술기획",
|
||||
isOwner: false,
|
||||
jobTitle: "플랫폼 운영",
|
||||
position: "책임",
|
||||
},
|
||||
{
|
||||
tenantId: "hanmac-team-id",
|
||||
tenantSlug: "hanmac-team",
|
||||
tenantName: "한맥팀",
|
||||
isOwner: true,
|
||||
jobTitle: "개발",
|
||||
position: "선임",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
if (route.request().method() === "PUT") {
|
||||
updatePayload = route.request().postDataJSON();
|
||||
return route.fulfill({
|
||||
json: {
|
||||
id: "u-1",
|
||||
name: "Family User",
|
||||
email: "family@test.com",
|
||||
status: "active",
|
||||
},
|
||||
});
|
||||
}
|
||||
return route.fallback();
|
||||
});
|
||||
|
||||
await page.goto("/users/u-1");
|
||||
await page
|
||||
.getByTestId("detail-appointment-row-1")
|
||||
.getByRole("switch", { name: /대표 조직/i })
|
||||
.click();
|
||||
await expect(
|
||||
page.getByTestId("detail-appointment-row-0").getByRole("switch", {
|
||||
name: /대표 조직/i,
|
||||
}),
|
||||
).not.toBeChecked();
|
||||
await expect(
|
||||
page.getByTestId("detail-appointment-row-1").getByRole("switch", {
|
||||
name: /대표 조직/i,
|
||||
}),
|
||||
).toBeChecked();
|
||||
await page.locator("form").evaluate((form) => {
|
||||
(form as HTMLFormElement).requestSubmit();
|
||||
});
|
||||
|
||||
await expect.poll(() => updatePayload).toMatchObject({
|
||||
tenantSlug: "hanmac-team",
|
||||
primaryTenantId: "hanmac-team-id",
|
||||
primaryTenantName: "한맥팀",
|
||||
primaryTenantIsOwner: true,
|
||||
metadata: {
|
||||
primaryTenantId: "hanmac-team-id",
|
||||
primaryTenantName: "한맥팀",
|
||||
primaryTenantSlug: "hanmac-team",
|
||||
primaryTenantIsOwner: true,
|
||||
additionalAppointments: [
|
||||
{ tenantId: "03dbe16b-e47b-4f72-927b-782807d67a35", isPrimary: false },
|
||||
{ tenantId: "hanmac-team-id", isPrimary: true },
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("should show conflict error when creating with an existing Login ID", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
363
adminfront/tests/worksmobile.spec.ts
Normal file
363
adminfront/tests/worksmobile.spec.ts
Normal file
@@ -0,0 +1,363 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Worksmobile tenant management", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.setItem("locale", "ko");
|
||||
window.localStorage.setItem("admin_session", "fake-token");
|
||||
window.localStorage.setItem("RoleSwitcher-Collapsed", "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}`;
|
||||
const authData = {
|
||||
access_token: "fake-token",
|
||||
token_type: "Bearer",
|
||||
profile: { sub: "admin-user", name: "Admin", role: "super_admin" },
|
||||
expires_at: Math.floor(Date.now() / 1000) + 36000,
|
||||
};
|
||||
window.localStorage.setItem(key, JSON.stringify(authData));
|
||||
});
|
||||
|
||||
await page.route("**/oidc/**", async (route) => {
|
||||
await route.fulfill({ json: { issuer: "http://localhost:5000/oidc" } });
|
||||
});
|
||||
});
|
||||
|
||||
test("opens Worksmobile in the current tab and filters comparison rows", async ({
|
||||
page,
|
||||
}) => {
|
||||
const comparisonRequests: boolean[] = [];
|
||||
const syncRequests: string[] = [];
|
||||
|
||||
await page.route("**/api/v1/**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const method = route.request().method();
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
|
||||
if (url.pathname.endsWith("/user/me")) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
id: "admin-user",
|
||||
name: "Admin",
|
||||
role: "super_admin",
|
||||
manageableTenants: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith("/admin/tenants/hanmac-family-id") &&
|
||||
method === "GET"
|
||||
) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
id: "hanmac-family-id",
|
||||
name: "한맥 가족",
|
||||
slug: "hanmac-family",
|
||||
type: "COMPANY_GROUP",
|
||||
status: "active",
|
||||
parentId: null,
|
||||
},
|
||||
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",
|
||||
type: "COMPANY_GROUP",
|
||||
status: "active",
|
||||
memberCount: 0,
|
||||
createdAt: "2026-05-04T00:00:00Z",
|
||||
updatedAt: "2026-05-04T00:00:00Z",
|
||||
},
|
||||
config: {
|
||||
enabled: true,
|
||||
tokenConfigured: true,
|
||||
},
|
||||
recentJobs: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/comparison",
|
||||
) &&
|
||||
method === "GET"
|
||||
) {
|
||||
const includeMatched =
|
||||
url.searchParams.get("includeMatched") === "true";
|
||||
comparisonRequests.push(includeMatched);
|
||||
|
||||
return route.fulfill({
|
||||
json: {
|
||||
users: includeMatched
|
||||
? [
|
||||
{
|
||||
resourceType: "USER",
|
||||
baronId: "user-matched",
|
||||
baronName: "홍길동",
|
||||
baronPrimaryOrgId: "team-tech",
|
||||
baronPrimaryOrgName: "기술기획",
|
||||
worksmobileId: "works-user-matched",
|
||||
externalKey: "user-matched",
|
||||
worksmobileName: "홍길동",
|
||||
status: "matched",
|
||||
worksmobilePrimaryOrgId: "works-team-tech",
|
||||
worksmobilePrimaryOrgName: "WORKS 기술기획",
|
||||
},
|
||||
{
|
||||
resourceType: "USER",
|
||||
baronId: "user-missing",
|
||||
baronName: "김누락",
|
||||
status: "missing_in_worksmobile",
|
||||
},
|
||||
{
|
||||
resourceType: "USER",
|
||||
worksmobileId: "works-user-only",
|
||||
externalKey: "works-user-only",
|
||||
worksmobileName: "박웍스",
|
||||
status: "missing_in_baron",
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
resourceType: "USER",
|
||||
baronId: "user-missing",
|
||||
baronName: "김누락",
|
||||
status: "missing_in_worksmobile",
|
||||
},
|
||||
{
|
||||
resourceType: "USER",
|
||||
worksmobileId: "works-user-only",
|
||||
externalKey: "works-user-only",
|
||||
worksmobileName: "박웍스",
|
||||
status: "missing_in_baron",
|
||||
},
|
||||
],
|
||||
groups: [
|
||||
{
|
||||
resourceType: "GROUP",
|
||||
baronId: "group-missing",
|
||||
baronName: "Baron 전용 조직",
|
||||
baronParentId: "parent-tech",
|
||||
baronParentName: "기술본부",
|
||||
status: "missing_in_worksmobile",
|
||||
},
|
||||
{
|
||||
resourceType: "GROUP",
|
||||
worksmobileId: "works-group-only",
|
||||
externalKey: "works-group-only",
|
||||
worksmobileName: "WORKS 전용 조직",
|
||||
worksmobileParentId: "works-parent-tech",
|
||||
worksmobileParentName: "WORKS 기술본부",
|
||||
status: "missing_in_baron",
|
||||
},
|
||||
],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/users/user-missing/sync",
|
||||
) &&
|
||||
method === "POST"
|
||||
) {
|
||||
syncRequests.push("user-missing");
|
||||
return route.fulfill({
|
||||
json: { id: "job-user-missing", resourceId: "user-missing" },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
||||
});
|
||||
|
||||
await page.goto("/tenants/hanmac-family-id");
|
||||
await page.getByRole("link", { name: "Worksmobile" }).click();
|
||||
|
||||
await expect(page).toHaveURL(/\/tenants\/hanmac-family-id\/worksmobile$/);
|
||||
await expect(page.getByText("Baron / Works 비교")).toBeVisible();
|
||||
await expect(page.getByText("domainMappings")).not.toBeVisible();
|
||||
await expect(page.getByText("SCIM token")).not.toBeVisible();
|
||||
await expect(page.getByText("김누락")).toBeVisible();
|
||||
await expect(page.getByText("박웍스")).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("홍길동")).not.toBeVisible();
|
||||
expect(comparisonRequests[0]).toBe(true);
|
||||
|
||||
const filterButtons = page
|
||||
.getByRole("button", {
|
||||
name: /Baron에만 있음|WORKS에만 있음|양쪽에 다 있음/,
|
||||
})
|
||||
.allTextContents();
|
||||
await expect.poll(() => filterButtons).toEqual([
|
||||
"Baron에만 있음",
|
||||
"WORKS에만 있음",
|
||||
"양쪽에 다 있음",
|
||||
]);
|
||||
|
||||
await page.getByRole("button", { name: "WORKS에만 있음" }).click();
|
||||
await expect(page.getByText("박웍스")).toBeVisible();
|
||||
await expect(page.getByText("김누락")).toBeVisible();
|
||||
await expect(page.getByText("홍길동")).not.toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "양쪽에 다 있음" }).click();
|
||||
await expect(page.getByText("홍길동")).toHaveCount(2);
|
||||
await expect(page.getByText("기술기획", { exact: true })).toBeVisible();
|
||||
await expect(page.getByText("team-tech", { exact: true })).toBeVisible();
|
||||
await expect(page.getByText("WORKS 기술기획")).toBeVisible();
|
||||
await expect(page.getByText("works-team-tech")).toBeVisible();
|
||||
await expect(page.getByText("김누락")).toBeVisible();
|
||||
await expect(page.getByText("박웍스")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Baron에만 있음" }).click();
|
||||
await expect(page.getByText("홍길동")).toHaveCount(2);
|
||||
await expect(page.getByText("김누락")).not.toBeVisible();
|
||||
await expect(page.getByText("박웍스")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "WORKS에만 있음" }).click();
|
||||
await expect(page.getByText("홍길동")).toHaveCount(2);
|
||||
await expect(page.getByText("김누락")).not.toBeVisible();
|
||||
await expect(page.getByText("박웍스")).not.toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "양쪽에 다 있음" }).click();
|
||||
await expect(page.getByText("김누락")).toBeVisible();
|
||||
await expect(page.getByText("박웍스")).toBeVisible();
|
||||
await expect(page.getByText("홍길동")).toHaveCount(2);
|
||||
|
||||
await page.getByRole("button", { name: "Baron에만 있음" }).click();
|
||||
await expect(page.getByText("김누락")).toBeVisible();
|
||||
await expect(page.getByText("박웍스")).not.toBeVisible();
|
||||
await expect(page.getByText("홍길동")).not.toBeVisible();
|
||||
|
||||
await page
|
||||
.getByRole("row", { name: /김누락/ })
|
||||
.getByRole("checkbox")
|
||||
.check();
|
||||
await page
|
||||
.getByRole("button", { name: "선택 구성원 WORKS에 생성" })
|
||||
.click();
|
||||
await expect.poll(() => syncRequests).toEqual(["user-missing"]);
|
||||
});
|
||||
|
||||
test("shows a toast when selected WORKS creation fails", async ({ page }) => {
|
||||
await page.route("**/api/v1/**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
const method = route.request().method();
|
||||
const headers = { "Access-Control-Allow-Origin": "*" };
|
||||
|
||||
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") &&
|
||||
method === "GET"
|
||||
) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
id: "hanmac-family-id",
|
||||
name: "한맥 가족",
|
||||
slug: "hanmac-family",
|
||||
parentId: null,
|
||||
},
|
||||
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: {},
|
||||
recentJobs: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/comparison",
|
||||
) &&
|
||||
method === "GET"
|
||||
) {
|
||||
return route.fulfill({
|
||||
json: {
|
||||
users: [
|
||||
{
|
||||
resourceType: "USER",
|
||||
baronId: "user-fail",
|
||||
baronName: "실패 사용자",
|
||||
status: "missing_in_worksmobile",
|
||||
},
|
||||
],
|
||||
groups: [],
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
url.pathname.endsWith(
|
||||
"/admin/tenants/hanmac-family-id/worksmobile/users/user-fail/sync",
|
||||
) &&
|
||||
method === "POST"
|
||||
) {
|
||||
return route.fulfill({
|
||||
status: 500,
|
||||
json: { error: "WORKS API rejected user creation" },
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
return route.fulfill({ json: { items: [], total: 0 }, headers });
|
||||
});
|
||||
|
||||
await page.goto("/tenants/hanmac-family-id/worksmobile");
|
||||
await page
|
||||
.getByRole("row", { name: /실패 사용자/ })
|
||||
.getByRole("checkbox")
|
||||
.check();
|
||||
await page
|
||||
.getByRole("button", { name: "선택 구성원 WORKS에 생성" })
|
||||
.click();
|
||||
|
||||
await expect(page.getByText("WORKS 생성 작업 등록 실패")).toBeVisible();
|
||||
await expect(
|
||||
page.getByText(/WORKS API rejected user creation/),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user