Move the tests from scripts/ to tests/ by feature

Unit tests go to tests/unit/<area>/, browser smoke tests to
tests/smoke/<area>/, and tests against a running desktop app to
tests/native/. Files named after dates, work passes, or Kanban cards get
feature names, for example editorOctober12 -> editor/footnotes.

scripts/ keeps the build, release, and package tools. Plugin repositories
import scripts/packagePlugin.mjs, and the Terminal smoke test imports
scripts/pluginMocks.mjs, which now re-exports the harness copy.

The unit tests get their own type check (tests/tsconfig.json) with Node
types. pnpm check runs it after the app check. Add @types/node and fix
the three test mocks that it reported.
This commit is contained in:
Knotty Wyvern
2026-10-27 19:47:39 -07:00
parent 90d1940c73
commit e433bed28e
154 changed files with 269 additions and 227 deletions
+38
View File
@@ -0,0 +1,38 @@
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.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);
}
});