Files
EpicNext-Cms/src/lib/admin/operations-inbox.test.ts
T
Simo c389c3893d
CI / check (push) Successful in 52s
CI / deploy (push) Successful in 2m10s
CI / publish-container (push) Failing after 1m18s
feat(cms): improve catalog, editorial recovery and operations
2026-09-09 19:36:15 +02:00

36 lines
937 B
TypeScript

import { expect, it, vi } from "vitest";
import { collectOperations } from "./operations-inbox";
it("does not load unauthorized sources and reports failed sources separately", async () => {
const denied = vi.fn();
const result = await collectOperations([
{ source: "errors", allowed: false, load: denied },
{
source: "imports",
allowed: true,
load: async () => {
throw Error("offline");
},
},
]);
expect(denied).not.toHaveBeenCalled();
expect(result).toEqual({ items: [], unavailable: ["imports"] });
});
it("deduplicates, prioritizes and excludes empty work", async () => {
const item = {
id: "one",
source: "errors" as const,
href: "/admin/devops/cms-errors",
count: 2,
severity: 3,
};
const result = await collectOperations([
{
source: "errors",
allowed: true,
load: async () => [item, item, { ...item, id: "empty", count: 0 }],
},
]);
expect(result.items).toEqual([item]);
});