mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Size the Lessons modal like the Notebook and offer suggestions on the Lessons card
AI Assisted
This commit is contained in:
1 parent
8459836d3b
commit
a90fb8647c
7 files changed
+91
-9
No files matched your search
@@ -392,7 +392,7 @@ const chipOf = (s) => s.page.locator("#aside").getByRole("button", { name: "Ask
|
||||
|
||||
// What a person sees break: the chip on a card where there is nothing to pick,
|
||||
// on a settled record, or missing where they are unsure what to pick.
|
||||
test("the Ask for suggestions chip shows on open choice, multi and confirm cards only", async (t) => {
|
||||
test("the Ask for suggestions chip shows on open choice, multi, confirm and lessons cards only", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "plan",
|
||||
@@ -401,13 +401,14 @@ test("the Ask for suggestions chip shows on open choice, multi and confirm cards
|
||||
{ id: "c1", kind: "choice", title: "Export format", body: "Which format?", options: [opt("A", "CSV"), opt("B", "JSON")] },
|
||||
{ id: "m1", kind: "multi", title: "Columns", body: "Which?", options: [opt("1", "Date"), opt("2", "User")] },
|
||||
{ id: "y1", kind: "confirm", title: "Keep going", body: "Carry on?" },
|
||||
{ id: "l1", kind: "lessons", title: "Lessons to keep", body: "Choose for each one.", required: false, rows: [{ id: "r1", type: "lesson", text: "A lesson.", why: "", origin: "You said this.", note: "", flags: [], refused: null, area: "General", kind: "convention", about: ["a.js"], areas: ["General"], choices: ["Keep", "Reword", "Drop"] }] },
|
||||
{ id: "t1", kind: "text", title: "What to call it", body: "A name.", required: false },
|
||||
{ id: "d1", kind: "choice", title: "Old pick", body: "Which?", options: [opt("A", "CSV"), opt("B", "JSON")], status: "answered", answer: { k: "B" } },
|
||||
],
|
||||
agent: { status: "waiting" },
|
||||
},
|
||||
});
|
||||
for (const [id, title, shown] of [["c1", "Export format", 1], ["m1", "Columns", 1], ["y1", "Keep going", 1], ["t1", "What to call it", 0], ["d1", "Old pick", 0]]) {
|
||||
for (const [id, title, shown] of [["c1", "Export format", 1], ["m1", "Columns", 1], ["y1", "Keep going", 1], ["l1", "Lessons to keep", 1], ["t1", "What to call it", 0], ["d1", "Old pick", 0]]) {
|
||||
await goTo(s, id, title);
|
||||
assert.equal(await chipOf(s).count(), shown, `chip on ${id}`);
|
||||
if (shown) assert.equal(await textOf(chipOf(s)), "Ask for suggestions");
|
||||
|
||||
@@ -517,6 +517,28 @@ test("lessons card: Not now and the corner close leave every lesson waiting and
|
||||
}
|
||||
});
|
||||
|
||||
test("lessons card: the dialog has Ask for suggestions, which sends one request and shows the reply in a Suggestions box", async (t) => {
|
||||
const { s, dlg } = await reviewOpen(t);
|
||||
s.wait(10);
|
||||
postCard(s);
|
||||
await dlg.locator(".lessons-row").waitFor();
|
||||
const ask = dlg.getByRole("button", { name: "Ask for suggestions" });
|
||||
assert.equal(await ask.isDisabled(), false);
|
||||
assert.equal(await dlg.locator(".lessons-suggestions").count(), 0, "nothing asked yet");
|
||||
await ask.click();
|
||||
const got = s.wait(10);
|
||||
assert.equal(got.code, 0);
|
||||
const sentAction = got.actions.find((a) => a.suggest === true);
|
||||
assert.ok(sentAction, JSON.stringify(got.actions));
|
||||
assert.equal(sentAction.i, "lessons");
|
||||
assert.match(got.reply, /^Suggestions wanted on Lessons to keep:/m);
|
||||
await dlg.locator(".lessons-suggestions", { hasText: "Asking Plan2Code" }).waitFor();
|
||||
assert.equal(await dlg.getByRole("button", { name: "Ask for suggestions" }).isDisabled(), true, "one request waits at a time");
|
||||
assert.equal(await dlg.getByRole("button", { name: "Keep" }).count(), 1, "the lessons stay open to choose");
|
||||
s.post({ items: [{ id: "lessons", thread: [{ who: "agent", text: "1. Keep it: a real trap." }] }], agent: { status: "waiting" } });
|
||||
await dlg.locator(".lessons-suggestions", { hasText: "Keep it: a real trap." }).waitFor();
|
||||
});
|
||||
|
||||
test("lessons card: closing with choices made asks first, and Keep editing goes back", async (t) => {
|
||||
const { s, dlg } = await reviewOpen(t);
|
||||
s.wait(10);
|
||||
|
||||
Reference in new issue
Block a user