Update empty scene document test and add validation tests for invalid world settings

This commit is contained in:
2026-03-31 05:14:06 +02:00
parent 4ba4a9adf0
commit e5a472f693
2 changed files with 53 additions and 0 deletions

View File

@@ -9,6 +9,25 @@ describe("createEmptySceneDocument", () => {
expect(document.version).toBe(SCENE_DOCUMENT_VERSION);
expect(document.name).toBe("Untitled Scene");
expect(document.world).toEqual({
background: {
mode: "solid",
colorHex: "#2f3947"
},
ambientLight: {
colorHex: "#f7f1e8",
intensity: 1
},
sunLight: {
colorHex: "#fff1d5",
intensity: 1.75,
direction: {
x: -0.6,
y: 1,
z: 0.35
}
}
});
expect(document.brushes).toEqual({});
expect(document.entities).toEqual({});
expect(document.modelInstances).toEqual({});

View File

@@ -116,4 +116,38 @@ describe("validateSceneDocument", () => {
])
);
});
it("detects invalid world lighting and background settings", () => {
const document = createEmptySceneDocument();
document.world.background = {
mode: "verticalGradient",
topColorHex: "sky-blue",
bottomColorHex: "#18212b"
};
document.world.ambientLight.intensity = -0.25;
document.world.sunLight.direction = {
x: 0,
y: 0,
z: 0
};
const validation = validateSceneDocument(document);
expect(validation.errors).toEqual(
expect.arrayContaining([
expect.objectContaining({
code: "invalid-world-background-top-color",
path: "world.background.topColorHex"
}),
expect.objectContaining({
code: "invalid-world-ambient-intensity",
path: "world.ambientLight.intensity"
}),
expect.objectContaining({
code: "invalid-world-sun-direction",
path: "world.sunLight.direction"
})
])
);
});
});