- Editor area with tab bar, CodeMirror 6 view, close question and notices (ui/src/components/editor/, ui/src/stores/editor.ts), mounted in App.vue; the project tree opens files through the editor store. - BufferSync: local edits to buffer.edit against the confirmed version, one call in flight, resync on stale_version or newer bufferChanged with rebase of unsent changes; EngineText maps CodeMirror positions to engine UTF-16 offsets for CRLF text. - Save, save all and close from engine default shortcuts via listCommands. - Dirty marker, Save / Don't Save / Cancel, non-blocking notice when a dirty file changes or disappears on disk. - Vitest: keystroke bursts with stale versions and remote edits (LF and CRLF), mapping, store and component tests against a fake engine. - Progress docs: Editor core 8% (est.), depth ~1.4%, G2, ui-parity tabs, M1 row, architecture, README status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/**
|
|
* Tests for the root component: it loads product information on mount and
|
|
* shows it, or the error, in the status bar.
|
|
*/
|
|
import { flushPromises, mount } from "@vue/test-utils";
|
|
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 App from "../src/App.vue";
|
|
|
|
describe("App", () => {
|
|
beforeEach(() => {
|
|
invoke.mockReset();
|
|
setActivePinia(createPinia());
|
|
});
|
|
|
|
it("shows name and version in the status bar", async () => {
|
|
invoke.mockImplementation((command: string) =>
|
|
Promise.resolve(
|
|
command === "engine_list_commands"
|
|
? []
|
|
: { name: "Lutra", version: "0.0.0", slogan: "An otterly perfect IDE" },
|
|
),
|
|
);
|
|
const wrapper = mount(App);
|
|
await flushPromises();
|
|
expect(wrapper.get("[data-test=status-bar]").text()).toBe("Lutra 0.0.0");
|
|
expect(wrapper.get("[data-test=main]").text()).toBe("An otterly perfect IDE");
|
|
});
|
|
|
|
it("shows the engine error when the call fails", async () => {
|
|
invoke.mockRejectedValue({ code: "internal", message: "engine unavailable" });
|
|
const wrapper = mount(App);
|
|
await flushPromises();
|
|
const bar = wrapper.get("[data-test=status-bar]");
|
|
expect(bar.text()).toBe("engine unavailable");
|
|
expect(bar.classes()).toContain("status-bar--error");
|
|
});
|
|
});
|