mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 20:51:19 -08:00
Restyle the web console and tidy its labels, Ask tab, cleanup and help
AI Assisted
This commit is contained in:
1 parent
710c751c2f
commit
e9679c47b9
103 files changed
+4054
-2273
No files matched your search
@@ -14,7 +14,8 @@
|
||||
// The shots use the console's Ocean highlight rather than its default orange:
|
||||
// it is the console's nearest to the Plan2Code blue the site and README use.
|
||||
//
|
||||
// Shots: dashboard, dashboard-plan, dashboard-utilities, question, doc, build, signoff, finish, ask, git.
|
||||
// Shots: dashboard, dashboard-plan, dashboard-utilities, question, doc, build, signoff, signoff-changes, finish, ask, git,
|
||||
// notebook, learning, lessons, deps, activities and prototypes.
|
||||
// --compare adds workspace, stop, delete, help, prefs and cleanup: screens the
|
||||
// docs never show, for checking a change by eye against a "before" set. Its
|
||||
// --out must be outside docs/screenshots/, so the set is never published.
|
||||
@@ -86,15 +87,50 @@ const SHOTS = {
|
||||
doc: { workflow: "plan", posts: ["doc"], tab: "What we've agreed" },
|
||||
build: { workflow: "implement", posts: ["build"], tab: "phase-3.md" },
|
||||
signoff: { workflow: "implement", posts: ["signoff"] },
|
||||
// The sign-off with its Changes tab open: the diff is a file in the session folder.
|
||||
"signoff-changes": { workflow: "implement", posts: ["signoff", "signoff-changes"], files: { "changes.diff": "changes.diff" }, tab: "Changes" },
|
||||
finish: { workflow: "implement", posts: ["signoff", "finish"] },
|
||||
ask: { workflow: "plan", posts: ["question"], ask: "Where are tasks paged?" },
|
||||
// The git board draws itself from a real repository, so this shot runs in
|
||||
// its own git sample project; the post only hands the board back to you.
|
||||
git: { workflow: "git", posts: ["git"], repo: true },
|
||||
// The dashboard of a project with Learning on and two lessons waiting: its
|
||||
// Learning row and the banner with Review.
|
||||
learning: {
|
||||
workflow: "dashboard",
|
||||
posts: ["dashboard"],
|
||||
project: "learning",
|
||||
// The Learning row sits last on the dashboard, below the fold: bring the
|
||||
// end of the page into view.
|
||||
open: async (page) => {
|
||||
await page.locator(".learn-row").first().waitFor({ timeout: 10000 });
|
||||
await page.evaluate(() => document.querySelector(".learn-row").scrollIntoView({ block: "end", behavior: "instant" }));
|
||||
await sleep(400);
|
||||
},
|
||||
},
|
||||
|
||||
// The card that offers the lessons noted during a phase, at the end of the run.
|
||||
lessons: { workflow: "implement", posts: ["lessons"], project: "learning" },
|
||||
// The Update dependencies report and its finish.
|
||||
deps: { workflow: "deps", posts: ["deps"] },
|
||||
// The Activities picker, opened over a build in progress.
|
||||
activities: {
|
||||
workflow: "implement",
|
||||
posts: ["build"],
|
||||
open: async (page) => {
|
||||
// Activities is off by default: switch it on for this page, then open it.
|
||||
await page.evaluate(() => { document.getElementById("btn-activities").hidden = false; });
|
||||
await page.click("#btn-activities");
|
||||
await page.waitForSelector("#activities-modal[open]", { timeout: 10000 });
|
||||
await page.waitForSelector("#activities-picker:not([hidden])", { timeout: 10000 });
|
||||
},
|
||||
},
|
||||
// A spec with two saved prototypes: the Prototypes tab lists them.
|
||||
prototypes: { workflow: "implement", posts: ["build", "prototypes"], project: "prototypes", tab: "Prototypes" },
|
||||
// The Notebook dialog over the plan question, with two named tabs: Call notes
|
||||
// (a heading, bullets and bold, shown live) and Ideas, with the first one
|
||||
// open. The store is the scratch folder's, never the real one.
|
||||
notepad: {
|
||||
notebook: {
|
||||
workflow: "plan",
|
||||
posts: ["question"],
|
||||
open: async (page) => {
|
||||
@@ -304,6 +340,41 @@ function makeFreshProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
// The Learning shots' project: the sample with Learning switched on and two
|
||||
// lessons waiting, noted through the same script the skills use, into the
|
||||
// throwaway Learning store.
|
||||
function makeLearningProject() {
|
||||
const project = path.join(SCRATCH, "learning", "task-api");
|
||||
fs.mkdirSync(path.join(project, ".plan2code"), { recursive: true });
|
||||
fs.cpSync(path.join(SCRATCH, "task-api"), project, { recursive: true });
|
||||
fs.writeFileSync(path.join(project, ".plan2code", "settings.json"), JSON.stringify({ format: 1, learning: "on" }, null, 2) + "\n");
|
||||
const note = (text, kind, about) =>
|
||||
spawnSync(
|
||||
process.execPath,
|
||||
[path.join(ROOT, "src", "skill-scripts", "lessons.mjs"), "note", "--type", "lesson", "--text", text, "--kind", kind, "--about", about, "--source", "said", "--skill", "implement"],
|
||||
{ cwd: project, env: ENV, encoding: "utf8" }
|
||||
);
|
||||
note("Every list endpoint pages with a cursor, never an offset.", "convention", "src/tasks");
|
||||
note("Run one test file with node --test test/tasks.test.js; npm test also starts the Postgres container.", "command", "test/tasks.test.js");
|
||||
return project;
|
||||
}
|
||||
|
||||
// The Prototypes shot's project: the sample spec with two saved prototype
|
||||
// choices, one a Markdown note and one an HTML page.
|
||||
function makePrototypesProject() {
|
||||
const project = path.join(SCRATCH, "prototypes", "task-api");
|
||||
fs.cpSync(path.join(SCRATCH, "task-api"), project, { recursive: true });
|
||||
const dir = path.join(project, "specs", "task-api", "prototypes");
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(dir, "task-list.md"),
|
||||
"# Task list prototype\n\n**Chosen:** Variant B, a compact list with the status as a colored dot.\n\n- Filters sit in one row above the list.\n- Each row shows the title, the assignee and the due date.\n- Empty state: \"No tasks yet. Add the first one.\"\n"
|
||||
);
|
||||
fs.writeFileSync(path.join(dir, "task-list.html"), "<!doctype html><title>Task list</title><h1>Task list</h1>\n");
|
||||
fs.writeFileSync(path.join(dir, "task-detail.md"), "# Task detail prototype\n\n**Chosen:** Variant A, a side panel over the list.\n");
|
||||
return project;
|
||||
}
|
||||
|
||||
// The Workspace shot's second folder, beside the sample project.
|
||||
function makeExtraFolder() {
|
||||
const dir = path.join(SCRATCH, "task-web");
|
||||
@@ -368,9 +439,12 @@ function post(project, sid, name) {
|
||||
}
|
||||
|
||||
// Opens a session for the shot and posts its payloads. Returns { sid, url }.
|
||||
// `files` are copied into the session folder first, the way a skill's own
|
||||
// script (changes.mjs) leaves a diff there.
|
||||
function stage(project, spec) {
|
||||
const r = cli(project, "open", "--workflow", spec.workflow, "--no-open");
|
||||
if (r.code !== 0 || !r.out || !r.out.url) throw new Error(`open failed (${r.code}): ${r.err.trim()}`);
|
||||
for (const [name, from] of Object.entries(spec.files || {})) fs.copyFileSync(path.join(PAYLOADS, from), path.join(r.out.session, name));
|
||||
for (const name of spec.posts) post(project, r.out.sid, name);
|
||||
return { sid: r.out.sid, url: r.out.url };
|
||||
}
|
||||
@@ -608,13 +682,22 @@ async function main() {
|
||||
// A saved role keeps the dashboard's "pick your role" banner out of shot,
|
||||
// and the Ocean highlight is the console's nearest to the Plan2Code blue
|
||||
// the landing page uses.
|
||||
fs.writeFileSync(path.join(HOME, "looks.json"), JSON.stringify({ looks: { role: "engineer", accent: "ocean", welcomeSeen: true } }));
|
||||
fs.writeFileSync(path.join(HOME, "looks.json"), JSON.stringify({ looks: { role: "engineer", accent: "ocean", welcomeSeen: true, skillLaunched: true, meterTipSeen: true } }));
|
||||
browser = await launchBrowser({
|
||||
...(typeof args.browser === "string" ? { executablePath: args.browser } : {}),
|
||||
args: ["--no-first-run", "--no-default-browser-check", "--mute-audio"],
|
||||
});
|
||||
for (const name of names) {
|
||||
const where = table[name].repo ? makeGitProject() : table[name].fresh ? makeFreshProject() : project;
|
||||
const spec = table[name];
|
||||
const where = spec.repo
|
||||
? makeGitProject()
|
||||
: spec.fresh
|
||||
? makeFreshProject()
|
||||
: spec.project === "learning"
|
||||
? makeLearningProject()
|
||||
: spec.project === "prototypes"
|
||||
? makePrototypesProject()
|
||||
: project;
|
||||
const { sid, url } = stage(where, table[name]);
|
||||
try {
|
||||
if (table[name].ask) await captureAsk(browser, where, sid, url, table[name].ask);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
diff --git a/src/tasks/paginate.js b/src/tasks/paginate.js
|
||||
index 3f1a2b4..8c9d0e1 100644
|
||||
--- a/src/tasks/paginate.js
|
||||
+++ b/src/tasks/paginate.js
|
||||
@@ -1,7 +1,9 @@
|
||||
// Cursor paging for GET /tasks: up to 50 tasks a page, oldest first.
|
||||
-export function paginate(tasks, cursor, limit = 50) {
|
||||
+export const MAX_LIMIT = 50;
|
||||
+
|
||||
+export function paginate(tasks, cursor, limit = MAX_LIMIT) {
|
||||
const start = cursor ? tasks.findIndex((t) => t.id === cursor) + 1 : 0;
|
||||
- const page = tasks.slice(start, start + limit);
|
||||
+ const page = tasks.slice(start, start + Math.min(limit, MAX_LIMIT));
|
||||
return { tasks: page, nextCursor: page.length === limit ? page[page.length - 1].id : null };
|
||||
}
|
||||
diff --git a/src/tasks/routes.js b/src/tasks/routes.js
|
||||
new file mode 100644
|
||||
index 0000000..b7d5e22
|
||||
--- /dev/null
|
||||
+++ b/src/tasks/routes.js
|
||||
@@ -0,0 +1,14 @@
|
||||
+import { paginate } from "./paginate.js";
|
||||
+import { taskSchema } from "./schema.js";
|
||||
+
|
||||
+// The /tasks routes: list with paging and filters, create, update, delete.
|
||||
+export default async function routes(app) {
|
||||
+ app.get("/tasks", async (req) => {
|
||||
+ const { cursor, limit, status, assignee } = req.query;
|
||||
+ const all = await app.db.tasks.find({ status, assignee });
|
||||
+ return paginate(all, cursor, Number(limit) || undefined);
|
||||
+ });
|
||||
+
|
||||
+ app.post("/tasks", { schema: { body: taskSchema } }, async (req, reply) => {
|
||||
+ return reply.code(201).send(await app.db.tasks.insert(req.body));
|
||||
+ });
|
||||
+}
|
||||
diff --git a/src/tasks/schema.js b/src/tasks/schema.js
|
||||
new file mode 100644
|
||||
index 0000000..4d0e9a1
|
||||
--- /dev/null
|
||||
+++ b/src/tasks/schema.js
|
||||
@@ -0,0 +1,8 @@
|
||||
+// The Zod schema for a task.
|
||||
+export const taskSchema = {
|
||||
+ type: "object",
|
||||
+ required: ["title"],
|
||||
+ properties: {
|
||||
+ title: { type: "string", minLength: 1 },
|
||||
+ status: { enum: ["todo", "doing", "done"] },
|
||||
+ },
|
||||
+};
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"workflow": "deps",
|
||||
"title": "Update dependencies",
|
||||
"headline": { "stage": "Report", "cleared": 4, "total": 4, "confidence": "2 updates applied, 1 undone, 1 left alone." },
|
||||
"docs": [
|
||||
{
|
||||
"id": "report",
|
||||
"title": "Report",
|
||||
"blocks": [
|
||||
{
|
||||
"id": "report",
|
||||
"state": "settled",
|
||||
"md": "## What happened\n\n2 updates were applied and pass the tests. 1 update broke a test and was undone. 1 was left alone because it needs a newer Node.\n\n**Folder looked at:** `task-api` (npm, 4 updates).\n\n| Package | Change | Size | Outcome |\n| --- | --- | --- | --- |\n| `fastify` | 4.26.0 to 4.28.1 | small fix | Updated, tests pass |\n| `zod` | 3.22.4 to 3.23.8 | small fix | Updated, tests pass |\n| `pg` | 8.11.3 to 8.13.1 | new features | Undone: `test/db.test.js` failed after the update |\n| `pino` | 8.19.0 to 9.5.0 | big change | Not tried: needs Node 20, you declare 18 |\n\n**Still open:** no known security problems.\n\n**Changes already there before the run:** none.\n\nThe updates are not saved in git yet. The Git skill commits them."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"finish": {
|
||||
"headline": "2 updates applied, 1 undone, 1 not tried",
|
||||
"body": "`fastify` and `zod` are updated and `npm test` passes. `pg` broke `test/db.test.js` and was put back. `pino` needs Node 20, so it was left alone.",
|
||||
"command": "/plan2code-git",
|
||||
"doc": "report",
|
||||
"dashboard": true
|
||||
},
|
||||
"agent": { "status": "waiting" }
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"title": "task-api: Phase 3",
|
||||
"headline": { "stage": "Phase 3: API endpoints", "cleared": 11, "total": 11 },
|
||||
"items": [
|
||||
{
|
||||
"id": "lessons",
|
||||
"kind": "lessons",
|
||||
"title": "Lessons to keep",
|
||||
"body": "Choose for each one. Nothing is kept unless you choose it, and anything you leave keeps waiting.",
|
||||
"opening": null,
|
||||
"rows": [
|
||||
{
|
||||
"id": "l1",
|
||||
"type": "lesson",
|
||||
"text": "Every list endpoint pages with a cursor, never an offset.",
|
||||
"why": "Offsets skip rows when tasks are created while a client is paging.",
|
||||
"origin": "You said this.",
|
||||
"note": "",
|
||||
"flags": [],
|
||||
"refused": null,
|
||||
"area": "General",
|
||||
"kind": "convention",
|
||||
"about": ["src/tasks"],
|
||||
"areas": ["General"],
|
||||
"choices": ["Keep", "Reword", "Drop"]
|
||||
},
|
||||
{
|
||||
"id": "l2",
|
||||
"type": "lesson",
|
||||
"text": "Run a single test file with node --test test/tasks.test.js; npm test also starts the Postgres container.",
|
||||
"why": "",
|
||||
"origin": "Found by reading the code.",
|
||||
"note": "",
|
||||
"flags": [],
|
||||
"refused": null,
|
||||
"area": "General",
|
||||
"kind": "command",
|
||||
"about": ["test/tasks.test.js"],
|
||||
"areas": ["General"],
|
||||
"choices": ["Keep", "Reword", "Drop"]
|
||||
},
|
||||
{
|
||||
"id": "l3",
|
||||
"type": "lesson",
|
||||
"text": "Every error goes through errorShape() in src/app.js, so 400, 404 and 409 answer in one shape.",
|
||||
"why": "",
|
||||
"origin": "Found by reading the code.",
|
||||
"note": "",
|
||||
"flags": [],
|
||||
"refused": null,
|
||||
"area": "General",
|
||||
"kind": "how-it-works",
|
||||
"about": ["src/app.js"],
|
||||
"areas": ["General"],
|
||||
"choices": ["Keep", "Reword", "Drop"]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"agent": { "status": "waiting" }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"specDir":"specs/task-api"}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"docs": [
|
||||
{
|
||||
"id": "changes",
|
||||
"title": "Changes",
|
||||
"blocks": [
|
||||
{
|
||||
"id": "diff",
|
||||
"diff": "changes.diff"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -46,7 +46,7 @@ export const BUDGETS = {
|
||||
"review.md": 1140, // raised by the lessons card line's bytes only
|
||||
"revise-plan.md": 1422, // raised by the UI prototype line's bytes only
|
||||
"test.md": 5540, // raised by the lessons card line's bytes only
|
||||
"ui-prototype.md": 4000,
|
||||
"ui-prototype.md": 4600,
|
||||
"xray.md": 2500,
|
||||
},
|
||||
// One printed line each, for a session with one choice card.
|
||||
|
||||
@@ -315,7 +315,7 @@ test("framed, a finished screen with a button still to press is the person's mov
|
||||
const paused = await openSession(browser, { t, workflow: "implement", payload: WORKING, env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
|
||||
await until(async () => (await last(paused)) === "busy", 5000);
|
||||
paused.post({ finish: { headline: "Paused at Phase 2", command: "/plan2code-3-implement specs/audit-export/overview.md" } });
|
||||
await until(async () => (await paused.page.locator("#agent-text").textContent()).startsWith("Paused"), 5000);
|
||||
await until(async () => (await paused.page.locator("#agent-text").textContent()).startsWith("Stopped"), 5000);
|
||||
assert.equal(await last(paused), "plain", "a paused finish has nothing left to press");
|
||||
});
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ import {
|
||||
noteAction,
|
||||
noteReplyLines,
|
||||
pruneStaged,
|
||||
seedStaged,
|
||||
suggestAction,
|
||||
suggestReplyLines,
|
||||
progressTotal,
|
||||
@@ -103,6 +104,7 @@ import {
|
||||
loopLessonsLine,
|
||||
} from "../src/web-console/public/answers.js";
|
||||
import { chatView } from "../src/web-console/public/chat.js";
|
||||
import { agoWords, whenTitle, whenWords } from "../src/web-console/public/labels.js";
|
||||
import { ACCENTS, DEFAULT_ACCENT, RETIRED_ACCENTS, accentId } from "../src/web-console/public/palette.js";
|
||||
import {
|
||||
needsRoleNudge,
|
||||
@@ -606,6 +608,51 @@ test("pruneStaged drops a multi pick the re-posted card now locks, and leaves a
|
||||
assert.deepEqual(out.staged.c1.k, "A", "only a multi draws locked rows");
|
||||
});
|
||||
|
||||
test("seedStaged stages a multi card's starting ticks once, in option order, never touching its inputs", () => {
|
||||
const multi = (id, options, extra = {}) => ({ id, kind: "multi", status: "open", options, ...extra });
|
||||
const items = [multi("m1", [{ k: "A", text: "a", ticked: true }, { k: "B", text: "b" }, { k: "C", text: "c", ticked: true }])];
|
||||
const staged = {};
|
||||
const seeded = {};
|
||||
const out = seedStaged(items, staged, seeded);
|
||||
assert.equal(out.changed, true);
|
||||
assert.deepEqual(out.staged.m1, { type: "answer", kind: "multi", ks: ["A", "C"] });
|
||||
assert.deepEqual(out.seeded, { m1: true });
|
||||
assert.deepEqual(staged, {});
|
||||
assert.deepEqual(seeded, {});
|
||||
|
||||
// Once: after the person clears it, the returned seeded mark keeps it cleared.
|
||||
const again = seedStaged(items, {}, out.seeded);
|
||||
assert.equal(again.changed, false);
|
||||
assert.deepEqual(again.staged, {});
|
||||
// Reopened with the same id: still seeded once.
|
||||
assert.equal(seedStaged([{ ...items[0], status: "reopened" }], {}, out.seeded).changed, false);
|
||||
assert.equal(seedStaged([{ ...items[0], status: "reopened" }], {}, {}).changed, true);
|
||||
|
||||
// Left alone: already staged, already sent, settled, a choice, no ticked row.
|
||||
const mine = { m1: { type: "answer", kind: "multi", ks: ["B"] } };
|
||||
assert.deepEqual(seedStaged(items, mine, {}).staged, mine);
|
||||
assert.equal(seedStaged(items, {}, {}, { m1: { at: 1 } }).changed, false);
|
||||
assert.equal(seedStaged([{ ...items[0], status: "answered" }], {}, {}).changed, false);
|
||||
assert.equal(seedStaged([{ ...items[0], kind: "choice" }], {}, {}).changed, false);
|
||||
assert.equal(seedStaged([multi("m2", [{ k: "A", text: "a" }, { k: "B", text: "b", ticked: false }])], {}, {}).changed, false);
|
||||
|
||||
// A locked row is never seeded, even if it says ticked.
|
||||
const locked = seedStaged([multi("m3", [{ k: "A", text: "a", ticked: true, locked: true }, { k: "B", text: "b", ticked: true }])], {}, {});
|
||||
assert.deepEqual(locked.staged.m3.ks, ["B"]);
|
||||
assert.equal(seedStaged([multi("m4", [{ k: "A", text: "a", ticked: true, locked: true }])], {}, {}).changed, false);
|
||||
});
|
||||
|
||||
test("answerLines says None ticked for an empty pick on a card that started ticked, and nothing new for other cards", () => {
|
||||
const item = { id: "m1", kind: "multi", options: [{ k: "A", text: "Colors", ticked: true }] };
|
||||
assert.deepEqual(answerLines(item, { type: "answer", kind: "multi", ks: [] }), ["None ticked"]);
|
||||
// A multi without starting ticks keeps its record as before, note-only picks included.
|
||||
const plain = { id: "m2", kind: "multi", options: [{ k: "A", text: "Colors" }] };
|
||||
assert.deepEqual(answerLines(plain, { type: "answer", kind: "multi", ks: [], text: "a note" }), []);
|
||||
assert.deepEqual(answerLines(item, { type: "answer", kind: "multi", ks: ["A"] }), ["A · Colors"]);
|
||||
assert.deepEqual(answerLines(item, { skipped: true, ks: [] }), ["Skipped"]);
|
||||
assert.deepEqual(answerLines({ id: "c1", kind: "choice", options: [] }, { ks: [] }), []);
|
||||
});
|
||||
|
||||
test("document helpers: the extension allow-list, the picker's accept, sizes, and the kind of an old entry", () => {
|
||||
assert.equal(MAX_ATTACHMENTS, 5);
|
||||
assert.equal(MAX_DOC_BYTES, 10 * 1024 * 1024);
|
||||
@@ -763,6 +810,7 @@ const contrast = (a, b) => {
|
||||
|
||||
test("every highlight color is readable in both themes", () => {
|
||||
const panel = { light: "#ffffff", dark: "#201d1a" };
|
||||
const page = { light: "#f6f3ee", dark: "#171513" };
|
||||
// Nineteen a row in the wide Preferences dialog, two rows at most.
|
||||
assert.ok(Object.keys(ACCENTS).length >= 32 && Object.keys(ACCENTS).length <= 38);
|
||||
assert.ok(ACCENTS[DEFAULT_ACCENT], "the default must be in the list");
|
||||
@@ -775,6 +823,7 @@ test("every highlight color is readable in both themes", () => {
|
||||
for (const c of a[theme]) assert.match(c, /^#[0-9a-f]{6}$/, `${id} ${theme}: ${c}`);
|
||||
assert.ok(contrast(ink, fill) >= 4.5, `${id} ${theme}: label on the fill is ${contrast(ink, fill).toFixed(2)}:1`);
|
||||
assert.ok(contrast(fill, soft) >= 4.5, `${id} ${theme}: badge text on the tint is ${contrast(fill, soft).toFixed(2)}:1`);
|
||||
assert.ok(contrast(fill, page[theme]) >= 4.5, `${id} ${theme}: accent text on the page is ${contrast(fill, page[theme]).toFixed(2)}:1`);
|
||||
assert.ok(contrast(line, panel[theme]) >= 1.8, `${id} ${theme}: border barely shows at ${contrast(line, panel[theme]).toFixed(2)}:1`);
|
||||
}
|
||||
}
|
||||
@@ -1720,6 +1769,21 @@ test("validate: a multi's pick-list fields are checked only when present, each r
|
||||
refused(notMulti, "counter:", "only a multi");
|
||||
// Every refusal carries the field done right, as the other rules do.
|
||||
for (const p of multi([opt("A", { group: "" })])) assert.match(p, /\{/);
|
||||
|
||||
// Starting ticks and row pills: accepted in shape, refused out of it.
|
||||
assert.deepEqual(multi([opt("A", { ticked: true, tag: "Keep" }), opt("B", { ticked: false, tag: "Free up" }), opt("C", { tag: "T".repeat(16) })]), []);
|
||||
assert.deepEqual(multi([opt("A", { ticked: true }), opt("B", { locked: true, ticked: false })]), []);
|
||||
refused(multi([opt("A", { ticked: "yes" })]), "options:", 'option "A"', '"ticked"', "true or false");
|
||||
refused(multi([opt("A", { ticked: true, locked: true })]), 'option "A"', "locked and ticked", 'Drop "ticked"');
|
||||
refused(multi([opt("A", { tag: "" })]), 'option "A"', '"tag"', "1 to 16");
|
||||
refused(multi([opt("A", { tag: " " })]), 'option "A"', '"tag"');
|
||||
refused(multi([opt("A", { tag: "T".repeat(17) })]), 'option "A"', '"tag"');
|
||||
refused(multi([opt("A", { tag: 5 })]), 'option "A"', '"tag"');
|
||||
for (const p of multi([opt("A", { ticked: "yes" })])) assert.match(p, /\{/);
|
||||
const onChoice = (extra) => validate({ items: [{ id: "picks", kind: "choice", title: "Pick one", status: "open", options: [opt("A", extra), opt("B")] }] });
|
||||
refused(onChoice({ ticked: true }), 'option "A"', '"ticked"', "only goes on a multi");
|
||||
refused(onChoice({ tag: "Keep" }), 'option "A"', '"tag"', "only goes on a multi");
|
||||
assert.deepEqual(onChoice({}), []);
|
||||
});
|
||||
|
||||
test("lessons answers: a line per decision, what was left waiting, and the decisions file's JSON", () => {
|
||||
@@ -1911,15 +1975,15 @@ test("meter: levels, ring, fold and tooltip wording", () => {
|
||||
);
|
||||
assert.equal(pointsFrom([{ kind: "folder-issue", id: "L1:api", name: "api", reason: "denied" }]), 0);
|
||||
|
||||
assert.equal(tooltipFor(1), "This session is fresh (1 point).");
|
||||
assert.equal(tooltipFor(1), "This conversation is fresh (1 point).");
|
||||
assert.match(tooltipFor(5), /getting long \(5 points\)/);
|
||||
assert.match(tooltipFor(10), /done a lot \(10 points\)/);
|
||||
assert.deepEqual(meterView([{ kind: "launch", id: "L1", workflow: "document" }]), {
|
||||
points: 2,
|
||||
level: "green",
|
||||
fraction: 2 / 15,
|
||||
words: "Session: fresh",
|
||||
tooltip: "This session is fresh (2 points).",
|
||||
words: "Conversation: fresh",
|
||||
tooltip: "This conversation is fresh (2 points).",
|
||||
items: [{ label: "Document started", points: 2 }],
|
||||
});
|
||||
});
|
||||
@@ -2850,3 +2914,26 @@ test("a refused patch leaves state.json byte for byte as it was", () => {
|
||||
cli(["stop", "--session", s.sid, "--force"]);
|
||||
}
|
||||
});
|
||||
|
||||
test("whenWords writes how long ago, then the short date and time, against a fixed now", () => {
|
||||
const now = Date.parse("2026-11-15T21:42:00Z");
|
||||
const at = (offsetMs) => new Date(now - offsetMs).toISOString();
|
||||
const H = 3_600_000;
|
||||
const stamp = (ms) => new Date(now - ms).toLocaleString(undefined, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" });
|
||||
assert.equal(whenWords(at(6 * H), now), `6 h ago · ${stamp(6 * H)}`);
|
||||
assert.equal(whenWords(at(30_000), now).split(" · ")[0], "just now");
|
||||
assert.equal(whenWords(at(5 * 60_000), now).split(" · ")[0], "5 min ago");
|
||||
assert.equal(whenWords(at(26 * H), now).split(" · ")[0], "1 day ago");
|
||||
assert.equal(whenWords(at(5 * 24 * H), now).split(" · ")[0], "5 days ago");
|
||||
assert.equal(whenWords(at(42 * 24 * H), now).split(" · ")[0], "6 weeks ago");
|
||||
assert.equal(whenWords(at(120 * 24 * H), now).split(" · ")[0], "4 months ago");
|
||||
assert.equal(whenWords(at(800 * 24 * H), now).split(" · ")[0], "2 years ago");
|
||||
// A time ahead of the clock is just now, and nothing readable gives nothing.
|
||||
assert.equal(whenWords(at(-H), now).split(" · ")[0], "just now");
|
||||
for (const bad of ["", null, undefined, "not a date"]) assert.equal(whenWords(bad, now), "");
|
||||
// A different year names the year, and the full stamp is the title's.
|
||||
assert.match(whenWords(at(800 * 24 * H), now), /[0-9]{4}/);
|
||||
assert.equal(whenTitle(at(H)), new Date(now - H).toLocaleString());
|
||||
assert.equal(whenTitle("nope"), "");
|
||||
assert.equal(agoWords(59 * 60_000), "59 min ago");
|
||||
});
|
||||
@@ -1430,7 +1430,7 @@ test("page rules: dropTab puts a tab just before another, or at the end", () =>
|
||||
test("page rules: the tab codes have sentences of their own", () => {
|
||||
for (const code of ["bad-name", "duplicate-name", "too-many-tabs", "no-such-tab"]) assert.ok(rules.ERROR_CODES.includes(code), code);
|
||||
assert.equal(rules.errorSentence("duplicate-name"), "There is already a tab with that name.");
|
||||
assert.equal(rules.errorSentence("no-such-tab"), "That tab is no longer in this notepad.");
|
||||
assert.equal(rules.errorSentence("no-such-tab"), "That tab is no longer in this Notebook.");
|
||||
assert.match(rules.errorSentence("too-many-tabs"), new RegExp(String(NOTEPAD_MAX_TABS)));
|
||||
});
|
||||
|
||||
|
||||
@@ -1850,6 +1850,8 @@ test("a drag on the board reaches a pointer game, a question mid-drag cancels it
|
||||
await openActivities(s);
|
||||
await s.page.keyboard.press(" ");
|
||||
assert.equal(await overlay(s), "", "running");
|
||||
// The dialog's opening motion must be over before the canvas is measured, or the box moves under the press.
|
||||
await s.page.evaluate(() => Promise.all(document.getAnimations().filter((a) => a.effect && a.effect.getTiming().iterations !== Infinity).map((a) => a.finished.catch(() => {}))));
|
||||
const box = await s.page.locator("#activities-canvas").boundingBox();
|
||||
const at = (dx, dy) => [box.x + dx, box.y + dy];
|
||||
await s.page.mouse.move(...at(40, 40));
|
||||
|
||||
@@ -342,6 +342,46 @@ test("the Subagents dialog shows the saved strength, explains the picked one, go
|
||||
assert.match(await textOf(help), /One step lighter everywhere/);
|
||||
});
|
||||
|
||||
// An unsaved edit never leaves the dialog silently: Cancel, Esc or a click
|
||||
// outside ask first, in Preferences' order, with focus on Keep editing.
|
||||
test("the Subagents dialog asks before it drops an edit, in Preferences' order, and closes at once when nothing changed", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "implement",
|
||||
payload: { agent: { status: "working", activity: "Task 1 of 2" } },
|
||||
});
|
||||
const modal = s.page.locator("#subagents-modal");
|
||||
const ask = modal.locator("#subagents-unsaved");
|
||||
const open = async () => {
|
||||
await s.page.locator("#btn-subagents").click();
|
||||
await modal.waitFor();
|
||||
};
|
||||
|
||||
await open();
|
||||
await modal.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await modal.waitFor({ state: "hidden" });
|
||||
|
||||
await open();
|
||||
await modal.locator('input[name="subagents-strength"][value="best"]').check();
|
||||
await modal.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await ask.waitFor();
|
||||
assert.match(await textOf(ask), /Discard your changes?/);
|
||||
assert.deepEqual(await ask.getByRole("button").allTextContents(), ["Keep editing", "Discard", "Save"]);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.id), "subagents-unsaved-keep", "focus starts on Keep editing");
|
||||
await ask.getByRole("button", { name: "Keep editing" }).click();
|
||||
await ask.waitFor({ state: "hidden" });
|
||||
assert.equal(await modal.evaluate((d) => d.open), true, "Keep editing leaves the dialog open");
|
||||
assert.equal(await modal.locator('input[name="subagents-strength"][value="best"]').isChecked(), true, "and the edit stays");
|
||||
|
||||
await s.page.keyboard.press("Escape");
|
||||
await ask.waitFor();
|
||||
await ask.getByRole("button", { name: "Discard" }).click();
|
||||
await modal.waitFor({ state: "hidden" });
|
||||
|
||||
await open();
|
||||
assert.equal(await modal.locator('input[name="subagents-strength"][value="balanced"]').isChecked(), true, "Discard dropped the edit");
|
||||
});
|
||||
|
||||
// What a person sees break: the strength a helper ran with missing from the
|
||||
// tab, or a stray line under a helper that reported none.
|
||||
test("the Subagents tab shows a reported helper's strength line and none for a helper without one", async (t) => {
|
||||
@@ -535,3 +575,27 @@ test("the Ask for suggestions chip stays away while the loop drives, even on a c
|
||||
await s.page.locator("#thread-c1").waitFor();
|
||||
assert.equal(await chipOf(s).count(), 0, "no chip while the loop drives");
|
||||
});
|
||||
|
||||
// The top bar names its tools: the gear says User Preferences, and the home and
|
||||
// Subagents buttons carry a text label beside the icon above the narrow
|
||||
// breakpoint. The Subagents button opens a dialog, so it is not a toggle.
|
||||
test("the top bar names User Preferences, Dashboard and Subagents, and Subagents opens a dialog instead of toggling", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "implement",
|
||||
payload: { agent: { status: "working", activity: "Task 1 of 2" } },
|
||||
});
|
||||
await s.page.setViewportSize({ width: 1200, height: 800 });
|
||||
const gear = s.page.locator("#btn-looks");
|
||||
assert.equal(await gear.getAttribute("title"), "User Preferences");
|
||||
assert.equal(await gear.getAttribute("aria-label"), "User Preferences");
|
||||
const subs = s.page.locator("#btn-subagents");
|
||||
await subs.waitFor();
|
||||
assert.match(await textOf(subs), /^Subagents: (on|off)$/, "a text label beside the icon");
|
||||
assert.equal(await subs.getAttribute("aria-haspopup"), "dialog");
|
||||
assert.equal(await subs.getAttribute("aria-pressed"), null, "not a toggle");
|
||||
assert.match((await subs.getAttribute("aria-label")) || "", /^Subagents: (on|off)$/, "the state is in the label");
|
||||
assert.match(await textOf(s.page.locator("#btn-home")), /^Dashboard$/, "the way home is named");
|
||||
await s.page.setViewportSize({ width: 600, height: 800 });
|
||||
await s.page.waitForFunction(() => getComputedStyle(document.querySelector("#btn-subagents .topbar-label")).display === "none");
|
||||
});
|
||||
@@ -11,7 +11,7 @@ import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { gitInit } from "./skill-script-helpers.mjs";
|
||||
import { pageSuite, openSession, tempProject, sendAndCollect, itemCard, scrollTopOf, scrollCard, stylesOf, styleOf , fillBox, boxValue, settled } from "./page-test-helpers.mjs";
|
||||
import { pageSuite, openSession, tempProject, sendAndCollect, drawn, itemCard, scrollTopOf, scrollCard, stylesOf, styleOf , fillBox, boxValue, settled } from "./page-test-helpers.mjs";
|
||||
|
||||
const suite = pageSuite(test);
|
||||
|
||||
@@ -992,3 +992,114 @@ test("a long pick list draws group headings, opens a row, holds a locked row and
|
||||
const got = await sendAndCollect(s);
|
||||
assert.deepEqual(answerTo(got, "deps").ks.sort(), ["C1", "S1"], "the locked row never reaches the agent");
|
||||
});
|
||||
|
||||
// A multi card that starts with ticks (`ticked`) and notes its rows with a pill (`tag`).
|
||||
const carry = (extra = {}) => ({
|
||||
id: "carry",
|
||||
kind: "multi",
|
||||
title: "Carry over",
|
||||
body: "What to keep from your app.",
|
||||
options: [
|
||||
{ k: "A", text: "Colors", ticked: true, tag: "Keep", detail: "You did not ask to change them." },
|
||||
{ k: "B", text: "Layout", tag: "Free up", detail: "You asked to rethink the table." },
|
||||
{ k: "C", text: "Fonts", ticked: true, tag: "Keep" },
|
||||
],
|
||||
...extra,
|
||||
});
|
||||
|
||||
test("a multi's ticked rows open ticked and ready to send, its tags draw as pills the checkbox names, and sending untouched sends the ticks", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan" });
|
||||
const card = await ask(s, carry());
|
||||
|
||||
assert.equal(await card.getByLabel("A: Colors").isChecked(), true);
|
||||
assert.equal(await card.getByLabel("B: Layout").isChecked(), false);
|
||||
assert.equal(await card.getByLabel("C: Fonts").isChecked(), true);
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), false, "ready to send without a click");
|
||||
|
||||
// The pill is text on the row and part of the checkbox's accessible name (the key prefix stays).
|
||||
assert.deepEqual(await card.locator(".pill.tag").allTextContents(), ["Keep", "Free up", "Keep"]);
|
||||
assert.equal(await card.getByLabel("A: Colors, Keep").count(), 1);
|
||||
assert.equal(await card.getByLabel("B: Layout, Free up").count(), 1);
|
||||
// The pill is the agent's note: ticking a row does not move it.
|
||||
await card.getByLabel("B: Layout").check();
|
||||
assert.deepEqual(await card.locator(".pill.tag").allTextContents(), ["Keep", "Free up", "Keep"]);
|
||||
await card.getByLabel("B: Layout").uncheck();
|
||||
|
||||
const got = await sendAndCollect(s);
|
||||
assert.deepEqual(answerTo(got, "carry"), { ks: ["A", "C"] });
|
||||
assert.equal(got.reply, "Carry over: A, C");
|
||||
});
|
||||
|
||||
test("unticking every starting tick is an answer that reads none, and a cleared card is never re-ticked by a redraw or a reload", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan" });
|
||||
const card = await ask(s, carry());
|
||||
|
||||
await card.getByLabel("A: Colors").uncheck();
|
||||
await card.getByLabel("C: Fonts").uncheck();
|
||||
await card.getByLabel("C: Fonts").waitFor();
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), false, "an empty pick on a card with starting ticks is still sendable");
|
||||
|
||||
// An agent post redraws the page: the card stays cleared.
|
||||
s.post({ title: "Carry over", agent: { status: "waiting" } });
|
||||
await settled(s.page, "#main");
|
||||
assert.equal(await card.getByLabel("A: Colors").isChecked(), false);
|
||||
assert.equal(await card.getByLabel("C: Fonts").isChecked(), false);
|
||||
|
||||
// So does a reload.
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
const again = itemCard(s.page, "carry");
|
||||
await again.waitFor();
|
||||
await settled(s.page, "#main");
|
||||
assert.equal(await again.getByLabel("A: Colors").isChecked(), false, "a reload never re-ticks a cleared card");
|
||||
assert.equal(await again.getByLabel("C: Fonts").isChecked(), false);
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), false);
|
||||
|
||||
const got = await sendAndCollect(s);
|
||||
assert.deepEqual(answerTo(got, "carry"), { ks: [] });
|
||||
assert.match(got.reply, /none$/);
|
||||
});
|
||||
|
||||
test("clearing the note on a card with starting ticks keeps its empty pick, so the card stays sendable", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan" });
|
||||
const card = await ask(s, carry());
|
||||
await card.getByLabel("A: Colors").uncheck();
|
||||
await card.getByLabel("C: Fonts").uncheck();
|
||||
const box = card.locator(".md-host");
|
||||
await fillBox(box, "only the logo");
|
||||
await fillBox(box, "");
|
||||
await settled(s.page, "#main");
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), false, "the empty pick is still an answer");
|
||||
const got = await sendAndCollect(s);
|
||||
assert.deepEqual(answerTo(got, "carry"), { ks: [] });
|
||||
});
|
||||
|
||||
test("a card with starting ticks cleared and sent with a note still says none, then the note", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan" });
|
||||
const card = await ask(s, carry());
|
||||
await card.getByLabel("A: Colors").uncheck();
|
||||
await card.getByLabel("C: Fonts").uncheck();
|
||||
await fillBox(card.locator(".md-host"), "keep the logo");
|
||||
await settled(s.page, "#main");
|
||||
const got = await sendAndCollect(s);
|
||||
assert.deepEqual(answerTo(got, "carry"), { ks: [], text: "keep the logo" });
|
||||
assert.equal(got.reply, "Carry over: none; keep the logo", "the agent hears the cleared pick, not the note alone");
|
||||
});
|
||||
|
||||
test("a multi with no ticked row still opens empty, and unticking its last box stages nothing", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan" });
|
||||
const card = await ask(s, {
|
||||
id: "plain",
|
||||
kind: "multi",
|
||||
title: "Columns",
|
||||
body: "Which?",
|
||||
options: [opt("1", "Date"), opt("2", "User")],
|
||||
});
|
||||
assert.equal(await card.getByLabel("Date").isChecked(), false);
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), true, "nothing ticked, nothing to send");
|
||||
await card.getByLabel("Date").check();
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), false);
|
||||
await card.getByLabel("Date").uncheck();
|
||||
await settled(s.page, "#main");
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), true, "unticking the last box is no answer, as before");
|
||||
});
|
||||
@@ -126,12 +126,12 @@ async function toTheMenu(s) {
|
||||
return main;
|
||||
}
|
||||
|
||||
// Sets the picker's "Hide unavailable workflows" switch. Looks are kept per
|
||||
// Sets the picker's "Hide unavailable skills" switch. Looks are kept per
|
||||
// console home, so each test sets the one it needs rather than trusting the
|
||||
// default.
|
||||
async function hideUnavailable(main, on) {
|
||||
const box = main.getByRole("switch", { name: "Hide unavailable workflows" });
|
||||
if ((await box.isChecked()) !== on) await main.getByText("Hide unavailable workflows").click();
|
||||
const box = main.getByRole("switch", { name: "Hide unavailable skills" });
|
||||
if ((await box.isChecked()) !== on) await main.getByText("Hide unavailable skills").click();
|
||||
assert.equal(await box.isChecked(), on);
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ test("a handoff shows as a dashed Handoff chip even with no spec, and picking it
|
||||
assert.equal(await main.getByRole("button", { name, exact: true }).count(), 1, `the preview has ${name}`);
|
||||
}
|
||||
assert.equal(await lightOf(main, "/plan2code-1-plan").count(), 0, "the skill cards give way to the preview");
|
||||
assert.equal(await main.getByRole("switch", { name: "Hide unavailable workflows" }).count(), 0, "and so does their toggle");
|
||||
assert.equal(await main.getByRole("switch", { name: "Hide unavailable skills" }).count(), 0, "and so does their toggle");
|
||||
});
|
||||
|
||||
// What a person would see break: Pick it up here sends nothing, or sends more
|
||||
@@ -553,21 +553,21 @@ test("the update banner shows on the dashboard only, and its dismiss hides it",
|
||||
const build = await openSession(browser, { t, workflow: "implement", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
const dash = await openSession(browser, { t, workflow: "dashboard", payload: MENU, project: tempProject(DRAFT_PROJECT) });
|
||||
const main = await toTheMenu(dash);
|
||||
const banner = main.getByRole("button", { name: /UPDATE AVAILABLE · v99\.0\.0/ });
|
||||
const banner = main.getByRole("button", { name: /Update available · v99\.0\.0/ });
|
||||
await banner.waitFor();
|
||||
// The build's server booted under the same record; a later frame has landed
|
||||
// on its page by the time this text shows, and it still has no banner.
|
||||
build.post({ agent: { status: "working", activity: "Task 1 of 1, one more look" } });
|
||||
await build.page.getByText("Task 1 of 1, one more look").first().waitFor();
|
||||
assert.equal(await build.page.getByText("UPDATE AVAILABLE").count(), 0, "a build's page has no banner");
|
||||
assert.equal(await build.page.getByText("Update available").count(), 0, "a build's page has no banner");
|
||||
|
||||
await main.getByRole("button", { name: "Dismiss until next time" }).click();
|
||||
await banner.waitFor({ state: "hidden" });
|
||||
});
|
||||
|
||||
// Under the desktop app (PLAN2CODE_IN_APP=1) the banner shows too: the app
|
||||
// cannot replace itself, so a new release is a terminal command there as well,
|
||||
// and the modal says to run it outside the app and reopen the app.
|
||||
// Under the desktop app (PLAN2CODE_IN_APP=1) the banner shows too: the modal
|
||||
// points at the bar's Update and restart first, and keeps the command as the
|
||||
// fallback, run outside the app, then the app reopened.
|
||||
test("under the app, the update banner shows and its steps are worded for the app", async (t) => {
|
||||
aNewerReleaseExists(t);
|
||||
const dash = await openSession(await suite.browser(), {
|
||||
@@ -578,9 +578,10 @@ test("under the app, the update banner shows and its steps are worded for the ap
|
||||
env: { PLAN2CODE_IN_APP: "1" },
|
||||
});
|
||||
const main = await toTheMenu(dash);
|
||||
await main.getByRole("button", { name: /UPDATE AVAILABLE · v99\.0\.0/ }).click();
|
||||
await main.getByRole("button", { name: /Update available · v99\.0\.0/ }).click();
|
||||
const modal = dash.page.locator("#update-modal");
|
||||
await modal.waitFor();
|
||||
await modal.locator("#update-step-run strong", { hasText: "Update and restart" }).waitFor();
|
||||
await modal.getByText("a terminal outside the app", { exact: false }).waitFor();
|
||||
await modal.getByText("close the app and open it again", { exact: false }).waitFor();
|
||||
assert.equal(await modal.locator("#update-command code").textContent(), "plan2code update");
|
||||
@@ -866,3 +867,58 @@ test("every group keeps one card width and leaves no card alone on a row, at eac
|
||||
assert.ok(settled, `at ${width}, ${want} across, every row holding two cards or more, all one width: ${JSON.stringify(rows)}`);
|
||||
}
|
||||
});
|
||||
|
||||
// First run: until a skill has been launched from this machine, the dashboard
|
||||
// offers one call to action. The role line is held and Learning "Not set up"
|
||||
// waits at the bottom; after the first launch the quiet line shows.
|
||||
function savedLooksFile(t, looks) {
|
||||
const file = path.join(HOME, "looks.json");
|
||||
fs.mkdirSync(HOME, { recursive: true });
|
||||
fs.writeFileSync(file, JSON.stringify({ looks }));
|
||||
t.after(() => fs.rmSync(file, { force: true }));
|
||||
}
|
||||
|
||||
test("before the first launch the dashboard holds the role line and draws Learning at the bottom", async (t) => {
|
||||
savedLooksFile(t, { welcomeSeen: true });
|
||||
const project = tempProject(DRAFT_PROJECT);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: MENU, project });
|
||||
const main = await toTheMenu(s);
|
||||
assert.equal(await main.locator(".dash-extras").count(), 0, "no optional extras on the first dashboard");
|
||||
assert.equal(await main.locator(".dash-nudge").filter({ hasText: "role" }).count(), 0, "and no role banner");
|
||||
await main.locator(".learn-row.is-not-set-up").waitFor();
|
||||
assert.equal(await main.locator(".learn-row.is-top").count(), 0, "Learning Not set up is not at the top");
|
||||
assert.equal(await main.locator(".learn-row.is-bottom.is-not-set-up").count(), 1, "it sits at the bottom");
|
||||
assert.doesNotMatch(await main.locator(".learn-row .btn").first().getAttribute("class"), /primary/, "with a plain button");
|
||||
});
|
||||
|
||||
test("after the first launch one quiet line offers the role and Learning, and a launch sets the flag", async (t) => {
|
||||
savedLooksFile(t, { welcomeSeen: true });
|
||||
const project = tempProject(DRAFT_PROJECT);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: MENU, project });
|
||||
const main = await toTheMenu(s);
|
||||
assert.equal(await main.locator(".dash-extras").count(), 0);
|
||||
const planCard = main.getByRole("button").filter({ has: s.page.locator("code", { hasText: /^\/plan2code-1-plan$/ }) });
|
||||
await planCard.click();
|
||||
await main.getByRole("button", { name: "Start Plan" }).click();
|
||||
assert.ok(
|
||||
await until(() => s.page.evaluate(async () => ((await (await fetch("/looks")).json()).looks || {}).skillLaunched === true)),
|
||||
"the first launch saved the flag"
|
||||
);
|
||||
// Back to default keeps it.
|
||||
const kept = await s.page.evaluate(async () => {
|
||||
const { resetLooks, looks } = await import("/looks.js");
|
||||
resetLooks();
|
||||
return (await import("/looks.js")).looks.skillLaunched;
|
||||
});
|
||||
assert.equal(kept, true, "Back to default never clears the flag");
|
||||
});
|
||||
|
||||
test("with the flag set the dashboard shows the quiet extras line", async (t) => {
|
||||
savedLooksFile(t, { welcomeSeen: true, skillLaunched: true });
|
||||
const project = tempProject(DRAFT_PROJECT);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: MENU, project });
|
||||
const main = await toTheMenu(s);
|
||||
const line = main.locator(".dash-extras");
|
||||
await line.waitFor();
|
||||
assert.match(await textOf(line), /Two optional extras: set your role, switch on Learning\./);
|
||||
});
|
||||
@@ -220,7 +220,7 @@ test("the commit table keeps the person's ticks across an agent post, and a clic
|
||||
assert.equal(await tickBox(page, "notes.md").isChecked(), false, "an agent post put the tick back");
|
||||
assert.equal(await tickBox(page, "src/app.js").isChecked(), true);
|
||||
// Their click goes out with the one file. Then the agent commits it and a new file turns up.
|
||||
await page.locator(".git-panel-actions").getByRole("button", { name: "Commit 1 file" }).click();
|
||||
await stepButton(page, "Commit 1 file").click();
|
||||
assert.deepEqual(s.wait(10).actions[0].files, ["src/app.js"]);
|
||||
const g = gitInit(dir, "feature/x");
|
||||
g("add", "src/app.js");
|
||||
@@ -311,3 +311,32 @@ test("over the git board a note box grows with its text, and the no-repo note on
|
||||
await itemCard(bare.page, "y1").waitFor();
|
||||
assert.match(await textOf(aside), /asks above what to do/);
|
||||
});
|
||||
|
||||
// The three W25 leftovers, checked against the current build.
|
||||
test("the Changes tab offers one Commit N files, Send is gone with nothing to send, and Done with git sits outside the tablist", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "git", project: changesProject({ branch: "feature/x" }), payload: READY });
|
||||
const { page } = s;
|
||||
await page.getByRole("tablist").waitFor();
|
||||
await stepButton(page, "Commit 2 files").waitFor();
|
||||
// One Commit N files across the whole board, not one in the step and one in the table.
|
||||
assert.equal(await page.getByRole("button", { name: /^Commit \d+ files?$/ }).count(), 1, "one commit button on the Changes tab");
|
||||
assert.equal(await page.locator(".git-panel-actions").getByRole("button", { name: /^Commit \d+ files?$/ }).count(), 0, "the table carries no second one");
|
||||
// Unticking a file moves the one button's count.
|
||||
await tickBox(page, "notes.md").uncheck();
|
||||
await stepButton(page, "Commit 1 file").waitFor();
|
||||
|
||||
// No open card and nothing staged: the footer keeps its words, the Send button is not drawn.
|
||||
assert.equal(await page.locator("#btn-send").isHidden(), true, "no Send button on a board with nothing to send");
|
||||
assert.match((await page.locator("#footer-summary").innerText()).trim(), /Nothing to send yet/, "the status words stay");
|
||||
|
||||
// Done with git is beside the tablist, not one of its tabs, and at the right end of the row.
|
||||
const done = page.getByRole("button", { name: "Done with git" });
|
||||
assert.equal(await page.getByRole("tablist").getByRole("button", { name: "Done with git" }).count(), 0, "not inside the tablist");
|
||||
const [tabs, btn] = await Promise.all([page.getByRole("tablist").boundingBox(), done.boundingBox()]);
|
||||
assert.ok(btn.x >= tabs.x + tabs.width - 1, "to the right of the tabs");
|
||||
});
|
||||
|
||||
test("a card open on the board brings the Send button back", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "git", project: changesProject({ branch: "feature/x" }), payload: { ...READY, items: [confirmCard] } });
|
||||
await s.page.locator("#btn-send").waitFor({ state: "visible" });
|
||||
});
|
||||
@@ -11,7 +11,7 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { pageSuite, openSession, tempProject, textOf, drawn , fillBox} from "./page-test-helpers.mjs";
|
||||
import { pageSuite, openSession, tempProject, textOf, drawn, fillBox, itemCard, boxValue } from "./page-test-helpers.mjs";
|
||||
import { HOME, cli, until } from "./web-console-test-helpers.mjs";
|
||||
import { HELP_TABS } from "../src/web-console/public/help.js";
|
||||
import { CATALOG_GROUPS, SKILL_CATALOG } from "../src/web-console/public/answers.js";
|
||||
@@ -274,7 +274,7 @@ test("the update banner opens a modal with the exact update commands, and its di
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: { agent: { status: "waiting" } }, project: tempProject() });
|
||||
await toTheDashboard(s);
|
||||
const main = s.page.locator("#main");
|
||||
await main.getByRole("button", { name: /UPDATE AVAILABLE · v99\.0\.0/ }).click();
|
||||
await main.getByRole("button", { name: /Update available · v99\.0\.0/ }).click();
|
||||
|
||||
const modal = s.page.locator("#update-modal");
|
||||
await modal.waitFor();
|
||||
@@ -283,21 +283,27 @@ test("the update banner opens a modal with the exact update commands, and its di
|
||||
assert.equal(await releases.getAttribute("href"), RELEASES_URL);
|
||||
assert.equal(await releases.getAttribute("rel"), "noopener noreferrer");
|
||||
assert.equal(await textOf(s.page.locator("#update-command code")), "plan2code update");
|
||||
// Step 1 is one sentence and the command; the rest waits in a closed disclosure.
|
||||
const more = s.page.locator("#update-more");
|
||||
assert.equal(await more.evaluate((node) => node.open), false, "the extra help starts closed");
|
||||
assert.equal(await textOf(more.locator("summary")), "Command not found, or nothing happened?");
|
||||
await more.locator("summary").click();
|
||||
assert.equal(
|
||||
await textOf(s.page.locator("#update-fallback code")),
|
||||
"npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git"
|
||||
"npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git#release"
|
||||
);
|
||||
assert.match(await textOf(more), /git ls-remote https:\/\/github\.com\/jparkerweb\/plan2code\.git/);
|
||||
await s.page.locator("#update-done").click();
|
||||
await modal.waitFor({ state: "hidden" });
|
||||
|
||||
// The ×: gone now, remembered under this session's key, and still gone after a reload.
|
||||
await main.getByRole("button", { name: "Dismiss until next time" }).click();
|
||||
await main.getByRole("button", { name: /UPDATE AVAILABLE/ }).waitFor({ state: "hidden" });
|
||||
await main.getByRole("button", { name: /Update available/ }).waitFor({ state: "hidden" });
|
||||
assert.equal(await s.page.evaluate((k) => sessionStorage.getItem(k), "p2c-update-dismissed:" + s.sid), "99.0.0");
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
await toTheDashboard(s);
|
||||
assert.equal(await main.getByRole("button", { name: /UPDATE AVAILABLE/ }).count(), 0, "the banner came back after a reload");
|
||||
assert.equal(await main.getByRole("button", { name: /Update available/ }).count(), 0, "the banner came back after a reload");
|
||||
});
|
||||
|
||||
// Under the app Help's update line names both notices, says the command runs
|
||||
@@ -389,7 +395,7 @@ test("under the app, Help's dashboard and Continue here explainers point at the
|
||||
});
|
||||
|
||||
// The Welcome dialog's own onboarding tip gave the same classic-only advice.
|
||||
test("under the app, the Welcome dialog's refresh tip names New Session, not a new conversation", async (t) => {
|
||||
test("under the app, the Welcome dialog's terminal tip names the terminal panel and teaches Send", async (t) => {
|
||||
savedLooks(t, null);
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
@@ -401,9 +407,9 @@ test("under the app, the Welcome dialog's refresh tip names New Session, not a n
|
||||
await toTheDashboard(s);
|
||||
const welcome = s.page.locator("#welcome-modal");
|
||||
await welcome.waitFor();
|
||||
const text = s.page.locator("#welcome-refresh-text");
|
||||
await text.getByText("press New Session at the top of the window", { exact: false }).waitFor();
|
||||
assert.equal(await text.getByText("new conversation", { exact: false }).count(), 0, "no classic-mode wording under the app");
|
||||
const text = s.page.locator("#welcome-terminal-text");
|
||||
await text.getByText("asking permission in the terminal panel", { exact: false }).waitFor();
|
||||
assert.match(await textOf(welcome), /Nothing leaves this page until you press Send to Plan2Code/, "the Welcome teaches Send");
|
||||
});
|
||||
|
||||
// The Troubleshooting tab's own "getting a new link" recovery flow is
|
||||
@@ -536,7 +542,9 @@ for (const inApp of [true, false]) {
|
||||
});
|
||||
const texts = await visibleHelpText(s);
|
||||
const hits = [];
|
||||
for (const [tab, text] of Object.entries(texts)) {
|
||||
for (const [tab, rawText] of Object.entries(texts)) {
|
||||
// "Reset this tab" is a button's name, not a mode's wording.
|
||||
const text = rawText.replace(/Reset this tab/g, "Reset");
|
||||
for (const re of inApp ? BROWSER_ONLY : APP_ONLY) {
|
||||
const hit = text.match(re);
|
||||
if (hit) hits.push(`${tab}: ...${text.slice(Math.max(0, hit.index - 50), hit.index + 50).replace(/\s+/g, " ")}...`);
|
||||
@@ -548,3 +556,86 @@ for (const inApp of [true, false]) {
|
||||
assert.match(all, inApp ? /terminal panel/ : /your terminal/);
|
||||
});
|
||||
}
|
||||
|
||||
test("? opens Help from the page, but not from a text box or behind a dialog", async (t) => {
|
||||
savedLooks(t, { welcomeSeen: true });
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const box = itemCard(s.page, "q1").locator(".md-host, input[type=text], textarea").first();
|
||||
await box.waitFor();
|
||||
// From a text box the ? is a typed character, and Help stays shut.
|
||||
await fillBox(box, "why");
|
||||
await s.page.evaluate(() => document.querySelector("#main .md-host").field.focus());
|
||||
await s.page.keyboard.type("?");
|
||||
assert.equal(await helpModal(s).isVisible(), false, "typing ? in a box does not open Help");
|
||||
assert.match(await boxValue(box), /why\?/, "the ? was typed");
|
||||
// Behind a dialog it does nothing either.
|
||||
await s.page.click("#btn-looks");
|
||||
await s.page.locator("#looks-modal[open]").waitFor();
|
||||
await s.page.keyboard.press("?");
|
||||
assert.equal(await helpModal(s).isVisible(), false, "no Help behind another dialog");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await s.page.locator("#looks-modal[open]").waitFor({ state: "detached" });
|
||||
// From the page itself it opens Help on the same topic the ? button would.
|
||||
await s.page.locator("#title").click();
|
||||
await s.page.keyboard.press("?");
|
||||
await helpModal(s).waitFor();
|
||||
const viaKey = await selectedTab(s).getAttribute("id");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await helpModal(s).waitFor({ state: "hidden" });
|
||||
await s.page.click("#btn-about");
|
||||
await helpModal(s).waitFor();
|
||||
assert.equal(viaKey, await selectedTab(s).getAttribute("id"), "the key opens the topic the button opens");
|
||||
});
|
||||
|
||||
test("Help's topics sit under four group headings that the arrow keys skip, and the filter hides what does not match", async (t) => {
|
||||
savedLooks(t, { welcomeSeen: true });
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openHelp(s);
|
||||
const heads = s.page.locator("#help-tabs .help-tab-group");
|
||||
assert.deepEqual(await heads.allTextContents(), ["Start here", "Working in a session", "Tools", "Reference"]);
|
||||
assert.equal(await s.page.locator("#help-tabs .help-tab-group[tabindex]").count(), 0, "a heading is no tab stop");
|
||||
assert.equal(await s.page.locator("#help-tabs [role=tab]").count(), HELP_TABS.length, "only topics are tabs");
|
||||
// The arrow keys walk topics, never the headings: from "stuck" the next is "around".
|
||||
await tabButton(s, "stuck").click();
|
||||
await s.page.keyboard.press("ArrowDown");
|
||||
assert.equal(await focusedId(s), "help-tab-around");
|
||||
|
||||
// The filter: by label, and by words inside a panel; a heading with nothing left goes too.
|
||||
const filter = s.page.locator("#help-filter");
|
||||
await filter.fill("git board");
|
||||
const visible = async () => s.page.locator("#help-tabs [role=tab]:not([hidden])").evaluateAll((n) => n.map((b) => b.id.replace("help-tab-", "")));
|
||||
assert.ok((await visible()).includes("git"), "the git board topic stays");
|
||||
assert.ok(!(await visible()).includes("planny"), "an unrelated topic goes");
|
||||
// Arrow keys now walk only what is shown.
|
||||
const first = (await visible())[0];
|
||||
await tabButton(s, first).click();
|
||||
await s.page.keyboard.press("ArrowDown");
|
||||
assert.ok((await visible()).includes((await focusedId(s)).replace("help-tab-", "")), "focus stays on a shown topic");
|
||||
await filter.fill("zzzz-nothing");
|
||||
assert.equal(await s.page.locator("#help-filter-empty").isVisible(), true, "says nothing matches");
|
||||
assert.equal(await s.page.locator("#help-tabs .help-tab-group:not([hidden])").count(), 0, "a heading with no topic left goes too");
|
||||
await filter.fill("");
|
||||
assert.equal((await visible()).length, HELP_TABS.length, "cleared, every topic is back");
|
||||
assert.equal(await s.page.locator("#help-tabs .help-tab-group:not([hidden])").count(), 4);
|
||||
});
|
||||
|
||||
test("with a filter typed the topic list stays reachable by keyboard, and a closed Help forgets the filter", async (t) => {
|
||||
savedLooks(t, { welcomeSeen: true });
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openHelp(s);
|
||||
const filter = s.page.locator("#help-filter");
|
||||
// The selected topic (the first) is filtered away: some shown topic must still be a tab stop.
|
||||
await filter.fill("git board");
|
||||
assert.equal(await s.page.locator("#help-tabs [role=tab][tabindex='0']:not([hidden])").count(), 1, "one shown tab stop");
|
||||
await filter.press("ArrowDown");
|
||||
const focused = await focusedId(s);
|
||||
assert.match(focused, /^help-tab-/, "the down arrow steps into the topics");
|
||||
assert.equal(await s.page.locator("#" + focused).isHidden(), false, "a shown one");
|
||||
// Close with the filter still typed: the next open starts clean, on a shown topic.
|
||||
await s.page.keyboard.press("Escape");
|
||||
await helpModal(s).waitFor({ state: "hidden" });
|
||||
await openHelp(s);
|
||||
assert.equal(await filter.inputValue(), "", "the filter is cleared");
|
||||
assert.equal(await s.page.locator("#help-tabs [role=tab]:not([hidden])").count(), HELP_TABS.length, "every topic is back");
|
||||
assert.equal(await focusedId(s), "help-tab-" + HELP_TABS[0].id, "focus lands on the topic Help opened on");
|
||||
});
|
||||
@@ -65,14 +65,21 @@ for (const [state, pill] of [
|
||||
["not-set-up", "Not set up"],
|
||||
["off", "Off"],
|
||||
]) {
|
||||
test(`${state}: the row sits under the picker with its pill and Switch on`, async (t) => {
|
||||
test(`${state}: the row sits where its state puts it, with its pill and Switch on`, async (t) => {
|
||||
const { main } = await dashboard(t, PROJECT(state === "not-set-up" ? null : state));
|
||||
const row = main.locator("section.learn-row");
|
||||
await row.waitFor();
|
||||
const where = await placeOf(main);
|
||||
assert.equal(where.rows, 1);
|
||||
assert.equal(where.row, where.toggle + 1, "directly after the hide-unavailable toggle");
|
||||
assert.ok(where.row < where.firstGroup, "above the card groups");
|
||||
if (state === "not-set-up") {
|
||||
// A newcomer's first dashboard offers one call to action, so Not set up waits at the bottom.
|
||||
assert.ok(where.row > where.lastGroup, "after the card groups");
|
||||
assert.equal(where.row, where.tip - 1, "directly before the approval tip");
|
||||
assert.equal(await row.getByRole("button", { name: "Switch on" }).evaluate((b) => b.classList.contains("primary")), false, "a plain button");
|
||||
} else {
|
||||
assert.equal(where.row, where.toggle + 1, "directly after the hide-unavailable toggle");
|
||||
assert.ok(where.row < where.firstGroup, "above the card groups");
|
||||
}
|
||||
assert.equal((await row.locator(".learn-pill").textContent()).trim(), pill);
|
||||
assert.equal(await row.getByRole("button", { name: "Switch on" }).isEnabled(), true);
|
||||
if (state === "not-set-up") {
|
||||
|
||||
@@ -391,6 +391,22 @@ test("a note that cannot be read leaves the editor read-only, and nothing typed
|
||||
assert.equal(await shows(s, "The real note"), "The real note");
|
||||
});
|
||||
|
||||
test("a Notebook that cannot be read offers Try again, which reads it again and clears the line", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
saveNote(s.project, "The real note");
|
||||
await s.page.route("**/notepad", (route) => (route.request().method() === "GET" ? route.abort() : route.continue()));
|
||||
await s.page.click("#btn-notepad");
|
||||
await s.page.locator("#notepad-modal[open]").waitFor();
|
||||
const retry = s.page.locator("#notepad-retry");
|
||||
await retry.waitFor();
|
||||
assert.equal(await retry.innerText(), "Try again");
|
||||
await s.page.unroute("**/notepad");
|
||||
await retry.click();
|
||||
await retry.waitFor({ state: "hidden" });
|
||||
assert.equal(await shows(s, "The real note"), "The real note");
|
||||
assert.equal(await s.page.locator("#notepad-status").innerText(), "", "the read-failure line is gone");
|
||||
});
|
||||
|
||||
test("a note too long to save keeps its text when the notepad is closed and opened again", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
saveNote(s.project, "Saved earlier");
|
||||
@@ -914,7 +930,7 @@ const sendPicture = (s, kind, color) =>
|
||||
{ kind, fill: color },
|
||||
);
|
||||
|
||||
test("Add image, paste and drop each add a thumbnail whose files are on disk and which survives closing", async (t) => {
|
||||
test("Add picture, paste and drop each add a thumbnail whose files are on disk and which survives closing", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
assert.equal(await thumbs(s).count(), 0);
|
||||
@@ -931,9 +947,9 @@ test("Add image, paste and drop each add a thumbnail whose files are on disk and
|
||||
assert.equal(await docText(s), "", "no picture landed in the text");
|
||||
|
||||
const alts = await s.page.locator("#notepad-strip img").evaluateAll((imgs) => imgs.map((i) => i.alt));
|
||||
assert.deepEqual(alts, ["Notebook image 1", "Notebook image 2", "Notebook image 3"]);
|
||||
assert.deepEqual(alts, ["Notebook picture 1", "Notebook picture 2", "Notebook picture 3"]);
|
||||
const xs = await s.page.locator("#notepad-strip .notepad-thumb-delete").evaluateAll((b) => b.map((x) => x.getAttribute("aria-label")));
|
||||
assert.deepEqual(xs, ["Delete image 1", "Delete image 2", "Delete image 3"]);
|
||||
assert.deepEqual(xs, ["Delete picture 1", "Delete picture 2", "Delete picture 3"]);
|
||||
|
||||
// Closed and opened again, the strip is drawn from the stored pictures,
|
||||
// oldest first, each from its stored thumbnail.
|
||||
@@ -972,7 +988,7 @@ test("the X asks first: Keep keeps the picture, Delete removes both its files",
|
||||
|
||||
await s.page.click("#notepad-strip li:nth-child(1) .notepad-thumb-delete");
|
||||
await s.page.locator(".notepad-ask").waitFor();
|
||||
assert.match(await s.page.locator(".notepad-ask").innerText(), /Delete this image\?/);
|
||||
assert.match(await s.page.locator(".notepad-ask").innerText(), /Delete this picture?\?/);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Keep", "Keep has the focus");
|
||||
assert.deepEqual(filesOf(s, first), [true, true], "one click deleted nothing");
|
||||
// Enter on the focused button keeps it.
|
||||
@@ -986,7 +1002,7 @@ test("the X asks first: Keep keeps the picture, Delete removes both its files",
|
||||
await until(() => !filesOf(s, first).some(Boolean), 4000);
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-strip > li").length === 1);
|
||||
assert.deepEqual(stored(s).map((img) => img.id), [second]);
|
||||
assert.equal(await s.page.locator("#notepad-strip img").getAttribute("alt"), "Notebook image 1");
|
||||
assert.equal(await s.page.locator("#notepad-strip img").getAttribute("alt"), "Notebook picture 1");
|
||||
});
|
||||
|
||||
test("the preview opens at the clicked picture, steps and wraps, and Esc closes it before the Notebook", async (t) => {
|
||||
@@ -1103,7 +1119,7 @@ test("a delete that fails keeps the thumbnail and says why", async (t) => {
|
||||
await s.page.waitForFunction(() => !document.querySelector(".notepad-ask"));
|
||||
assert.equal(await thumbs(s).count(), 1);
|
||||
assert.deepEqual(filesOf(s, id), [true, true]);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.getAttribute("aria-label")), "Delete image 1", "the focus is back on the X");
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.getAttribute("aria-label")), "Delete picture 1", "the focus is back on the X");
|
||||
});
|
||||
|
||||
/* ------------------------------------------------- Cleanup, phone, Help */
|
||||
@@ -1141,6 +1157,9 @@ test("User Preferences, Cleanup offers a month-old notepad by its folder and rem
|
||||
assert.ok((await list.locator(".cleanup-summary").innerText()).includes("1 old notebook"), "the summary counts it as a notepad");
|
||||
assert.equal(await list.locator(".cleanup-row").filter({ hasText: "notepads/" }).count(), 0, "the notepads folder is no stray");
|
||||
assert.equal(fs.existsSync(notepadFolder(s.project)), true, "a scan only looks");
|
||||
// A Notebook is your own writing, so it starts unticked: deleting it is a choice.
|
||||
assert.equal(await row.locator("input[type=checkbox]").isChecked(), false, "a Notebook starts unticked");
|
||||
await row.locator("input[type=checkbox]").check();
|
||||
|
||||
await s.page.click("#cleanup-delete");
|
||||
await s.page.waitForFunction(() => /^Deleted /.test(document.getElementById("cleanup-status").textContent));
|
||||
@@ -1163,6 +1182,7 @@ test("the notepad works at phone width: full screen, nothing wider than the wind
|
||||
await openNotepad(s);
|
||||
await addViaButton(s, "#c33");
|
||||
await noSideScroll("the notepad");
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-modal").getAnimations().length === 0);
|
||||
const modal = await box("#notepad-modal");
|
||||
assert.deepEqual([modal.x, modal.y, modal.width, modal.height], [0, 0, 390, 844], "the notepad fills the screen");
|
||||
const inner = await s.page.$eval("#notepad-modal", (m) => ({ sw: m.scrollWidth, cw: m.clientWidth }));
|
||||
@@ -1171,9 +1191,10 @@ test("the notepad works at phone width: full screen, nothing wider than the wind
|
||||
const x = await box(".notepad-thumb-delete");
|
||||
assert.ok(x.width >= 30 && x.height >= 30, "the X is big enough to tap");
|
||||
const strip = await box("#notepad-strip");
|
||||
assert.ok(strip.width > 300, "the pictures get the full width under Add image");
|
||||
assert.ok(strip.width > 300, "the pictures get the full width under Add picture");
|
||||
|
||||
await s.page.click(".attach-open");
|
||||
await s.page.waitForFunction(() => document.getElementById("picview").getAnimations().length === 0);
|
||||
await s.page.locator("#picview[open]").waitFor();
|
||||
await noSideScroll("the preview");
|
||||
const img = await box("#picview-img");
|
||||
|
||||
@@ -12,7 +12,7 @@ import path from "node:path";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { pageSuite, openSession, textOf, drawn, styleOf, stylesOf } from "./page-test-helpers.mjs";
|
||||
import { HOME, MODELS_DIR, backdate } from "./web-console-test-helpers.mjs";
|
||||
import { HOME, MODELS_DIR, backdate, until } from "./web-console-test-helpers.mjs";
|
||||
import { formatBytes } from "../src/web-console/public/answers.js";
|
||||
|
||||
const suite = pageSuite(test);
|
||||
@@ -208,7 +208,8 @@ function seedShippedModels(t) {
|
||||
fs.writeFileSync(
|
||||
SHIPPED_FILE,
|
||||
JSON.stringify({
|
||||
claude: [{ id: "sonnet", label: "Sonnet" }, { id: "opus", label: "Opus" }],
|
||||
// Labels as models.json ships them: the description only, the id printed beside it.
|
||||
claude: [{ id: "sonnet", label: "latest Sonnet" }, { id: "opus", label: "latest Opus" }],
|
||||
devin: [{ id: "swe-2-medium", label: "SWE 2 Medium" }, { id: "swe-2-high", label: "SWE 2 High" }, { id: "claude-opus-5-5-medium", label: "Opus 5.5 Medium" }],
|
||||
codex: [],
|
||||
strengths: {
|
||||
@@ -243,9 +244,13 @@ test("Agents & models: Claude's panel shows the shipped rows as default, and onl
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openAgentsTab(s);
|
||||
// The card already shows what each strength uses.
|
||||
assert.match(await textOf(agentCard(s, "cli:claude").locator(".card-tiers")), /Thrifty\s+Sonnet · low[\s\S]*Best\s+Opus · medium/);
|
||||
// A card line names the model by its id; the description is its tooltip.
|
||||
assert.match(await textOf(agentCard(s, "cli:claude").locator(".card-tiers")), /Thrifty\s+sonnet · low[\s\S]*Best\s+opus · medium/);
|
||||
assert.equal(await agentCard(s, "cli:claude").locator(".card-tier span[title]").first().getAttribute("title"), "latest Sonnet");
|
||||
await openAgent(s, "Claude");
|
||||
assert.equal(await textOf(loopRow(s, "thrifty").locator(".strength-model")), "Sonnet");
|
||||
// The picked model reads as the model rows do: its description with the id beside it.
|
||||
assert.match(await textOf(loopRow(s, "thrifty").locator(".strength-model")), /^latest Sonnet\s+sonnet$/);
|
||||
assert.equal(await textOf(loopRow(s, "thrifty").locator(".strength-model code")), "sonnet");
|
||||
assert.equal(await loopRow(s, "thrifty").locator('select[data-field="effort"]').inputValue(), "low");
|
||||
assert.equal(await wordPill(s, "best", "opus").getAttribute("aria-pressed"), "true");
|
||||
assert.equal(await wordPill(s, "best", "sonnet").getAttribute("aria-pressed"), "false");
|
||||
@@ -268,7 +273,7 @@ test("Agents & models: Claude's panel shows the shipped rows as default, and onl
|
||||
assert.deepEqual(savedStrengths(), { claude: { thrifty: { model: "opus", effort: "low" } } }, "only the changed row is written");
|
||||
|
||||
await loopRow(s, "thrifty").locator(".strength-reset").click();
|
||||
assert.equal(await textOf(loopRow(s, "thrifty").locator(".strength-model")), "Sonnet", "Reset restores the shipped row");
|
||||
assert.match(await textOf(loopRow(s, "thrifty").locator(".strength-model")), /^latest Sonnet\s+sonnet$/, "Reset restores the shipped row");
|
||||
assert.equal(await textOf(loopRow(s, "thrifty").locator(".strength-default")), "default");
|
||||
await agentForm(s).locator(".prefs-unsaved-badge").waitFor();
|
||||
await formButton(s, "Save").click();
|
||||
@@ -556,7 +561,12 @@ test("Agents & models: an unsaved edit asks first on Close, a scrim click, Esc,
|
||||
await edit(`alpha-${name}-kept`);
|
||||
await leave();
|
||||
await unsavedPrompt(s).waitFor();
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement?.id), "prefs-unsaved-save", `${name}: Save has focus`);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement?.id), "prefs-unsaved-keep", `${name}: Keep editing has focus`);
|
||||
assert.deepEqual(
|
||||
await unsavedPrompt(s).locator("button").allInnerTexts(),
|
||||
["Keep editing", "Discard", "Save"],
|
||||
`${name}: the Lessons prompt's order`,
|
||||
);
|
||||
await unsavedPrompt(s).getByRole("button", { name: "Keep editing" }).click();
|
||||
await unsavedPrompt(s).waitFor({ state: "hidden" });
|
||||
assert.equal(await modal.evaluate((d) => d.open), true, `${name}: the dialog stays open`);
|
||||
@@ -693,7 +703,7 @@ test("Cleanup scans the console home and lists an old session folder with its si
|
||||
const dir = path.join(HOME, "sessions", sid);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
const state = path.join(dir, "state.json");
|
||||
fs.writeFileSync(state, "x".repeat(3000));
|
||||
fs.writeFileSync(state, JSON.stringify({ title: "shop", workflow: "pathfinder", pad: "x".repeat(3000) }));
|
||||
backdate(state);
|
||||
backdate(dir);
|
||||
t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
|
||||
@@ -704,18 +714,42 @@ test("Cleanup scans the console home and lists an old session folder with its si
|
||||
assert.equal(await list.locator(".cleanup-row").count(), 0, "Cleanup lists things before a scan");
|
||||
assert.equal(await s.page.locator("#cleanup-delete").isHidden(), true, "Delete is offered before a scan");
|
||||
await s.page.click("#cleanup-scan");
|
||||
const row = list.locator(".cleanup-row").filter({ hasText: sid });
|
||||
const row = list.locator(".cleanup-row").filter({ hasText: "Pathfinder · shop" });
|
||||
await row.waitFor();
|
||||
assert.match(await textOf(row), new RegExp(`^Session ${sid}`));
|
||||
assert.match(await textOf(row), /^Pathfinder · shop · [0-9]+ (weeks|months) ago/, "a session is named by its skill, title and age, not its folder");
|
||||
assert.equal(await row.locator("input[type=checkbox]").isChecked(), true, "a session starts ticked");
|
||||
const size = await textOf(row.locator(".cleanup-size"));
|
||||
assert.match(size, /^\d/, "the row names a size");
|
||||
assert.ok(size === formatBytes(3000) || /^[\d.,]+\s*(kB|KB|MB|B)\b/.test(size), `the size reads as a size: ${size}`);
|
||||
assert.ok(size === formatBytes(3040) || /^[\d.,]+\s*(kB|KB|MB|B)\b/.test(size), `the size reads as a size: ${size}`);
|
||||
assert.match(await textOf(s.page.locator("#cleanup-delete")), /^Delete 1 item · /, "the button says what it will do");
|
||||
// Unticking everything leaves nothing to send.
|
||||
await row.locator("input[type=checkbox]").uncheck();
|
||||
assert.equal(await s.page.locator("#cleanup-delete").isDisabled(), true, "nothing ticked, nothing to delete");
|
||||
assert.match(await textOf(s.page.locator("#cleanup-delete")), /^Nothing ticked/);
|
||||
await row.locator("input[type=checkbox]").check();
|
||||
assert.match(await textOf(list.locator(".cleanup-summary")), /1 old session/);
|
||||
assert.match(await textOf(s.page.locator("#cleanup-status")), /^Found \d+ items?\./);
|
||||
assert.equal(await s.page.locator("#cleanup-delete").isVisible(), true, "Delete these is offered once something is found");
|
||||
// The scan only looks.
|
||||
assert.equal(fs.existsSync(dir), true, "a scan deleted the folder");
|
||||
|
||||
// While a delete is on its way, ticking a box never re-enables Delete.
|
||||
let release;
|
||||
const held = new Promise((r) => (release = r));
|
||||
await s.page.route("**/cleanup", async (route) => {
|
||||
if (!/"delete"/.test(route.request().postData() || "")) return route.continue();
|
||||
await held;
|
||||
return route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, removed: [], failed: [], bytes: 0 }) });
|
||||
});
|
||||
await s.page.click("#cleanup-delete");
|
||||
await s.page.waitForFunction(() => /Deleting/.test(document.getElementById("cleanup-status").textContent));
|
||||
await row.locator("input[type=checkbox]").uncheck();
|
||||
await row.locator("input[type=checkbox]").check();
|
||||
assert.equal(await s.page.locator("#cleanup-delete").isDisabled(), true, "Delete stays off mid-request");
|
||||
release();
|
||||
await s.page.waitForFunction(() => /Nothing was deleted/.test(document.getElementById("cleanup-status").textContent));
|
||||
await s.page.unroute("**/cleanup");
|
||||
|
||||
// Closing preferences forgets the scan: a reopened dialog starts clean.
|
||||
await s.page.click("#looks-done");
|
||||
await s.page.click("#btn-looks");
|
||||
@@ -810,9 +844,9 @@ test("below 720 px the side list is a horizontal strip with no hints", async (t)
|
||||
await s.page.waitForFunction(() => document.getElementById("prefs-tabs").getAttribute("aria-orientation") === "vertical");
|
||||
});
|
||||
|
||||
test("Set up preferences on the dashboard opens on Appearance with agents and models loaded", async (t) => {
|
||||
test("Set your role on the dashboard opens on Appearance with agents and models loaded", async (t) => {
|
||||
fs.mkdirSync(HOME, { recursive: true });
|
||||
fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { welcomeSeen: true } }));
|
||||
fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { welcomeSeen: true, skillLaunched: true } }));
|
||||
t.after(() => fs.rmSync(LOOKS_FILE, { force: true }));
|
||||
const file = path.join(MODELS_DIR, "agents.json");
|
||||
fs.mkdirSync(MODELS_DIR, { recursive: true });
|
||||
@@ -826,7 +860,7 @@ test("Set up preferences on the dashboard opens on Appearance with agents and mo
|
||||
const skip = s.page.getByRole("button", { name: "Skip the intro" });
|
||||
await skip.click();
|
||||
await skip.waitFor({ state: "hidden" });
|
||||
await s.page.getByRole("button", { name: "Set up preferences" }).click();
|
||||
await s.page.getByRole("button", { name: "set your role" }).click();
|
||||
await s.page.locator("#looks-modal[open]").waitFor();
|
||||
assert.equal(await selectedTab(s), "prefs-tab-appearance");
|
||||
await s.page.click("#prefs-tab-agents");
|
||||
@@ -837,7 +871,7 @@ test("Set up preferences on the dashboard opens on Appearance with agents and mo
|
||||
assert.doesNotMatch(await s.page.locator("#agents-status").innerText(), /could not be loaded/);
|
||||
});
|
||||
|
||||
test("Back to default resets only the tab on screen, and is hidden on Agents & models and System", async (t) => {
|
||||
test("Reset this tab resets only the tab on screen, and is hidden on Agents & models and System", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await s.page.click("#btn-looks");
|
||||
@@ -1102,3 +1136,59 @@ test("the sound picker: Tab reaches Play from the select, and a row stacks insid
|
||||
assert.equal(fits.length, PICK_EVENTS.length, "every row is drawn");
|
||||
assert.equal(fits.every(Boolean), true, "no control spills out of the dialog at 600px");
|
||||
});
|
||||
|
||||
test("Cleanup's Delete sends only the ticked ids", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const made = ["20250801-101010-aaaaaa", "20250801-101010-bbbbbb"].map((sid) => {
|
||||
const dir = path.join(HOME, "sessions", sid);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, "state.json"), JSON.stringify({ title: sid.endsWith("aaaaaa") ? "first" : "second", workflow: "plan" }));
|
||||
backdate(path.join(dir, "state.json"));
|
||||
backdate(dir);
|
||||
t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
|
||||
return sid;
|
||||
});
|
||||
const sent = [];
|
||||
await s.page.route("**/cleanup", async (route) => {
|
||||
const body = JSON.parse(route.request().postData() || "{}");
|
||||
if (body.delete) {
|
||||
sent.push(body.delete);
|
||||
return route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, removed: body.delete, failed: [], refused: [], bytes: 10 }) });
|
||||
}
|
||||
return route.fallback();
|
||||
});
|
||||
await s.page.click("#btn-looks");
|
||||
await s.page.click("#prefs-tab-system");
|
||||
await s.page.click("#cleanup-scan");
|
||||
const first = s.page.locator("#cleanup-list .cleanup-row").filter({ hasText: "Plan · first" });
|
||||
await first.waitFor();
|
||||
await first.locator("input[type=checkbox]").uncheck();
|
||||
await s.page.click("#cleanup-delete");
|
||||
await until(() => sent.length === 1);
|
||||
assert.deepEqual(sent[0], ["session:" + made[1]], "only the ticked session is sent");
|
||||
});
|
||||
|
||||
test("Reset this tab shows Reset with an Undo that puts the tab back, and the dialog says what saves itself", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await s.page.click("#btn-looks");
|
||||
assert.match(await textOf(s.page.locator("#prefs-lead")), /^Changes save as you make them\. Agents have their own Save\.$/);
|
||||
assert.equal(await textOf(s.page.locator("#looks-reset")), "Reset this tab");
|
||||
assert.match(await textOf(s.page.locator("#looks-skip-intro + span")), /^Skip the wake-up intro$/);
|
||||
await s.page.locator('input[name="looks-theme"][value="dark"]').check();
|
||||
await swatch(s, "violet").click();
|
||||
await s.page.click("#looks-reset");
|
||||
await s.page.waitForFunction(() => !document.documentElement.hasAttribute("data-theme"));
|
||||
const mark = s.page.locator("#prefs-panel-appearance .prefs-saved.is-reset");
|
||||
await mark.waitFor();
|
||||
assert.match(await textOf(mark), /^Reset\. Undo$/);
|
||||
await mark.getByRole("button", { name: "Undo" }).click();
|
||||
await s.page.waitForFunction(() => document.documentElement.getAttribute("data-theme") === "dark");
|
||||
assert.equal(await swatch(s, "violet").getAttribute("aria-pressed"), "true", "the highlight is back too");
|
||||
assert.equal(await mark.count(), 0, "the Undo note is gone once used");
|
||||
await s.page.waitForFunction(async () => {
|
||||
const saved = (await (await fetch("/looks")).json()).looks || {};
|
||||
return saved.theme === "dark" && saved.accent === "violet";
|
||||
});
|
||||
});
|
||||
@@ -252,3 +252,82 @@ test("a tab deleted between Start and the box leaves the box empty, with a banne
|
||||
assert.equal(await boxValue(boxOf(s)), "");
|
||||
assert.equal(await readyPictures(s).count(), 0);
|
||||
});
|
||||
|
||||
// Clear needs no native confirm: it clears at once and offers Undo for ten
|
||||
// seconds, deleting the attachments' files on the server only when the window
|
||||
// closes.
|
||||
const CHOICE = {
|
||||
items: [{ id: "q1", kind: "text", title: "Name it", body: "A name." }],
|
||||
agent: { status: "waiting" },
|
||||
};
|
||||
|
||||
test("Clear clears at once with an Undo that restores it, and deletes attachments only once the window closes", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: CHOICE, clock: true });
|
||||
s.page.on("dialog", (d) => {
|
||||
assert.fail("Clear must not open a native dialog: " + d.message());
|
||||
});
|
||||
const deletes = [];
|
||||
await s.page.route("**/uploads/**", (route) => {
|
||||
if (route.request().method() === "DELETE") deletes.push(route.request().url());
|
||||
return route.fulfill({ status: 200, body: "{}" });
|
||||
});
|
||||
const box = itemCard(s.page, "q1").locator(".md-host, input[type=text]").first();
|
||||
await fillBox(box, "audit-export");
|
||||
// An attachment on that note, as the page holds it after an upload.
|
||||
await s.page.evaluate(async () => {
|
||||
const { page, saveNow, redraw } = await import("/state.js");
|
||||
page.local.images.q1 = [{ key: "k1", id: "abc123", path: "uploads/abc123.png", name: "shot.png" }];
|
||||
saveNow();
|
||||
redraw();
|
||||
});
|
||||
const clear = s.page.locator("#btn-clear");
|
||||
await clear.waitFor();
|
||||
await clear.click();
|
||||
const banner = s.page.locator("#banner");
|
||||
await banner.getByText(/^Cleared/).waitFor();
|
||||
assert.equal(await boxValue(itemCard(s.page, "q1").locator(".md-host, input[type=text]").first()), "", "the box is empty at once");
|
||||
assert.equal(deletes.length, 0, "nothing deleted on the server yet");
|
||||
// Undo puts the text and the picture back, and the file is never deleted.
|
||||
await banner.getByRole("button", { name: "Undo" }).click();
|
||||
assert.equal(await boxValue(itemCard(s.page, "q1").locator(".md-host, input[type=text]").first()), "audit-export", "undo restores the answer");
|
||||
assert.equal(await s.page.evaluate(async () => (await import("/state.js")).page.local.images.q1?.length), 1, "and the picture");
|
||||
await s.page.clock.fastForward(12_000);
|
||||
assert.equal(deletes.length, 0, "an undone clear deletes nothing");
|
||||
|
||||
// Clear again and let the window close: the file goes.
|
||||
await clear.click();
|
||||
await banner.getByText(/^Cleared/).waitFor();
|
||||
await s.page.clock.fastForward(11_000);
|
||||
await until(() => deletes.length === 1);
|
||||
assert.match(deletes[0], /abc123/);
|
||||
await banner.waitFor({ state: "hidden" });
|
||||
});
|
||||
|
||||
test("Clear while a picture is uploading: Undo brings it back finished, not stuck uploading", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: CHOICE });
|
||||
let release;
|
||||
const gate = new Promise((r) => (release = r));
|
||||
await s.page.route("**/upload", async (route) => {
|
||||
await gate;
|
||||
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, id: "up1", path: "uploads/up1.jpg", name: "p.jpg", size: 5, kind: "image" }) });
|
||||
});
|
||||
await s.page.route("**/uploads/**", (route) => route.fulfill({ status: 200, body: "{}" }));
|
||||
await itemCard(s.page, "q1").waitFor();
|
||||
await s.page.evaluate(async () => {
|
||||
const c = document.createElement("canvas");
|
||||
c.width = c.height = 8;
|
||||
c.getContext("2d").fillRect(0, 0, 8, 8);
|
||||
const blob = await new Promise((r) => c.toBlob(r, "image/png"));
|
||||
const { attachFiles } = await import("/uploads.js");
|
||||
attachFiles("q1", [new File([blob], "p.png", { type: "image/png" })]);
|
||||
});
|
||||
await until(() => s.page.evaluate(async () => ((await import("/state.js")).page.local.images.q1 || []).some((i) => i.status === "uploading")));
|
||||
await s.page.locator("#btn-clear").click();
|
||||
const banner = s.page.locator("#banner");
|
||||
await banner.getByText(/^Cleared/).waitFor();
|
||||
release();
|
||||
await s.page.waitForTimeout(300);
|
||||
await banner.getByRole("button", { name: "Undo" }).click();
|
||||
const back = await s.page.evaluate(async () => ((await import("/state.js")).page.local.images.q1 || []).map((i) => ({ status: i.status, id: i.id })));
|
||||
assert.deepEqual(back, [{ status: "ready", id: "up1" }], "the upload finished into the set-aside picture, and Undo restored it");
|
||||
});
|
||||
@@ -12,7 +12,7 @@ import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { pageSuite, openSession, itemCard, drawn, textOf, tempProject , fillBox, boxValue, sendAsk, styleOf } from "./page-test-helpers.mjs";
|
||||
import { cli, until } from "./web-console-test-helpers.mjs";
|
||||
import { cli, until, HOME } from "./web-console-test-helpers.mjs";
|
||||
import { STOP_HANDOFF_REPLY, HOME_REPLY } from "../src/web-console/public/answers.js";
|
||||
import { CHAT_OFFLINE_TEXT } from "../src/web-console/public/chat.js";
|
||||
// How long the page waits without contact before it calls itself offline:
|
||||
@@ -23,7 +23,7 @@ const suite = pageSuite(test);
|
||||
|
||||
|
||||
// The banner the page raises when it loses its server mid-session.
|
||||
const LOST_CONTACT = /Lost contact with Plan2Code\. Nothing you have typed is lost\./;
|
||||
const LOST_CONTACT = /Not connected right now. Nothing you have typed is lost./;
|
||||
|
||||
// A plan session on the person's turn, the way an agent opens one: one text
|
||||
// question and the agent listening.
|
||||
@@ -233,7 +233,7 @@ test("Continue here shows beside a skill's next step while the meter is not red
|
||||
assert.equal(got.reply, "Start Implement (/plan2code-3-implement) for specs/audit-export, right here in this session.");
|
||||
// The hop's resume is the dashboard's: the skill's workflow and the spec.
|
||||
assert.match(got.resume, /--workflow implement --spec specs\/audit-export$/);
|
||||
await main.getByRole("button", { name: "Starting the next step…" }).waitFor();
|
||||
await main.getByRole("button", { name: "Starting the next skill…" }).waitFor();
|
||||
assert.equal(await main.getByRole("button", { name: "Back to the dashboard" }).isDisabled(), true, "one press locks the other buttons");
|
||||
|
||||
// No skill to continue into: a git command, or a pause.
|
||||
@@ -685,7 +685,7 @@ test("Stop session, confirmed, sends __stop with no handoff", async (t) => {
|
||||
assert.deepEqual(stop, { i: "__stop", type: "stop" });
|
||||
});
|
||||
|
||||
test("Stop with a handoff sends __stop with handoff, and the paused finish and stop that follow end on the paused screen, not an error", async (t) => {
|
||||
test("Stop with a handoff sends __stop with handoff, and the paused finish and stop that follow end on the stopped screen, not an error", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await s.page.click("#btn-stop");
|
||||
const handoff = s.page.locator("#stop-handoff");
|
||||
@@ -716,8 +716,8 @@ test("Stop with a handoff sends __stop with handoff, and the paused finish and s
|
||||
!LOST_CONTACT.test(await s.page.locator("#banner").innerText()) &&
|
||||
!(await s.page.locator("#planny").getAttribute("class")).includes("is-gone");
|
||||
assert.ok(await holds(settled, GONE_AFTER_MS + 3000), "the page raised a lost-contact state after a paused finish");
|
||||
assert.match(await main.innerText(), /Session paused/i);
|
||||
assert.match(await textOf(s.page.locator("#agent-text")), /^Paused\./);
|
||||
assert.match(await main.innerText(), /Session stopped/i);
|
||||
assert.match(await textOf(s.page.locator("#agent-text")), /^Stopped./);
|
||||
assert.ok(await main.locator("code").filter({ hasText: /^\/plan2code-1-plan --web$/ }).count(), "the resume command is gone");
|
||||
});
|
||||
|
||||
@@ -759,7 +759,7 @@ test("a page that loses its server goes offline, and after a resume it shows the
|
||||
await s.page.waitForFunction(() => document.getElementById("planny").classList.contains("is-gone"), null, {
|
||||
timeout: GONE_AFTER_MS + 10000,
|
||||
});
|
||||
assert.match(await textOf(s.page.locator("#agent-text")), /^Not connected\. Your answers are saved\./);
|
||||
assert.match(await textOf(s.page.locator("#agent-text")), /^Not connected right now. Your answers are saved./);
|
||||
assert.match(await s.page.locator("#banner").innerText(), LOST_CONTACT);
|
||||
assert.equal(await s.page.locator("#btn-send").isDisabled(), true, "Send is on with no server");
|
||||
|
||||
@@ -832,7 +832,7 @@ test("the quiet, not running and not connected lines offer What to check, openin
|
||||
await s.page.clock.fastForward(GONE_AFTER_MS);
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
}
|
||||
await lineSays(s, /^Not connected\. Your answers are saved\./);
|
||||
await lineSays(s, /^Not connected right now. Your answers are saved./);
|
||||
assert.equal(await whatToCheck(s).count(), 1, "the not connected line carries What to check");
|
||||
});
|
||||
|
||||
@@ -904,7 +904,7 @@ test("a Send that finds the server gone says so at once, with the reconnect help
|
||||
await s.page.click("#btn-send");
|
||||
await s.page.waitForFunction(() => document.getElementById("planny").classList.contains("is-gone"), null, { timeout: 3000 });
|
||||
assert.match(await s.page.locator("#banner").innerText(), LOST_CONTACT);
|
||||
assert.match(await textOf(statusLine(s)), /^Not connected\. Your answers are saved\./);
|
||||
assert.match(await textOf(statusLine(s)), /^Not connected right now. Your answers are saved./);
|
||||
assert.equal(await whatToCheck(s).count(), 1, "the not connected line carries What to check");
|
||||
});
|
||||
|
||||
@@ -1102,7 +1102,9 @@ test("Stop with a handoff sends its own reply line beside the stop, and a plain
|
||||
|
||||
// A finish that offers a review, a commit and the dashboard, on a build.
|
||||
const OFFERS = { headline: "Quick task done", command: "/plan2code-5-git", review: true, commit: true, dashboard: true };
|
||||
const closeGuide = (s) => s.page.getByRole("region", { name: "Before you close this" });
|
||||
// Folded into the closed "Closing or starting fresh" section, so the role query also reads what is hidden.
|
||||
const closeGuide = (s) => s.page.getByRole("region", { name: "Before you close this", includeHidden: true });
|
||||
const openFolded = (s) => s.page.evaluate(() => document.querySelectorAll(".handoff-more").forEach((d) => (d.open = true)));
|
||||
|
||||
// What a person sees break: "Safe to close" printed under "Review requested", or the review offer coming back after a reload.
|
||||
test("Before you close this shows while a review is on offer, goes while it is asked, and the asked offer stays locked after a reload", async (t) => {
|
||||
@@ -1212,7 +1214,7 @@ test("Before you close this goes while a commit or the dashboard is starting, an
|
||||
await gone.page.clock.fastForward(GONE_AFTER_MS);
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
}
|
||||
await closeGuide(gone).waitFor();
|
||||
await closeGuide(gone).waitFor({ state: "attached" });
|
||||
});
|
||||
|
||||
// What a person sees break: a finished screen with no Before you close this,
|
||||
@@ -1231,6 +1233,7 @@ test("every finished shape shows Before you close this with its three rows, and
|
||||
await main.getByRole("heading", { name: headline }).waitFor();
|
||||
const guide = closeGuide(s);
|
||||
assert.equal(await guide.count(), 1, `${headline}: one guide`);
|
||||
await openFolded(s);
|
||||
assert.equal(await guide.locator("li").count(), 3, `${headline}: three rows`);
|
||||
const text = await textOf(guide);
|
||||
for (const label of ["Before you close this", "Safe to close", "Start fresh", "Carry on"]) assert.ok(text.includes(label), `${headline}: says "${label}"`);
|
||||
@@ -1264,6 +1267,7 @@ test("under the app, Before you close this points at New Session, and never at a
|
||||
s.post({ finish: { headline: "A skill next", command: "/plan2code-4-finalize" } });
|
||||
await main.getByRole("heading", { name: "A skill next" }).waitFor();
|
||||
const guide = closeGuide(s);
|
||||
await openFolded(s);
|
||||
const text = await textOf(guide);
|
||||
assert.ok(text.includes("Press New Session at the top of the window to start the agent fresh."), "Start fresh points at New Session");
|
||||
assert.ok(text.includes("Paste the command above into the terminal panel, or start from the dashboard with /plan2code."), "Carry on names the terminal panel");
|
||||
@@ -1323,7 +1327,7 @@ test("the top bar's back triangle asks first, then sends __dashboard with the ty
|
||||
await s.page.click("#btn-home");
|
||||
const modal = s.page.locator("#home-modal");
|
||||
await modal.waitFor();
|
||||
assert.match(await textOf(modal), /Leave this workflow\?/);
|
||||
assert.match(await textOf(modal), /Leave this skill?\?/);
|
||||
assert.match(await textOf(modal.locator("#home-blurb")), /The answer you have ready goes with it\./);
|
||||
await modal.locator("#home-cancel").click();
|
||||
await modal.waitFor({ state: "hidden" });
|
||||
@@ -1334,7 +1338,7 @@ test("the top bar's back triangle asks first, then sends __dashboard with the ty
|
||||
const got = collect(s);
|
||||
assert.deepEqual(got.actions.map(({ i, type }) => ({ i, type })), [{ i: "q1", type: "answer" }, { i: "__dashboard", type: "dashboard" }]);
|
||||
assert.ok(got.reply.includes("audit-export") && got.reply.endsWith(HOME_REPLY), `the reply carries the answer, then the home line: ${got.reply}`);
|
||||
await s.page.waitForFunction(() => document.getElementById("btn-home").disabled);
|
||||
await s.page.waitForFunction(() => document.getElementById("btn-home").getAttribute("aria-disabled") === "true");
|
||||
});
|
||||
|
||||
// What a person sees break: Commit it now, or Changelog's commit offer, hops
|
||||
@@ -1448,3 +1452,146 @@ test("under the app, Planny's finished line says to close the window, not the ta
|
||||
const line = await lineSays(s, /close this window/);
|
||||
assert.doesNotMatch(line, /close this tab/, "no classic-mode wording under the app");
|
||||
});
|
||||
|
||||
// The meter's one-time tip lives in its popover (it used to sit in the Welcome
|
||||
// dialog): the first time the pill leaves green, opened once, then never again.
|
||||
test("the meter popover shows a one-time tip the first time the pill turns yellow", async (t) => {
|
||||
const file = path.join(HOME, "looks.json");
|
||||
fs.mkdirSync(HOME, { recursive: true });
|
||||
fs.writeFileSync(file, JSON.stringify({ looks: { welcomeSeen: true } }));
|
||||
t.after(() => fs.rmSync(file, { force: true }));
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "implement", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
const once = s.page.locator("#meter-once");
|
||||
assert.equal(await once.isHidden(), true, "nothing at green");
|
||||
// Six points: a fifteen-task phase, the yellow level.
|
||||
s.post({ run: { event: "implement-phase", id: "phase-1", tasks: 18 } });
|
||||
const pill = s.page.locator("#meter-pill[data-level='yellow']");
|
||||
await pill.waitFor();
|
||||
await pill.click();
|
||||
await once.waitFor();
|
||||
assert.match(await once.innerText(), /once the meter passes half/i);
|
||||
assert.ok(await until(() => s.page.evaluate(async () => ((await (await fetch("/looks")).json()).looks || {}).meterTipSeen === true)), "opening it with the tip showing saved the flag");
|
||||
// A redraw while the popover is open must not take the tip away mid-read.
|
||||
s.post({ agent: { activity: "Task 2 of 2" } });
|
||||
await s.page.getByText("Task 2 of 2").first().waitFor();
|
||||
assert.equal(await once.isVisible(), true, "the tip stays up through a redraw while its popover is open");
|
||||
await pill.click();
|
||||
await s.page.locator("#meter-pop").waitFor({ state: "hidden" });
|
||||
assert.equal(await once.isHidden(), true, "closing the popover retires the tip");
|
||||
await s.page.reload();
|
||||
const again = s.page.locator("#meter-pill[data-level='yellow']");
|
||||
await again.waitFor();
|
||||
await again.click();
|
||||
assert.equal(await s.page.locator("#meter-once").isHidden(), true, "the tip does not come back");
|
||||
});
|
||||
|
||||
// One primary per finish by a fixed rule (review, else commit, else Continue
|
||||
// here, else Back to the dashboard), and the quiet extras folded into one
|
||||
// closed section.
|
||||
test("every finish shape shows exactly one primary button by the fixed rule, and the extras fold away", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "quick-task", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
const main = s.page.locator("#main");
|
||||
const primaries = () => main.locator("button.primary");
|
||||
const shapes = [
|
||||
["Everything on offer", { command: "/plan2code-5-git", review: true, commit: true, dashboard: true }, "Review it now"],
|
||||
["Commit and dashboard", { command: "/plan2code-5-git", commit: true, dashboard: true }, "Commit it now"],
|
||||
["A skill next", { command: "/plan2code-4-finalize", dashboard: true }, "Continue here"],
|
||||
["Only the dashboard", { dashboard: true }, "Back to the dashboard"],
|
||||
["Paused here", { command: "/plan2code-3-implement specs/x/overview.md" }, "Copy"],
|
||||
["Nothing left", {}, "Copy"],
|
||||
];
|
||||
for (const [headline, rest, primary] of shapes) {
|
||||
s.post({ finish: { headline, ...rest } });
|
||||
await main.getByRole("heading", { name: headline }).waitFor();
|
||||
assert.equal(await primaries().count(), 1, `${headline}: exactly one primary`);
|
||||
assert.match(await primaries().first().innerText(), new RegExp(primary), `${headline}: the primary is ${primary}`);
|
||||
}
|
||||
// The extras are one closed section, "Closing or starting fresh".
|
||||
s.post({ finish: { headline: "Folded", command: "/plan2code-4-finalize" } });
|
||||
await main.getByRole("heading", { name: "Folded" }).waitFor();
|
||||
const more = main.locator("details.handoff-more");
|
||||
assert.equal(await more.count(), 1, "one folded section");
|
||||
assert.equal(await more.evaluate((d) => d.open), false, "closed");
|
||||
assert.match(await textOf(more.locator("summary")), /Closing or starting fresh/);
|
||||
await more.locator("summary").click();
|
||||
await closeGuide(s).waitFor();
|
||||
});
|
||||
|
||||
// Stop and Back lock with aria-disabled while Plan2Code has the turn: a press
|
||||
// opens a small note saying why, and acts on nothing.
|
||||
test("Stop session and Back are aria-disabled mid-task, and a press explains instead of stopping", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "implement", payload: { agent: { status: "working", activity: "Task 1 of 3" } } });
|
||||
const stop = s.page.locator("#btn-stop");
|
||||
await stop.waitFor();
|
||||
assert.equal(await stop.getAttribute("aria-disabled"), "true", "locked");
|
||||
assert.equal(await stop.evaluate((n) => n.disabled), false, "but not disabled, so a press still lands");
|
||||
// Playwright reads aria-disabled as disabled, so the press is forced.
|
||||
await stop.click({ force: true });
|
||||
const pop = s.page.locator(".lock-pop");
|
||||
await pop.waitFor();
|
||||
assert.match(await textOf(pop), /Plan2Code is mid-task, so Stop unlocks at its next check-in. To interrupt it now, press Esc in the terminal./);
|
||||
// Wide enough to read and inside the window (right-anchoring once squeezed it to a strip).
|
||||
const box = await pop.boundingBox();
|
||||
const width = await s.page.evaluate(() => window.innerWidth);
|
||||
assert.ok(box.width > 250 && box.x >= 0 && box.x + box.width <= width, `the note is readable and on screen: ${JSON.stringify(box)}`);
|
||||
assert.equal(await s.page.locator("#stop-modal[open]").count(), 0, "no Stop dialog");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await pop.waitFor({ state: "detached" });
|
||||
const home = s.page.locator("#btn-home");
|
||||
assert.equal(await home.getAttribute("aria-disabled"), "true", "Back is locked too");
|
||||
await home.click({ force: true });
|
||||
assert.match(await textOf(s.page.locator(".lock-pop")), /Back to the dashboard unlocks at its next check-in/);
|
||||
assert.equal(await s.page.locator("#home-modal[open]").count(), 0, "no Back dialog");
|
||||
// On the person's turn the lock lifts and Stop opens its dialog.
|
||||
s.post({ items: [{ id: "q1", kind: "text", title: "Name it", body: "A name." }], agent: { status: "waiting" } });
|
||||
await s.page.waitForFunction(() => !document.getElementById("btn-stop").hasAttribute("aria-disabled"));
|
||||
await stop.click();
|
||||
await s.page.locator("#stop-modal[open]").waitFor();
|
||||
await s.page.keyboard.press("Escape");
|
||||
await s.page.locator("#stop-modal[open]").waitFor({ state: "detached" });
|
||||
// Back already on its way home says so, never "mid-task, press Esc".
|
||||
await home.click();
|
||||
await s.page.locator("#home-modal[open]").waitFor();
|
||||
await s.page.click("#home-go");
|
||||
await s.page.waitForFunction(() => document.getElementById("btn-home").getAttribute("aria-disabled") === "true");
|
||||
await home.click({ force: true });
|
||||
const going = s.page.locator(".lock-pop");
|
||||
await going.waitFor();
|
||||
assert.match(await textOf(going), /^Opening the dashboard/);
|
||||
});
|
||||
|
||||
// A timed success never wipes a newer warning, and a warning can be dismissed.
|
||||
test("a timed banner clears only its own message, and a warn banner has a Dismiss button", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await itemCard(s.page, "q1").waitFor();
|
||||
const shown = await s.page.evaluate(async () => {
|
||||
const core = await import("/screens/core.js");
|
||||
const box = document.getElementById("banner");
|
||||
const ok = core.banner("Sent. Plan2Code is picking it up now.", "good");
|
||||
const warn = core.banner("That did not go through. Nothing was lost; try again.", "warn");
|
||||
core.clearBanner(ok); // the success's own timer fires late
|
||||
const kept = !box.hidden && box.textContent.includes("did not go through");
|
||||
core.clearBanner(warn);
|
||||
return { kept, goneAfter: box.hidden, tokensDiffer: ok !== warn };
|
||||
});
|
||||
assert.deepEqual(shown, { kept: true, goneAfter: true, tokensDiffer: true });
|
||||
await s.page.evaluate(async () => (await import("/screens/core.js")).banner("A refused send.", "warn"));
|
||||
const banner = s.page.locator("#banner");
|
||||
await banner.waitFor();
|
||||
await banner.getByRole("button", { name: "Dismiss" }).click();
|
||||
await banner.waitFor({ state: "hidden" });
|
||||
// Info and success banners are not dismissible: they go by themselves.
|
||||
await s.page.evaluate(async () => (await import("/screens/core.js")).banner("Sent.", "good"));
|
||||
assert.equal(await banner.getByRole("button", { name: "Dismiss" }).count(), 0, "no Dismiss on a success");
|
||||
});
|
||||
|
||||
// A finished session has nothing to send, ever: no dead Send button, and the
|
||||
// footer says why in words.
|
||||
test("a finished session draws no Send button and keeps the footer's words", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "quick-task", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
assert.equal(await s.page.locator("#btn-send").isHidden(), false, "Send is drawn while the session runs");
|
||||
s.post({ finish: { headline: "Quick task done", command: "/plan2code-5-git" } });
|
||||
await s.page.locator("#main").getByRole("heading", { name: "Quick task done" }).waitFor();
|
||||
await s.page.locator("#btn-send").waitFor({ state: "hidden" });
|
||||
assert.match(await textOf(s.page.locator("#footer-summary")), /^All done\./);
|
||||
});
|
||||
@@ -165,7 +165,7 @@ test("the setup page renders found, outside and missing rows with their way forw
|
||||
assert.equal(await table(s).locator("button.split-row").count(), 5, "the four builtin rows and the template");
|
||||
// Nothing picked yet: the pane shows the empty text, and the row badges are
|
||||
// already drawn with each entry's state.
|
||||
assert.equal(await pane(s).locator(".split-empty").count(), 1, "the pane's empty text before a pick");
|
||||
assert.equal(await pane(s).locator(".empty").count(), 1, "the pane's empty text before a pick");
|
||||
assert.equal(await rowByKey(s, "found-one").locator(".prefs-badge.ok").count(), 1);
|
||||
assert.equal(await textOf(rowByKey(s, "found-one").locator(".prefs-badge")), "Found");
|
||||
assert.equal(await textOf(rowByKey(s, "outer").locator(".prefs-badge")), "Found outside PATH");
|
||||
|
||||
@@ -402,7 +402,7 @@ test("a typed line never starts a reply line of its own", () => {
|
||||
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", () => {
|
||||
test("an approved edit stops saying 'Applying it' once the agent has answered it", () => {
|
||||
const frame = {
|
||||
conversation: 1,
|
||||
messages: [
|
||||
|
||||
@@ -26,12 +26,13 @@ function setup({ agent = { status: "waiting" }, items = [question()], ...S } = {
|
||||
|
||||
const working = (sinceMs, extra = {}) => ({ status: "working", since: ago(sinceMs), ...extra });
|
||||
|
||||
test("send state: a finished session is closed, and says paused when its headline does", () => {
|
||||
test("send state: a finished session is closed, and says stopped when its headline says paused", () => {
|
||||
setup({ finish: { headline: "Phase 3 is done" } });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "This session is finished.", short: "Session finished" });
|
||||
// A finished session has nothing to send, ever: the button is hidden and the words stay.
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "This session is finished.", short: "Session finished", hide: true });
|
||||
setup({ finish: { headline: "Paused at Step 2" } });
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "This session is paused.", short: "Session paused" });
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "This session is stopped.", short: "Session stopped", hide: true });
|
||||
});
|
||||
|
||||
test("send state: a finish wins over a dropped connection", () => {
|
||||
@@ -184,3 +185,24 @@ test("suggest state: the chip follows Send, and waits while its own request does
|
||||
setup({ items: [replied] });
|
||||
assert.deepEqual(suggestState(replied), ready, "the agent's reply frees it");
|
||||
});
|
||||
|
||||
// One phrase for a page that lost the server (Help's "Not connected" state):
|
||||
// the constant is exported, the send button uses it, and every other place
|
||||
// that says it imports it instead of typing its own wording.
|
||||
test("the not-connected phrase is one exported constant and the sites use it", async () => {
|
||||
const { NOT_CONNECTED, NOT_CONNECTED_KEPT, notConnected } = await import("../src/web-console/public/labels.js");
|
||||
assert.equal(NOT_CONNECTED, "Not connected right now.");
|
||||
assert.equal(notConnected(), NOT_CONNECTED);
|
||||
assert.equal(notConnected(NOT_CONNECTED_KEPT), `${NOT_CONNECTED} ${NOT_CONNECTED_KEPT}`);
|
||||
setup();
|
||||
page.gone = true;
|
||||
assert.equal(sendState().why, NOT_CONNECTED);
|
||||
const fs = await import("node:fs");
|
||||
const root = new URL("../src/web-console/public/", import.meta.url);
|
||||
const sites = ["send-state.js", "notepad.js", "screens/core.js", "screens/cleanup.js", "screens/learning-row.js", "screens/ask.js", "screens/notepad.js", "screens/ending.js"];
|
||||
for (const file of sites) {
|
||||
const text = fs.readFileSync(new URL(file, root), "utf8");
|
||||
assert.match(text, /labels\.js"/, `${file} imports the constant`);
|
||||
assert.doesNotMatch(text, /["'`][^"'`\n]*(Lost contact with Plan2Code|Plan2Code is not reachable|Plan2Code is not answering)/, `${file} types no wording of its own`);
|
||||
}
|
||||
});
|
||||
@@ -81,7 +81,7 @@ test("the page carries its first state, title and badge, so the first paint need
|
||||
assert.equal((html.match(/<script\b/g) || []).length, 2, "the boot block and app.js, nothing else");
|
||||
// Written into the markup, escaped, with `$&` and `$'` left as typed.
|
||||
assert.ok(html.includes(`<h1 id="title">Lunch </script><script>alert(1)</script> $& $' app</h1>`));
|
||||
assert.ok(html.includes('<span class="badge" id="badge">Building</span>'));
|
||||
assert.ok(html.includes('<span class="pill is-accent is-caps badge" id="badge">Building</span>'));
|
||||
assert.ok(html.includes("Starting Implement"), "the static starting screen names the skill");
|
||||
assert.ok(html.includes('rel="modulepreload" href="/app.js"'));
|
||||
cli(["stop", "--session", res.json.sid, "--force"]);
|
||||
@@ -403,6 +403,8 @@ test("the scratch sweep removes old patches and helpers, never looks, the pointe
|
||||
}
|
||||
});
|
||||
|
||||
const SESSION_STATE = JSON.stringify({ title: "shop", workflow: "pathfinder" });
|
||||
|
||||
test("cleanup finds old sessions and strays in both folders, and keeps every protected name and this session", async () => {
|
||||
const plan2code = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-cleanup-"));
|
||||
const consoleDir = path.join(plan2code, "console");
|
||||
@@ -420,7 +422,7 @@ test("cleanup finds old sessions and strays in both folders, and keeps every pro
|
||||
return p;
|
||||
};
|
||||
const session = (sid, stale) => {
|
||||
const state = put(path.join(consoleDir, "sessions", sid, "state.json"));
|
||||
const state = put(path.join(consoleDir, "sessions", sid, "state.json"), SESSION_STATE);
|
||||
if (stale) backdate(state);
|
||||
return path.dirname(state);
|
||||
};
|
||||
@@ -492,6 +494,12 @@ test("cleanup finds old sessions and strays in both folders, and keeps every pro
|
||||
for (const id of ["root:app", "root:app.json", "root:agents.json", "root:prototypes", "root:learning"]) assert.equal(items.some((i) => i.id === id), false, `${id} is never a stray`);
|
||||
assert.equal(STRAY_GRACE_MS, 60 * 60 * 1000);
|
||||
assert.equal(items.find((i) => i.id === "console:p1.json").bytes, 5);
|
||||
// A session row names itself by title, skill and when it was last touched, never by path.
|
||||
const row = items.find((i) => i.id === "session:20250801-101010-aaaaaa");
|
||||
assert.equal(row.title, "shop");
|
||||
assert.equal(row.workflow, "pathfinder");
|
||||
assert.ok(Number.isFinite(Date.parse(row.at)), "at is an ISO time");
|
||||
assert.equal(items.find((i) => i.id === "console:p1.json").title, undefined, "a stray carries no title");
|
||||
assert.equal(items.find((i) => i.id === "root:console-dev").kind, "folder");
|
||||
assert.equal(bytes, items.reduce((n, i) => n + i.bytes, 0));
|
||||
|
||||
@@ -506,7 +514,7 @@ test("cleanup finds old sessions and strays in both folders, and keeps every pro
|
||||
);
|
||||
assert.deepEqual(done.removed.sort(), ["console:p1.json", "root:console-dev", "session:20250801-101010-aaaaaa"]);
|
||||
assert.deepEqual(done.failed, []);
|
||||
assert.equal(done.bytes, 5 + 3 + 2);
|
||||
assert.equal(done.bytes, 5 + 3 + SESSION_STATE.length);
|
||||
assert.equal(fs.existsSync(old), false);
|
||||
assert.equal(fs.existsSync(path.join(plan2code, "console-dev")), false);
|
||||
assert.ok(fs.existsSync(path.join(plan2code, "notes.txt")), "not asked for, so not removed");
|
||||
|
||||
@@ -531,7 +531,7 @@ test("the page carries the way home: the triangle, its confirm, and the wiring",
|
||||
for (const id of ["home-modal", "home-blurb", "home-warn", "home-cancel", "home-go"]) {
|
||||
assert.ok(html.includes(`id="${id}"`), `index.html must carry #${id}`);
|
||||
}
|
||||
assert.ok(html.includes("Leave this workflow?"));
|
||||
assert.ok(html.includes("Leave this skill?"));
|
||||
assert.match(css, /\.home-btn path\s*\{\s*fill:\s*var\(--accent\)/, "the triangle is filled with the highlight color");
|
||||
});
|
||||
|
||||
@@ -889,7 +889,7 @@ test("looks: resetLooks(keys) changes only those keys, and the role is marked as
|
||||
assert.equal(looks.role, ROLE_NOT_SET, "cleared but marked as asked");
|
||||
assert.equal(looks.sound, false, "sounds untouched by Appearance");
|
||||
assert.equal(looks.hideActivities, false);
|
||||
assert.equal(looks.skipIntro, DEFAULT_LOOKS.skipIntro, "Appearance resets Always SKIP Intro");
|
||||
assert.equal(looks.skipIntro, DEFAULT_LOOKS.skipIntro, "Appearance resets Skip the wake-up intro");
|
||||
resetLooks(prefsResetScope("sounds"));
|
||||
assert.equal(looks.sound, true);
|
||||
assert.equal(looks.soundQuestion, true);
|
||||
|
||||
@@ -325,10 +325,14 @@ test("update banner: the modal is in the page, with the exact command and no inl
|
||||
assert.doesNotMatch(dialog[1], /<script/i);
|
||||
const panel = helpTemplate().match(/<section class="help-panel" data-tab="dashboard">([\s\S]*?)<\/section>/);
|
||||
assert.ok(panel, "the help has a dashboard topic");
|
||||
assert.match(panel[1], /UPDATE AVAILABLE/, "the dashboard topic explains the banner");
|
||||
assert.match(panel[1], /Update available/, "the dashboard topic explains the banner");
|
||||
assert.doesNotMatch(panel[1], /\sstyle=/);
|
||||
assert.doesNotMatch(panel[1], /<script/i);
|
||||
assert.ok(dash.includes('"npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git"'), "the dashboard copies the exact command");
|
||||
assert.ok(dash.includes('"npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git#release"'), "the dashboard copies the exact command");
|
||||
// One sentence and the command up front; the rest sits in a closed details element.
|
||||
assert.match(dialog[1], /<details class="update-more" id="update-more">\s*<summary>Command not found, or nothing happened\?<\/summary>/);
|
||||
assert.ok(dialog[1].indexOf("update-command") < dialog[1].indexOf("<details"), "the command comes before the disclosure");
|
||||
assert.ok(dialog[1].indexOf("git ls-remote") > dialog[1].indexOf("<details"), "the ls-remote note is inside the disclosure");
|
||||
});
|
||||
|
||||
test("update banner: built only on the dashboard, dismissed per session, and Help's version links to Releases", () => {
|
||||
@@ -366,7 +370,7 @@ test("help: the stuck tab is second, with a callout and four symptom rows before
|
||||
assert.equal(HELP_TABS[1].id, "stuck");
|
||||
const tpl = helpTemplate();
|
||||
const panel = tpl.match(/<section class="help-panel" data-tab="stuck">([\s\S]*?)<\/section>/)[1];
|
||||
assert.match(panel, /<div class="help-callout" role="note">/);
|
||||
assert.match(panel, /<div class="callout is-stage help-callout" role="note">/);
|
||||
assert.match(panel, /Check this first/);
|
||||
assert.match(panel, /look at your terminal/);
|
||||
assert.equal((panel.match(/class="help-row"/g) || []).length, 4, "four symptom rows");
|
||||
@@ -388,7 +392,7 @@ test("help: privacy names the handoffs folder and preferences says Cleanup never
|
||||
"the lead no longer says everything lives under the console folder"
|
||||
);
|
||||
const prefs = tpl.match(/<section class="help-panel" data-tab="prefs">([\s\S]*?)<\/section>/)[1];
|
||||
const cleanup = prefs.slice(prefs.indexOf("<strong>Cleanup</strong>"), prefs.indexOf("<strong>Back to default</strong>"));
|
||||
const cleanup = prefs.slice(prefs.indexOf("<strong>Cleanup</strong>"), prefs.indexOf("<strong>Reset this tab</strong>"));
|
||||
assert.match(cleanup, /handoffs/, "the Cleanup text names the handoffs folder");
|
||||
assert.match(cleanup, /never\s+offered/, "the Cleanup text says the handoffs folder is never offered for removal");
|
||||
});
|
||||
@@ -554,3 +558,15 @@ test("Diagnose's opening cards: only What is wrong is required", () => {
|
||||
const prompt = fs.readFileSync(path.join(ROOT, "src", "plan2code-diagnose.md"), "utf8");
|
||||
assert.match(prompt, /the last two `"required":false`/, "the prompt says the last two cards are optional");
|
||||
});
|
||||
|
||||
test("help: the four group headings split the topics in order, so grouping never moves a tab", async () => {
|
||||
const { HELP_GROUPS, helpGroupStart } = await import("../src/web-console/public/help.js");
|
||||
assert.deepEqual(HELP_GROUPS.map((g) => g.title), ["Start here", "Working in a session", "Tools", "Reference"]);
|
||||
const ids = HELP_TABS.map((t) => t.id);
|
||||
const at = HELP_GROUPS.map((g) => ids.indexOf(g.from));
|
||||
assert.equal(at[0], 0, "the first group starts at the first topic");
|
||||
assert.deepEqual(at, [...at].sort((a, b) => a - b), "groups run in the topics' own order");
|
||||
assert.ok(at.every((i) => i >= 0), "every group starts at a real topic");
|
||||
assert.equal(helpGroupStart("planny"), null, "a topic inside a group opens no heading");
|
||||
assert.equal(HELP_TABS.findIndex((t) => t.id === "stuck"), 1, "stuck stays second");
|
||||
});
|
||||
@@ -26,6 +26,7 @@ test("state: page starts as app.js always started it", () => {
|
||||
noteSend: null,
|
||||
noteSent: null,
|
||||
retract: {},
|
||||
seeded: {},
|
||||
chat: { draft: "", history: [], about: null, pending: [], lastSeenReplyId: null, images: [], conversation: null },
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user