Add saved sign text size controls with independent QR sizing
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { savedSignSchema } from "./sign";
|
||||
|
||||
test("text sizing survives saved design round trips and rejects invalid scales", () => {
|
||||
const base = { title: "Event", headline: "Share", message: "Welcome", paper: "letter", ink: "indigo" };
|
||||
expect(savedSignSchema.parse(base).headlineScale).toBeUndefined();
|
||||
const sized = { ...base, headlineScale: 150, messageScale: 125, titleScale: 75 };
|
||||
expect(savedSignSchema.parse(JSON.parse(JSON.stringify(sized)))).toEqual(sized);
|
||||
for (const key of ["headlineScale", "messageScale", "titleScale"]) {
|
||||
for (const value of [0, 74, 151, Infinity, NaN, "125"]) expect(savedSignSchema.safeParse({ ...base, [key]: value }).success).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
test("saved designs reject unsafe assets, invalid settings, and embedded runtime fonts", () => {
|
||||
const design = { title: "Our event", headline: "Share your moments", message: "Photos welcome", paper: "card6x4", ink: "indigo" };
|
||||
expect(savedSignSchema.safeParse(design).success).toBe(true);
|
||||
|
||||
@@ -29,6 +29,9 @@ const papers: ["custom", ...(keyof typeof SIGN_PAPERS)[]] = ["custom", ...Object
|
||||
export const savedSignSchema = z.object({
|
||||
title: z.string().trim().min(1).max(120), headline: z.string().trim().min(1).max(44),
|
||||
message: z.string().trim().min(1).max(120),
|
||||
headlineScale: z.number().finite().min(75).max(150).optional(),
|
||||
messageScale: z.number().finite().min(75).max(150).optional(),
|
||||
titleScale: z.number().finite().min(75).max(150).optional(),
|
||||
paper: z.enum(papers),
|
||||
ink: z.enum(["indigo", "black"]), layout: z.enum(["photo", "typography", "compact"]).optional(),
|
||||
customWidth: z.number().finite().optional(), customHeight: z.number().finite().optional(),
|
||||
|
||||
Reference in New Issue
Block a user