Lutra/ui/tests/layout/ToolWindow.test.ts
danny 003b7970e6 M1.5: main window layout and project tree against mocked engine events
Left Project tool window (hide/show stripe, pointer and keyboard resize),
editor area placeholder and status bar. Project tree with lazy
project.children listings, WAI-ARIA keyboard navigation, Lucide icons,
dimmed ignored/excluded entries and refresh on TreeChanged. Empty state
runs project.openDialog. Pinia store fed only by engine events and
command results; events come through a local onEngineEvent adapter until
the desktop bridge (M1.4) lands. Lucide via @lucide/vue (the renamed
lucide-vue-next, ISC).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 19:24:23 +02:00

46 lines
2 KiB
TypeScript

/**
* Tests for the left tool window: hide and show, and keyboard resizing
* clamped to the allowed range.
*/
import { mount } from "@vue/test-utils";
import { describe, expect, it } from "vitest";
import ToolWindow from "../../src/components/layout/ToolWindow.vue";
describe("ToolWindow", () => {
it("hides to a stripe and shows again", async () => {
const wrapper = mount(ToolWindow, {
props: {
title: "Project",
open: true,
"onUpdate:open": (open: boolean) => wrapper.setProps({ open }),
},
slots: { default: "<p data-test='content'>tree</p>" },
});
expect(wrapper.find("[data-test=content]").exists()).toBe(true);
await wrapper.get("[data-test=tool-window-hide]").trigger("click");
expect(wrapper.find("[data-test=content]").exists()).toBe(false);
expect(wrapper.find("[data-test=tool-window-stripe]").exists()).toBe(true);
await wrapper.get("[data-test=tool-window-show]").trigger("click");
expect(wrapper.find("[data-test=content]").exists()).toBe(true);
});
it("resizes with the keyboard within the limits", async () => {
const wrapper = mount(ToolWindow, {
props: {
title: "Project",
width: 200,
minWidth: 150,
maxWidth: 230,
"onUpdate:width": (width: number) => wrapper.setProps({ width }),
},
});
const splitter = wrapper.get("[data-test=tool-window-splitter]");
await splitter.trigger("keydown", { key: "ArrowRight" });
expect(wrapper.get("[data-test=tool-window]").attributes("style")).toContain("width: 212px");
await splitter.trigger("keydown", { key: "ArrowRight", shiftKey: true });
expect(wrapper.get("[data-test=tool-window]").attributes("style")).toContain("width: 230px");
await splitter.trigger("keydown", { key: "ArrowLeft", shiftKey: true });
await splitter.trigger("keydown", { key: "ArrowLeft", shiftKey: true });
expect(wrapper.get("[data-test=tool-window]").attributes("style")).toContain("width: 150px");
});
});