1
0
forked from baron/baron-sso

orgfront 코드 체크 추가, 백엔드 기준 강화

This commit is contained in:
2026-05-14 09:49:37 +09:00
parent 92e607aee8
commit 8bca127723
16 changed files with 786 additions and 77 deletions

View File

@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import {
type OrgNode,
buildOrgSelectionOptions,
buildUsersMap,
clampScale,
getOrgNodeHeaderFill,
getSemanticZoomMode,
@@ -385,4 +386,24 @@ describe("org chart layout", () => {
buildOrgSelectionOptions(familyRoot).map((option) => option.label),
).toEqual(["총괄기획&기술개발센터", "삼안", "한맥기술", "바론그룹"]);
});
it("maps legacy companyCode users to matching tenant slugs", () => {
const usersMap = buildUsersMap(
[
{
...member("engineering-user"),
companyCode: "engineering",
tenantSlug: undefined,
tenant: undefined,
joinedTenants: undefined,
},
],
[tenantNode("engineering", "ORGANIZATION", "Engineering", "engineering")],
{ activeOnly: true },
);
expect(usersMap.get("engineering")?.map((user) => user.id)).toEqual([
"engineering-user",
]);
});
});

View File

@@ -1132,7 +1132,7 @@ function getLeafMembershipSlugs(
});
}
function buildUsersMap(
export function buildUsersMap(
users: UserSummary[],
rootNodes: TenantNode[],
options: { activeOnly: boolean },
@@ -1146,6 +1146,7 @@ function buildUsersMap(
const slugs = new Set<string>();
const primarySlug = user.tenantSlug?.toLowerCase() || "";
const legacyCompanySlug = user.companyCode?.toLowerCase() || "";
if (
primarySlug &&
!isSystemGlobalTenant({
@@ -1157,6 +1158,17 @@ function buildUsersMap(
) {
slugs.add(primarySlug);
}
if (
legacyCompanySlug &&
!isSystemGlobalTenant({
id: legacyCompanySlug,
slug: legacyCompanySlug,
type: legacyCompanySlug,
name: legacyCompanySlug,
})
) {
slugs.add(legacyCompanySlug);
}
if (user.tenant?.slug && !isSystemGlobalTenant(user.tenant)) {
slugs.add(user.tenant.slug.toLowerCase());
}