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");
|
||||
|
||||
Reference in new issue
Block a user