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>
This commit is contained in:
parent
faadb05eb3
commit
003b7970e6
16 changed files with 1541 additions and 32 deletions
51
ui/tests/project/store.test.ts
Normal file
51
ui/tests/project/store.test.ts
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Tests for the project store on its own: stale listings are dropped and
|
||||
* events of unknown kinds are ignored.
|
||||
*/
|
||||
import { createPinia, setActivePinia } from "pinia";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const invoke = vi.hoisted(() => vi.fn());
|
||||
vi.mock("@tauri-apps/api/core", () => ({ invoke }));
|
||||
|
||||
import type { EngineEvent } from "../../src/components/project/engineEvents";
|
||||
import { parentOf, useProjectStore } from "../../src/stores/project";
|
||||
|
||||
describe("project store", () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
invoke.mockReset();
|
||||
});
|
||||
|
||||
it("drops a listing that was superseded by a newer request", async () => {
|
||||
const resolvers: ((value: unknown) => void)[] = [];
|
||||
invoke.mockImplementation(() => new Promise((resolve) => resolvers.push(resolve)));
|
||||
const store = useProjectStore();
|
||||
store.handleEvent({ type: "ProjectOpened", root: { path: "/p", name: "p" } });
|
||||
const second = store.loadChildren("");
|
||||
resolvers[1]?.([{ name: "new.php", path: "new.php", kind: "file", ignored: false }]);
|
||||
await second;
|
||||
resolvers[0]?.([{ name: "old.php", path: "old.php", kind: "file", ignored: false }]);
|
||||
await Promise.resolve();
|
||||
expect(store.rows.map((row) => (row.kind === "entry" ? row.entry.path : row.kind))).toEqual(["new.php"]);
|
||||
});
|
||||
|
||||
it("shows a loading row while the root lists", () => {
|
||||
invoke.mockImplementation(() => new Promise(() => undefined));
|
||||
const store = useProjectStore();
|
||||
store.handleEvent({ type: "ProjectOpened", root: { path: "/p", name: "p" } });
|
||||
expect(store.rows).toEqual([{ kind: "loading", dir: "", depth: 0 }]);
|
||||
});
|
||||
|
||||
it("ignores events it does not handle", () => {
|
||||
const store = useProjectStore();
|
||||
store.handleEvent({ type: "BufferOpened" } as unknown as EngineEvent);
|
||||
expect(store.root).toBeNull();
|
||||
expect(invoke).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("computes parents", () => {
|
||||
expect(parentOf("a/b/c.php")).toBe("a/b");
|
||||
expect(parentOf("c.php")).toBe("");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue