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.
47 lines
2.0 KiB
TypeScript
47 lines
2.0 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { tabsToClose } from "../../../src/lib/workspace/tabActions.ts";
|
|
import { Documents } from "../../../src/lib/workspace/documents.svelte.ts";
|
|
|
|
function setup() {
|
|
return new Documents({
|
|
read: async () => "original", write: async () => {}, image: async () => "data:image/png;base64,",
|
|
kind: () => "text", chrome: () => "Writing",
|
|
}, () => {});
|
|
}
|
|
const entry = (path: string) => ({ rel_path: path, name: path, kind: "file" as const });
|
|
|
|
test("group closes follow tab order and preserve pins without changing the active tab", async () => {
|
|
const docs = setup();
|
|
for (const name of ["a.md", "b.md", "c.md", "d.md"]) await docs.open(entry(name));
|
|
docs.togglePin("b.md");
|
|
docs.move("d.md", 1);
|
|
const paths = (scope: "one" | "others" | "after" | "all") => tabsToClose(docs.buffers, "d.md", scope).map(tab => tab.relPath);
|
|
assert.deepEqual(paths("one"), ["d.md"]);
|
|
assert.deepEqual(paths("others"), ["a.md", "c.md"]);
|
|
assert.deepEqual(paths("after"), ["c.md"]);
|
|
assert.deepEqual(paths("all"), ["a.md", "d.md", "c.md"]);
|
|
assert.equal(docs.activePath, "d.md");
|
|
assert.deepEqual(tabsToClose(docs.buffers, "missing.md", "all"), []);
|
|
assert.equal(tabsToClose(docs.buffers, "b.md", "one")[0].pinned, true);
|
|
});
|
|
|
|
test("pinning protects current and empty tabs from replacement, and survives rename", async () => {
|
|
const docs = setup();
|
|
await docs.open(entry("a.md"));
|
|
docs.togglePin("a.md");
|
|
await docs.open(entry("b.md"), "current");
|
|
assert.deepEqual(docs.buffers.map(tab => tab.relPath), ["a.md", "b.md"]);
|
|
docs.rename("a.md", "renamed.md");
|
|
assert.equal(docs.buffers[0].pinned, true);
|
|
docs.newTab();
|
|
const blank = docs.active!;
|
|
docs.togglePin(blank.relPath);
|
|
await docs.open(entry("c.md"));
|
|
assert.ok(docs.buffers.includes(blank));
|
|
docs.select("renamed.md");
|
|
docs.togglePin("renamed.md");
|
|
await docs.open(entry("d.md"), "current");
|
|
assert.ok(!docs.buffers.some(tab => tab.relPath === "renamed.md"));
|
|
});
|