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:
Leon TonhäuserandClaude Opus 5.5 committed 2026-11-30 22:19:34 +01:00
commit c0c2425dda
106 files changed
+10000 -110

No files matched your search

+20 -3
View File
@@ -12,6 +12,10 @@ import { startPostgres } from "./postgres";
const testDb = await startPostgres({
through: "0001_editorial_approval_notice.sql",
migrationsDir: "drizzle-history/pre-squash-2026-08",
alsoApply: [
"drizzle/0002_release_notes_calendar.sql",
"drizzle/0003_collab_invoice_activity.sql",
],
});
afterAll(() => testDb.stop());
@@ -199,10 +203,23 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents",
await testDb.applyRemainingMigrations();
// The retry path refreshes the upstream snapshot before resolving the
// persisted intent, so the mock must answer with the legacy-clean ids.
const immich = {
getAlbum: vi.fn(),
getAsset: vi.fn(),
searchPhotos: vi.fn(),
getAlbum: vi.fn().mockResolvedValue({ id: validAlbumId, albumName: "Presse 2026" }),
getAsset: vi.fn().mockResolvedValue({
id: validAssetId,
type: "IMAGE",
originalFileName: "jubel.jpg",
originalMimeType: "image/jpeg",
albums: [{ id: validAlbumId }],
}),
searchPhotos: vi.fn().mockResolvedValue({
items: [{ id: validAssetId }],
total: 1,
nextPage: null,
previousPage: null,
}),
};
const usageService = createUsageService({
repository: createUsageServiceRepository(testDb.database),
+4
View File
@@ -8,6 +8,10 @@ import { startPostgres } from "./postgres";
const testDb = await startPostgres({
through: "0001_editorial_approval_notice.sql",
migrationsDir: "drizzle-history/pre-squash-2026-08",
alsoApply: [
"drizzle/0002_release_notes_calendar.sql",
"drizzle/0003_collab_invoice_activity.sql",
],
});
afterAll(() => testDb.stop());
+10 -1
View File
@@ -30,7 +30,11 @@ export type PostgresTestDatabase = {
};
export async function startPostgres(
{ through, migrationsDir }: { through?: string; migrationsDir?: string } = {},
{
through,
migrationsDir,
alsoApply = [],
}: { through?: string; migrationsDir?: string; alsoApply?: string[] } = {},
): Promise<PostgresTestDatabase> {
const container = await new PostgreSqlContainer("postgres:17-alpine")
.withDatabase("portal")
@@ -44,6 +48,11 @@ export async function startPostgres(
if (through && throughIndex < 0) throw new Error(`Unknown migration: ${through}`);
let appliedMigrationCount = throughIndex + 1;
await applyMigrationFiles(pool, migrationsDir, migrationFiles.slice(0, appliedMigrationCount));
// Additive current-chain migrations (new tables/columns) that the historical
// chain predates, so current service code can run against the old schema.
for (const file of alsoApply) {
await pool.query(await readFile(path.join(process.cwd(), file), "utf8"));
}
const db = drizzle({ client: pool, schema });
+61
View File
@@ -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
+1
View File
@@ -23,6 +23,7 @@ export const reportFixture: BillingReportSnapshot = {
purpose: "Print Nutzung",
reference: "REF-001",
priceCents: 6_000,
collab: false,
createdAt: new Date("2026-03-15T10:00:00.000Z"),
},
],