Merge v2.1-2.2.0 features onto SakaniUI base
Ports calendar, self-service, sorting, image descriptions, logo (2.1), filename search (2.1.1), statistics page, collab option and bundled invoice PDF delivery (2.2.0) onto the deployed SakaniUI portal. Also fixes the statistics daily series, which ended yesterday and so hid today's activity from the charts, and ignores Playwright test-results/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
c0c2425dda
106 files changed
+10000
-110
No files matched your search
@@ -72,11 +72,19 @@ async function seedEditorial({
|
||||
priceCents = 1_500,
|
||||
albumId: grantedAlbumId = albumId,
|
||||
revoked = false,
|
||||
collabEnabled = false,
|
||||
flatrateActive = false,
|
||||
flatratePriceCents = null,
|
||||
flatrateAssetLimit = null,
|
||||
}: {
|
||||
status?: "active" | "suspended" | "pending_approval";
|
||||
priceCents?: number | null;
|
||||
albumId?: string;
|
||||
revoked?: boolean;
|
||||
collabEnabled?: boolean;
|
||||
flatrateActive?: boolean;
|
||||
flatratePriceCents?: number | null;
|
||||
flatrateAssetLimit?: number | null;
|
||||
} = {}) {
|
||||
const userId = randomUUID();
|
||||
const editorialId = randomUUID();
|
||||
@@ -94,6 +102,10 @@ async function seedEditorial({
|
||||
loginEmail: `${userId}@example.com`,
|
||||
status,
|
||||
currentPriceCents: priceCents,
|
||||
collabEnabled,
|
||||
flatrateActive,
|
||||
flatratePriceCents,
|
||||
flatrateAssetLimit,
|
||||
});
|
||||
await database.insert(albumGrants).values({
|
||||
editorialAccountId: editorialId,
|
||||
@@ -569,6 +581,55 @@ test("repeat ownership is scoped to the active editorial", async () => {
|
||||
).rejects.toMatchObject({ code: "USAGE_NOT_FOUND" });
|
||||
});
|
||||
|
||||
test("collab usages are free and flagged when the editorial is enabled", async () => {
|
||||
const editorialId = await seedEditorial({ collabEnabled: true });
|
||||
const { usageService } = createServices();
|
||||
|
||||
const intent = await usageService.createNewUsage({ ...newInput(editorialId), collab: true });
|
||||
|
||||
expect(intent.priceCents).toBe(0);
|
||||
const [usage] = await database
|
||||
.select({ collab: usages.collab, priceCents: usages.priceCents })
|
||||
.from(usages)
|
||||
.where(eq(usages.id, intent.usageId));
|
||||
expect(usage).toEqual({ collab: true, priceCents: 0 });
|
||||
const [audit] = await database
|
||||
.select({ newValues: auditEvents.newValues })
|
||||
.from(auditEvents)
|
||||
.where(and(eq(auditEvents.entityId, intent.usageId), eq(auditEvents.eventType, "billable_usage_created")));
|
||||
expect(audit.newValues).toMatchObject({ collab: true, priceCents: 0 });
|
||||
});
|
||||
|
||||
test("collab usages are rejected when the editorial is not enabled", async () => {
|
||||
const editorialId = await seedEditorial({ collabEnabled: false });
|
||||
const { usageService } = createServices();
|
||||
|
||||
await expect(
|
||||
usageService.createNewUsage({ ...newInput(editorialId), collab: true }),
|
||||
).rejects.toMatchObject({ code: "COLLAB_NOT_ENABLED" });
|
||||
});
|
||||
|
||||
test("collab usages do not consume the flatrate asset limit", async () => {
|
||||
const editorialId = await seedEditorial({
|
||||
collabEnabled: true,
|
||||
flatrateActive: true,
|
||||
flatratePriceCents: 500,
|
||||
flatrateAssetLimit: 1,
|
||||
});
|
||||
const { usageService } = createServices();
|
||||
|
||||
const collabIntent = await usageService.createNewUsage({ ...newInput(editorialId), collab: true });
|
||||
expect(collabIntent.priceCents).toBe(0);
|
||||
|
||||
// The single flatrate slot is still free after the collab usage.
|
||||
const flatrateIntent = await usageService.createNewUsage(newInput(editorialId));
|
||||
expect(flatrateIntent.priceCents).toBe(0);
|
||||
|
||||
// Limit exhausted: the next regular usage costs the individual price.
|
||||
const paidIntent = await usageService.createNewUsage(newInput(editorialId));
|
||||
expect(paidIntent.priceCents).toBe(1_500);
|
||||
});
|
||||
|
||||
async function markDelivered(downloadId: string): Promise<void> {
|
||||
const deliveredAt = new Date();
|
||||
await database
|
||||
|
||||
Reference in new issue
Block a user