diff options
Diffstat (limited to 'test-suite/unit/background-policy.test.mjs')
| -rw-r--r-- | test-suite/unit/background-policy.test.mjs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test-suite/unit/background-policy.test.mjs b/test-suite/unit/background-policy.test.mjs index ea08be0..98eaa7c 100644 --- a/test-suite/unit/background-policy.test.mjs +++ b/test-suite/unit/background-policy.test.mjs @@ -71,7 +71,7 @@ function piHarness({ session = "alpha", send } = {}) { } const flagCases = [ - [{}, false], [{ background: false }, false], [{ background: true }, true], + [{}, true], [{ background: false }, false], [{ background: true }, true], [{ foreground: true }, false], [{ foreground: false }, true], [{ background: false, foreground: false }, false], [{ background: true, foreground: true }, true], ]; @@ -96,6 +96,7 @@ test("session background on overrides all per-call/legacy foreground flags; off test("every registered page tool, tab.new, and chrome_launch(url) use the central policy", async () => { const h = piHarness(); + await h.background("on"); const cases = [ ["chrome_launch", { url: "https://example.test" }, "tab.new"], ["chrome_tab", { action: "new", group: false, groupTitle: "other" }, "tab.new"], @@ -143,7 +144,11 @@ test("typing options and verification pass through real tool registrations witho test("activation is rejected before dispatch; existing on/off/toggle/status commands suffice", async () => { const h = piHarness(); - await assert.rejects(h.tool("chrome_tab", { action: "activate", targetId: "2", background: false }), /background mode.*\/chrome background off/); + await h.tool("chrome_tab", { action: "activate", targetId: "2" }); + assert.equal(h.calls.at(-1).params.foreground, true, "activation is allowed by default"); + h.calls.length = 0; + await h.background("on"); + await assert.rejects(h.tool("chrome_tab", { action: "activate", targetId: "2", background: false }), /background mode on/); assert.equal(h.calls.length, 0); await h.background("off"); await h.tool("chrome_tab", { action: "activate", targetId: "2" }); @@ -199,9 +204,9 @@ test("shared-owner sessions retain independent policies; per-call background sti const sharedCalls = []; const send = async (action, params) => { sharedCalls.push({ action, params }); return {}; }; const a = piHarness({ session: "A", send }), b = piHarness({ session: "B", send }); - await b.background("off"); + await a.background("on"); await a.send("tab.new", { background: false }); - await b.send("tab.new", {}); + await b.send("tab.new", { background: false }); assert.equal(sharedCalls[0].params.sessionKey, "session:A"); assert.equal(sharedCalls[0].params.foreground, false); assert.equal(sharedCalls[0].action, "tab.new.background"); @@ -314,6 +319,7 @@ function assertNoFocus(h) { test("Pi-to-worker background aliases preserve grouping, screenshot output, and ownership-aware cleanup", async () => { const h = workerHarness(); const pi = piHarness({ send: (action, params) => h.w.dispatch(action, params) }); + await pi.background("on"); const opened = await pi.tool("chrome_tab", { action: "new", group: false, groupTitle: "wrong", background: false }); assert.equal(opened.details.result.group.title, "Pi Session: alpha"); const launched = await pi.tool("chrome_launch", { url: "https://fixture.test" }); |
