mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Test when the Send button is available and what it says
AI Assisted
This commit is contained in:
1 parent
7509b09b81
commit
7f1851fbb9
2 files changed
+154
-1
No files matched your search
+1
-1
@@ -11,7 +11,7 @@
|
||||
"fix:eol": "node scripts/fix-line-endings.mjs",
|
||||
"play": "node scripts/play.mjs",
|
||||
"pretest": "node scripts/fix-line-endings.mjs",
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-test-map.mjs scripts/test-script-test-match.mjs scripts/test-script-test-commands.mjs scripts/test-script-run-check.mjs scripts/test-script-pr-prep.mjs scripts/test-script-coverage.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-pointers.mjs scripts/test-console-wire-budgets.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-lantern.mjs scripts/test-web-console-activities-ghoul-marrow.mjs scripts/test-web-console-activities-ghoul-mat.mjs scripts/test-web-console-activities-ghoul-eye.mjs scripts/test-web-console-activities-ghoul-bonestair.mjs scripts/test-web-console-activities-ghoul-heart.mjs scripts/test-web-console-activities-ghoul-ending.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-test-map.mjs scripts/test-script-test-match.mjs scripts/test-script-test-commands.mjs scripts/test-script-run-check.mjs scripts/test-script-pr-prep.mjs scripts/test-script-coverage.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-pointers.mjs scripts/test-console-wire-budgets.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-lantern.mjs scripts/test-web-console-activities-ghoul-marrow.mjs scripts/test-web-console-activities-ghoul-mat.mjs scripts/test-web-console-activities-ghoul-eye.mjs scripts/test-web-console-activities-ghoul-bonestair.mjs scripts/test-web-console-activities-ghoul-heart.mjs scripts/test-web-console-activities-ghoul-ending.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-send-state.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gpt-tokenizer": "2.9.0",
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
// Web console tests, the Send button: public/send-state.js decides whether
|
||||
// Send is available and what its button says, from the shared page state. It
|
||||
// only defines, so it imports here under plain Node and each case sets `page`
|
||||
// directly.
|
||||
// Run with: node --test scripts/test-web-console-send-state.mjs
|
||||
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { page, fresh } from "../src/web-console/public/state.js";
|
||||
import { WORKING_GRACE_MS } from "../src/web-console/public/selectors.js";
|
||||
import { sendState } from "../src/web-console/public/send-state.js";
|
||||
|
||||
const MIN = 60 * 1000;
|
||||
const ago = (ms) => new Date(Date.now() - ms).toISOString();
|
||||
const question = (id = "q1", extra = {}) => ({ id, kind: "choice", title: "Export format", status: "open", required: true, ...extra });
|
||||
|
||||
// A waiting agent seen just now, one open question, nothing staged.
|
||||
function setup({ agent = { status: "waiting" }, items = [question()], ...S } = {}) {
|
||||
page.S = { workflow: "test", agent, items, ...S };
|
||||
page.local = fresh();
|
||||
page.gone = false;
|
||||
page.pendingResult = false;
|
||||
page.agentLastSeen = ago(0);
|
||||
page.chatFrame = null;
|
||||
}
|
||||
|
||||
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", () => {
|
||||
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" });
|
||||
setup({ finish: { headline: "Paused at Step 2" } });
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "This session is paused.", short: "Session paused" });
|
||||
});
|
||||
|
||||
test("send state: a finish wins over a dropped connection", () => {
|
||||
setup({ finish: { headline: "Done" } });
|
||||
page.gone = true;
|
||||
assert.equal(sendState().short, "Session finished");
|
||||
});
|
||||
|
||||
test("send state: offline reads Not connected, whatever is staged", () => {
|
||||
setup();
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
page.gone = true;
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "Not connected right now.", short: "Not connected" });
|
||||
});
|
||||
|
||||
test("send state: the loop driving locks Send until a question it does not handle waits", () => {
|
||||
setup({ loop: { driving: true }, items: [question("q1", { handledBy: "loop" })] });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "The loop is building. Cards unlock when it needs you.", short: "The loop is building" });
|
||||
|
||||
setup({ loop: { driving: true }, items: [question("q2")] });
|
||||
page.local.staged.q2 = { k: "A" };
|
||||
assert.deepEqual(sendState(), { disabled: false, why: "" }, "a question for the person unlocks it");
|
||||
|
||||
setup({ loop: { driving: true }, loopEnd: { at: ago(0) }, items: [question("q1", { handledBy: "loop" })] });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
assert.deepEqual(sendState(), { disabled: false, why: "" }, "a posted loopEnd lets go of the page");
|
||||
});
|
||||
|
||||
test("send state: a send still being collected stays disabled, and says so once nobody comes for it", () => {
|
||||
setup();
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
page.pendingResult = true;
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "Your last answers are on their way. One moment.", short: "" });
|
||||
|
||||
page.agentLastSeen = ago(2 * MIN);
|
||||
assert.deepEqual(sendState(), {
|
||||
disabled: true,
|
||||
why: "Saved, and waiting for Plan2Code to come back for them.",
|
||||
short: "Saved, not picked up",
|
||||
});
|
||||
});
|
||||
|
||||
test("send state: while the agent works, an answer or a note to an open question can still go", () => {
|
||||
setup({ agent: working(MIN) });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
const open = { disabled: false, why: "Plan2Code is still working. Your answers wait for it to look.", short: "Still working · it reads this next" };
|
||||
assert.deepEqual(sendState(), open);
|
||||
|
||||
setup({ agent: working(MIN) });
|
||||
page.local.drafts["thread-q1"] = "Prefer CSV for Excel.";
|
||||
assert.deepEqual(sendState(), open, "a typed note counts as much as a staged answer");
|
||||
});
|
||||
|
||||
test("send state: a question already sent is not the person's turn while the agent works", () => {
|
||||
setup({ agent: working(MIN) });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
page.local.sent.q1 = true;
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "Wait for Plan2Code to finish.", short: "" });
|
||||
});
|
||||
|
||||
test("send state: past the working grace, something staged can be pushed through", () => {
|
||||
setup({ agent: working(WORKING_GRACE_MS + MIN), items: [] });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
assert.deepEqual(sendState(), { disabled: false, why: "Plan2Code has been busy a while. You can send anyway.", short: "Busy · send anyway" });
|
||||
});
|
||||
|
||||
test("send state: past the working grace with nothing staged, open questions say a note unlocks Send", () => {
|
||||
setup({ agent: working(WORKING_GRACE_MS + MIN), items: [question("q1", { submitted: { at: ago(MIN) } })] });
|
||||
assert.deepEqual(sendState(), {
|
||||
disabled: true,
|
||||
why: "Plan2Code has been busy a while. Answer something or add a note, and you can send anyway.",
|
||||
short: "Busy · a note unlocks Send",
|
||||
});
|
||||
|
||||
setup({ agent: working(WORKING_GRACE_MS + MIN), items: [] });
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "Plan2Code has been busy a while.", short: "Busy a while" });
|
||||
});
|
||||
|
||||
test("send state: quietMinutes stretches the working grace", () => {
|
||||
setup({ agent: working(10 * MIN, { quietMinutes: 30 }), items: [] });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "Wait for Plan2Code to finish.", short: "" });
|
||||
|
||||
setup({ agent: working(31 * MIN, { quietMinutes: 30 }), items: [] });
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
assert.equal(sendState().short, "Busy · send anyway", "past the stretched grace the hatch opens");
|
||||
});
|
||||
|
||||
test("send state: inside the working grace Send waits, and reads Gone quiet once the agent is adrift", () => {
|
||||
setup({ agent: working(MIN), items: [] });
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "Wait for Plan2Code to finish.", short: "" });
|
||||
|
||||
setup({ agent: working(4 * MIN), items: [] });
|
||||
page.agentLastSeen = ago(4 * MIN);
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "Wait for Plan2Code to finish.", short: "Gone quiet" });
|
||||
});
|
||||
|
||||
test("send state: an idle page enables Send only once something is staged or typed", () => {
|
||||
setup();
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "" });
|
||||
|
||||
page.local.staged.q1 = { k: "A" };
|
||||
assert.deepEqual(sendState(), { disabled: false, why: "" });
|
||||
|
||||
setup();
|
||||
page.local.drafts["thread-q1"] = " ";
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "" }, "a blank note is nothing to send");
|
||||
});
|
||||
|
||||
test("send state: a note waits while its picture uploads, and goes once it is ready", () => {
|
||||
setup();
|
||||
page.local.drafts["thread-q1"] = "See the screenshot.";
|
||||
page.local.images.q1 = [{ key: "a", status: "uploading" }];
|
||||
assert.deepEqual(sendState(), { disabled: true, why: "" }, "a held note is not sent");
|
||||
|
||||
page.local.images.q1 = [{ key: "a", status: "ready", url: "/uploads/a.jpg" }];
|
||||
assert.deepEqual(sendState(), { disabled: false, why: "" });
|
||||
});
|
||||
Reference in new issue
Block a user