Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "node scripts/build.mjs",
"expand:type": "node scripts/expand-type.mjs",
"verify": "node scripts/verify.mjs",
"test": "node --test scripts/schema-expansion.test.mjs scripts/person-contract.test.mjs && npm run build && npm run verify && node --test scripts/person-pack.test.mjs scripts/tasknotes-upgrade.test.mjs"
"test": "node --test scripts/schema-expansion.test.mjs scripts/person-contract.test.mjs && npm run build && npm run verify && node --test scripts/person-pack.test.mjs scripts/tasknotes-upgrade.test.mjs scripts/tasknotes-plugin-collections.test.mjs"
},
"dependencies": {
"ajv": "^8.20.0",
Expand Down
13 changes: 13 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta0-custom.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta0-default.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta0-kept-v4-custom.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta0-kept-v4-default.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta3-custom.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta3-default.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta3-from-beta0-custom.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions scripts/fixtures/tasknotes-5.0/beta3-from-beta0-default.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions scripts/fixtures/tasknotes-5.0/v4-custom.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions scripts/fixtures/tasknotes-5.0/v4-default.json

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions scripts/tasknotes-plugin-collections.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
import { dirname, join } from "node:path";
import { tmpdir } from "node:os";
import { cliPackEngine } from "./cli-pack-engine.mjs";

// Collections exactly as the TaskNotes 5.0 plugin writes them (upgraded from
// TaskNotes 4.13.6 and the 5.0 betas, with default and customized settings).
// Every TaskNotes pack must install over them, as TaskNotes App does through
// Connect, without conflicts and without dropping statuses or touching records.
const LATEST = "0.3.0-rc.17";
const command = process.env.MDBASE_VERIFY_CLI;
const fixtures = new URL("./fixtures/tasknotes-5.0/", import.meta.url);

async function reviewedInstall(engine) {
let assessment = await engine.assess();
assert.equal(assessment.valid, true, JSON.stringify(assessment));
const adoptions = Object.fromEntries(assessment.result.resources
.filter((r) => r.mode === "managed" && r.action === "conflict" && r.installed_digest === undefined)
.map((r) => [r.target, r.current_digest]));
assessment = await engine.assess(adoptions);
assert.equal(assessment.valid, true, JSON.stringify(assessment));
assert.equal(assessment.result.status !== "conflict", true,
JSON.stringify(assessment.result.resources.filter((r) => r.action === "conflict")));
return engine.apply(assessment.result.assessment_digest, adoptions);
}

for (const name of (await readdir(fixtures)).filter((file) => file.endsWith(".json")).sort()) {
test(`TaskNotes ${LATEST} installs over a TaskNotes 5.0 plugin collection: ${name}`, { skip: !command }, async () => {
const { files } = JSON.parse(await readFile(new URL(name, fixtures), "utf8"));
const root = await mkdtemp(join(tmpdir(), "tasknotes-plugin-collection-"));
let engine;
try {
for (const [path, document] of Object.entries(files)) {
await mkdir(dirname(join(root, path)), { recursive: true });
await writeFile(join(root, path), document);
}
const provision = JSON.parse(await readFile(new URL(`../dist/packs/tasknotes.task/${LATEST}.json`, import.meta.url), "utf8"));
engine = await cliPackEngine(command, root, provision, "dev.mdbase.tests");
const result = await reviewedInstall(engine);
assert.equal(result.valid, true, JSON.stringify(result));
const type = await readFile(join(root, "_types/task.md"), "utf8");
if (files["_types/task.md"].includes("- cancelled")) assert.match(type, /- cancelled/);
assert.match(type, /version: 0\.3\.0-rc\.5/);
for (const path of Object.keys(files).filter((path) => !path.startsWith("_") && !path.startsWith("mdbase"))) {
assert.equal(await readFile(join(root, path), "utf8"), files[path], path);
}
} finally {
await engine?.close();
await rm(root, { recursive: true, force: true });
}
});
}
Loading