feat: implement document actions for managing artboards, zoom, and history; update UI components to utilize new actions
This commit is contained in:
34
app/document-actions.test.ts
Normal file
34
app/document-actions.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { commandIds } from "@commands/ids";
|
||||
import { createImageStudioApp } from "./app";
|
||||
|
||||
describe("document actions", () => {
|
||||
test("share zoom, fit, and history behavior across UI entry points", () => {
|
||||
const app = createImageStudioApp();
|
||||
const artboard = app.store.getState().document.artboards[0];
|
||||
if (!artboard) throw new Error("Expected the default artboard.");
|
||||
|
||||
app.actions.document.zoomTo(2);
|
||||
app.actions.document.zoomBy(0.5);
|
||||
expect(app.store.getState().editor.viewport.zoom).toBe(1);
|
||||
|
||||
app.actions.document.fitArtboard(artboard.id);
|
||||
expect(app.store.getState().editor.viewport.center).toEqual({ x: 0, y: 0 });
|
||||
|
||||
expect(app.actions.document.canUndo()).toBe(true);
|
||||
app.actions.document.undo();
|
||||
expect(app.store.getState().document.artboards).toHaveLength(0);
|
||||
expect(app.actions.document.canRedo()).toBe(true);
|
||||
app.actions.document.redo();
|
||||
expect(app.store.getState().document.artboards).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("opens Generate through the canonical workspace command", () => {
|
||||
const app = createImageStudioApp({ createDefaultArtboard: false });
|
||||
app.actions.document.openGenerate();
|
||||
expect(app.store.getState().editor.workspace.panel).toBe("generate");
|
||||
|
||||
app.store.dispatch(commandIds.workspaceSetPanel, { panel: "none" });
|
||||
expect(app.store.getState().editor.workspace.panel).toBe("none");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user