From 37314877561fd3d45ccbcfbd5d948109abf029d8 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 13 Apr 2026 23:55:45 +0200 Subject: [PATCH] Add NPC presence window validation tests --- .../domain/scene-document-validation.test.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/domain/scene-document-validation.test.ts b/tests/domain/scene-document-validation.test.ts index 677c113d..47b9d8c9 100644 --- a/tests/domain/scene-document-validation.test.ts +++ b/tests/domain/scene-document-validation.test.ts @@ -506,6 +506,57 @@ describe("validateSceneDocument", () => { ); }); + it("validates authored NPC presence windows", () => { + const zeroWindowNpc = createNpcEntity({ + id: "entity-npc-zero-window", + actorId: "actor-town-zero-window", + presence: createNpcTimeWindowPresence({ + startHour: 8, + endHour: 12 + }) + }); + zeroWindowNpc.presence = { + mode: "timeWindow", + startHour: 8, + endHour: 8 + }; + + const invalidRangeNpc = createNpcEntity({ + id: "entity-npc-invalid-range", + actorId: "actor-town-invalid-range", + presence: createNpcTimeWindowPresence({ + startHour: 20, + endHour: 2 + }) + }); + invalidRangeNpc.presence = { + mode: "timeWindow", + startHour: 25, + endHour: 2 + }; + + const validation = validateSceneDocument({ + ...createEmptySceneDocument(), + entities: { + [zeroWindowNpc.id]: zeroWindowNpc, + [invalidRangeNpc.id]: invalidRangeNpc + } + }); + + expect(validation.errors).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + code: "invalid-npc-presence-zero-window", + path: "entities.entity-npc-zero-window.presence.startHour" + }), + expect.objectContaining({ + code: "invalid-npc-presence-start-range", + path: "entities.entity-npc-invalid-range.presence.startHour" + }) + ]) + ); + }); + it("accepts authored point and spot lights with an active image background asset", () => { const imageAsset = { id: "asset-background-panorama",