1
0
forked from baron/baron-sso

fix(adminfront): guard employee ID metadata in GPO priority swap

This commit is contained in:
2026-05-28 08:53:28 +09:00
parent 899365de9d
commit 7401454bc0
3 changed files with 191 additions and 76 deletions

View File

@@ -0,0 +1,104 @@
import type { BulkUserItem, TenantSummary } from "../../../lib/adminApi";
import { applyGeneralPlanningOfficePriority } from "./generalPlanningOfficePriority";
function tenant(
id: string,
name: string,
slug: string,
parentId?: string,
): TenantSummary {
return {
id,
type: "COMPANY",
name,
slug,
description: "",
status: "active",
parentId,
memberCount: 0,
createdAt: "",
updatedAt: "",
};
}
describe("applyGeneralPlanningOfficePriority", () => {
it("promotes the general planning office appointment and preserves string employee IDs", () => {
const user: BulkUserItem = {
email: "dual@test.com",
name: "Dual User",
tenantSlug: "hanmac-tech",
department: "개발팀",
grade: "책임",
position: "팀장",
jobTitle: "Backend",
metadata: {
employee_id: "EMP001",
},
additionalAppointments: [
{
tenantSlug: "planning-team",
tenantName: "경영기획팀",
department: "센터",
grade: "수석",
jobTitle: "Architecture",
metadata: {
employee_id: "EMP002",
},
},
],
};
const result = applyGeneralPlanningOfficePriority(user, [
tenant("gpo", "총괄기획실", "gpo"),
tenant("planning", "경영기획팀", "planning-team", "gpo"),
tenant("tech", "한맥기술", "hanmac-tech"),
]);
expect(result.tenantSlug).toBe("planning-team");
expect(result.department).toBe("센터");
expect(result.grade).toBe("수석");
expect(result.jobTitle).toBe("Architecture");
expect(result.metadata.employee_id).toBe("EMP002");
expect(result.additionalAppointments?.[0]).toMatchObject({
tenantSlug: "hanmac-tech",
department: "개발팀",
grade: "책임",
position: "팀장",
jobTitle: "Backend",
metadata: {
employee_id: "EMP001",
},
});
});
it("does not write non-string employee IDs into string metadata", () => {
const user: BulkUserItem = {
email: "dual@test.com",
name: "Dual User",
tenantSlug: "hanmac-tech",
metadata: {
employee_id: "EMP001",
},
additionalAppointments: [
{
tenantSlug: "gpo",
tenantName: "총괄기획실",
metadata: {
employee_id: 1002,
},
},
],
};
const result = applyGeneralPlanningOfficePriority(user, [
tenant("gpo", "총괄기획실", "gpo"),
tenant("tech", "한맥기술", "hanmac-tech"),
]);
expect(result.tenantSlug).toBe("gpo");
expect(result.metadata.employee_id).toBeUndefined();
expect(result.additionalAppointments?.[0].metadata).toMatchObject({
employee_id: "EMP001",
});
});
});