mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Use US English spelling throughout and check it in npm test
AI Assisted
This commit is contained in:
1 parent
e67aaabdce
commit
899b3a48d8
84 files changed
+319
-240
No files matched your search
@@ -43,7 +43,7 @@ const CWD = path.resolve(args.cwd || ROOT);
|
||||
const HOME = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-bench-"));
|
||||
const ENV = { ...process.env, PLAN2CODE_CONSOLE_HOME: HOME, PLAN2CODE_NO_BROWSER: "1" };
|
||||
// A fresh cached failure: the boot-time release check stays off the network,
|
||||
// so a slow GitHub never colours the timings.
|
||||
// so a slow GitHub never colors the timings.
|
||||
fs.writeFileSync(path.join(HOME, "update-check.json"), JSON.stringify({ checkedAt: Date.now(), latest: null }));
|
||||
|
||||
// Resolves at the first stdout line carrying a url, and again at exit.
|
||||
|
||||
@@ -23,7 +23,7 @@ test("playwright-core is pinned exactly in the root devDependencies", () => {
|
||||
// A fake file system holding only `present`.
|
||||
const only = (...present) => (p) => present.includes(p);
|
||||
|
||||
test("findBrowser picks Chrome, then Edge, and honours PLAN2CODE_TEST_BROWSER", async () => {
|
||||
test("findBrowser picks Chrome, then Edge, and honors PLAN2CODE_TEST_BROWSER", async () => {
|
||||
const { findBrowser, BROWSER_PATHS } = await import("./browser.mjs");
|
||||
const chrome = BROWSER_PATHS.chrome[0];
|
||||
const edge = BROWSER_PATHS.msedge[0];
|
||||
|
||||
@@ -378,7 +378,7 @@ test("pathfinder brief-data: calendar dates only, no future since, no NNs or lin
|
||||
|
||||
/* ===================================================== review-fix regressions */
|
||||
|
||||
test("pathfinder: claim, resolve and rule-out honour --dry-run", () => {
|
||||
test("pathfinder: claim, resolve and rule-out honor --dry-run", () => {
|
||||
const { root, pf } = mapFixture();
|
||||
const P = (...a) => runScript("plan2code-0-pathfinder", "pathfinder.mjs", [...a, "--root", root]);
|
||||
P("reconcile", "audit-export");
|
||||
|
||||
@@ -158,7 +158,7 @@ test("specs status: checklist formats, groups, task markers, numbering, totals,
|
||||
[3, "Web UI", "pending"],
|
||||
[4, "Docs", "pending"],
|
||||
]);
|
||||
assert.deepEqual(j.parallelGroups.map((g) => [g.id, g.phases]), [["A", [3, 4]]], "a group labelled sequential is not a parallel group");
|
||||
assert.deepEqual(j.parallelGroups.map((g) => [g.id, g.phases]), [["A", [3, 4]]], "a group labeled sequential is not a parallel group");
|
||||
assert.deepEqual(j.totals, { total: 11, complete: 4, assumed: 1, pending: 5, "in-progress": 0, blocked: 1, unknown: 0, completed: 5, incomplete: 5 });
|
||||
assert.equal(j.completionPercent, 45);
|
||||
assert.equal(j.phases[0].tasks.total, 3, "a named testing task (1.T) counts");
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// The project writes US English: docs, comments, prompts, UI text, test names.
|
||||
// A rule in prose was missed once ("colours" slipped into a reply and ~100
|
||||
// files carried UK spellings), so this keeps it.
|
||||
// Run with: node --test scripts/test-us-english.mjs
|
||||
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const SELF = "scripts/test-us-english.mjs";
|
||||
|
||||
// Tracked text files. Vendored code stays as shipped, and binaries have no words.
|
||||
const SKIP = /(^|\/)(node_modules|dist|target|vendor)\/|package-lock\.json$|\.(png|jpe?g|gif|ico|icns|mp3|wav|woff2?|ttf|lock)$/i;
|
||||
|
||||
// UK spellings with a clear US form. Whole words, any case.
|
||||
const UK = new RegExp(
|
||||
"\\b(" +
|
||||
[
|
||||
"colour\\w*", "grey\\w*", "behaviour\\w*", "centre[sd]?", "centred", "cancell(?:ed|ing)", "labell(?:ed|ing)",
|
||||
"relabell\\w*", "travell(?:ed|ing|er)", "judgement", "neighbour\\w*", "honour\\w*", "favour\\w*", "licence",
|
||||
"defence", "offence", "whilst", "amongst", "artefacts?", "catalogue[sd]?",
|
||||
"analys(?:e|ed|ing)", "(?:organ|recogn|normal|summar|sanit|optim|final|initial|serial|custom|priorit|minim|maxim|util|canonical|material|stabil|anonym|synchron|standard|categor|author|visual|emphas|apolog|special|character|central|random|token|local|capital|critic|memor|synthes|real)is(?:e|es|ed|ing|ation|ations|er|ers|able)",
|
||||
].join("|") +
|
||||
")\\b",
|
||||
"gi"
|
||||
);
|
||||
|
||||
// Names that keep the UK spelling because they are data contracts read in
|
||||
// several places (see Code Style in .agents-docs/AGENTS-code-style.md), plus
|
||||
// HTML's own attribute. Removed before the scan.
|
||||
const CONTRACTS = [
|
||||
/aria-labelledby/g,
|
||||
/\.greyed\b/g,
|
||||
/\bgreyed(?=\s*:)/g,
|
||||
/\bconst greyed\b/g,
|
||||
/\bgreyed(?=, card)/g,
|
||||
/^\/\/\s+greyed\b/gm,
|
||||
/\bcancelled(?=\s*:)/g,
|
||||
/\.cancelled\b/g,
|
||||
/"cancelled"/g,
|
||||
/\bconst cancelled\b/g,
|
||||
/\bcancelled(?=\.[a-z])/g,
|
||||
];
|
||||
|
||||
function trackedTextFiles() {
|
||||
const r = spawnSync("git", ["ls-files"], { cwd: ROOT, encoding: "utf8" });
|
||||
assert.equal(r.status, 0, r.stderr);
|
||||
return r.stdout.split("\n").filter((f) => f && f !== SELF && !SKIP.test(f));
|
||||
}
|
||||
|
||||
test("tracked text is written in US English", () => {
|
||||
const found = [];
|
||||
for (const rel of trackedTextFiles()) {
|
||||
let text;
|
||||
try {
|
||||
text = fs.readFileSync(path.join(ROOT, rel), "utf8");
|
||||
} catch {
|
||||
continue; // listed but deleted in the working tree
|
||||
}
|
||||
for (const re of CONTRACTS) text = text.replace(re, "");
|
||||
text.split("\n").forEach((line, i) => {
|
||||
for (const m of line.matchAll(UK)) found.push(`${rel}:${i + 1}: ${m[0]}`);
|
||||
});
|
||||
}
|
||||
assert.deepEqual(found, [], `UK spellings (use the US form, e.g. color, gray, behavior, canceled, -ize):\n${found.join("\n")}`);
|
||||
});
|
||||
@@ -247,7 +247,7 @@ test("nextAbout: pick sets about, drop and sent clear it, the old Ask events do
|
||||
assert.equal(JSON.stringify(picked), before, "prev is never mutated");
|
||||
});
|
||||
|
||||
test("nextAbout: an old { about, frozen, dropped } tracker normalises to the new shape", () => {
|
||||
test("nextAbout: an old { about, frozen, dropped } tracker normalizes to the new shape", () => {
|
||||
const old = { about: CARD_Q1, frozen: true, dropped: false };
|
||||
assert.deepEqual(nextAbout(old, { type: "leave-ask" }), { history: [], about: CARD_Q1 });
|
||||
assert.deepEqual(nextAbout({ frozen: false, dropped: true }, {}), { history: [], about: null });
|
||||
|
||||
@@ -190,7 +190,7 @@ test("two sessions keep their own cookies: each server reads only the one named
|
||||
// state.json has two writers, `post` and the server's /submit. Both are held
|
||||
// at the lock here until each has read nothing yet, then let go together:
|
||||
// whichever writes second must be building on the first one's write.
|
||||
test("a post and a submit that overlap both survive: the state lock serialises them", async () => {
|
||||
test("a post and a submit that overlap both survive: the state lock serializes them", async () => {
|
||||
const s = openSession();
|
||||
try {
|
||||
const lock = path.join(s.session, STATE_LOCK_FILE);
|
||||
|
||||
@@ -368,7 +368,7 @@ test("git board view: no control leaks the busy lock, in any state, mode, tab or
|
||||
assert.ok(["nav", "action", "done"].includes(gate), `${where}: "${words(c)}" (${c.tag}) has no data-gate`);
|
||||
const own = c.attrs["data-own"] === "true";
|
||||
if (!controlAllowed(mode, gate)) assert.ok(isOff(c), `${where}: "${words(c)}" is live while busy`);
|
||||
else assert.equal(isOff(c), own, `${where}: "${words(c)}" is ${isOff(c) ? "greyed with no reason of its own" : "live despite its own reason"}`);
|
||||
else assert.equal(isOff(c), own, `${where}: "${words(c)}" is ${isOff(c) ? "grayed with no reason of its own" : "live despite its own reason"}`);
|
||||
checked++;
|
||||
}
|
||||
const done = all.filter((c) => c.textContent === "Done with git");
|
||||
@@ -512,7 +512,7 @@ test("git board host: the host draws the board only through drawGitBoard, and th
|
||||
|
||||
// The commit table's ticks and the click that re-seeds them are page tests now
|
||||
// ("the commit table keeps the person's ticks across an agent post, and a click
|
||||
// re-seeds them" and its neighbours in test-web-console-page-git.mjs).
|
||||
// re-seeds them" and its neighbors in test-web-console-page-git.mjs).
|
||||
|
||||
test("git board docs: the agent prose, Help topic and readme describe the tabbed board", () => {
|
||||
const read = (p) => fs.readFileSync(new URL(p, import.meta.url), "utf8");
|
||||
|
||||
@@ -281,7 +281,7 @@ test("git: commits on a run go only with git-commits, as a whole number", () =>
|
||||
}
|
||||
});
|
||||
|
||||
test("git: the Git card is never greyed, and its resume command is /plan2code-git", () => {
|
||||
test("git: the Git card is never grayed, and its resume command is /plan2code-git", () => {
|
||||
const entry = SKILL_CATALOG.find((e) => e.skill === "plan2code-git");
|
||||
assert.equal(entry.workflow, "git");
|
||||
assert.deepEqual(cardAvailability(entry, { hasAgents: true, isGit: false }, null), { on: true, note: GIT_INIT_NOTE });
|
||||
|
||||
@@ -24,7 +24,7 @@ test("another console's cookie beside ours does not lock this one out", async ()
|
||||
const theirsOnly = await fetch(s.base + "/state", { headers: { cookie: other } });
|
||||
assert.equal(theirsOnly.status, 403);
|
||||
await theirsOnly.arrayBuffer();
|
||||
// The old shared name is no longer honoured.
|
||||
// The old shared name is no longer honored.
|
||||
const legacy = await fetch(s.base + "/state", { headers: { cookie: `p2c_console=${token}` } });
|
||||
assert.equal(legacy.status, 403);
|
||||
await legacy.arrayBuffer();
|
||||
|
||||
@@ -310,7 +310,7 @@ test("reorderTabs needs exactly the current ids once each, and setLastTab rememb
|
||||
refusal(() => readNotepad(folder, "../x"), "no-such-tab");
|
||||
});
|
||||
|
||||
test("deleteTab: the folder goes, last moves to a neighbour, and the last tab left leaves an empty list", () => {
|
||||
test("deleteTab: the folder goes, last moves to a neighbor, and the last tab left leaves an empty list", () => {
|
||||
const folder = freshFolder();
|
||||
const [a, b, c] = ["A", "B", "C"].map((n) => createTab(folder, n).id);
|
||||
saveNote(folder, b, "bye");
|
||||
|
||||
@@ -171,7 +171,7 @@ test("a sign-off card opens its document, and each verdict reaches the agent", a
|
||||
await card.getByRole("button", { name: /Read .*Completion report.* in full/ }).click();
|
||||
await s.page.getByText("Phase 3 adds the /tasks endpoints.").waitFor();
|
||||
assert.ok(await s.page.getByText("Phase 3 adds the /tasks endpoints.").isVisible(), "the report is on screen");
|
||||
// The danger verdict is marked as such: here the class is the behaviour.
|
||||
// The danger verdict is marked as such: here the class is the behavior.
|
||||
await s.page.locator("#views").getByRole("button", { name: /^Questions/ }).click();
|
||||
card = itemCard(s.page, "so1");
|
||||
assert.match(await card.getByRole("button", { name: "Throw it away" }).getAttribute("class"), /danger/);
|
||||
@@ -338,16 +338,16 @@ test("a redraw keeps the place of the dashboard, the waiting screen and the fini
|
||||
assert.equal(await itemCard(s.page, "q2").evaluate((el) => el.scrollTop), 0, "the new question opened part-way down");
|
||||
});
|
||||
|
||||
// The accent colour as the browser resolves it, and a button's outline colour,
|
||||
// The accent color as the browser resolves it, and a button's outline color,
|
||||
// so "wears the accent" is read off the screen, not off a class name.
|
||||
const accentOf = (page) =>
|
||||
page.evaluate(() => {
|
||||
const probe = document.createElement("i");
|
||||
probe.style.color = "var(--accent)";
|
||||
document.body.appendChild(probe);
|
||||
const colour = getComputedStyle(probe).color;
|
||||
const color = getComputedStyle(probe).color;
|
||||
probe.remove();
|
||||
return colour;
|
||||
return color;
|
||||
});
|
||||
const outlineOf = (button) => button.evaluate((b) => getComputedStyle(b).borderTopColor);
|
||||
const warnOf = (page) =>
|
||||
@@ -355,9 +355,9 @@ const warnOf = (page) =>
|
||||
const probe = document.createElement("i");
|
||||
probe.style.color = "var(--warn)";
|
||||
document.body.appendChild(probe);
|
||||
const colour = getComputedStyle(probe).color;
|
||||
const color = getComputedStyle(probe).color;
|
||||
probe.remove();
|
||||
return colour;
|
||||
return color;
|
||||
});
|
||||
|
||||
// What a person sees break: the way forward on a sign-off card looks like any
|
||||
@@ -390,9 +390,9 @@ test("Skip this one and a comment box's quick answer are the same small accent b
|
||||
const quick = card.getByRole("button", { name: "No changes" });
|
||||
const look = (b) => b.evaluate((x) => { const c = getComputedStyle(x); return [c.fontSize, c.paddingTop, c.paddingLeft, c.color]; });
|
||||
assert.deepEqual(await look(skip), await look(quick), "the two chips look alike");
|
||||
const [size, , , colour] = await look(skip);
|
||||
const [size, , , color] = await look(skip);
|
||||
assert.equal(size, "12px", "small, not a full-size button");
|
||||
assert.equal(colour, await accentOf(s.page), "in the accent");
|
||||
assert.equal(color, await accentOf(s.page), "in the accent");
|
||||
});
|
||||
|
||||
// What a person sees break: Combine phases is missing from a plan's breakdown,
|
||||
|
||||
@@ -19,7 +19,7 @@ const suite = pageSuite(test);
|
||||
// A project that is set up (AGENTS.md) with one spec holding a Plan draft.
|
||||
// A PLAN-DRAFT whose Status line says only "Draft" (no "Resume at Phase N")
|
||||
// scans as `planned`, which the picker labels "Ready to document". Plan is
|
||||
// still lit for it (only exploring, fixed and documented-or-later grey Plan
|
||||
// still lit for it (only exploring, fixed and documented-or-later gray Plan
|
||||
// out); Document is the state's own next step.
|
||||
const DRAFT_PROJECT = {
|
||||
"AGENTS.md": "# AGENTS.md\n\nA small demo project.\n",
|
||||
@@ -60,7 +60,7 @@ test("a Plan launch from the dashboard carries the picked spec, and its resume t
|
||||
|
||||
// The Plan card is lit for this spec; picking it asks to confirm.
|
||||
const planCard = main.getByRole("button").filter({ has: s.page.locator("code", { hasText: /^\/plan2code-1-plan$/ }) });
|
||||
assert.equal(await planCard.isEnabled(), true, "the Plan card is greyed for a drafted plan");
|
||||
assert.equal(await planCard.isEnabled(), true, "the Plan card is grayed for a drafted plan");
|
||||
await planCard.click();
|
||||
await main.getByRole("button", { name: "Start Plan" }).click();
|
||||
|
||||
@@ -146,7 +146,7 @@ test("a fixed bug is hidden while unavailable workflows are, dimmed when they sh
|
||||
assert.equal(await demo.getAttribute("aria-current"), "true", "the picker opens on the plan, not the newer fixed bug");
|
||||
assert.equal(await chipFor(main, "old-bug").count(), 0, "the fixed bug's chip is hidden while unavailable workflows are");
|
||||
|
||||
// Switched off: the chip shows, labelled and dimmed, and still not picked.
|
||||
// Switched off: the chip shows, labeled and dimmed, and still not picked.
|
||||
await hideUnavailable(main, false);
|
||||
const bug = chipFor(main, "old-bug");
|
||||
await bug.waitFor();
|
||||
@@ -180,7 +180,7 @@ test("a fixed bug's Delete asks once with no name to type, while any other spec
|
||||
|
||||
// The fixed bug: a visible Delete, its own warning, and one press sends it.
|
||||
const del = main.getByRole("button", { name: "Delete the spec old-bug" });
|
||||
assert.equal(await textOf(del), "Delete", "a fixed bug's Delete is a labelled button");
|
||||
assert.equal(await textOf(del), "Delete", "a fixed bug's Delete is a labeled button");
|
||||
await del.click({ force: true });
|
||||
await dialog.waitFor();
|
||||
assert.match(await textOf(s.page.locator("#delete-warn")), /The bug is fixed, so this only clears the write-up/);
|
||||
@@ -203,17 +203,17 @@ const pickedChip = (main, name) => main.locator('button[aria-current="true"]', {
|
||||
|
||||
// What a person would see break: picking another target leaves the launch
|
||||
// aimed at the old spec, or the cards lit for it.
|
||||
test("picking Start from scratch instead of a spec greys Document, and a launch then carries no spec", async (t) => {
|
||||
test("picking Start from scratch instead of a spec grays Document, and a launch then carries no spec", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: MENU, project: tempProject(DRAFT_PROJECT) });
|
||||
const main = await toTheMenu(s);
|
||||
const document = lightOf(main, "/plan2code-2-document");
|
||||
await pickedChip(main, "demo").waitFor();
|
||||
assert.equal(await document.isEnabled(), true, "Document is lit for the drafted spec");
|
||||
|
||||
// From scratch there is no draft to document: the card greys.
|
||||
// From scratch there is no draft to document: the card grays.
|
||||
await chipFor(main, "Start from scratch").click();
|
||||
await pickedChip(main, "Start from scratch").waitFor();
|
||||
assert.equal(await document.isDisabled(), true, "Document is greyed with no spec picked");
|
||||
assert.equal(await document.isDisabled(), true, "Document is grayed with no spec picked");
|
||||
assert.equal(await chipFor(main, "demo").getAttribute("aria-current"), "false");
|
||||
|
||||
// Back on the spec it is lit again; then from scratch once more to launch.
|
||||
@@ -270,7 +270,7 @@ async function openHandoffMenu(t, env) {
|
||||
// project has, or picking it still shows the skill cards beside the preview.
|
||||
test("a handoff shows as a dashed Handoff chip even with no spec, and picking it swaps the cards for a preview of four buttons", async (t) => {
|
||||
const { main, chip } = await openHandoffMenu(t);
|
||||
assert.match(await textOf(chip), /Handoff/i, "the chip is labelled Handoff");
|
||||
assert.match(await textOf(chip), /Handoff/i, "the chip is labeled Handoff");
|
||||
assert.equal(await chip.getAttribute("aria-current"), "false", "a handoff is offered, not picked for you");
|
||||
assert.equal(await chip.evaluate((b) => getComputedStyle(b).borderTopStyle), "dashed", "the chip's border is dashed");
|
||||
assert.ok(await lightOf(main, "/plan2code-1-plan").isVisible(), "the cards show before a handoff is picked");
|
||||
|
||||
@@ -301,7 +301,7 @@ test("the editor follows the console's light and dark themes", async (t) => {
|
||||
await openNotepad(s);
|
||||
await setDoc(s, "# Heading\n\nText");
|
||||
await s.page.locator("#notepad-editor .cm-h1").waitFor();
|
||||
const colours = (theme) =>
|
||||
const colors = (theme) =>
|
||||
s.page.evaluate((th) => {
|
||||
document.documentElement.setAttribute("data-theme", th);
|
||||
const root = getComputedStyle(document.documentElement);
|
||||
@@ -325,13 +325,13 @@ test("the editor follows the console's light and dark themes", async (t) => {
|
||||
background: getComputedStyle(shadow.querySelector(".cm-editor")).backgroundColor,
|
||||
};
|
||||
}, theme);
|
||||
const light = await colours("light");
|
||||
const dark = await colours("dark");
|
||||
const light = await colors("light");
|
||||
const dark = await colors("dark");
|
||||
for (const [name, c] of Object.entries({ light, dark })) {
|
||||
assert.equal(c.text, c.ink, `${name}: text in the console's ink`);
|
||||
assert.equal(c.heading, c.accent, `${name}: headings in the highlight colour`);
|
||||
assert.equal(c.caret, c.accent, `${name}: the caret in the highlight colour`);
|
||||
assert.equal(c.background, c.panel, `${name}: the editor on the panel colour`);
|
||||
assert.equal(c.heading, c.accent, `${name}: headings in the highlight color`);
|
||||
assert.equal(c.caret, c.accent, `${name}: the caret in the highlight color`);
|
||||
assert.equal(c.background, c.panel, `${name}: the editor on the panel color`);
|
||||
}
|
||||
assert.notEqual(light.text, dark.text, "the two themes differ");
|
||||
assert.notEqual(light.background, dark.background);
|
||||
@@ -706,7 +706,7 @@ test("Delete asks twice, Escape backs out of either, and only the second confirm
|
||||
await panel.waitFor({ state: "hidden" });
|
||||
assert.equal(fs.existsSync(folder), true);
|
||||
|
||||
// Both confirms: gone, with its folder, and the neighbour is shown.
|
||||
// Both confirms: gone, with its folder, and the neighbor is shown.
|
||||
await s.page.click(X_SELECTED);
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
@@ -714,7 +714,7 @@ test("Delete asks twice, Escape backs out of either, and only the second confirm
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
|
||||
assert.deepEqual(await selectedName(s), ["Notes"]);
|
||||
assert.equal(await shows(s, "keep me"), "keep me");
|
||||
assert.equal(listTabs(s.project).last, idOf(s, "Notes"), "the neighbour became the last tab");
|
||||
assert.equal(listTabs(s.project).last, idOf(s, "Notes"), "the neighbor became the last tab");
|
||||
|
||||
// Delete the last tab: the empty state, with the focus on its button.
|
||||
await s.page.click(X_SELECTED);
|
||||
@@ -808,7 +808,7 @@ test("when the tab after a delete cannot be loaded, the deleted text is not left
|
||||
await typeInto(s, "doomed text");
|
||||
const ideas = idOf(s, "Ideas");
|
||||
await until(() => readNotepad(s.project, ideas).text === "doomed text", 4000);
|
||||
// The neighbour's read fails, as if the connection dropped right after the delete.
|
||||
// The neighbor's read fails, as if the connection dropped right after the delete.
|
||||
await s.page.route("**/notepad?tab=*", (route) => route.abort());
|
||||
await s.page.click(X_SELECTED);
|
||||
await s.page.click("#notepad-delete-go");
|
||||
@@ -836,8 +836,8 @@ const readyCount = (s, n) =>
|
||||
s.page.waitForFunction((want) => document.querySelectorAll("#notepad-strip > li.is-ready").length === want, n, { timeout: 5000 });
|
||||
|
||||
// A small PNG drawn in the page, as base64: a real picture for reencode() to
|
||||
// decode, one colour per call so the pictures differ.
|
||||
const pngBase64 = (s, colour) =>
|
||||
// decode, one color per call so the pictures differ.
|
||||
const pngBase64 = (s, color) =>
|
||||
s.page.evaluate(async (fill) => {
|
||||
const c = document.createElement("canvas");
|
||||
c.width = 320;
|
||||
@@ -849,13 +849,13 @@ const pngBase64 = (s, colour) =>
|
||||
let bin = "";
|
||||
for (const b of new Uint8Array(await blob.arrayBuffer())) bin += String.fromCharCode(b);
|
||||
return btoa(bin);
|
||||
}, colour);
|
||||
}, color);
|
||||
|
||||
const pngFile = async (s, colour, name = "shot.png") => ({ name, mimeType: "image/png", buffer: Buffer.from(await pngBase64(s, colour), "base64") });
|
||||
const pngFile = async (s, color, name = "shot.png") => ({ name, mimeType: "image/png", buffer: Buffer.from(await pngBase64(s, color), "base64") });
|
||||
|
||||
async function addViaButton(s, colour) {
|
||||
async function addViaButton(s, color) {
|
||||
const before = stored(s).length;
|
||||
await s.page.setInputFiles("#notepad-file", await pngFile(s, colour));
|
||||
await s.page.setInputFiles("#notepad-file", await pngFile(s, color));
|
||||
await until(() => stored(s).length === before + 1 && filesOf(s, stored(s).at(-1).id).every(Boolean), 5000);
|
||||
await readyCount(s, before + 1);
|
||||
}
|
||||
@@ -863,7 +863,7 @@ async function addViaButton(s, colour) {
|
||||
// A synthetic paste or drop of one PNG, sent to the editor, where a person's
|
||||
// would land. A paste answers whether the page took it from the editor, a
|
||||
// drop whether the dialog lit up while it was dragged over.
|
||||
const sendPicture = (s, kind, colour) =>
|
||||
const sendPicture = (s, kind, color) =>
|
||||
s.page.evaluate(
|
||||
async ({ kind, fill }) => {
|
||||
const c = document.createElement("canvas");
|
||||
@@ -882,7 +882,7 @@ const sendPicture = (s, kind, colour) =>
|
||||
ta.dispatchEvent(new DragEvent("drop", { dataTransfer: dt, bubbles: true, cancelable: true, composed: true }));
|
||||
return lit;
|
||||
},
|
||||
{ kind, fill: colour },
|
||||
{ kind, fill: color },
|
||||
);
|
||||
|
||||
test("Add image, paste and drop each add a thumbnail whose files are on disk and which survives closing", async (t) => {
|
||||
@@ -963,7 +963,7 @@ test("the X asks first: Keep keeps the picture, Delete removes both its files",
|
||||
test("the preview opens at the clicked picture, steps and wraps, and Esc closes it before the Notebook", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
for (const colour of ["#c33", "#3c3", "#33c"]) await addViaButton(s, colour);
|
||||
for (const color of ["#c33", "#3c3", "#33c"]) await addViaButton(s, color);
|
||||
const urls = stored(s).map((img) => img.url);
|
||||
const shown = () =>
|
||||
s.page.evaluate(() => ({
|
||||
|
||||
@@ -164,7 +164,7 @@ test("Continue here is hidden once the session meter is red, and the command and
|
||||
// Under the desktop app (PLAN2CODE_IN_APP=1) the fresh-session advice in the
|
||||
// meter's popover and the dashboard's red banner must point at the app's own
|
||||
// New Session, never a command to copy into a terminal that is not there:
|
||||
// the popover's is a button filled with the user's highlight colour.
|
||||
// the popover's is a button filled with the user's highlight color.
|
||||
test("under the app, the meter popover and the dashboard's red banner point at New Session, not a command", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
@@ -185,11 +185,11 @@ test("under the app, the meter popover and the dashboard's red banner point at N
|
||||
const probe = document.createElement("i");
|
||||
probe.style.color = "var(--accent)";
|
||||
n.append(probe);
|
||||
const colour = getComputedStyle(probe).color;
|
||||
const color = getComputedStyle(probe).color;
|
||||
probe.remove();
|
||||
return [getComputedStyle(n).backgroundColor, colour];
|
||||
return [getComputedStyle(n).backgroundColor, color];
|
||||
});
|
||||
assert.equal(fill, highlight, "filled with the user's highlight colour");
|
||||
assert.equal(fill, highlight, "filled with the user's highlight color");
|
||||
assert.equal(await fresh.locator("code").count(), 0, "no command to copy under the app");
|
||||
});
|
||||
|
||||
|
||||
@@ -671,7 +671,7 @@ test("help: the template's icons and panels match HELP_TABS in order, headed by
|
||||
}
|
||||
});
|
||||
|
||||
test("help: every diagram tab has one labelled picture, the rest none; no inline styles or scripts", () => {
|
||||
test("help: every diagram tab has one labeled picture, the rest none; no inline styles or scripts", () => {
|
||||
const tpl = helpTemplate();
|
||||
assert.doesNotMatch(tpl, /\sstyle=/);
|
||||
assert.doesNotMatch(tpl, /<script/i);
|
||||
@@ -691,7 +691,7 @@ test("help: every diagram tab has one labelled picture, the rest none; no inline
|
||||
assert.doesNotMatch(body, /<div class="help-figure"[^>]*><\/div>/, `${t.id}'s insertion point is filled`);
|
||||
if (t.id === "planny") {
|
||||
const fig = body.match(/<figure class="help-figure help-moods"[^>]*role="img"[^>]*aria-labelledby="hd-planny-title"/);
|
||||
assert.ok(fig, "the Planny moods are one labelled role=img figure");
|
||||
assert.ok(fig, "the Planny moods are one labeled role=img figure");
|
||||
const label = body.match(/id="hd-planny-title"[^>]*>([^<]*)</);
|
||||
assert.ok(label && label[1].trim(), "the moods figure's label exists and says something");
|
||||
continue;
|
||||
@@ -700,9 +700,9 @@ test("help: every diagram tab has one labelled picture, the rest none; no inline
|
||||
assert.ok(svg, `${t.id} draws an svg diagram`);
|
||||
const open = svg[0].slice(0, svg[0].indexOf(">"));
|
||||
assert.match(open, /role="img"/, `${t.id}'s diagram is an image`);
|
||||
const labelled = open.match(/aria-labelledby="([^"]+)"/);
|
||||
assert.ok(labelled, `${t.id}'s diagram is labelled`);
|
||||
for (const id of labelled[1].split(/\s+/)) {
|
||||
const labeled = open.match(/aria-labelledby="([^"]+)"/);
|
||||
assert.ok(labeled, `${t.id}'s diagram is labeled`);
|
||||
for (const id of labeled[1].split(/\s+/)) {
|
||||
const ref = svg[1].match(new RegExp(`<(title|desc) id="${id}">([\\s\\S]*?)</\\1>`));
|
||||
assert.ok(ref && ref[2].trim(), `${t.id}'s diagram has a non-empty #${id}`);
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ function appJsReaders(dir) {
|
||||
const publicPath = /["']public["']\s*,\s*["']app\.js["']|\bpublic\/app\.js/.test(text) && /\breadFile(Sync)?\b/.test(text);
|
||||
return oneStatement || handedToAHelper || publicPath;
|
||||
})
|
||||
.map((f) => `${f} reads public/app.js as text: test the behaviour in a page test, or read the screen file that holds it`);
|
||||
.map((f) => `${f} reads public/app.js as text: test the behavior in a page test, or read the screen file that holds it`);
|
||||
}
|
||||
|
||||
test("shape: no test in scripts/ reads public/app.js as text", () => {
|
||||
@@ -266,10 +266,10 @@ test("shape: the app.js check names the test file that reads it", () => {
|
||||
fs.writeFileSync(path.join(dir, "test-fine.mjs"), 'const r = await fetch(base + "/app.js");\nfs.appendFileSync(path.join(d, "src", "app.js"), "x");\n');
|
||||
assert.deepEqual(appJsReaders(dir), []);
|
||||
fs.writeFileSync(path.join(dir, "test-reads-it.mjs"), 'const app = fs.readFileSync(path.join(ROOT, "public", "app.js"), "utf8");\n');
|
||||
assert.deepEqual(appJsReaders(dir), ["test-reads-it.mjs reads public/app.js as text: test the behaviour in a page test, or read the screen file that holds it"]);
|
||||
assert.deepEqual(appJsReaders(dir), ["test-reads-it.mjs reads public/app.js as text: test the behavior in a page test, or read the screen file that holds it"]);
|
||||
fs.rmSync(path.join(dir, "test-reads-it.mjs"));
|
||||
fs.writeFileSync(path.join(dir, "test-alias.mjs"), 'const web = (f) => fs.readFileSync(path.join(ROOT, "public", f), "utf8");\nconst app = web("app.js");\n');
|
||||
assert.deepEqual(appJsReaders(dir), ["test-alias.mjs reads public/app.js as text: test the behaviour in a page test, or read the screen file that holds it"]);
|
||||
assert.deepEqual(appJsReaders(dir), ["test-alias.mjs reads public/app.js as text: test the behavior in a page test, or read the screen file that holds it"]);
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ test("finished: any finished state is never the picker's default, not only fixed
|
||||
assert.equal(defaultSpec(specs.slice(0, 2), lookup), null, "only finished specs: start from scratch");
|
||||
assert.equal(defaultSpec(specs)?.dir, "specs/a", "the real table does not know archived, so it is in play");
|
||||
|
||||
// The cards greyed for a fixed bug give a made-up finished state the same reason.
|
||||
// The cards grayed for a fixed bug give a made-up finished state the same reason.
|
||||
const archived = { dir: "specs/a", name: "a", state: "archived" };
|
||||
for (const entry of CARD_ENTRIES) {
|
||||
const fixed = cardAvailability(entry, SCAN, { dir: "specs/b", name: "b", state: "fixed" });
|
||||
@@ -463,12 +463,12 @@ test("card rules: every state still in play is taken by at least one card", () =
|
||||
assert.deepEqual(untakenStates(without, TABLE), ["no card's states take planned: add it to the skills.js entries whose card it lights"]);
|
||||
});
|
||||
|
||||
test("card rules: a card's states and greyed reasons name only real states", () => {
|
||||
test("card rules: a card's states and grayed reasons name only real states", () => {
|
||||
const known = new Set([...Object.keys(TABLE), "none"]);
|
||||
for (const sk of SKILLS) {
|
||||
if (Array.isArray(sk.states)) for (const st of sk.states) assert.ok(known.has(st), `${sk.skill} takes ${st}, which is no state`);
|
||||
for (const key of Object.keys(sk.greyed || {})) assert.ok(key === "default" || key === "finished" || known.has(key), `${sk.skill}'s greyed names ${key}, which is no state`);
|
||||
if (Array.isArray(sk.states) && sk.card) assert.ok(sk.greyed && sk.greyed.default, `${sk.skill} has a default greyed reason`);
|
||||
for (const key of Object.keys(sk.greyed || {})) assert.ok(key === "default" || key === "finished" || known.has(key), `${sk.skill}'s grayed names ${key}, which is no state`);
|
||||
if (Array.isArray(sk.states) && sk.card) assert.ok(sk.greyed && sk.greyed.default, `${sk.skill} has a default grayed reason`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -718,10 +718,10 @@ test("a card with a note box over the git board flows at its own height, never s
|
||||
|
||||
test("a card and its pager in the git board's card slot fill the board's width, never shrink to their content", () => {
|
||||
const css = joinedCss();
|
||||
// .card and .pager centre with auto inline margins; in the slot's grid those
|
||||
// .card and .pager center with auto inline margins; in the slot's grid those
|
||||
// would shrink a short confirm, and the pager under it, to fit their content.
|
||||
assert.match(css, /\.card\s*\{[^}]*margin:\s*0 auto/, "the base card still centres outside the board");
|
||||
assert.match(css, /\.pager\s*\{[^}]*margin:\s*0 auto/, "the base pager still centres outside the board");
|
||||
assert.match(css, /\.card\s*\{[^}]*margin:\s*0 auto/, "the base card still centers outside the board");
|
||||
assert.match(css, /\.pager\s*\{[^}]*margin:\s*0 auto/, "the base pager still centers outside the board");
|
||||
assert.match(css, /\.git-cards > \.card,\s*\.git-cards > \.pager\s*\{\s*margin:\s*0;\s*\}/, "the card slot drops the auto margins for both");
|
||||
});
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ test("workspace: the original can be renamed and described but never removed; ot
|
||||
}
|
||||
});
|
||||
|
||||
test("workspace: browse returns the picked folder, or cancelled, and is hidden when the session looks remote", async () => {
|
||||
test("workspace: browse returns the picked folder, or canceled, and is hidden when the session looks remote", async () => {
|
||||
const picked = tempFolder();
|
||||
const echo = consoleSession(["--workflow", "plan"], { env: { PLAN2CODE_PICKER_ECHO: picked } });
|
||||
const cancel = consoleSession(["--workflow", "plan"], { env: { PLAN2CODE_PICKER_ECHO: "-" } });
|
||||
|
||||
@@ -35,7 +35,7 @@ export const VERSIONS = Object.freeze({
|
||||
});
|
||||
|
||||
export const HEADER =
|
||||
"/* CodeMirror 6 (state, view, language, commands, lang-markdown), MIT licence, (c) Marijn Haverbeke and others.\n" +
|
||||
"/* CodeMirror 6 (state, view, language, commands, lang-markdown), MIT license, (c) Marijn Haverbeke and others.\n" +
|
||||
" * https://codemirror.net/ . Bundled by scripts/vendor-codemirror.mjs; do not edit by hand.\n" +
|
||||
" * Versions: " +
|
||||
Object.entries(VERSIONS)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//
|
||||
// PLAN2CODE_PICKER_ECHO (tests only, beside PLAN2CODE_NO_BROWSER): when set
|
||||
// in the server's environment, /workspace/browse returns it as the picked
|
||||
// folder instead of opening a picker, and "-" as a cancelled one.
|
||||
// folder instead of opening a picker, and "-" as a canceled one.
|
||||
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
@@ -26,7 +26,7 @@ import { readChat } from "../src/web-console/inbox.mjs";
|
||||
export const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
export const CONSOLE_CLI = path.join(ROOT, "src", "web-console", "console.mjs");
|
||||
|
||||
// Canonicalised the same way server.mjs canonicalises a session dir (DIR,
|
||||
// Canonicalized the same way server.mjs canonicalizes a session dir (DIR,
|
||||
// server.mjs): on a machine whose %TEMP% itself resolves through an 8.3
|
||||
// short name (seen in the wild on Windows), a server started later writes
|
||||
// `state.worktree` in its realpath'd form, while anything in a test that
|
||||
|
||||
Reference in new issue
Block a user