54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
assigneeValueFromSelection,
|
|
currentUserAssigneeOption,
|
|
formatAssigneeUserLabel,
|
|
parseAssigneeValue,
|
|
} from "./assignees";
|
|
|
|
describe("assignee selection helpers", () => {
|
|
it("encodes and parses agent assignees", () => {
|
|
const value = assigneeValueFromSelection({ assigneeAgentId: "agent-123" });
|
|
|
|
expect(value).toBe("agent:agent-123");
|
|
expect(parseAssigneeValue(value)).toEqual({
|
|
assigneeAgentId: "agent-123",
|
|
assigneeUserId: null,
|
|
});
|
|
});
|
|
|
|
it("encodes and parses current-user assignees", () => {
|
|
const [option] = currentUserAssigneeOption("local-board");
|
|
|
|
expect(option).toEqual({
|
|
id: "user:local-board",
|
|
label: "Me",
|
|
searchText: "me board human local-board",
|
|
});
|
|
expect(parseAssigneeValue(option.id)).toEqual({
|
|
assigneeAgentId: null,
|
|
assigneeUserId: "local-board",
|
|
});
|
|
});
|
|
|
|
it("treats an empty selection as no assignee", () => {
|
|
expect(parseAssigneeValue("")).toEqual({
|
|
assigneeAgentId: null,
|
|
assigneeUserId: null,
|
|
});
|
|
});
|
|
|
|
it("keeps backward compatibility for raw agent ids in saved drafts", () => {
|
|
expect(parseAssigneeValue("legacy-agent-id")).toEqual({
|
|
assigneeAgentId: "legacy-agent-id",
|
|
assigneeUserId: null,
|
|
});
|
|
});
|
|
|
|
it("formats current and board user labels consistently", () => {
|
|
expect(formatAssigneeUserLabel("user-1", "user-1")).toBe("Me");
|
|
expect(formatAssigneeUserLabel("local-board", "someone-else")).toBe("Board");
|
|
expect(formatAssigneeUserLabel("user-abcdef", "someone-else")).toBe("user-");
|
|
});
|
|
});
|