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
+28
View File
@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import test from "node:test";
import { documentHeadings, headingLinkLine, linkFragment } from "../../../src/lib/workspace/headingLinks.ts";
test("section links decode fragments without changing the file path", () => {
assert.equal(linkFragment("notes/a%23b.md#Caf%C3%A9%20setup"), "Café setup");
assert.equal(linkFragment("#literal%"), "literal%");
assert.equal(linkFragment("a.md"), null);
assert.equal(headingLinkLine("# Title", ""), 1);
});
test("headings use rendered text, Unicode, and unique slugs", () => {
const source = "# **Windows** setup!\n\n## Café `setup`\n\n## Windows setup!\n\n## Windows setup-1\n\n## Windows setup!\n";
assert.deepEqual(documentHeadings(source).map(({ slug }) => slug),
["windows-setup", "café-setup", "windows-setup-1", "windows-setup-1-1", "windows-setup-2"]);
assert.equal(headingLinkLine(source, "windows-setup-2"), 9);
assert.equal(headingLinkLine(source, "Café setup"), 3);
assert.equal(headingLinkLine(source, "missing"), null);
});
test("section lines exclude properties and code, and include Setext headings", () => {
const source = "---\r\ntitle: Test\r\n---\r\n\r\n```md\r\n# Fake\r\n```\r\n\r\nInstall\r\n=======\r\n\r\n## Real ###\r\n";
assert.deepEqual(documentHeadings(source), [
{ text: "Install", slug: "install", line: 9 },
{ text: "Real", slug: "real", line: 12 },
]);
assert.equal(headingLinkLine(source, "fake"), null);
});