feat: v2.2 batch (calendar, self-service, sort, description, filename search, stats, collab, invoice) on pre-redesign base

This commit is contained in:
Leon Tonhäuser committed 2026-11-30 21:20:13 +01:00
1 parent 453bece72c
commit 7204dd6b60
108 files changed
+10400 -105

No files matched your search

@@ -1,6 +1,7 @@
import { expect, test, vi } from "vitest";
import { createDownloadIntentHandler } from "./intent-handler";
import { UsageAccountingError } from "@/modules/usages/types";
const editorialId = "11111111-1111-4111-8111-111111111111";
const assetId = "22222222-2222-4222-8222-222222222222";
@@ -159,3 +160,46 @@ test("returns retry-after without creating an intent when the editorial limit is
);
expect(deps.createNewUsage).not.toHaveBeenCalled();
});
test("passes the collab flag through to the usage service", async () => {
const deps = dependencies();
deps.createNewUsage.mockResolvedValue({
id: downloadId,
usageId,
assetId,
priceCents: 0,
billable: true,
status: "authorized",
authorizedAt: new Date("2026-08-10T10:00:00.000Z"),
});
const response = await post(createDownloadIntentHandler(deps), {
kind: "new_usage",
assetId,
albumId,
purpose: "Collab Strecke",
idempotencyKey,
collab: true,
});
expect(response.status).toBe(201);
expect(deps.createNewUsage).toHaveBeenCalledWith(
expect.objectContaining({ editorialId, collab: true }),
);
await expect(response.json()).resolves.toMatchObject({ priceCents: 0 });
});
test("maps COLLAB_NOT_ENABLED to 403 with a stable code", async () => {
const deps = dependencies();
deps.createNewUsage.mockRejectedValue(new UsageAccountingError("COLLAB_NOT_ENABLED"));
const response = await post(createDownloadIntentHandler(deps), {
kind: "new_usage",
assetId,
albumId,
purpose: "Collab Strecke",
idempotencyKey,
collab: true,
});
expect(response.status).toBe(403);
await expect(response.json()).resolves.toEqual({ code: "COLLAB_NOT_ENABLED" });
});