mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Add a per-phase webhook message and more detail to loop notifications
AI Assisted
This commit is contained in:
1 parent
e5155778bf
commit
5136269ca7
7 files changed
+632
-79
No files matched your search
@@ -557,6 +557,7 @@ test("loop-setup: a new project reads as the defaults with remembered false, and
|
||||
assert.equal(got.setup.notifyUrl, "", "no web address is called by default");
|
||||
assert.equal(got.setup.notifyKind, "query");
|
||||
assert.equal(got.setup.notifyParam, "message");
|
||||
assert.equal(got.setup.notifyPhases, false, "a phase-complete message is opt-in");
|
||||
assert.equal(fs.existsSync(LOOP_SETUP_PATH), false, "reading never creates the file");
|
||||
});
|
||||
|
||||
@@ -626,6 +627,31 @@ test("loop-setup: an entry saved before fixMode existed reads as levels", () =>
|
||||
assert.deepEqual(got.read.fix, ["warning"], "the saved fields are kept");
|
||||
});
|
||||
|
||||
test("loop-setup: the phase-complete message saves as a yes or no, and an older entry reads as no", () => {
|
||||
fs.rmSync(LOOP_SETUP_PATH, { force: true });
|
||||
const got = inStore(
|
||||
async (m, { project, workspace }) => {
|
||||
const fs = await import("node:fs");
|
||||
const { foldKey } = await import(workspace);
|
||||
const base = { ...m.LOOP_DEFAULTS, fix: [...m.LOOP_DEFAULTS.fix], notifyUrl: "https://example.com/hook" };
|
||||
const on = m.saveLoopSetup(project, { ...base, notifyPhases: true }).notifyPhases;
|
||||
let refused = "";
|
||||
try {
|
||||
m.saveLoopSetup(project, { ...base, notifyPhases: "yes" });
|
||||
} catch (e) {
|
||||
refused = e.message;
|
||||
}
|
||||
const { notifyPhases, ...older } = { ...base, saved: "2026-01-01T00:00:00.000Z" };
|
||||
fs.writeFileSync(m.LOOP_SETUP_FILE, JSON.stringify({ schema: 1, projects: { [foldKey(project)]: older } }));
|
||||
return { on, refused, older: m.readLoopSetup(project).notifyPhases };
|
||||
},
|
||||
{ project: projectA, workspace: WORKSPACE_URL }
|
||||
);
|
||||
assert.equal(got.on, true);
|
||||
assert.match(got.refused, /"notifyPhases" must be true or false/);
|
||||
assert.equal(got.older, false, "an entry saved before the box existed sends no phase messages");
|
||||
});
|
||||
|
||||
test("loop-setup: good web addresses save, with a bad name allowed only while no address is set", () => {
|
||||
fs.rmSync(LOOP_SETUP_PATH, { force: true });
|
||||
const got = inStore(
|
||||
@@ -778,7 +804,7 @@ test("loop-setup: GET /loop-setup lists the phases left for a spec and refuses a
|
||||
}
|
||||
|
||||
// Saving through the route, then reading it back in a new request.
|
||||
const save = await send({ review: true, fixMode: "smart", fix: ["critical"], commit: true, onQuestion: "stop", afterLast: "offer-finalize", quickCheck: "", notifyKind: "query", notifyUrl: "https://example.com/hook", notifyParam: "msg", retryOnce: true, silenceMinutes: 30, phaseStrength: false, strengths: {} });
|
||||
const save = await send({ review: true, fixMode: "smart", fix: ["critical"], commit: true, onQuestion: "stop", afterLast: "offer-finalize", quickCheck: "", notifyKind: "query", notifyUrl: "https://example.com/hook", notifyParam: "msg", notifyPhases: true, retryOnce: true, silenceMinutes: 30, phaseStrength: false, strengths: {} });
|
||||
assert.equal(save.status, 200, await save.clone().text());
|
||||
const after = await get("?spec=specs/demo");
|
||||
assert.equal(after.body.remembered, true);
|
||||
@@ -948,7 +974,7 @@ test("GET /loop-setup?agent= answers the loop agent's resolved strengths and thi
|
||||
// A save with picks reads back for its own spec; a pick for a phase that is not there is pruned.
|
||||
const entry = {
|
||||
review: true, fixMode: "smart", fix: ["critical"], commit: true, onQuestion: "guess", afterLast: "offer-finalize", quickCheck: "",
|
||||
notifyKind: "query", notifyUrl: "", notifyParam: "message", retryOnce: true, silenceMinutes: 20, phaseStrength: true,
|
||||
notifyKind: "query", notifyUrl: "", notifyParam: "message", notifyPhases: false, retryOnce: true, silenceMinutes: 20, phaseStrength: true,
|
||||
strengths: { "specs/demo": [{ n: 2, name: "Two", strength: "best" }, { n: 9, name: "Gone", strength: "best" }] },
|
||||
};
|
||||
const save = await fetch(`${base}/loop-setup`, { method: "POST", headers: { "content-type": "application/json", cookie, origin: base, connection: "close" }, body: JSON.stringify(entry) });
|
||||
|
||||
@@ -73,6 +73,8 @@ test("the web address field shows the name only beside an address, warns while t
|
||||
|
||||
assert.equal(await url.inputValue(), "");
|
||||
assert.equal(await param.isVisible(), false, "no address, no name to set");
|
||||
const phases = s.page.locator("#loop-notify-phases");
|
||||
assert.equal(await phases.isVisible(), false, "no address, no phase messages to choose");
|
||||
assert.equal(await warn.isVisible(), false);
|
||||
|
||||
await url.fill("example.com");
|
||||
@@ -83,6 +85,9 @@ test("the web address field shows the name only beside an address, warns while t
|
||||
assert.equal(await warn.isVisible(), false);
|
||||
assert.equal(await param.isVisible(), true);
|
||||
assert.equal(await param.inputValue(), "message", "the default name");
|
||||
assert.equal(await phases.isVisible(), true);
|
||||
assert.equal(await phases.isChecked(), false, "a message per phase is opt-in");
|
||||
await phases.check();
|
||||
|
||||
await param.fill("a b");
|
||||
assert.match(await textOf(warn), /letters, digits/);
|
||||
@@ -103,6 +108,7 @@ test("the web address field shows the name only beside an address, warns while t
|
||||
const reread = await s.page.evaluate(async () => (await fetch("/loop-setup")).json());
|
||||
assert.equal(reread.notifyUrl, "https://example.com/hook?team=a");
|
||||
assert.equal(reread.notifyParam, "msg");
|
||||
assert.equal(reread.notifyPhases, true, "the box is saved with the setup");
|
||||
assert.equal(reread.remembered, true);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user