35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
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");
|
|
});
|
|
});
|