mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 03:10:38 +09:00
Add me and unassigned assignee options
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
6365e03731
commit
32ab4f8e47
6 changed files with 219 additions and 41 deletions
53
ui/src/lib/assignees.test.ts
Normal file
53
ui/src/lib/assignees.test.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
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-");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue