Assign invite-joined agents to company CEO
This commit is contained in:
33
server/src/__tests__/invite-join-manager.test.ts
Normal file
33
server/src/__tests__/invite-join-manager.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveJoinRequestAgentManagerId } from "../routes/access.js";
|
||||
|
||||
describe("resolveJoinRequestAgentManagerId", () => {
|
||||
it("returns null when no CEO exists in the company agent list", () => {
|
||||
const managerId = resolveJoinRequestAgentManagerId([
|
||||
{ id: "a1", role: "cto", reportsTo: null },
|
||||
{ id: "a2", role: "engineer", reportsTo: "a1" },
|
||||
]);
|
||||
|
||||
expect(managerId).toBeNull();
|
||||
});
|
||||
|
||||
it("selects the root CEO when available", () => {
|
||||
const managerId = resolveJoinRequestAgentManagerId([
|
||||
{ id: "ceo-child", role: "ceo", reportsTo: "manager-1" },
|
||||
{ id: "manager-1", role: "cto", reportsTo: null },
|
||||
{ id: "ceo-root", role: "ceo", reportsTo: null },
|
||||
]);
|
||||
|
||||
expect(managerId).toBe("ceo-root");
|
||||
});
|
||||
|
||||
it("falls back to the first CEO when no root CEO is present", () => {
|
||||
const managerId = resolveJoinRequestAgentManagerId([
|
||||
{ id: "ceo-1", role: "ceo", reportsTo: "mgr" },
|
||||
{ id: "ceo-2", role: "ceo", reportsTo: "mgr" },
|
||||
{ id: "mgr", role: "cto", reportsTo: null },
|
||||
]);
|
||||
|
||||
expect(managerId).toBe("ceo-1");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user