mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-29 21:21:18 -08:00
Quiet the Tidy up banner once a tidy-up finds nothing
AI Assisted
This commit is contained in:
1 parent
634e4df10e
commit
ee530d36c0
9 files changed
+148
-8
No files matched your search
@@ -119,6 +119,36 @@ test("scan.learning.nearCap: true at 22 general lessons or 30 in an area, false
|
||||
assert.deepEqual(listing(full), before, "the scan writes nothing");
|
||||
});
|
||||
|
||||
test("scan.learning.nearCap stays false once a tidy-up found nothing, until the saved lessons change", async (t) => {
|
||||
const dir = project({ ...SETTINGS("on"), ".plan2code/lessons/general.md": lessonFile("General", 23) });
|
||||
assert.equal(learningScan(dir).nearCap, true);
|
||||
const s = dashboard(t, dir);
|
||||
const res = await s.post("/learning/tidy-quiet", {});
|
||||
assert.equal(res.status, 200);
|
||||
const body = await res.json();
|
||||
assert.equal(body.ok, true);
|
||||
assert.equal(body.learning.nearCap, false, "the answer carries the patched scan");
|
||||
assert.equal(readState(s.session).scan.learning.nearCap, false, "the page repaints from the patched scan");
|
||||
assert.equal(learningScan(dir).nearCap, false, "a later scan agrees");
|
||||
assert.ok(fs.existsSync(path.join(storeDir(dir), "tidy-quiet.json")), "it lives in the learning store on this machine");
|
||||
// The lessons change (a merge, a new lesson): the nudge may come back.
|
||||
fs.writeFileSync(path.join(dir, ".plan2code", "lessons", "general.md"), lessonFile("General", 24));
|
||||
assert.equal(learningScan(dir).nearCap, true);
|
||||
});
|
||||
|
||||
test("POST /learning/tidy-quiet is 409 when the project is not on and writes nothing into the project", async (t) => {
|
||||
for (const files of [{}, SETTINGS("off")]) {
|
||||
const s = dashboard(t, project(files));
|
||||
const res = await s.post("/learning/tidy-quiet", {});
|
||||
assert.equal(res.status, 409);
|
||||
assert.deepEqual(await res.json(), { error: "not-on" });
|
||||
}
|
||||
const dir = project({ ...SETTINGS("on"), ".plan2code/lessons/general.md": lessonFile("General", 23) });
|
||||
const before = listing(dir);
|
||||
await dashboard(t, dir).post("/learning/tidy-quiet", {});
|
||||
assert.deepEqual(listing(dir), before);
|
||||
});
|
||||
|
||||
test("a failure in Learning's core never fails the scan", () => {
|
||||
const boom = () => {
|
||||
throw new Error("the core broke");
|
||||
|
||||
@@ -282,6 +282,17 @@ test("the banner nudges a tidy-up when lessons are near their limit, and only th
|
||||
assert.equal(await below.main.locator(".learn-banner").count(), 0, "no banner below the line");
|
||||
});
|
||||
|
||||
test("Not now hides the tidy-up nudge at once and it stays hidden for the same lessons", async (t) => {
|
||||
const full = await dashboard(t, { ...PROJECT("on"), ".plan2code/lessons/general.md": lessonFile("General", 22) });
|
||||
const banner = full.main.locator(".learn-banner");
|
||||
await banner.waitFor();
|
||||
await banner.getByRole("button", { name: "Not now" }).click();
|
||||
await until(async () => (await full.main.locator(".learn-banner").count()) === 0, 5000);
|
||||
const state = await full.s.page.evaluate(() => fetch("/learning/state").then((r) => r.json()));
|
||||
assert.equal(state.nearCap, false, "the server remembers it");
|
||||
assert.equal(await full.main.locator(".learn-banner").count(), 0, "still hidden after the repaint");
|
||||
});
|
||||
|
||||
test("a launch from a dashboard showing lessons waiting carries fromBanner", async (t) => {
|
||||
const { s, main } = await dashboard(t, PROJECT("on"), (p) =>
|
||||
writeWaiting(p, { id: "20261113-120000-eeeeee", type: "lesson", text: "Waits.", noted: new Date().toISOString() })
|
||||
|
||||
@@ -189,7 +189,7 @@ test("shape: no page module sets a style attribute from script", () => {
|
||||
// no routes of its own: its buttons are sends (`__git`), through /submit.
|
||||
const ROUTE_ORDER = [
|
||||
"/health", "/s/", "/handover", "/", "SERVABLE", "/overview", "/agents-doc", "/prototypes", "/prototype", "/handoff", "/version", "/state", "/events", "/draft",
|
||||
"/looks", "/looks", "/subagents", "/learning/pause", "/learning/state", "/learning/lessons", "/pr-host", "/models", "/models", "/agents", "/agents", "/agents/test", "/agents/use-path", "/cleanup", "/upload",
|
||||
"/looks", "/looks", "/subagents", "/learning/pause", "/learning/tidy-quiet", "/learning/state", "/learning/lessons", "/pr-host", "/models", "/models", "/agents", "/agents", "/agents/test", "/agents/use-path", "/cleanup", "/upload",
|
||||
"/notepad", "/notepad/text", "/notepad/image", "/notepad/thumb", "/notepad/image/delete", "/notepad/tab",
|
||||
"/notepad/tab/rename", "/notepad/tab/delete", "/notepad/tab/order", "/notepad/tab/last", "/notepad/tab/sent", "/notepad/images/",
|
||||
"/attachments/", "/shots/", "/uploads/", "/submit", "/open-link", "/open-prototype", "/chat", "/chat/decision", "/workspace",
|
||||
|
||||
Reference in new issue
Block a user