contracts 1.17.0: brand style, church.update, the Website's export, licence storage limit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -141,8 +141,8 @@ describe("exports", () => {
|
||||
expect(() => decryptExport(file, encryptExport(zip).key)).toThrow();
|
||||
});
|
||||
|
||||
it("the sample has no internal ids", () => {
|
||||
const data = sample("church-export.json");
|
||||
it.each(["church-export.json", "church-export-website.json"])("%s has no internal ids", (file) => {
|
||||
const data = sample(file);
|
||||
expect(churchExportSchema.safeParse(data).success).toBe(true);
|
||||
const keys: string[] = [];
|
||||
const walk = (v: unknown): void => {
|
||||
|
||||
@@ -35,7 +35,9 @@ const SAMPLE_SCHEMA: Record<string, string> = {
|
||||
"hub-heartbeat-accounts.json": "hub-heartbeat-request",
|
||||
"hub-heartbeat-response.json": "hub-heartbeat-response",
|
||||
"hub-licence-payload.json": "hub-licence-payload",
|
||||
"hub-licence-payload-website.json": "hub-licence-payload",
|
||||
"church-export.json": "church-export",
|
||||
"church-export-website.json": "church-export",
|
||||
"church-changed.json": "church-changed",
|
||||
"link-connect.json": "link-connect",
|
||||
"link-connected.json": "link-connected",
|
||||
@@ -52,6 +54,8 @@ const SAMPLE_SCHEMA: Record<string, string> = {
|
||||
"people-remove-demo-reply.json": "people-remove-demo-reply",
|
||||
"people-check.json": "identity-request",
|
||||
"people-check-reply.json": "people-check-reply",
|
||||
"church-update.json": "identity-request",
|
||||
"church-update-reply.json": "church-update-reply",
|
||||
};
|
||||
|
||||
describe("JSON Schema (schemas/)", () => {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
importBatchReplySchema,
|
||||
peopleEnsureReplySchema,
|
||||
messagingTestReplySchema,
|
||||
peopleRemoveDemoReplySchema, peopleCheckReplySchema,
|
||||
peopleRemoveDemoReplySchema, peopleCheckReplySchema, churchUpdateReplySchema,
|
||||
userDeletedReplySchema,
|
||||
userExportReplySchema,
|
||||
} from "../src";
|
||||
@@ -44,7 +44,9 @@ const SCHEMAS: Record<string, z.ZodType> = {
|
||||
"hub-heartbeat-accounts.json": hub.heartbeatRequestSchema,
|
||||
"hub-heartbeat-response.json": hub.heartbeatResponseSchema,
|
||||
"hub-licence-payload.json": hub.licencePayloadSchema,
|
||||
"hub-licence-payload-website.json": hub.licencePayloadSchema,
|
||||
"church-export.json": churchExportSchema,
|
||||
"church-export-website.json": churchExportSchema,
|
||||
"church-changed.json": churchChangedSchema,
|
||||
"link-connect.json": linkConnectSchema,
|
||||
"link-connected.json": linkConnectedSchema,
|
||||
@@ -61,6 +63,8 @@ const SCHEMAS: Record<string, z.ZodType> = {
|
||||
"people-remove-demo-reply.json": peopleRemoveDemoReplySchema,
|
||||
"people-check.json": identityRequestSchema,
|
||||
"people-check-reply.json": peopleCheckReplySchema,
|
||||
"church-update.json": identityRequestSchema,
|
||||
"church-update-reply.json": churchUpdateReplySchema,
|
||||
};
|
||||
|
||||
describe("samples", () => {
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import {
|
||||
brandStyleSchema,
|
||||
churchExportSchema,
|
||||
churchSchema,
|
||||
CORNERS,
|
||||
FONT_PAIRING_IDS,
|
||||
FONT_PAIRINGS,
|
||||
hub,
|
||||
identityRequestSchema,
|
||||
TEMPLATE_FONT_PAIRINGS,
|
||||
WEBSITE_TEMPLATES,
|
||||
} from "../src";
|
||||
import type { Church, ChurchExport } from "../src";
|
||||
import { sample } from "./helpers";
|
||||
|
||||
describe("brand style (1.17.0)", () => {
|
||||
it("has the 8 confirmed font pairings, ids unchanged", () => {
|
||||
// These ids are stored in churches' profiles: changing or removing one is a breaking change.
|
||||
expect(FONT_PAIRING_IDS).toEqual(["classic", "scholarly", "editorial", "impact", "contemporary", "friendly", "warm", "modern"]);
|
||||
expect(CORNERS).toEqual(["sharp", "soft", "round"]);
|
||||
});
|
||||
|
||||
it("each template recommends three different pairings, and every pairing is recommended somewhere", () => {
|
||||
expect(Object.keys(TEMPLATE_FONT_PAIRINGS).sort()).toEqual([...WEBSITE_TEMPLATES].sort());
|
||||
for (const picks of Object.values(TEMPLATE_FONT_PAIRINGS)) expect(new Set(picks).size).toBe(3);
|
||||
const recommended = new Set(Object.values(TEMPLATE_FONT_PAIRINGS).flat());
|
||||
expect([...recommended].sort()).toEqual([...FONT_PAIRING_IDS].sort());
|
||||
});
|
||||
|
||||
it("every pairing names a heading and a body font", () => {
|
||||
for (const p of Object.values(FONT_PAIRINGS)) {
|
||||
expect(p.heading.family.length).toBeGreaterThan(0);
|
||||
expect(p.body.family.length).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
|
||||
it("a profile without a style still parses (Accounts before 1.7.0)", () => {
|
||||
const c = sample<Church>("church.json");
|
||||
delete c.branding.style;
|
||||
const parsed = churchSchema.parse(c);
|
||||
expect(parsed.branding.style).toBeUndefined();
|
||||
});
|
||||
|
||||
it("an unknown pairing or corner from a newer Accounts reads as null instead of failing", () => {
|
||||
expect(brandStyleSchema.parse({ fontPairing: "gothic", corners: "pointy" })).toEqual({ fontPairing: null, corners: null });
|
||||
const c = sample<Church>("church.json");
|
||||
const parsed = churchSchema.parse({ ...c, branding: { ...c.branding, style: { fontPairing: "gothic", corners: "round" } } });
|
||||
expect(parsed.branding.style).toEqual({ fontPairing: null, corners: "round" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("the Website's export (1.17.0)", () => {
|
||||
const data = () => sample<ChurchExport>("church-export-website.json");
|
||||
|
||||
it("is optional, so Events' and Accounts' exports are unchanged", () => {
|
||||
const events = churchExportSchema.parse(sample("church-export.json"));
|
||||
expect(events.website).toBeUndefined();
|
||||
});
|
||||
|
||||
it("refuses an unknown template, a page path that isn't one, and media outside uploads/", () => {
|
||||
const d = data();
|
||||
const bad = (website: object) => churchExportSchema.safeParse({ ...d, website: { ...d.website, ...website } }).success;
|
||||
expect(bad({ template: "minimal" })).toBe(false);
|
||||
expect(bad({ pages: [{ ...d.website!.pages[0]!, path: "about" }] })).toBe(false);
|
||||
expect(bad({ media: [{ path: "../etc/passwd", alt: null, caption: null }] })).toBe(false);
|
||||
});
|
||||
|
||||
it("a message is a YouTube-feed or hand-added link", () => {
|
||||
const d = data();
|
||||
const msg = { ...d.website!.messages[0]!, source: "upload" };
|
||||
expect(churchExportSchema.safeParse({ ...d, website: { ...d.website, messages: [msg] } }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("licence storage limit (1.17.0)", () => {
|
||||
it("is optional, and only whole non-negative bytes", () => {
|
||||
const lic = sample<hub.LicencePayload>("hub-licence-payload-website.json");
|
||||
expect(hub.licencePayloadSchema.parse(lic).limits.storageBytes).toBe(10737418240);
|
||||
expect(hub.licencePayloadSchema.parse(sample("hub-licence-payload.json")).limits.storageBytes).toBeUndefined();
|
||||
expect(hub.licencePayloadSchema.safeParse({ ...lic, limits: { ...lic.limits, storageBytes: -1 } }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("church.update (1.17.0)", () => {
|
||||
const req = () => sample<Record<string, unknown>>("church-update.json");
|
||||
|
||||
it("needs an actor and something to change", () => {
|
||||
expect(identityRequestSchema.safeParse({ ...req(), actor: null }).success).toBe(false);
|
||||
expect(identityRequestSchema.safeParse({ ...req(), church: {} }).success).toBe(false);
|
||||
});
|
||||
|
||||
it("takes part of branding (only the style), but not the fields Accounts fills in", () => {
|
||||
const parsed = identityRequestSchema.parse({ ...req(), church: { branding: { style: { fontPairing: "modern", corners: null } } } });
|
||||
expect(parsed.type === "church.update" && parsed.church.branding).toEqual({ style: { fontPairing: "modern", corners: null } });
|
||||
const withLinks = identityRequestSchema.parse({ ...req(), church: { name: "Hope", links: { accounts: "https://evil.example" }, customerId: "x" } });
|
||||
expect(withLinks.type === "church.update" && Object.keys(withLinks.church)).toEqual(["name"]);
|
||||
});
|
||||
|
||||
it("still checks what it's given", () => {
|
||||
expect(identityRequestSchema.safeParse({ ...req(), church: { branding: { colours: { primary: "blue", accent: null } } } }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user