feat(editorial): validate publications and preserve partial event updates

This commit is contained in:
Simo committed 2026-09-11 00:36:55 +02:00
1 parent 76f0420d64
commit db4acbb46e
14 files changed
+613 -16

No files matched your search

+25 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { createEventSchema, eventTypeSchema } from "./event";
import { createEventSchema, eventTypeSchema, updateEventSchema } from "./event";
describe("eventTypeSchema", () => {
it("accepts valid type", () => {
@@ -98,3 +98,27 @@ describe("createEventSchema", () => {
}
});
});
it("preserves omitted status and recurrence on partial event updates", () => {
expect(updateEventSchema.parse({ title: "Changed" })).toEqual({
title: "Changed",
});
});
it("rejects a null event start instead of converting it to the Unix epoch", () => {
expect(
createEventSchema.safeParse({
title: "Event",
description: "Details",
typeId: 1,
startsAt: null,
status: "published",
}).success,
).toBe(false);
});
it("distinguishes an omitted image from explicit image removal", () => {
expect(updateEventSchema.parse({ title: "Changed" })).not.toHaveProperty(
"image",
);
expect(updateEventSchema.parse({ image: "" })).toEqual({ image: null });
});