mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-16 19:29:26 +02:00
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { InboxItem } from "@multica/core/types";
|
|
import { deduplicateInboxItems } from "./inbox-display";
|
|
|
|
function item(overrides: Partial<InboxItem>): InboxItem {
|
|
return {
|
|
id: "inbox-1",
|
|
workspace_id: "workspace-1",
|
|
recipient_type: "member",
|
|
recipient_id: "member-1",
|
|
actor_type: "agent",
|
|
actor_id: "agent-1",
|
|
type: "new_comment",
|
|
severity: "info",
|
|
issue_id: "issue-1",
|
|
title: "Issue title",
|
|
body: null,
|
|
issue_status: null,
|
|
read: false,
|
|
archived: false,
|
|
created_at: "2026-06-15T08:00:00Z",
|
|
details: null,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("deduplicateInboxItems", () => {
|
|
it("keeps the newest issue row while preserving an older comment anchor", () => {
|
|
const merged = deduplicateInboxItems([
|
|
item({
|
|
id: "comment-notification",
|
|
created_at: "2026-06-15T08:00:00Z",
|
|
details: { comment_id: "comment-1" },
|
|
}),
|
|
item({
|
|
id: "status-notification",
|
|
type: "status_changed",
|
|
created_at: "2026-06-15T08:01:00Z",
|
|
details: { from: "in_progress", to: "in_review" },
|
|
}),
|
|
]);
|
|
|
|
expect(merged).toHaveLength(1);
|
|
expect(merged[0]).toMatchObject({
|
|
id: "status-notification",
|
|
type: "status_changed",
|
|
details: {
|
|
from: "in_progress",
|
|
to: "in_review",
|
|
comment_id: "comment-1",
|
|
},
|
|
});
|
|
});
|
|
});
|