Sync upstream into v2.8.0: the git board splits into Changes, Branches and Sync tabs that open on the next step (ticket-free)

AI Assisted
This commit is contained in:
jparkerweb committed 2026-10-14 20:03:09 -07:00
1 parent 7e2c824d4f
commit fdf43b197f
22 files changed
+2556 -803

No files matched your search

+360
View File
@@ -0,0 +1,360 @@
// Git board fixture: canned state.git snapshots, one per journey step and edge case.
//
// A copy of specs/git-board-redesign/pathfinder/sketch-00/states.js, the repo
// states every Pathfinder sketch moved between. Shape follows
// src/web-console/git-repo.mjs snapshot(). `expect` is [primary op, secondary
// op] under the agreed next-step rules (nextStep() in git-board.js), and
// `expectTab` the tab that owns that step. Times are relative to a fixed NOW,
// so ages read the same on every run.
export const NOW = Date.parse("2026-10-14T12:00:00Z");
const ago = (mins) => new Date(NOW - mins * 60000).toISOString();
const ORIGIN = {
name: "origin",
url: "git@github.com:jparkerweb/plan2code.git",
host: "github.com",
web: "https://github.com/jparkerweb/plan2code",
kind: "github",
};
const pr = (head) => `https://github.com/jparkerweb/plan2code/compare/main...${head}?expand=1`;
const last = (subject, author, mins) => ({ subject, author, at: ago(mins) });
function local(name, extra = {}) {
return {
name,
current: false,
default: name === "main",
remote: null,
upstream: `origin/${name}`,
upstreamRemote: "origin",
ahead: 0,
behind: 0,
gone: false,
merged: false,
last: last("Update README", "Justin Parker", 60 * 24),
...extra,
};
}
function remoteOnly(name, subject, author, mins) {
return { name, current: false, default: false, remote: "origin", upstream: null, upstreamRemote: null, ahead: null, behind: null, gone: false, merged: false, last: last(subject, author, mins) };
}
// The branches every journey shares; `current` and the current row's tracking are set per state.
function branches(current, row = {}) {
const rows = [
local("main", { last: last("Release 4.12.0", "Justin Parker", 60 * 5) }),
local("feature/ABC-12001-export-csv", { last: last("Add CSV export button to the audit view", "Justin Parker", 40) }),
local("feature/ABC-11980-audit-filter", { last: last("Filter audit events by actor", "Priya Raman", 60 * 26) }),
local("fix/ABC-11890-null-ticket", { merged: true, last: last("Guard against a null ticket id", "Sam Okafor", 60 * 24 * 6) }),
local("chore/bump-deps", { merged: true, last: last("Bump dev dependencies", "Justin Parker", 60 * 24 * 9) }),
remoteOnly("feature/ABC-12010-sso-banner", "Show SSO expiry banner", "Dana Whitfield", 60 * 3),
remoteOnly("docs/readme-console", "Document the console's Ask tab", "Priya Raman", 60 * 24 * 2),
];
if (!rows.some((b) => b.name === current)) rows.splice(1, 0, local(current, { upstream: null, upstreamRemote: null, ahead: null, behind: null }));
return rows.map((b) => (b.name === current && !b.remote ? { ...b, current: true, ...row } : b));
}
const NO_CHANGES = { count: 0, heldBack: 0, files: [], untrackedDirs: [] };
const DIRTY_FEATURE = {
count: 4,
heldBack: 1,
files: [
{ path: "src/web-console/public/audit-export.js", state: "modified", staged: false, risky: false },
{ path: "src/web-console/public/app.css", state: "modified", staged: false, risky: false },
{ path: ".env.local", state: "new", staged: false, risky: true },
],
untrackedDirs: [{ path: "scripts/fixtures/audit/", files: 6 }],
};
const DIRTY_MAIN = {
count: 2,
heldBack: 0,
files: [
{ path: "src/web-console/public/login.js", state: "modified", staged: false, risky: false },
{ path: "scripts/test-login.mjs", state: "new", staged: false, risky: false },
],
untrackedDirs: [],
};
function snap({ branch, ahead = 0, behind = 0, upstream, gone = false, changes = NO_CHANGES, inProgress = null, conflicted = [], lastFetch = ago(5), remotes = [ORIGIN], rows, prUrl = null, hasCommits = true, detached = null, rebasing }) {
const up = upstream === undefined ? (branch ? `origin/${branch}` : null) : upstream;
return {
at: new Date(NOW).toISOString(),
repo: true,
hasCommits,
head: { branch, detached, ...(rebasing ? { rebasing } : {}), upstream: up, gone, ahead: up ? ahead : null, behind: up ? behind : null },
defaultBranch: "main",
inProgress,
conflicted,
changes,
remotes,
lastFetch,
refreshFailed: false,
branches: rows || branches(branch, { upstream: up, upstreamRemote: up ? "origin" : null, ahead: up ? ahead : null, behind: up ? behind : null, gone }),
prUrl,
};
}
const EXPORT = "feature/ABC-12001-export-csv";
const LOGIN = "fix/ABC-12044-login-redirect";
const FILTER = "feature/ABC-11980-audit-filter";
/** The three journeys, in click order. */
export const JOURNEYS = [
{ id: "commit-push", title: "Commit & push", states: ["cp-dirty", "cp-committing", "cp-ahead", "cp-pushing", "cp-pushed"] },
{ id: "new-branch", title: "Start a new branch", states: ["nb-main-dirty", "nb-creating", "nb-unpublished", "nb-publishing", "nb-published"] },
{ id: "pull-conflict", title: "Recover from a pull conflict", states: ["pc-diverged", "pc-pulling", "pc-conflict", "pc-resolved", "pc-continuing", "pc-rebased", "pc-pushing", "pc-pushed"] },
];
/**
* Every state: `git` (the snapshot), `journey` and `step` (or "edge"), `title`,
* `expect` (primary op, secondary op or null), `expectTab` (the tab owning the
* next step), `expectLine` where the line itself is pinned, `busy` (what is
* running, when a git command is), `result` (the git-result notice after the
* last action), and `on` (board op -> next state id) for the clicks a journey
* takes.
*/
export const STATES = {
/* Commit & push, on a published feature branch */
"cp-dirty": {
journey: "commit-push", step: 1, title: "4 changes on a feature branch (one held back)",
git: snap({ branch: EXPORT, changes: DIRTY_FEATURE, prUrl: pr(EXPORT) }),
expect: ["commit", "pr"],
expectTab: "changes",
on: { commit: "cp-committing" },
},
"cp-committing": {
journey: "commit-push", step: 2, title: "Committing (busy)", busy: "Committing 3 files on feature/ABC-12001-export-csv",
git: snap({ branch: EXPORT, changes: DIRTY_FEATURE, prUrl: pr(EXPORT) }),
expect: ["commit", "pr"],
expectTab: "changes",
on: { done: "cp-ahead" },
},
"cp-ahead": {
journey: "commit-push", step: 3, title: "Committed, 1 to push",
result: { title: "Committed 3 files", body: "`9f3c2ab` Add CSV export button to the audit view. `.env.local` was held back." },
git: snap({ branch: EXPORT, ahead: 1, changes: { count: 1, heldBack: 1, files: [DIRTY_FEATURE.files[2]], untrackedDirs: [] }, prUrl: pr(EXPORT) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { push: "cp-pushing" },
},
"cp-pushing": {
journey: "commit-push", step: 4, title: "Pushing (busy)", busy: "Pushing 1 commit to origin",
git: snap({ branch: EXPORT, ahead: 1, changes: { count: 1, heldBack: 1, files: [DIRTY_FEATURE.files[2]], untrackedDirs: [] }, prUrl: pr(EXPORT) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { done: "cp-pushed" },
},
"cp-pushed": {
journey: "commit-push", step: 5, title: "Pushed, pull request ready",
result: { title: "Pushed 1 commit to origin/feature/ABC-12001-export-csv", body: `\`9f3c2ab\`. [Open pull request](${pr(EXPORT)})` },
git: snap({ branch: EXPORT, changes: { count: 1, heldBack: 1, files: [DIRTY_FEATURE.files[2]], untrackedDirs: [] }, prUrl: pr(EXPORT) }),
expect: ["pr", "cleanup"],
expectTab: "sync",
on: {},
},
/* Start a new branch, from changes made on main */
"nb-main-dirty": {
journey: "new-branch", step: 1, title: "2 changes on main",
git: snap({ branch: "main", changes: DIRTY_MAIN }),
expect: ["create-commit", "commit"],
expectTab: "changes",
on: { "create-commit": "nb-creating", create: "nb-creating" },
},
"nb-creating": {
journey: "new-branch", step: 2, title: "Creating the branch and committing (busy)", busy: "Creating fix/ABC-12044-login-redirect from origin/main, then committing 2 files",
git: snap({ branch: "main", changes: DIRTY_MAIN }),
expect: ["create-commit", "commit"],
expectTab: "changes",
on: { done: "nb-unpublished" },
},
"nb-unpublished": {
journey: "new-branch", step: 3, title: "New branch with 1 commit, not published",
result: { title: "Created fix/ABC-12044-login-redirect and committed 2 files", body: "`4e7d1c0` Redirect to the login page after SSO expiry." },
git: snap({ branch: LOGIN, upstream: null }),
expect: ["publish", "cleanup"],
expectTab: "sync",
on: { publish: "nb-publishing" },
},
"nb-publishing": {
journey: "new-branch", step: 4, title: "Publishing (busy)", busy: "Publishing fix/ABC-12044-login-redirect to origin",
git: snap({ branch: LOGIN, upstream: null }),
expect: ["publish", "cleanup"],
expectTab: "sync",
on: { done: "nb-published" },
},
"nb-published": {
journey: "new-branch", step: 5, title: "Published, pull request ready",
result: { title: "Published fix/ABC-12044-login-redirect to origin", body: `[Open pull request](${pr(LOGIN)})` },
git: snap({ branch: LOGIN, prUrl: pr(LOGIN) }),
expect: ["pr", "cleanup"],
expectTab: "sync",
on: {},
},
/* Recover from a pull conflict */
"pc-diverged": {
journey: "pull-conflict", step: 1, title: "1 ahead, 3 behind",
git: snap({ branch: FILTER, ahead: 1, behind: 3, prUrl: pr(FILTER) }),
expect: ["pull", "push"],
expectTab: "sync",
on: { pull: "pc-pulling" },
},
"pc-pulling": {
journey: "pull-conflict", step: 2, title: "Pulling (busy)", busy: "Pulling origin/feature/ABC-11980-audit-filter (rebase)",
git: snap({ branch: FILTER, ahead: 1, behind: 3, prUrl: pr(FILTER) }),
expect: ["pull", "push"],
expectTab: "sync",
on: { done: "pc-conflict" },
},
"pc-conflict": {
journey: "pull-conflict", step: 3, title: "Rebase stopped on 2 conflicts, 1 with markers left",
result: { title: "Pull stopped on 2 conflicts", body: "Replaying `b81e9d4` Filter audit events by actor (1 of 1). Plan2Code resolved `src/web-console/public/audit.js`; `src/web-console/public/audit.css` still has markers." },
git: snap({
branch: null, detached: "b81e9d4", rebasing: FILTER, upstream: null, inProgress: "rebase",
conflicted: [
{ path: "src/web-console/public/audit.js", markers: false },
{ path: "src/web-console/public/audit.css", markers: true },
],
rows: branches(FILTER, { ahead: 1, behind: 3 }),
}),
expect: ["fix", "abort"],
expectTab: "sync",
on: { continue: "pc-conflict", abort: "pc-diverged", fix: "pc-resolved" },
},
"pc-resolved": {
journey: "pull-conflict", step: 4, title: "Every conflict resolved",
git: snap({
branch: null, detached: "b81e9d4", rebasing: FILTER, upstream: null, inProgress: "rebase",
conflicted: [
{ path: "src/web-console/public/audit.js", markers: false },
{ path: "src/web-console/public/audit.css", markers: false },
],
rows: branches(FILTER, { ahead: 1, behind: 3 }),
}),
expect: ["continue", "abort"],
expectTab: "sync",
on: { continue: "pc-continuing", abort: "pc-diverged" },
},
"pc-continuing": {
journey: "pull-conflict", step: 5, title: "Continuing the rebase (busy)", busy: "Continuing the rebase",
git: snap({
branch: null, detached: "b81e9d4", rebasing: FILTER, upstream: null, inProgress: "rebase",
conflicted: [
{ path: "src/web-console/public/audit.js", markers: false },
{ path: "src/web-console/public/audit.css", markers: false },
],
rows: branches(FILTER, { ahead: 1, behind: 3 }),
}),
expect: ["continue", "abort"],
expectTab: "sync",
on: { done: "pc-rebased" },
},
"pc-rebased": {
journey: "pull-conflict", step: 6, title: "Rebased, 1 to push",
result: { title: "Pull finished", body: "1 commit replayed on top of origin. Resolved `audit.js` (kept both filters) and `audit.css` (you fixed it). 1 commit ready to push." },
git: snap({ branch: FILTER, ahead: 1, prUrl: pr(FILTER) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { push: "pc-pushing" },
},
"pc-pushing": {
journey: "pull-conflict", step: 7, title: "Pushing (busy)", busy: "Pushing 1 commit to origin",
git: snap({ branch: FILTER, ahead: 1, prUrl: pr(FILTER) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { done: "pc-pushed" },
},
"pc-pushed": {
journey: "pull-conflict", step: 8, title: "Pushed, pull request ready",
result: { title: `Pushed 1 commit to origin/${FILTER}`, body: `\`c42d7e1\`. [Open pull request](${pr(FILTER)})` },
git: snap({ branch: FILTER, prUrl: pr(FILTER) }),
expect: ["pr", "cleanup"],
expectTab: "sync",
on: {},
},
/* Edges that break layouts */
"e-caught-up": {
journey: "edge", title: "All caught up on main",
git: snap({ branch: "main", rows: branches("main").map((b) => ({ ...b, merged: false })) }),
expect: [null, "create"],
expectTab: "sync",
expectLine: "All caught up on main · checked 5 min. ago",
on: {},
},
"e-stale": {
journey: "edge", title: "All caught up, but last checked 3 hours ago",
git: snap({ branch: "main", lastFetch: ago(180), rows: branches("main").map((b) => ({ ...b, merged: false })) }),
expect: [null, "create"],
expectTab: "sync",
expectLine: "All caught up on main · checked 3 hr. ago",
on: { refresh: "e-caught-up" },
},
"e-held-only": {
journey: "edge", title: "Caught up except a held-back file",
git: snap({ branch: "main", changes: { count: 1, heldBack: 1, files: [{ path: ".env.local", state: "new", staged: false, risky: true }], untrackedDirs: [] }, rows: branches("main").map((b) => ({ ...b, merged: false })) }),
expect: [null, "ignore"],
expectTab: "changes",
on: {},
},
"e-gone": {
journey: "edge", title: "Remote copy deleted",
git: snap({ branch: "feature/ABC-11702-old-banner", gone: true }),
expect: ["publish", "cleanup"],
expectTab: "sync",
on: {},
},
"e-no-remote": {
journey: "edge", title: "No remote at all",
git: snap({ branch: "main", upstream: null, remotes: [], lastFetch: null, rows: [local("main", { current: true, upstream: null, upstreamRemote: null, ahead: null, behind: null })] }),
expect: [null, "create"],
expectTab: "sync",
expectLine: "Nothing to commit on main · no remote yet",
on: {},
},
"e-first-commit": {
journey: "edge", title: "No commits yet",
git: snap({
branch: "main", hasCommits: false, upstream: null, remotes: [], lastFetch: null, rows: [],
changes: { count: 3, heldBack: 0, files: [{ path: "README.md", state: "new", staged: false, risky: false }, { path: "package.json", state: "new", staged: false, risky: false }], untrackedDirs: [{ path: "src/", files: 12 }] },
}),
expect: ["commit", null],
expectTab: "changes",
on: {},
},
"e-detached": {
journey: "edge", title: "Detached at a commit",
git: snap({ branch: null, detached: "a1b2c3d", upstream: null, rows: branches("main").map((b) => ({ ...b, current: false })) }),
expect: ["create", "cleanup"],
expectTab: "branches",
on: {},
},
"e-many-branches": {
journey: "edge", title: "300 branches, 40 merged",
git: snap({
branch: "main",
rows: [
local("main", { current: true }),
...Array.from({ length: 120 }, (_, i) =>
local(`feature/ABC-${11000 + i}-${["export", "filter", "banner", "login", "audit", "sso"][i % 6]}-${i}`, {
merged: i < 40,
ahead: i % 7 === 0 ? 2 : 0,
behind: i % 5 === 0 ? 4 : 0,
last: last(`Work on ABC-${11000 + i}`, ["Justin Parker", "Priya Raman", "Sam Okafor", "Dana Whitfield"][i % 4], 60 * (i + 1)),
}),
),
...Array.from({ length: 179 }, (_, i) => remoteOnly(`feature/ABC-${12100 + i}-remote-${i}`, `Remote work ${i}`, "Dana Whitfield", 60 * 24 + i * 30)),
],
}),
expect: ["cleanup", null],
expectTab: "branches",
on: {},
},
};
+538
View File
@@ -0,0 +1,538 @@
// Web console tests, the tabbed git board's rules: next step, tabs, badges, busy.
// Run with: node --test scripts/test-web-console-git-board.mjs
//
// Every sample repo state the Pathfinder sketches moved between lives in
// scripts/fixtures/git-board-states.mjs, each with the next step it must
// produce. The rules are pure (git-board.js), so no browser is needed.
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import { JOURNEYS, NOW, STATES } from "./fixtures/git-board-states.mjs";
import {
BRANCH_TYPES,
GIT_TABS,
busyMode,
commitTicks,
controlAllowed,
createSources,
gitReply,
nextStep,
pickTab,
tabBadges,
} from "../src/web-console/public/git-board.js";
import { drawGitBoard } from "../src/web-console/public/git-board-view.js";
const VIEW_SRC = fs.readFileSync(new URL("../src/web-console/public/git-board-view.js", import.meta.url), "utf8");
const MODES = ["offline", "running", "card", "idle"];
const ROLES = ["nav", "action", "done"];
const TAB_IDS = GIT_TABS.map((t) => t.id);
const step = (id) => nextStep(STATES[id].git, { now: NOW });
const badges = (id) => {
const s = step(id);
return tabBadges(STATES[id].git, { now: NOW, stepTab: s.tab });
};
test("git board rules: every sample state gives its expected primary, secondary and tab", () => {
for (const [id, s] of Object.entries(STATES)) {
const n = nextStep(s.git, { now: NOW });
const got = [n.primary ? n.primary.op : null, n.secondary[0] ? n.secondary[0].op : null];
assert.deepEqual(got, s.expect, `${id}: primary and secondary`);
assert.equal(n.tab, s.expectTab, `${id}: owning tab`);
if (s.expectLine) assert.equal(n.line, s.expectLine, `${id}: line`);
assert.ok(n.secondary.length <= (n.primary ? 1 : 2), `${id}: at most one secondary beside a primary`);
for (const st of [n.primary, ...n.secondary].filter(Boolean)) assert.ok(TAB_IDS.includes(st.tab), `${id}: ${st.op} has a tab`);
}
});
test("git board rules: every journey names states that exist", () => {
for (const j of JOURNEYS) for (const id of j.states) assert.ok(STATES[id], `${j.id} names ${id}`);
});
test("git board rules: held-back files never drive the step, and fill an empty secondary with the ignore offer", () => {
const held = step("e-held-only");
assert.equal(held.primary, null);
assert.deepEqual(held.secondary.map((s) => s.op), ["ignore", "refresh"]);
assert.equal(held.secondary[0].label, "Add `.env.local` to .gitignore");
assert.deepEqual(held.secondary[0].files, [".env.local"]);
assert.equal(held.held, "`.env.local` held back");
assert.equal(held.tab, "changes");
const dirty = step("cp-dirty");
assert.equal(dirty.primary.label, "Commit 3 files", "4 changes minus the held-back .env.local");
assert.equal(dirty.held, "`.env.local` held back");
const two = nextStep({
...STATES["e-held-only"].git,
changes: {
count: 2,
heldBack: 2,
files: [
{ path: ".env.local", state: "new", risky: true },
{ path: "dump.sql", state: "new", risky: true },
],
untrackedDirs: [],
},
}, { now: NOW });
assert.equal(two.held, "2 files held back");
assert.equal(two.secondary[0].label, "Add 2 held-back files to .gitignore");
assert.equal(two.secondary[0].why, "Keep them out of every commit.");
assert.equal(held.secondary[0].why, "Keep it out of every commit.");
});
test("git board rules: no default branch means no clean-up step or badge, as boardActions() offers none", () => {
const git = STATES["e-gone"].git;
assert.equal(step("e-gone").secondary[0].op, "cleanup");
const noDefault = { ...git, defaultBranch: null, branches: git.branches.map((b) => ({ ...b, default: false, merged: false, gone: b.current ? b.gone : b.name === "chore/bump-deps" })) };
const n = nextStep(noDefault, { now: NOW });
assert.ok(![n.primary, ...n.secondary].some((s) => s && s.op === "cleanup"));
assert.equal(tabBadges(noDefault, { now: NOW, stepTab: n.tab }).branches, null);
});
test("git board badges: no 'not published' badge before the first commit, even with a remote", () => {
const git = { ...STATES["e-first-commit"].git, remotes: STATES["cp-dirty"].git.remotes, lastFetch: STATES["cp-dirty"].git.lastFetch };
const n = nextStep(git, { now: NOW });
assert.equal(n.primary.op, "commit");
assert.equal(tabBadges(git, { now: NOW, stepTab: n.tab }).sync, null);
});
test("git board rules: the stale line never changes the step, and needs a remote", () => {
const fresh = step("e-caught-up");
const stale = step("e-stale");
assert.equal(fresh.stale, null);
assert.equal(stale.stale, "Checked 3 hr. ago — Refresh?");
assert.deepEqual(stale.primary, fresh.primary);
assert.deepEqual(stale.secondary.map((s) => s.op), fresh.secondary.map((s) => s.op));
assert.equal(step("e-no-remote").stale, null);
const never = nextStep({ ...STATES["e-caught-up"].git, lastFetch: null }, { now: NOW });
assert.equal(never.stale, "Never checked — Refresh?");
});
test("git board rules: no remote reads 'Nothing to commit … no remote yet', and still offers Refresh", () => {
const n = step("e-no-remote");
assert.equal(n.line, "Nothing to commit on main · no remote yet");
assert.deepEqual(n.secondary.map((s) => [s.op, s.label]), [["create", "New branch"], ["refresh", "Refresh"]]);
});
test("git board rules: a pushed branch on an unknown host gets no pull request step", () => {
const git = STATES["pc-pushed"].git;
const unknown = { ...git, remotes: git.remotes.map((r) => ({ ...r, kind: null })) };
assert.equal(step("pc-pushed").primary.op, "pr");
assert.ok(step("pc-pushed").primary.url.startsWith("https://"));
const n = nextStep(unknown, { now: NOW });
assert.notEqual(n.primary && n.primary.op, "pr");
assert.ok(![n.primary, ...n.secondary].some((s) => s && s.op === "pr"));
});
test("git board rules: mid-operation, Fix the files while markers remain, then Continue, Abort once", () => {
const fix = step("pc-conflict");
assert.equal(fix.primary.label, "Fix the files");
assert.equal(fix.secondary[0].label, "Abort the rebase");
assert.equal(step("pc-resolved").primary.op, "continue");
const am = nextStep({ ...STATES["pc-resolved"].git, inProgress: "am" }, { now: NOW });
assert.equal(am.secondary[0].label, "Abort the git am");
});
test("git board rules: on the default branch, a branch is suggested and committing there is the secondary", () => {
const n = step("nb-main-dirty");
assert.equal(n.primary.label, "Start a branch for 2 files");
assert.equal(n.secondary[0].label, "Commit on main");
assert.equal(n.secondary[0].tab, "changes");
});
test("git board badges: each tab badges what it has waiting, and the next step's tab is filled", () => {
const dirty = badges("cp-dirty");
assert.deepEqual([dirty.changes.text, dirty.changes.kind, dirty.changes.next], ["3", "count", true]);
assert.equal(dirty.changes.label, "3 waiting, next step");
assert.equal(dirty.branches.text, "2");
assert.equal(dirty.branches.next, false);
assert.equal(dirty.sync, null);
const held = badges("e-held-only");
assert.deepEqual([held.changes.kind, held.changes.text, held.changes.next], ["dot", "·", false], "no primary, so no filled badge");
assert.equal(badges("e-many-branches").branches.text, "40");
assert.equal(badges("pc-diverged").sync.text, "↑1 ↓3");
assert.equal(badges("pc-diverged").sync.label, "1 to push, 3 to pull, next step");
assert.equal(badges("nb-unpublished").sync.text, "↑");
assert.equal(badges("e-gone").sync.text, "↑");
assert.equal(badges("e-stale").sync.text, "?");
assert.equal(badges("e-caught-up").sync, null);
const conflict = badges("pc-conflict");
assert.equal(conflict.sync.kind, "warn");
assert.equal(conflict.sync.text, "!");
assert.equal(conflict.changes, null);
assert.equal(conflict.branches, null);
});
test("git board badges: a tab owning the step with nothing of its own gets a filled dot", () => {
const b = badges("cp-pushed");
assert.deepEqual([b.sync.kind, b.sync.text, b.sync.next], ["dot", "·", true]);
assert.equal(b.sync.label, "next step");
});
test("git board busy: offline beats running beats a waiting card", () => {
for (let bits = 0; bits < 16; bits++) {
const f = { running: Boolean(bits & 1), cardWaiting: Boolean(bits & 2), gone: Boolean(bits & 4), pending: Boolean(bits & 8) };
const want = f.gone || f.pending ? "offline" : f.running ? "running" : f.cardWaiting ? "card" : "idle";
assert.equal(busyMode(f), want, JSON.stringify(f));
}
assert.equal(busyMode(), "idle");
});
test("git board busy: nav always works, actions only when idle, Done with git while idle or a card waits", () => {
const want = {
nav: { offline: true, running: true, card: true, idle: true },
action: { offline: false, running: false, card: false, idle: true },
done: { offline: false, running: false, card: true, idle: true },
};
for (const role of ROLES) for (const mode of MODES) assert.equal(controlAllowed(mode, role), want[role][mode], `${role} in ${mode}`);
assert.equal(controlAllowed("idle", "nonsense"), false);
});
test("git board tabs: a landed click and arriving go to the step's tab; reload and background keep yours", () => {
for (const current of ["changes", "branches", "sync"]) {
assert.equal(pickTab({ current, stepTab: "branches", reason: "landed" }), "branches");
assert.equal(pickTab({ current, stepTab: "branches", reason: "arrival" }), "branches");
assert.equal(pickTab({ current, stepTab: "branches", reason: "reload" }), current);
assert.equal(pickTab({ current, stepTab: "branches", reason: "background" }), current);
}
for (const current of [null, "nonsense"]) {
assert.equal(pickTab({ current, stepTab: "changes", reason: "reload" }), "changes");
assert.equal(pickTab({ current, stepTab: "changes", reason: "background" }), "changes");
}
assert.equal(pickTab({ current: null, stepTab: null, reason: "arrival" }), "sync");
});
/* ------------------------------------------------------------ the view */
// The node API git-board-view.js may use (its header comment, phase 2 Task
// 2.1), and nothing else: touching any other property throws, so the view
// cannot drift onto something the real DOM has and this fake does not.
const NODE_API = new Set([
"appendChild", "append", "replaceChildren", "setAttribute", "removeAttribute", "addEventListener", "classList",
"className", "id", "type", "value", "checked", "disabled", "textContent", "placeholder", "title", "open", "href",
"target", "rel", "tabIndex",
]);
// What the test itself reads off a recorded node.
const TEST_ONLY = new Set(["tag", "children", "attrs", "listeners", "parent", "classes", "text"]);
function fakeNode(tag) {
const n = {
tag, children: [], attrs: {}, listeners: {}, parent: null, classes: new Set(), text: "",
id: "", type: "", value: "", checked: false, disabled: false, placeholder: "", title: "", open: false,
href: "", target: "", rel: "", tabIndex: 0,
appendChild(c) {
c.parent = proxy;
n.children.push(c);
return c;
},
append(...cs) {
for (const c of cs) proxy.appendChild(c);
},
replaceChildren(...cs) {
n.children = [];
n.text = "";
proxy.append(...cs);
},
setAttribute(k, v) {
n.attrs[k] = String(v);
},
removeAttribute(k) {
delete n.attrs[k];
},
addEventListener(type, fn) {
(n.listeners[type] ||= []).push(fn);
},
classList: {
add: (...c) => c.forEach((x) => n.classes.add(x)),
remove: (...c) => c.forEach((x) => n.classes.delete(x)),
toggle: (c, force) => {
const on = force === undefined ? !n.classes.has(c) : Boolean(force);
if (on) n.classes.add(c);
else n.classes.delete(c);
return on;
},
contains: (c) => n.classes.has(c),
},
};
const proxy = new Proxy(n, {
get(t, key) {
if (typeof key !== "string" || TEST_ONLY.has(key)) return t[key];
if (!NODE_API.has(key)) throw new Error(`the view used .${key}, which is not in its node API`);
if (key === "className") return [...t.classes].join(" ");
if (key === "textContent") return t.text + t.children.map((c) => c.textContent).join("");
return t[key];
},
set(t, key, v) {
if (typeof key === "string" && !NODE_API.has(key) && !TEST_ONLY.has(key)) throw new Error(`the view set .${key}, which is not in its node API`);
if (key === "className") t.classes = new Set(String(v || "").split(/\s+/).filter(Boolean));
else if (key === "textContent") {
t.children = [];
t.text = v == null ? "" : String(v);
} else t[key] = v;
return true;
},
});
return proxy;
}
/** The helpers the view is handed, recording every node made. */
function fakeH() {
const all = [];
const el = (tag, className, text) => {
const n = fakeNode(tag);
if (className) n.className = className;
if (text != null) n.textContent = text;
all.push(n);
return n;
};
return { el, md: (text, cls) => el("div", cls, text), copyButton: (text, cls) => el("button", cls, "Copy"), all };
}
/** ctx.on, recording every call as [name, ...args]. */
function fakeOn() {
const calls = [];
const rec = (name) => (...args) => calls.push([name, ...args]);
return {
calls,
send: rec("send"), redraw: rec("redraw"), pickTab: rec("pickTab"), openPanel: rec("openPanel"),
closePanel: rec("closePanel"), pickPrHost: rec("pickPrHost"), persist: rec("persist"),
};
}
// The Create prompt's fields as openCreate() in app.js seeds them.
const seedCreate = (git, commit = false) => ({
from: createSources(git, commit).preset,
type: BRANCH_TYPES[0],
description: "",
name: null,
commit,
files: commit ? [...commitTicks(git.changes)] : null,
ignore: [],
});
// The panels each tab can draw; "create-commit" is the create panel in commit mode, on Changes.
const PANELS = { changes: [null, "commit", "create-commit"], branches: [null, "create", "cleanup"], sync: [null] };
function draw(id, { mode = "idle", tab = null, panel = null, create = null } = {}) {
const s = STATES[id];
const git = s.git;
const step = nextStep(git, { now: NOW });
const badges = tabBadges(git, { now: NOW, stepTab: step.tab });
const board = {
tab,
panel: panel === "create-commit" ? "create" : panel,
create: create || (panel === "create" ? seedCreate(git) : panel === "create-commit" ? seedCreate(git, true) : null),
ticks: null, ignore: new Set(), sweep: null, query: "", showAll: false, remoteOpen: null, base: null,
};
const h = fakeH();
const on = fakeOn();
const out = drawGitBoard({
git, board, now: NOW, mode, step, badges, notice: s.result || null, activity: s.busy || null,
hasCard: false, offlineReason: "gone", h, on,
});
return { ...out, h, on, board, step };
}
function walk(node, out = []) {
out.push(node);
for (const c of node.children) walk(c, out);
return out;
}
const isControl = (n) => ["button", "input", "select"].includes(n.tag) || (["a", "span"].includes(n.tag) && n.classes.has("git-pr-open"));
const controls = (node) => walk(node).filter(isControl);
const isOff = (n) => (n.tag === "span" ? n.attrs["aria-disabled"] === "true" : Boolean(n.disabled));
// A control's words: its own text, or for a bare box, the label around it.
const words = (n) => n.textContent.trim() || (n.parent && n.parent.tag === "label" ? n.parent.textContent.trim() : "");
function* everyRender(modes = ["idle", "running", "card", "offline"]) {
for (const id of Object.keys(STATES)) {
for (const mode of modes) {
for (const tab of TAB_IDS) for (const panel of PANELS[tab]) yield { id, mode, tab, panel, r: draw(id, { mode, tab, panel }) };
}
}
}
test("git board view: no control leaks the busy lock, in any state, mode, tab or panel", () => {
let checked = 0;
for (const { id, mode, tab, panel, r } of everyRender()) {
const where = `${id} · ${mode} · ${tab} · ${panel}`;
const all = controls(r.node);
for (const c of all) {
const gate = c.attrs["data-gate"];
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"}`);
checked++;
}
const done = all.filter((c) => c.textContent === "Done with git");
assert.equal(done.length, 1, `${where}: exactly one Done with git`);
assert.equal(!done[0].disabled, mode === "idle" || mode === "card", `${where}: Done with git live only while idle or a card waits`);
}
assert.ok(checked > 1000, "the guard looked at the board's controls");
});
test("git board view: every function of today's board is reachable on some tab", () => {
const texts = new Set();
const ids = { select: new Set(), input: new Set() };
const take = (r) => {
for (const c of controls(r.node)) {
texts.add(words(c));
if (c.id && ids[c.tag]) ids[c.tag].add(c.id);
}
};
for (const { r } of everyRender(["idle"])) take(r);
// A name that is taken offers Switch to it.
take(draw("cp-dirty", { tab: "branches", panel: "create", create: { ...seedCreate(STATES["cp-dirty"].git), name: "main" } }));
// Exact, except the labels that carry a count ("Commit 3 files", "Show all 179").
const has = (want, prefix = false) => [...texts].some((t) => t === want || (prefix && t.startsWith(`${want} `)));
for (const want of [
"Add to .gitignore", "Create branch", "New branch", "Create", "Switch", "Delete", "Choose which to clean up…",
"Refresh", "Pull", "Publish", "Open pull request", "Copy", "Abort the rebase", "Continue", "Done with git",
"Switch to it",
]) {
assert.ok(has(want), `"${want}" is drawn somewhere`);
}
for (const want of ["Commit", "Show all", "Clean up", "Push"]) assert.ok(has(want, true), `"${want} …" is drawn somewhere`);
for (const id of ["git-pr-base", "git-new-from", "git-new-type"]) assert.ok(ids.select.has(id), `select #${id}`);
for (const id of ["git-search", "git-new-desc", "git-new-name"]) assert.ok(ids.input.has(id), `input #${id}`);
for (const [id, s] of Object.entries(STATES)) {
const head = draw(id).node.children.find((c) => c.tag === "header");
if (s.git.head.branch) assert.ok(head.textContent.includes(s.git.head.branch), `${id}: the header names the branch`);
}
assert.ok(draw("e-no-remote").node.children[0].textContent.includes("git remote add origin <url>"));
});
test("git board view: pins on its source and on a few states", () => {
for (const word of ["document", "window", "querySelector", "getBoundingClientRect", ".style"]) {
assert.ok(!VIEW_SRC.includes(word), `git-board-view.js never names ${word}`);
}
const imports = [...VIEW_SRC.matchAll(/\bfrom\s+["']([^"']+)["']/g)].map((m) => m[1]);
assert.deepEqual(imports, ["./git-board.js"], "it imports only ./git-board.js");
assert.doesNotMatch(VIEW_SRC, /\bimport\s*\(/, "and nothing dynamically");
const conflict = controls(draw("pc-conflict").node).filter((c) => c.textContent.startsWith("Abort"));
assert.equal(conflict.length, 1, "mid-rebase, Abort is offered once");
const held = draw("e-held-only", { tab: "changes" });
const strip = walk(held.node).find((n) => n.classes.has("git-step"));
assert.ok(strip, "the step strip is on Changes");
assert.ok(walk(strip).find((n) => n.classes.has("git-held")).textContent.includes("`.env.local` held back"));
assert.ok(controls(strip).some((c) => c.textContent === "Add `.env.local` to .gitignore"), "the ignore offer is the secondary");
const away = draw("cp-dirty", { tab: "sync" });
const hint = walk(away.node).find((n) => n.classes.has("git-hint"));
assert.ok(hint, "a tab that does not own the step points at it");
assert.ok(hint.textContent.includes("Commit 3 files"));
assert.ok(hint.textContent.startsWith("Next step is on Changes:"));
});
const click = (n) => n.listeners.click.forEach((fn) => fn());
const stepButtons = (r) => controls(walk(r.node).find((n) => n.classes.has("git-step")));
test("git board view: each step's click goes out as the board offers it", () => {
const held = draw("e-held-only");
click(stepButtons(held).find((c) => c.textContent.startsWith("Add ")));
assert.deepEqual(held.on.calls, [["openPanel", "commit", { ignore: [".env.local"], ticks: [] }]]);
const unpublished = draw("nb-unpublished");
click(stepButtons(unpublished).find((c) => c.textContent === "Publish"));
assert.deepEqual(unpublished.on.calls, [["send", "publish", { remote: "origin" }]]);
const main = draw("nb-main-dirty");
const [branch, onMain] = stepButtons(main);
click(branch);
click(onMain);
assert.deepEqual(main.on.calls, [["openPanel", "create", { commit: true }], ["openPanel", "commit"]]);
const away = draw("pc-conflict", { tab: "changes" });
click(walk(away.node).find((n) => n.classes.has("git-hint")));
assert.deepEqual(away.on.calls, [["pickTab", "sync"]]);
const op = draw("pc-conflict");
const opButtons = controls(walk(op.node).find((n) => n.classes.has("git-op")));
opButtons.forEach(click);
assert.deepEqual(op.on.calls, [["send", "continue", {}, { operation: "rebase" }], ["send", "abort", {}, { operation: "rebase" }]]);
});
test("git board view: a .gitignore-only pick commits just .gitignore, and never on a detached HEAD", () => {
const ignoreHeld = (git) => ({ ...git, changes: STATES["e-held-only"].git.changes });
const opened = (git) => {
const step = nextStep(git, { now: NOW });
const board = { tab: "changes", panel: "commit", create: null, ticks: new Set(), ignore: new Set([".env.local"]), sweep: null, query: "", showAll: false, remoteOpen: null, base: null };
const h = fakeH();
const on = fakeOn();
const { node } = drawGitBoard({ git, board, now: NOW, mode: "idle", step, badges: tabBadges(git, { now: NOW, stepTab: step.tab }), notice: null, activity: null, h, on });
return { node, on };
};
const onMain = opened(STATES["e-held-only"].git);
const add = controls(onMain.node).find((c) => c.textContent === "Add 1 to .gitignore");
assert.ok(add && !add.disabled);
click(add);
assert.deepEqual(onMain.on.calls, [["send", "commit", { files: [], ignore: [".env.local"] }]]);
const detached = opened(ignoreHeld(STATES["e-detached"].git));
assert.ok(!controls(detached.node).some((c) => c.textContent === "Add 1 to .gitignore"), "no commit straight onto a detached HEAD");
const make = controls(detached.node).find((c) => c.textContent === "Create branch");
assert.ok(make && !make.disabled, "the branch comes first, .gitignore pick and all");
click(make);
assert.deepEqual(detached.on.calls, [["openPanel", "create", { commit: true, files: [], ignore: [".env.local"] }]]);
assert.equal(gitReply("commit", { files: [], ignore: [".env.local"] }), "Add .env.local to .gitignore and commit just .gitignore.");
assert.equal(
gitReply("create", { name: "fix/x", from: "a1b2c3d", then: "commit", files: [], ignore: [".env.local"] }),
"Create fix/x from a1b2c3d. Then add .env.local to .gitignore and commit just .gitignore."
);
assert.equal(gitReply("commit", { files: ["a.js"], ignore: ["dist/"] }), "Commit this file: a.js. Add dist/ to .gitignore.");
});
test("git board host: app.js draws the board only through drawGitBoard, and the server serves the view", () => {
const app = fs.readFileSync(new URL("../src/web-console/public/app.js", import.meta.url), "utf8");
for (const gone of ["gitActionBar", "gitBranches", "smallButton", "gitHeader", "gitCommitPanel"]) {
assert.ok(!app.includes(`function ${gone}(`), `app.js no longer defines ${gone}()`);
}
const drawCalls = [...app.matchAll(/\bdrawGitBoard\(/g)].length;
assert.equal(drawCalls, 1, "one call to drawGitBoard");
const host = app.slice(app.indexOf("function renderGitBoard("), app.indexOf("function rememberGitTabScroll("));
assert.ok(host.includes("drawGitBoard("), "renderGitBoard is the one that calls it");
const server = fs.readFileSync(new URL("../src/web-console/server.mjs", import.meta.url), "utf8");
const servable = server.slice(server.indexOf("const SERVABLE = new Set(["), server.indexOf("]);", server.indexOf("const SERVABLE = new Set([")));
assert.ok(servable.includes('"git-board-view.js"'), "SERVABLE includes git-board-view.js");
});
test("git board host: the always-on commit table keeps the person's ticks, and a click re-seeds them", () => {
const app = fs.readFileSync(new URL("../src/web-console/public/app.js", import.meta.url), "utf8");
const send = app.slice(app.indexOf("async function sendGit("), app.indexOf("const gitOn = {"));
assert.match(send, /board\.ticks = null;\s*board\.ignore = new Set\(\);/, "a click drops the old picks");
const commit = app.slice(app.indexOf("function openCommit("), app.indexOf("function openCleanup("));
assert.ok(!commit.includes("commitTicks("), "opening the panel never re-seeds over their ticks");
assert.ok(commit.includes("tablePicks(git)"), "a detached commit carries the table's picks");
const panel = app.slice(app.indexOf("function openPanel("), app.indexOf("const closePanel ="));
assert.match(panel, /opts\.commit && !opts\.files\) return openCreate\(git, \{ \.\.\.opts, \.\.\.tablePicks\(git\) \}\)/, "Start a branch takes what is ticked");
});
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");
const notes = read("../src/web-console/notes/git.md");
const finishing = notes.slice(notes.indexOf("**Finishing**"));
assert.ok(finishing.includes("Done with git"), "notes/git.md Finishing names Done with git");
assert.ok(finishing.includes("cancel"), "notes/git.md Finishing cancels an open card");
assert.ok(!finishing.includes('"settle": ["<id>"]'), "the cancel rule never settles a card nothing was sent to");
assert.ok(notes.includes("`files[]` may be empty"), "notes/git.md allows a .gitignore-only commit");
assert.ok(read("../src/plan2code-git.md").includes("Done with git"), "plan2code-git.md names Done with git");
const html = read("../src/web-console/public/index.html");
const start = html.indexOf('<section class="help-panel" data-tab="git">');
const help = html.slice(start, html.indexOf("</section>", start));
for (const word of ["Changes", "Branches", "Sync", "Done with git"]) assert.ok(help.includes(word), `Help's git topic mentions ${word}`);
for (const old of ["one board", "one page"]) assert.ok(!help.includes(old), `Help's git topic no longer says "${old}"`);
assert.ok(!read("../.readme/web-console.md").includes("commits on one page"), "the readme no longer says commits on one page");
});
+7 -3
View File
@@ -327,7 +327,8 @@ test("git: the board stays locked from a click until the agent's next post, not
assert.equal(boardAwaiting({ sentAt, cardsAwaiting: 1, adrift: true }), false, "an agent gone quiet releases the lock");
const app = fs.readFileSync(new URL("../src/web-console/public/app.js", import.meta.url), "utf8");
assert.match(app, /const gitLocked = \(\) =>[^;]*gitAwaiting\(\)/, "gitLocked includes gitAwaiting()");
assert.match(app, /const gitMode = \(\) =>[^;]*gitAwaiting\(\)/, "the busy mode includes gitAwaiting()");
assert.match(app, /const gitLocked = \(\) => gitMode\(\) !== "idle";/, "gitLocked is anything but idle");
const send = app.slice(app.indexOf("async function sendGit("), app.indexOf("function renderGitBoard("));
assert.match(send, /local\.gitSentAt = Date\.now\(\);\s*save\(\);/, "a board click records when it was sent, and saves it");
assert.match(app, /sentAt: local\.gitSentAt[\s\S]{0,80}updatedAt: S\.updatedAt[\s\S]{0,80}cardsAwaiting: awaitingReply\(\)\.length/);
@@ -563,15 +564,18 @@ test("git board: the page draws it from git-board.js, with no inline styles", ()
const dir = path.join(path.dirname(CONSOLE_CLI), "public");
const app = fs.readFileSync(path.join(dir, "app.js"), "utf8");
const html = fs.readFileSync(path.join(dir, "index.html"), "utf8");
const view = fs.readFileSync(path.join(dir, "git-board-view.js"), "utf8");
assert.match(app, /^import [^;]+ from "\.\/git-board\.js";/m, "app.js imports git-board.js");
for (const m of ["git-board.js", "pr-url.js"]) assert.ok(html.includes(`rel="modulepreload" href="/${m}"`), `the page preloads ${m}`);
assert.match(app, /^import [^;]+ from "\.\/git-board-view\.js";/m, "app.js imports git-board-view.js");
for (const m of ["git-board.js", "git-board-view.js", "pr-url.js"]) assert.ok(html.includes(`rel="modulepreload" href="/${m}"`), `the page preloads ${m}`);
assert.match(app, /const isGitBoard = \(\) => S && S\.workflow === "git" && S\.git;/);
assert.match(app, /i: "__git", type: "git", op/, "a click is one __git action");
assert.match(app, /a\.rel = "noopener"/, "the PR link opens with rel=noopener");
assert.match(view, /a\.rel = "noopener"/, "the PR link opens with rel=noopener");
const start = app.indexOf("/* ------------------------------------------------------------ git board */");
const end = app.indexOf("/* ------------------------------------------------------------- welcome */");
assert.ok(start > 0 && end > start);
assert.doesNotMatch(app.slice(start, end), /setAttribute\(\s*["']style["']|\.style\./, "the board sets no inline styles");
assert.doesNotMatch(view, /setAttribute\(\s*["']style["']|\.style\./, "nor does its view");
});
// The board's every click is one `__git` action; the agent reads it off the
+6 -5
View File
@@ -220,11 +220,12 @@ test("a build's own count wins, 0 done included; a question workflow still fills
test("the git board: Publish names a remote only when there is one, and an open card holds the board", () => {
const js = app();
const action = js.slice(js.indexOf("function gitAction("), js.indexOf("/* The branch table */"));
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 at = js.indexOf("const gitLocked = ");
const at = js.indexOf("const gitMode = ");
assert.match(js.slice(at, js.indexOf(";", at)), /myTurn\(\)\.some\(\(i\) => i\.kind !== "notice"\)/);
const banner = js.slice(js.indexOf("function gitOpBanner("), js.indexOf("function gitActionBar("));
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");
});
@@ -343,7 +344,7 @@ test("keep names a copy from the upload's real path, so an 8.3 spelling reuses t
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 js = app();
const groups = js.slice(js.indexOf("function cleanupGroups("), js.indexOf("function openCleanup("));
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");
});
+12 -10
View File
@@ -550,7 +550,7 @@ test("a wait with nothing open leaves a working agent working", () => {
test("the git board lets go of a working agent that went adrift", () => {
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const at = js.indexOf("const gitLocked = ");
const at = js.indexOf("const gitMode = ");
const line = js.slice(at, js.indexOf(";", at));
assert.ok(line.includes("(agentWorking() && !agentAdrift())"), line);
});
@@ -649,8 +649,8 @@ test("a finish ends the working stretch, and resuming a pause starts a fresh one
test("a card with a note box over the git board flows at its own height, never shrunk under the board", () => {
const css = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.css"), "utf8");
const rule = css.slice(css.indexOf(".main:has(> .git-board) > .card,"), css.indexOf("{", css.indexOf(".main:has(> .git-board) > .card,")));
assert.ok(rule.includes(".main:has(> .git-board) > .card.is-primary.has-grow"), "the board's natural-height rule outranks .has-grow");
const rule = css.slice(css.indexOf(".git-cards > .card,"), css.indexOf("{", css.indexOf(".git-cards > .card,")));
assert.ok(rule.includes(".git-cards > .card.is-primary.has-grow"), "the board's natural-height rule outranks .has-grow");
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const fn = js.slice(js.indexOf("function markGrowBox("), js.indexOf("function naturalHeight("));
assert.ok(fn.includes("isGitBoard()"), "no box grows over the board");
@@ -668,16 +668,18 @@ test("long task lines, long words, a narrow board and a narrow Ask pane never wi
assert.match(rule(".main > .git-board"), /grid-template-columns: minmax\(0, 1fr\)/);
assert.match(rule(".git-table-wrap"), /overflow-x: auto/, "the branch table scrolls on its own");
assert.match(rule(".ask-actions"), /flex-wrap: wrap/, "the Ask pane's Send never clips");
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const fn = js.slice(js.indexOf("function branchTable("), js.indexOf("/* The panels */"));
assert.ok(fn.includes('el("div", "git-table-wrap")'), "branchTable wraps its table");
const view = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board-view.js"), "utf8");
const fn = view.slice(view.indexOf("function branchTable("), view.indexOf("function createPanel("));
assert.ok(fn.includes('h.el("div", "git-table-wrap")'), "branchTable wraps its table");
});
test("over the git board a note box grows with its text, and the no-repo note only points above when a card is there", () => {
const css = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.css"), "utf8");
assert.match(css, /\.main:has\(> \.git-board\) > \.card textarea \{ field-sizing: content; max-height: 50vh; \}/);
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const fn = js.slice(js.indexOf("function renderGitBoard("), js.indexOf("function rememberGitScroll("));
assert.ok(fn.includes('main.querySelector(":scope > .card")'), "the note checks for a card first");
assert.match(css, /\.git-cards > \.card textarea \{ field-sizing: content; max-height: 50vh; \}/);
const view = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board-view.js"), "utf8");
const fn = view.slice(view.indexOf("export function drawGitBoard("), view.indexOf("function header("));
assert.ok(fn.includes("ctx.hasCard"), "the note checks for a card first");
assert.ok(fn.includes("will ask what to do here in a moment"));
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
assert.match(js, /hasCard: Boolean\(card\)/, "the host says whether a card is in the slot");
});