Fill a lesson's Reword boxes with the words Ask for suggestions sends

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-29 10:49:42 -08:00
1 parent e0f82cc36b
commit 834b71e82d
7 files changed
+143 -7

No files matched your search

@@ -568,6 +568,74 @@ test("lessons card: Use this wording opens Reword filled with the suggestion, an
]);
});
test("lessons card: a Reword suggestion with words fills the lesson and Why boxes, open already or opened after", async (t) => {
const second = { ...ROWS[0], id: "w-later", text: "Another lesson.", why: "An old reason." };
const { s, card } = await lessonsCard(t, CARD([ROWS[0], second]));
const open = rowOf(card, "w-lesson");
// Reword picked before the suggestion lands.
await open.getByRole("button", { name: "Reword" }).click();
await open.locator(".lessons-edit").waitFor();
s.post({
items: [
{
id: "lessons",
suggested: {
"w-lesson": { choice: "Reword", text: "Run one page test file alone first.", why: "A full run hides a race between page tests." },
"w-later": { choice: "Reword", why: "The newer reason." },
},
},
],
agent: { status: "waiting" },
});
await open.locator(".lessons-choices button.is-suggested", { hasText: "Reword" }).waitFor();
await until(async () => (await open.getByLabel("Why").inputValue()) === "A full run hides a race between page tests.", 3000);
assert.equal(await open.getByLabel("The lesson").inputValue(), "Run one page test file alone first.", "the lesson box takes the suggested words");
// Reword opened after the suggestion: a suggestion without text keeps the row's own words.
const later = rowOf(card, "w-later");
await later.getByRole("button", { name: "Reword" }).click();
await later.locator(".lessons-edit").waitFor();
assert.equal(await later.getByLabel("Why").inputValue(), "The newer reason.");
assert.equal(await later.getByLabel("The lesson").inputValue(), "Another lesson.");
// What the person types afterwards stays through a later push.
await open.getByLabel("Why").fill("My own reason.");
s.post({ agent: { status: "waiting", activity: "Still here" } });
await settled(s.page, "#main");
assert.equal(await open.getByLabel("Why").inputValue(), "My own reason.", "the suggestion is applied once, never over typing");
const got = await sendAndCollect(s);
assert.deepEqual(got.actions.find((a) => a.i === "lessons").decisions, [
{ id: "w-lesson", choice: "Reword", text: "Run one page test file alone first.", why: "My own reason." },
{ id: "w-later", choice: "Reword", text: "Another lesson.", why: "The newer reason." },
]);
});
test("lessons card: suggested words fill an area's name without a Why, and leave a log line's several lessons whole", async (t) => {
const area = ROWS[4];
const log = { ...ROWS[3], id: "log:two", lessons: ["Run npm run fix:eol for line endings.", "Check .gitattributes first."] };
const { s, card } = await lessonsCard(t, CARD([area, log]));
s.post({
items: [
{
id: "lessons",
suggested: {
"w-area": { choice: "Rename", text: "Games", why: "Ignored: an area has no Why." },
"log:two": { choice: "Reword and move", text: "One sentence.", why: "Line endings break the diff." },
},
},
],
agent: { status: "waiting" },
});
const areaRow = rowOf(card, "w-area");
await areaRow.locator(".lessons-choices button.is-suggested", { hasText: "Rename" }).waitFor();
await areaRow.getByRole("button", { name: "Rename" }).click();
await until(async () => (await areaRow.getByLabel("The area's name").inputValue()) === "Games", 3000);
assert.equal(await areaRow.getByLabel("Why").count(), 0, "an area has no Why box");
const logRow = rowOf(card, "log:two");
await logRow.getByRole("button", { name: "Reword and move" }).click();
await until(async () => (await logRow.getByLabel("Why").inputValue()) === "Line endings break the diff.", 3000);
assert.equal(await logRow.getByLabel("Lesson 1").inputValue(), "Run npm run fix:eol for line endings.", "the several lessons stay");
assert.equal(await logRow.getByLabel("Lesson 2").inputValue(), "Check .gitattributes first.");
});
test("lessons card: a flagged row says what was flagged", async (t) => {
const flagged = { ...ROWS[0], id: "w-flag", flags: [{ pattern: "email", part: "a@b.c" }] };
const { card } = await lessonsCard(t, CARD([flagged]));