Stockage flat côté ticket + métadonnées d'attachments, lecture exposée côté backend/MCP, et UI minimale de liste/ajout dans TicketDetail. Traverse le domaine (Issue, ports), l'application (usecases + assistant de ticket), les adaptateurs infra/MCP (issues store, orchestrateur), les DTO backend/web- server/app-tauri, et le frontend (domain/ports/adapters/hooks/UI). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
101 lines
2.6 KiB
TypeScript
101 lines
2.6 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
|
const invoke = vi.fn();
|
|
vi.mock("@tauri-apps/api/core", () => ({
|
|
invoke: (...args: unknown[]) => invoke(...args),
|
|
Channel: class {
|
|
onmessage: ((chunk: unknown) => void) | null = null;
|
|
},
|
|
}));
|
|
|
|
import { TauriTicketGateway } from "./ticket";
|
|
|
|
describe("TauriTicketGateway invoke payloads", () => {
|
|
beforeEach(() => invoke.mockReset().mockResolvedValue({ items: [] }));
|
|
|
|
it("bulk status wraps refs and status in the request DTO", async () => {
|
|
await new TauriTicketGateway().bulkUpdateStatus(
|
|
"proj-1",
|
|
["#1", "#2"],
|
|
"inProgress",
|
|
);
|
|
|
|
expect(invoke).toHaveBeenCalledWith("ticket_bulk_update_status", {
|
|
request: {
|
|
projectId: "proj-1",
|
|
refs: ["#1", "#2"],
|
|
status: "inProgress",
|
|
},
|
|
});
|
|
});
|
|
|
|
it("bulk delete wraps refs in the request DTO", async () => {
|
|
await new TauriTicketGateway().bulkDelete("proj-1", ["#3", "#4"]);
|
|
|
|
expect(invoke).toHaveBeenCalledWith("ticket_bulk_delete", {
|
|
request: {
|
|
projectId: "proj-1",
|
|
refs: ["#3", "#4"],
|
|
},
|
|
});
|
|
});
|
|
|
|
it("passes createdBy through the ticket list request DTO", async () => {
|
|
await new TauriTicketGateway().list("proj-1", {
|
|
createdBy: { kind: "agent", agentId: "agent-1" },
|
|
});
|
|
|
|
expect(invoke).toHaveBeenCalledWith("ticket_list", {
|
|
request: {
|
|
projectId: "proj-1",
|
|
statuses: [],
|
|
priorities: [],
|
|
createdBy: { kind: "agent", agentId: "agent-1" },
|
|
},
|
|
});
|
|
});
|
|
|
|
it("wraps ticket attachment commands in the request DTO", async () => {
|
|
const gateway = new TauriTicketGateway();
|
|
|
|
await gateway.addAttachment(
|
|
"proj-1",
|
|
"#12",
|
|
"/tmp/note.txt",
|
|
3,
|
|
"text/plain",
|
|
);
|
|
await gateway.readAttachment("proj-1", "#12", "att-1");
|
|
await gateway.markAttachmentSummarized("proj-1", "#12", "att-1", 4);
|
|
|
|
expect(invoke).toHaveBeenNthCalledWith(1, "ticket_attachment_add", {
|
|
request: {
|
|
projectId: "proj-1",
|
|
ref: "#12",
|
|
path: "/tmp/note.txt",
|
|
expectedVersion: 3,
|
|
mime: "text/plain",
|
|
},
|
|
});
|
|
expect(invoke).toHaveBeenNthCalledWith(2, "ticket_attachment_read", {
|
|
request: {
|
|
projectId: "proj-1",
|
|
ref: "#12",
|
|
attachmentId: "att-1",
|
|
},
|
|
});
|
|
expect(invoke).toHaveBeenNthCalledWith(
|
|
3,
|
|
"ticket_attachment_mark_summarized",
|
|
{
|
|
request: {
|
|
projectId: "proj-1",
|
|
ref: "#12",
|
|
attachmentId: "att-1",
|
|
expectedVersion: 4,
|
|
},
|
|
},
|
|
);
|
|
});
|
|
});
|