feat: add non-destructive adjustment layers
This commit is contained in:
@@ -36,12 +36,26 @@ describe("project format", () => {
|
||||
test("rejects invalid persisted layer crops", () => {
|
||||
const document = projectDocument();
|
||||
const layer = document.artboards[0]!.layers[0]!;
|
||||
if (layer.type === "group") throw new Error("Expected image layer");
|
||||
if (layer.type !== "image" && layer.type !== "raster") throw new Error("Expected image layer");
|
||||
layer.sourceRect = { x: 0, y: 0, w: 0, h: 10 };
|
||||
const source = JSON.stringify({ format: "image-studio-project", version: 1, savedAt: "2026-07-10T12:00:00.000Z", document });
|
||||
expect(() => parseProject(source)).toThrow("invalid source crop");
|
||||
});
|
||||
|
||||
test("round-trips adjustment layers and rejects out-of-range settings", () => {
|
||||
const document = projectDocument();
|
||||
document.artboards[0]!.layers.unshift({ id: "adjust", type: "adjustment", name: "Color", visible: true, locked: false, opacity: 1, transform: { position: { x: 0, y: 0 }, scale: { x: 1, y: 1 }, rotation: 0 }, adjustment: { brightness: .2, contrast: 0, saturation: 0, colorBalance: { red: 0, green: 0, blue: 0 } } });
|
||||
expect(parseProject(serializeProject(document)).document.artboards[0]?.layers[0]?.type).toBe("adjustment");
|
||||
const invalid = JSON.parse(serializeProject(document)); invalid.document.artboards[0].layers[0].adjustment.brightness = 4;
|
||||
expect(() => parseProject(JSON.stringify(invalid))).toThrow("invalid settings");
|
||||
});
|
||||
|
||||
test("rejects nested adjustment scope", () => {
|
||||
const document = projectDocument();
|
||||
document.artboards[0]!.layers = [{ id: "group", type: "group", name: "Group", visible: true, locked: false, opacity: 1, transform: { position: { x: 0, y: 0 }, scale: { x: 1, y: 1 }, rotation: 0 }, children: [{ id: "adjust", type: "adjustment", name: "Color", visible: true, locked: false, opacity: 1, transform: { position: { x: 0, y: 0 }, scale: { x: 1, y: 1 }, rotation: 0 }, adjustment: { brightness: 0, contrast: 0, saturation: 0, colorBalance: { red: 0, green: 0, blue: 0 } } }] }];
|
||||
expect(() => parseProject(serializeProject(document))).toThrow("artboard level");
|
||||
});
|
||||
|
||||
test("creates safe project file names", () => {
|
||||
expect(projectFileName(" Summer / Study ")).toBe("Summer-Study.image-studio.json");
|
||||
expect(projectFileName("***")).toBe("untitled.image-studio.json");
|
||||
|
||||
Reference in New Issue
Block a user