Phase 4e. - app.css holds only imports. Its rules moved into files beside their code, in the original cascade order. Dead rules of the deleted TipTap Writer are gone. - workbenchKeys.ts is one table of the workbench shortcuts. Workbench runs the commands. - session.linkTargets is the one link resolution for the link menu and for link opening. - Documents is a rune module (documents.svelte.ts). Workbench reads the tabs and the active path from it, without a copy of all buffers on each change. The editor mount effect now copies the buffer inside untrack, so an edit does not remount the editor. - Unit tests can import .svelte.ts modules through a Node module hook that compiles them with the Svelte compiler. pnpm check, pnpm test (350 of 350), and the full smoke suite pass, except tables/linkCaret, which failed one time under load and passed on retry and 3 of 3 times alone.
39 lines
2.0 KiB
TypeScript
39 lines
2.0 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { orderWorkbenchTabs } from "../../../src/lib/workspace/workbenchTabs.ts";
|
|
import { tabsToClose } from "../../../src/lib/workspace/tabActions.ts";
|
|
import { Documents } from "../../../src/lib/workspace/documents.svelte.ts";
|
|
|
|
test("mixed tabs retain their positions through title changes, closes, and new tabs", () => {
|
|
const tabs = [
|
|
{ id: "a", relPath: "a.md", name: "a.md", pinned: true },
|
|
{ id: "b", relPath: "renamed.md", name: "renamed.md" },
|
|
{ id: "plugin-a", relPath: "plugin:a", name: "New page title" },
|
|
{ id: "plugin-b", relPath: "plugin:b", name: "Board" },
|
|
];
|
|
const ordered = orderWorkbenchTabs(tabs, ["plugin-a", "b", "a", "closed", "plugin-a"]);
|
|
assert.deepEqual(ordered.map(tab => tab.id), ["plugin-a", "b", "a", "plugin-b"]);
|
|
assert.equal(ordered[0].name, "New page title");
|
|
assert.deepEqual(tabsToClose(ordered, "plugin:a", "after").map(tab => tab.id), ["b", "plugin-b"]);
|
|
assert.deepEqual(tabsToClose(ordered, "renamed.md", "others").map(tab => tab.id), ["plugin-a", "plugin-b"]);
|
|
assert.deepEqual(tabsToClose(ordered, "plugin:b", "all").map(tab => tab.id), ["plugin-a", "b", "plugin-b"]);
|
|
});
|
|
|
|
test("replacing an empty or current document retains its tab position and creates a new buffer", async () => {
|
|
const docs = new Documents({
|
|
read: async path => path, write: async () => {}, image: async () => "",
|
|
kind: () => "text", chrome: () => "Writing",
|
|
}, () => {});
|
|
docs.newTab();
|
|
const emptyId = docs.active!.id;
|
|
const order = ["plugin-a", emptyId, "plugin-b"];
|
|
for (const rel_path of ["a.md", "b.md"]) {
|
|
const previousBuffer = docs.active!.id;
|
|
await docs.open({ rel_path, name: rel_path, kind: "file" }, "current");
|
|
assert.notEqual(docs.active!.id, previousBuffer);
|
|
assert.equal(docs.active!.tabId, emptyId);
|
|
const tabs = [{ id: "plugin-a" }, { id: "plugin-b" }, { id: docs.active!.tabId! }];
|
|
assert.deepEqual(orderWorkbenchTabs(tabs, order).map(tab => tab.id), order);
|
|
}
|
|
});
|