// Web console regression tests for what the end-to-end QA sweep found: each // test names the bug it pins (a settle that took an uncollected send, a notice // taking a question slot, a second phase that could not ask for sign-off, a // patch file PowerShell wrote, a session found only from its own folder...). // Run with: node --test scripts/test-web-console-qa.mjs // // Shared setup (a per-process console home, the CLI runner, fixtures) lives in // web-console-test-helpers.mjs; see the comment at its top. import test from "node:test"; import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { spawnSync } from "node:child_process"; import { applyPatch, validate, blankState } from "../src/web-console/patches.mjs"; import { rebasingBranch } from "../src/web-console/git-repo.mjs"; import { indentReply, noteReplyLines, agentRepliedAfterSend } from "../src/web-console/public/answers.js"; import { chatView } from "../src/web-console/public/chat.js"; import { ROOT, CONSOLE_CLI, ENV, cli, payload, readState, postPatch, EXPORT_A, openSession } from "./web-console-test-helpers.mjs"; import { joinedCss } from "./css-helpers.mjs"; const choice = (id, extra = {}) => ({ id, kind: "choice", title: `Question ${id}`, options: [ { k: "A", text: "One" }, { k: "B", text: "Two" }, ], status: "open", ...extra, }); const waitFor = (s, seconds = 10) => cli(["wait", "--session", s.sid, "--seconds", String(seconds)]); const runCli = (args, opts = {}) => spawnSync(process.execPath, [CONSOLE_CLI, ...args], { env: ENV, encoding: "utf8", ...opts }); const css = () => joinedCss(); /* ------------------------------------------------------------ settling */ test("settle: true records the send wait handed over, never a later one still uncollected", async () => { const s = openSession(); try { assert.equal((await s.send("/submit", EXPORT_A)).status, 200); assert.equal(waitFor(s).status, 0); assert.deepEqual(readState(s.session).collected.ids, ["q1"], "collecting records which cards the send carried"); postPatch(s, { settle: true, items: [choice("q2")] }); assert.equal((await s.send("/submit", { actions: [{ i: "q2", type: "answer", kind: "choice", k: "B" }], reply: "Question q2: B" })).status, 200); postPatch(s, { settle: true }); const items = readState(s.session).items; assert.equal(items.find((i) => i.id === "q1").status, "answered"); assert.equal(items.find((i) => i.id === "q2").status, "open", "q2's send is not the agent's yet"); } finally { cli(["stop", "--session", s.sid, "--force"]); } }); test("a skipped card settles as skipped, not as an answer", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), items: [{ ...choice("q1", { required: false }), submitted: { skipped: true, at: "2026-01-01T00:00:00.000Z" } }] }; const next = applyPatch(state, { settle: ["q1"] }); assert.equal(next.items[0].status, "skipped"); }); test("a question asked again keeps what the person wrote with their answer, in its thread", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), items: [{ id: "r1", kind: "review", title: "Plan", body: "v1", submitted: { verdict: "changes", text: "Rename tally to count.", at: "2026-01-01T00:00:00.000Z" } }], }; const next = applyPatch(state, { items: [{ id: "r1", status: "reopened", body: "v2", thread: [{ who: "agent", text: "Renamed it." }] }] }); const thread = next.items[0].thread; assert.ok(thread.some((m) => m.who === "user" && m.text === "Rename tally to count."), JSON.stringify(thread)); assert.ok(thread.findIndex((m) => m.who === "user") < thread.findIndex((m) => m.who === "agent"), "their note comes before the reply to it"); }); test("a thread reply after a send hands the question back (agentRepliedAfterSend)", () => { const sent = { submitted: { k: "A", at: "2026-01-01T00:00:01.000Z" } }; assert.equal(agentRepliedAfterSend({ ...sent, thread: [{ who: "agent", text: "Which one?", at: "2026-01-01T00:00:02.000Z" }] }), true); assert.equal(agentRepliedAfterSend({ ...sent, thread: [{ who: "agent", text: "Old", at: "2026-01-01T00:00:00.000Z" }] }), false); assert.equal(agentRepliedAfterSend({ ...sent, answer: { k: "A" }, thread: [{ who: "agent", text: "x", at: "2026-01-01T00:00:02.000Z" }] }), false); }); /* ---------------------------------------------------------- validation */ test("a notice never takes one of the three question slots", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "git" }), items: [{ id: "git-result", kind: "notice", title: "Done", body: "b", status: "open" }, choice("a"), choice("b"), choice("c")], }; assert.deepEqual(validate(state), []); }); test("agent.status is working or waiting, nothing else", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), agent: { status: "sleeping" } }; assert.ok(validate(state).some((p) => p.startsWith("agent.status:"))); }); test("an approved sign-off does not stop the next phase asking for its own", () => { const gate = (id, status) => ({ id, kind: "review", title: "Sign off", body: "b", required: false, status, gate: { id, authoritative: true } }); const state = { ...blankState({ sid: "x", project: "p", workflow: "implement" }), items: [gate("signoff", "answered"), gate("signoff-phase-2", "open")] }; assert.deepEqual(validate(state), []); const two = { ...state, items: [gate("signoff", "open"), gate("signoff-phase-2", "open")] }; assert.ok(validate(two).some((p) => /authoritative approval gates/.test(p)), "two open ones are still refused"); }); test("the dashboard refuses question cards: nothing there would draw them", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "dashboard" }), items: [choice("q1")] }; assert.ok(validate(state).some((p) => p.includes("dashboard draws no question cards"))); }); test("an unanswered note blocks a settle that ignores it", () => { const withNote = { ...choice("q1"), thread: [{ who: "user", text: "Why this option?" }], submitted: { k: "A", at: "2026-01-01T00:00:00.000Z" }, }; const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), items: [withNote] }; const next = applyPatch(state, { settle: ["q1"] }); assert.ok(validate(next).some((p) => p.includes('item "q1" thread: has an unanswered note'))); }); test("adding a thread reply in the same patch clears the note and allows the settle", () => { const withNote = { ...choice("q1"), thread: [{ who: "user", text: "Why this option?" }], submitted: { k: "A", at: "2026-01-01T00:00:00.000Z" }, }; const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), items: [withNote] }; const next = applyPatch(state, { items: [{ id: "q1", thread: [{ who: "agent", text: "Because it matches the brief." }] }], settle: ["q1"], }); assert.deepEqual(validate(next), []); }); test("an item with no user note left unanswered is unaffected", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), items: [choice("q1"), choice("q2")] }; assert.deepEqual(validate(state), []); const answered = { ...choice("q3"), thread: [{ who: "user", text: "Note" }, { who: "agent", text: "Reply." }], }; assert.deepEqual(validate({ ...state, items: [answered] }), []); }); test("deleting the item in the same patch is exempt from the unanswered-note check", () => { const withNote = { ...choice("q1"), thread: [{ who: "user", text: "Why this option?" }] }; const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), items: [withNote] }; const next = applyPatch(state, { items: [{ id: "q1", _delete: true }] }); assert.deepEqual(next.items, []); assert.deepEqual(validate(next), []); }); test("a finish patch is exempt from the unanswered-note check", () => { const withNote = { ...choice("q1"), thread: [{ who: "user", text: "Why this option?" }] }; const state = { ...blankState({ sid: "x", project: "p", workflow: "plan" }), items: [withNote] }; const next = applyPatch(state, { finish: { headline: "Done" } }); assert.deepEqual(validate(next), []); }); /* ------------------------------------------------- a note on a question */ const guardNoted = () => ({ ...choice("guard"), thread: [{ who: "user", text: "Why this option?" }], noted: true, }); const plan = (items) => ({ ...blankState({ sid: "x", project: "p", workflow: "plan" }), items }); const notedAfter = (patch, item = guardNoted()) => applyPatch(plan([item]), patch).items.find((i) => i.id === "guard"); // The reported session: a note lands on an open question, the agent replies in // its thread and asks the next question in the same patch, and the page buries // the new one while the person is still typing. The console refuses the patch // and names the fix. const NOTED_REFUSAL = 'item "guard" noted: has a note from the person that you answered in the thread: reword it, delete it ("_delete": true) or send "stands": true, in the same patch that adds a new question. Like this: {"id":"guard","stands":true}'; const guardReply = { id: "guard", thread: [{ who: "agent", text: "Because it matches the brief." }] }; const refusedPast = (state, patch) => assert.throws(() => applyPatch(state, patch), (e) => e.message === NOTED_REFUSAL); const passesPast = (state, patch) => { const next = applyPatch(state, patch); assert.deepEqual(validate(next), []); return next; }; test("a reply in the thread of a noted question, with a new question in the same patch, is refused", () => { const state = plan([choice("guard")]); state.items[0].noted = true; // the way the server sets it when the note lands refusedPast(state, { items: [guardReply, choice("build")] }); }); test("the refusal names every noted question still standing, and only those", () => { const state = plan([guardNoted(), { ...guardNoted(), id: "other" }]); assert.throws( () => applyPatch(state, { items: [guardReply, { id: "other", stands: true, thread: [{ who: "agent", text: "Still right." }] }, choice("build")] }), (e) => e.message === NOTED_REFUSAL, ); }); test("a reply alone on a noted question passes and keeps it noted: only a new question is refused", () => { const next = passesPast(plan([guardNoted()]), { items: [guardReply] }); assert.equal(next.items[0].noted, true); }); test("a later patch that adds a new question past a still-noted card is refused", () => { const replied = applyPatch(plan([guardNoted()]), { items: [guardReply] }); refusedPast(replied, { items: [choice("build")] }); }); test('"stands": true on the noted question lets a new question through', () => { const next = passesPast(plan([guardNoted()]), { items: [{ ...guardReply, stands: true }, choice("build")] }); assert.equal("noted" in next.items[0], false); }); test("rewording the noted question lets a new question through", () => { passesPast(plan([guardNoted()]), { items: [{ ...guardReply, body: "Which option fits the brief?" }, choice("build")] }); }); test("deleting the noted question in the same patch lets a new question through", () => { const next = passesPast(plan([guardNoted()]), { items: [{ id: "guard", _delete: true }, choice("build")] }); assert.deepEqual(next.items.map((i) => i.id), ["build"]); }); test("settling the noted question in the same patch lets a new question through", () => { passesPast(plan([guardNoted()]), { items: [{ ...guardReply, status: "answered", answer: { k: "A" } }, choice("build")] }); }); test("an answered or skipped card that still carries noted holds nothing up", () => { for (const status of ["answered", "skipped"]) { passesPast(plan([{ ...guardNoted(), thread: [], status }]), { items: [choice("build")] }); } }); test("an optional question or a notice may follow a noted card", () => { passesPast(plan([guardNoted()]), { items: [guardReply, choice("maybe", { required: false })] }); passesPast(plan([guardNoted()]), { items: [guardReply, { id: "fyi", kind: "notice", title: "Heads up" }] }); }); test("a patch that posts a finish is not held to the noted rule", () => { const finish = { headline: "Paused at the guard question", body: "Picked up later." }; assert.doesNotThrow(() => applyPatch(plan([guardNoted()]), { items: [guardReply, choice("build")], finish })); }); test("the dashboard is not held to the noted rule (it draws no cards at all)", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "dashboard" }), items: [guardNoted()] }; assert.doesNotThrow(() => applyPatch(state, { items: [guardReply, choice("build")] })); }); test("a noted card whose note is not yet replied to is refused for both, in one message", () => { assert.throws( () => applyPatch(plan([guardNoted()]), { items: [choice("build")] }), (e) => e.message === 'item "guard" thread: has an unanswered note from the person; reply in its thread in this patch. Like this: {"id":"guard","thread":[{"who":"agent","text":"..."}]}\n' + NOTED_REFUSAL, ); }); test("a top-level settle clears noted, so reopening the card later holds nothing up", () => { for (const settle of [true, ["guard"]]) { const sent = { ...guardNoted(), thread: [...guardNoted().thread, guardReply.thread[0]], submitted: { at: "2026-11-09T08:00:00.000Z", k: "A" } }; const settled = applyPatch(plan([sent]), { settle }); assert.equal(settled.items[0].status, "answered"); assert.equal("noted" in settled.items[0], false); passesPast(settled, { items: [{ id: "guard", status: "reopened" }, choice("build")] }); } }); test("one patch may settle an answered noted card and ask the next question", () => { const sent = { ...guardNoted(), thread: [...guardNoted().thread, guardReply.thread[0]], submitted: { at: "2026-11-09T08:00:00.000Z", k: "A" } }; passesPast(plan([sent]), { settle: true, items: [choice("build")] }); }); test("a reworded body clears noted", () => { assert.equal("noted" in notedAfter({ items: [{ id: "guard", body: "A different question." }] }), false); }); test("changed options clear noted", () => { const options = [{ k: "A", text: "Only this" }]; assert.equal("noted" in notedAfter({ items: [{ id: "guard", options }] }), false); }); test("a reply that leaves the question alone keeps noted", () => { const item = notedAfter({ items: [{ id: "guard", thread: [{ who: "agent", text: "Seen." }] }] }); assert.equal(item.noted, true); }); test("a patch that repeats the same body keeps noted", () => { assert.equal(notedAfter({ items: [{ id: "guard", body: guardNoted().body }] }).noted, true); }); test("deleting a noted question removes it with its flag", () => { assert.deepEqual(applyPatch(plan([guardNoted()]), { items: [{ id: "guard", _delete: true }] }).items, []); }); test("settling a noted question clears noted", () => { assert.equal("noted" in notedAfter({ items: [{ id: "guard", status: "answered" }] }), false); assert.equal("noted" in notedAfter({ items: [{ id: "guard", status: "skipped" }] }), false); assert.equal("noted" in notedAfter({ items: [{ id: "guard", answer: { k: "A" } }] }), false); }); test("stands: true clears noted and is never stored; a non-boolean stands is refused", () => { const item = notedAfter({ items: [{ id: "guard", stands: true }] }); assert.equal("noted" in item, false); assert.equal("stands" in item, false); const kept = notedAfter({ items: [{ id: "guard", stands: false }] }); assert.equal(kept.noted, true, "stands: false clears nothing"); assert.equal("stands" in kept, false); assert.throws(() => applyPatch(plan([guardNoted()]), { items: [{ id: "guard", stands: "yes" }] }), /stands/); }); test("stands on a new question is dropped, not stored", () => { const next = applyPatch(plan([]), { items: [{ ...choice("fresh"), stands: true }] }); assert.equal("stands" in next.items[0], false); }); /* ------------------------------------------------------------- the CLI */ test("post --file reads a patch PowerShell wrote: a UTF-8 BOM, or UTF-16", () => { const s = openSession(); try { const bom = payload("bom.json", {}); fs.writeFileSync(bom, "\uFEFF" + JSON.stringify({ agent: { activity: "From a BOM file" } }), "utf8"); assert.equal(runCli(["post", "--session", s.sid, "--file", bom]).status, 0); assert.equal(readState(s.session).agent.activity, "From a BOM file"); const u16 = payload("u16.json", {}); fs.writeFileSync(u16, Buffer.concat([Buffer.from([0xff, 0xfe]), Buffer.from(JSON.stringify({ agent: { activity: "From UTF-16" } }), "utf16le")])); assert.equal(runCli(["post", "--session", s.sid, "--file", u16]).status, 0); assert.equal(readState(s.session).agent.activity, "From UTF-16"); } finally { cli(["stop", "--session", s.sid, "--force"]); } }); test("wait and stop find a session's server from any folder, not only its project", () => { const s = openSession(); const elsewhere = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-elsewhere-")); try { const waited = runCli(["wait", "--session", s.sid, "--seconds", "1"], { cwd: elsewhere }); assert.notEqual(waited.status, 20, "the server is alive: " + waited.stdout); const stopped = runCli(["stop", "--session", s.sid, "--force"], { cwd: elsewhere }); assert.equal(JSON.parse(stopped.stdout).stopped, 1, stopped.stdout); } finally { cli(["stop", "--session", s.sid, "--force"]); fs.rmSync(elsewhere, { recursive: true, force: true }); } }); test("keep refuses a --from file outside the project, and keeps one copy per upload", () => { const s = openSession(); try { const uploads = path.join(s.session, "uploads"); fs.mkdirSync(uploads, { recursive: true }); const upload = path.join(uploads, "5f7dc81e-0000-4000-8000-000000000000.jpg"); fs.writeFileSync(upload, Buffer.from([0xff, 0xd8, 0xff, 0xd9])); const spec = path.join("specs", `qa-keep-${process.pid}`); const base = ["keep", "--session", s.sid, "--upload", upload, "--spec", spec]; try { const outside = runCli([...base, "--name", "a.png", "--from", "../elsewhere.md"]); assert.equal(outside.status, 3, outside.stderr); const first = JSON.parse(runCli([...base, "--name", "a.png"]).stdout); const again = JSON.parse(runCli([...base, "--name", "renamed.png"]).stdout); assert.equal(again.path, first.path, "the second keep reuses the first copy"); assert.equal(again.reused, true); } finally { fs.rmSync(path.join(ROOT, spec), { recursive: true, force: true }); } } finally { cli(["stop", "--session", s.sid, "--force"]); } }); test("pr-url refuses a pull request from the default branch into itself", () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-prurl-")); try { const git = (...a) => spawnSync("git", ["-c", "user.name=t", "-c", "user.email=t@t", ...a], { cwd: dir, encoding: "utf8" }); git("init", "-q", "-b", "main"); fs.writeFileSync(path.join(dir, "a.txt"), "a"); git("add", "a.txt"); git("commit", "-q", "-m", "a"); const res = spawnSync(process.execPath, [path.join(ROOT, "skills", "plan2code-git", "scripts", "git.mjs"), "pr-url"], { cwd: dir, encoding: "utf8" }); assert.equal(res.status, 4, res.stdout + res.stderr); assert.match(res.stdout + res.stderr, /is-base/); } finally { fs.rmSync(dir, { recursive: true, force: true }); } }); test("a rebase in progress names the branch it is rewriting", () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-rebase-")); try { fs.mkdirSync(path.join(dir, "rebase-merge")); fs.writeFileSync(path.join(dir, "rebase-merge", "head-name"), "refs/heads/main\n"); assert.equal(rebasingBranch({ "rebase-merge": path.join(dir, "rebase-merge") }), "main"); assert.equal(rebasingBranch({}), null); } finally { fs.rmSync(dir, { recursive: true, force: true }); } }); /* ------------------------------------------------------------ the page */ test("a typed line never starts a reply line of its own", () => { assert.equal(indentReply("a\nIdea name: foo\r\n Image: C:\\x"), "a\n Idea name: foo\n Image: C:\\x"); assert.deepEqual(noteReplyLines("Q", "one\ntwo", []), ["Note on Q: one\n two"]); }); test("an approved edit stops saying 'please wait' once the agent has answered it", () => { const frame = { conversation: 1, messages: [ { from: "agent", id: "r1", md: "Edit?", proposal: { summary: "s", files: ["a.md"] } }, { from: "person", kind: "decision", conversation: 1, seq: 2, re: "r1", decision: "approve" }, ], }; assert.equal(chatView(frame).rows[1].done, false); frame.messages.push({ from: "agent", id: "r2", re: 2, md: "Done", changed: [{ file: "a.md", added: 1, removed: 0 }] }); assert.equal(chatView(frame).rows[1].done, true); }); test("the git board: Publish names a remote only when there is one, and Continue is always offered", () => { const view = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board-view.js"), "utf8"); const action = view.slice(view.indexOf("function runStep("), view.indexOf("function stepButton(")); assert.match(action, /remotes\.length === 1/); const banner = view.slice(view.indexOf("function opBlock("), view.indexOf("function prBlock(")); assert.ok(!/if \(conflicted\.every/.test(banner), "Continue is always offered; plan continue checks the files itself"); }); test("kept attachments are served read-only from the session's spec, by their exact name shape", () => { const server = fs.readFileSync(path.join(ROOT, "src", "web-console", "routes.mjs"), "utf8"); const route = server.slice(server.indexOf("function attachment("), server.indexOf("function shot(")); assert.match(route, /req\.method !== "GET"/); assert.match(server, /const KEPT_ROUTE = new RegExp\(`\^\/attachments\/\(\[a-z0-9-\]\{1,40\}-\[0-9a-f-\]\{8\}/); const kept = server.slice(server.indexOf("function keptPath("), server.indexOf("function uploadPath(")); assert.match(kept, /realpathSync/); assert.match(kept, /path\.dirname\(real\)\.toLowerCase\(\) !== realDir\.toLowerCase\(\)/, "only files directly in attachments/"); const render = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "render.js"), "utf8"); assert.match(render, /return "\/attachments\/" \+ kept\[1\]\.toLowerCase\(\)/); assert.match(render, /function isComment\(t\)/, "HTML comments are not shown"); assert.match(render, /"!": \{ mark: "!", label: "blocked"/, "a blocked task gets its marker"); }); /* -------------------------------------------------------------- round 2 */ test("a patch that is valid JSON but not one object is refused (exit 2), never merged as junk keys", () => { const s = openSession(); try { for (const bad of ["[1,2]", '"hello"', "42", "true"]) { const res = runCli(["post", "--session", s.sid, "--file", "-"], { input: bad }); assert.equal(res.status, 2, bad); } assert.ok(!("0" in readState(s.session)), "no junk keys in the state"); } finally { cli(["stop", "--session", s.sid, "--force"]); } }); test("a plain reopen (status and a thread reply only) moves the sent note into the thread and frees the card", () => { const state = { ...blankState({ sid: "x", project: "p", workflow: "implement" }), items: [{ id: "signoff", kind: "review", title: "Sign off", body: "b", status: "open", submitted: { verdict: "changes", text: "Add a dry-run flag.", at: "2026-01-01T00:00:00.000Z" } }], }; const next = applyPatch(state, { items: [{ id: "signoff", status: "reopened", thread: [{ who: "agent", text: "Added it." }] }] }); const card = next.items[0]; assert.equal(card.submitted, undefined, "the card is theirs again"); assert.ok(card.thread.some((m) => m.who === "user" && m.text === "Add a dry-run flag.")); }); test("the git board's Publish reply names no remote when it sent none, and key chips show only for short keys", async () => { const { gitReply } = await import("../src/web-console/public/git-board.js"); assert.equal(gitReply("publish", {}), "Publish."); assert.equal(gitReply("publish", { remote: "backup" }), "Publish to backup."); const { showKey, optionLabel } = await import("../src/web-console/public/answers.js"); assert.equal(showKey("A", "CSV"), true); assert.equal(showKey("commit-first", "Commit first"), false); assert.equal(showKey("no", "No"), false, "a key that only repeats its label"); assert.equal(optionLabel({ options: [{ k: "i-fix-it", text: "I'll fix it" }] }, "i-fix-it"), "I'll fix it"); }); test("a skip is recorded as one, collected with the send, and settles as skipped", () => { const server = fs.readFileSync(path.join(ROOT, "src", "web-console", "routes.mjs"), "utf8"); assert.match(server, /\.\.\.\(type === "skip" \? \{ skipped: true \} : \{\}\)/); const cli = fs.readFileSync(path.join(ROOT, "src", "web-console", "cmd-post-wait.mjs"), "utf8"); assert.match(cli, /a\.type === "answer" \|\| a\.type === "skip"/); }); test("a send made before the last collection is never shown as still with the agent", () => { const cli = fs.readFileSync(path.join(ROOT, "src", "web-console", "cmd-post-wait.mjs"), "utf8"); assert.match(cli, /collected: \{ at: result\.consumedAt \|\| nowIso\(\), ids \}/, "the collection time, which every earlier send precedes"); }); /* -------------------------------------------------------------- round 3 */ test("a branch whose remote copy was deleted offers Publish again, not Pull or Push", async () => { const { boardActions } = await import("../src/web-console/public/git-board.js"); const acts = boardActions({ repo: true, hasCommits: true, head: { branch: "feature/x", upstream: "origin/feature/x", gone: true, ahead: null, behind: null }, remotes: [{ name: "origin" }], changes: { count: 0, heldBack: 0, files: [], untrackedDirs: [] }, branches: [], defaultBranch: "main", }); assert.equal(acts.pull.enabled, false); assert.match(acts.pull.title, /remote copy was deleted/); assert.equal(acts.push.shown, false); assert.equal(acts.publish.shown, true); assert.equal(acts.publish.enabled, true); }); test("keep names a copy from the upload's real path, so an 8.3 spelling reuses the same copy", () => { const src = fs.readFileSync(path.join(ROOT, "src", "web-console", "cmd-small.mjs"), "utf8"); assert.match(src, /attachmentName\(\{ upload: real\(upload\), name: args\.name \}\)/); }); test("the cleanup confirm is red only when a gone branch holds commits found nowhere else", () => { const src = fs.readFileSync(path.join(ROOT, "src", "plan2code-git-scripts", "git.mjs"), "utf8"); assert.match(src, /danger: x\.some\(\(b\) => deleteCheck\(s, localBranch\(s, b\)\)\.onlyHere\.count > 0\)/); const rules = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board.js"), "utf8"); const groups = rules.slice(rules.indexOf("export function cleanupGroups("), rules.indexOf("export function boardActions(")); assert.match(groups, /b\.merged && !b\.gone/, "gone wins on the page too, as cleanup-list has it"); });