Files
mesh-catalog/modules/powerlevel10k/test/module.test.ts
T
mesh-tools 652b00b25b
mesh/merge-gate checking again: the gate refused `unknown` because the controller judged with a node-engine validator pinned before mesh-host #117; mesh-co…
mesh/repo-check checking again: the gate refused `unknown` because the controller judged with a node-engine validator pinned before mesh-host #117; mesh-co…
mesh/delivery-group group feat/owned-paths checking: 0 of 2 member(s) ready
mesh/delivery superseded: a newer head of the same pull request
Say on every directory how it treats files it does not know, and check it (issue 1024, ADR 0422)
Every directory and archive resource carries `unknown`: move-out for a home folder whose program writes nothing there (the node-engine, delivered in mesh-host #117, moves the rest to ~/.local/state/mesh-moved/<module>/ with a list), module for ~/.ssh and ~/.claude, program elsewhere; `knows` keeps what a program or the operator relies on (powerlevel10k's compiled files, i3's scripts and the asus/g14 drop-ins, dunst's slack rule, betterbird's records, node-env's forge credential, issue 1033). Two shared folders are no longer declared. Each module's README says it. checks/owned holds every manifest to it; checks/sshdir stays while main's merge check runs it (issue 1035). Tests that pin a manifest follow the new key only. Reviewed in three rounds.
2026-10-17 16:23:03 +00:00

52 lines
3.2 KiB
TypeScript

// The prompt module's shape (novox/hq ADR 0204, ADR 0205): the vendored release is pinned, carries
// its licence in the archive, and is loaded with its configuration from the normal slot.
import { test } from "node:test";
import assert from "node:assert/strict";
import { existsSync, readFileSync, statSync } from "node:fs";
const at = (p: string) => new URL(`../${p}`, import.meta.url);
const m = JSON.parse(readFileSync(at("module.json"), "utf8"));
const artifact = (name: string) => m.build.artifacts.find((a: { name: string }) => a.name === name);
test("the theme archive is built from the vendored release and carries its licence", () => {
assert.deepEqual(artifact("theme"), { name: "theme", kind: "archive", from: "theme" });
assert.match(readFileSync(at("theme/LICENSE"), "utf8"), /Permission is hereby granted, free of charge/);
assert.ok(existsSync(at("theme/powerlevel10k.zsh-theme")));
assert.ok(existsSync(at("theme/gitstatus/LICENSE")));
});
test("the configuration archive holds the prompt's configuration and nothing else", () => {
assert.deepEqual(artifact("configuration"), { name: "configuration", kind: "archive", from: "config" });
assert.ok(statSync(at("config/p10k.zsh")).size > 0);
});
test("both are unpacked under the account's home, owned by the account", () => {
const byId = Object.fromEntries(m.resources.map((r: { id: string }) => [r.id, r]));
assert.deepEqual(byId.theme, { id: "theme", type: "archive", path: "${machine:account-home}/.local/share/powerlevel10k", owner: "${machine:account}", artifact: "theme", unknown: "move-out", knows: ["powerlevel9k.zsh-theme.zwc", "powerlevel10k.zsh-theme.zwc", "internal/p10k.zsh.zwc", "internal/icons.zsh.zwc", "internal/configure.zsh.zwc", "internal/worker.zsh.zwc", "internal/parser.zsh.zwc", "gitstatus/gitstatus.plugin.zsh.zwc", "gitstatus/install.zwc"] });
assert.deepEqual(byId.configuration, { id: "configuration", type: "archive", path: "${machine:account-home}/.config/powerlevel10k", owner: "${machine:account}", artifact: "configuration", unknown: "move-out" });
});
// The zsh code is an item of the collection shell:zsh:normal, its text a template in files/ (ADR 0348, 0349).
const shellCode = (): string => {
const items = m.items.filter((i: { collection: string }) => i.collection.startsWith("shell:"));
assert.equal(items.length, 1);
assert.equal(items[0].collection, "shell:zsh:normal", "for zsh, in the normal slot");
return readFileSync(at(items[0].template), "utf8");
};
test("the zsh code in the normal slot sources the theme, then the configuration, and turns on no instant prompt", () => {
assert.equal(m.shell, undefined);
const code = shellCode();
const sourced = [...code.matchAll(/\|\| source (\S+)/g)].map((x) => x[1]);
assert.deepEqual(sourced, ["~/.local/share/powerlevel10k/powerlevel10k.zsh-theme", "~/.config/powerlevel10k/p10k.zsh"]);
assert.doesNotMatch(code, /instant/);
});
test("the README names the upstream, the version and the licence", () => {
const readme = readFileSync(at("README.md"), "utf8");
assert.match(readme, /github\.com\/romkatv\/powerlevel10k/);
assert.match(readme, /v1\.20\.0/);
assert.match(readme, /MIT/);
assert.match(shellCode(), /v1\.20\.0/, "the version in the shell code's comment matches");
});