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
+120
View File
@@ -0,0 +1,120 @@
import assert from "node:assert/strict";
import test from "node:test";
import { dropHint, dropPlaceAt, planDrop, uniqueName } from "../../../src/lib/workspace/treeDrop.ts";
function kids(map: Record<string, string[]>) {
return (parent: string) => map[parent] ?? [];
}
test("same-folder drop before a sibling reorders and keeps the name", () => {
const plan = planDrop(
"notes/b.md",
{ name: "a.md", rel_path: "notes/a.md", kind: "file" },
"before",
kids({ notes: ["a.md", "b.md"] }),
);
assert.deepEqual(plan, {
action: "reorder",
parent: "notes",
names: ["b.md", "a.md"],
});
});
test("same-folder drop after a sibling inserts after that sibling", () => {
const plan = planDrop(
"notes/a.md",
{ name: "b.md", rel_path: "notes/b.md", kind: "file" },
"after",
kids({ notes: ["a.md", "b.md"] }),
);
assert.deepEqual(plan, {
action: "reorder",
parent: "notes",
names: ["b.md", "a.md"],
});
});
test("drop inside the parent folder is a no-op", () => {
const plan = planDrop(
"notes/a.md",
{ name: "notes", rel_path: "notes", kind: "folder" },
"inside",
kids({ notes: ["a.md", "b.md"], "": ["notes"] }),
);
assert.deepEqual(plan, { action: "noop" });
});
test("drop before a sibling folder reorders instead of moving inside", () => {
const plan = planDrop(
"inbox.md",
{ name: "notes", rel_path: "notes", kind: "folder" },
"before",
kids({ "": ["inbox.md", "notes"] }),
);
assert.deepEqual(plan, {
action: "reorder",
parent: "",
names: ["inbox.md", "notes"],
});
});
test("drop onto self is a no-op", () => {
const plan = planDrop(
"notes/a.md",
{ name: "a.md", rel_path: "notes/a.md", kind: "file" },
"before",
kids({ notes: ["a.md"] }),
);
assert.deepEqual(plan, { action: "noop" });
});
test("drop inside another folder moves under that folder", () => {
const plan = planDrop(
"inbox.md",
{ name: "notes", rel_path: "notes", kind: "folder" },
"inside",
kids({ "": ["inbox.md", "notes"], notes: ["a.md"] }),
);
assert.deepEqual(plan, {
action: "move",
from: "inbox.md",
to: "notes/inbox.md",
fromParent: "",
toParent: "notes",
destName: "inbox.md",
orderFrom: ["notes"],
orderTo: ["a.md", "inbox.md"],
});
});
test("drop into a folder that already has the name picks a unique name", () => {
const plan = planDrop(
"inbox.md",
{ name: "notes", rel_path: "notes", kind: "folder" },
"inside",
kids({ "": ["inbox.md", "notes"], notes: ["inbox.md"] }),
);
assert.equal(plan.action, "move");
if (plan.action === "move") {
assert.equal(plan.to, "notes/inbox 2.md");
assert.equal(plan.destName, "inbox 2.md");
}
});
test("uniqueName skips taken numbered suffixes", () => {
assert.equal(uniqueName(["alpha.md", "alpha 2.md"], "alpha.md"), "alpha 3.md");
});
test("dropPlaceAt splits a file row in half and a folder row into three bands", () => {
assert.equal(dropPlaceAt("file", 0.2), "before");
assert.equal(dropPlaceAt("file", 0.8), "after");
assert.equal(dropPlaceAt("folder", 0.1), "before");
assert.equal(dropPlaceAt("folder", 0.5), "inside");
assert.equal(dropPlaceAt("folder", 0.9), "after");
});
test("dropHint names the landing", () => {
assert.equal(dropHint("notes", "inside"), "Into notes");
assert.equal(dropHint("inbox.md", "before"), "Before inbox.md");
assert.equal(dropHint("inbox.md", "after"), "After inbox.md");
});