A client gallery is its own module. It is built from an event and its photographs and opens at /cliente/<slug> on the events site.
35 lines
1.8 KiB
TypeScript
35 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { clientGalleryIsOpen, CreateSiteGallery, photographerOwnsPhoto, readDesign, slugifyTitle } from "./site-gallery.js";
|
|
|
|
describe("client galleries", () => {
|
|
it("makes a public address from the title", () => {
|
|
expect(slugifyTitle("Helena e Miguel")).toBe("helena-e-miguel");
|
|
expect(slugifyTitle(" ")).toBe("galeria");
|
|
});
|
|
|
|
it("stays closed until it is published, and closes again at the set time", () => {
|
|
expect(clientGalleryIsOpen({ publishedAt: null, offlineAt: null })).toBe(false);
|
|
expect(clientGalleryIsOpen({ publishedAt: "2026-09-12T00:00:00.000Z", offlineAt: null }, new Date("2026-09-13T00:00:00.000Z"))).toBe(true);
|
|
expect(clientGalleryIsOpen({ publishedAt: "2026-09-12T00:00:00.000Z", offlineAt: "2026-10-01T00:00:00.000Z" }, new Date("2026-10-02T00:00:00.000Z"))).toBe(false);
|
|
});
|
|
|
|
it("falls back to the framed paper cover when the stored design is unreadable", () => {
|
|
expect(readDesign(null).cover).toBe("framed");
|
|
expect(readDesign({ cover: "modern", palette: "night", font: "sans", grid: "rows", size: "l", spacing: "wide", focalX: 0.2, focalY: 0.8 }).cover).toBe("modern");
|
|
});
|
|
|
|
it("starts with favorites on and reviews off", () => {
|
|
const created = CreateSiteGallery.parse({ title: "Helena e Miguel" });
|
|
expect(created.favorites).toBe(true);
|
|
expect(created.reviews).toBe(false);
|
|
expect(created.design.cover).toBe("framed");
|
|
expect(created.downloads.single).toBe(true);
|
|
});
|
|
|
|
it("keeps another photographer's frames out of the gallery", () => {
|
|
expect(photographerOwnsPhoto({ uploaderId: "me" }, "me")).toBe(true);
|
|
expect(photographerOwnsPhoto({ uploaderId: "other" }, "me")).toBe(false);
|
|
expect(photographerOwnsPhoto({ uploaderId: null }, "me")).toBe(false);
|
|
});
|
|
});
|