diff --git a/docs/requirements/020-bulk-grant-mode.md b/docs/requirements/020-bulk-grant-mode.md index 09eb593..24f2c97 100644 --- a/docs/requirements/020-bulk-grant-mode.md +++ b/docs/requirements/020-bulk-grant-mode.md @@ -19,14 +19,18 @@ pass. 2. **Mode switch**: a segmented control "Direct | Select" in the header tools at the top right; Direct keeps today's behaviour. Rejected: a switch per view. -3. **What collects**: in Select, every grant button toggles its item into - one shared selection (pressed state): inbox rows, Home, stream rows, the - review sheet and the key `a`. A grant of an item `selectable()` refuses - (red-gate review, rule request, decision without a recommendation, - operator row without a command) stays direct and its title says why. - Deny always acts at once with its reason; the Match deck and the palette - keep their own confirmed release. Rejected: a unified tray where denials - collect too. +3. **What collects** (operator 2026-11-20): in Select, every grant button + and every option pick toggles its item into one shared selection + (pressed state): inbox rows, Home, stream rows, the review sheet and the + key `a`. A decision or decision row keeps the option picked for it; + picking the same option again takes it out. Grant n signs every + batchable item under one passkey signature, then asks one more + signature per rule request and per red-gate review, one after the + other, since the server accepts neither inside a batch. Deny always + acts at once with its reason; the Match deck and the palette keep their + own confirmed release. Rejected: a unified tray where denials collect + too; rules, red-gate reviews and option picks acting directly in Select + (operator 2026-11-20: Select applies to every item). 4. **Tray**: in Select, beside the switch: `n selected` with Grant n, Deny n, Grant all green and Clear. Grant and Deny open the existing selection sheet that lists every entry and full command; one passkey @@ -85,15 +89,21 @@ flowchart TD - [ ] Tray "Grant n" opens the selection sheet with exactly the selected entries; one passkey signature covers them all, and after the undo time each is granted. -- [ ] In Select, the grant of a red-gate review and Accept on a rule request - act directly as in Direct; Deny acts at once in both modes. +- [ ] In Select, an option pick on a decision or decision row, the grant of + a red-gate review and Accept on a rule request add the item to the + selection; Grant n posts the batchable items under one signature, then + each rule and red-gate review under its own; Deny acts at once in both + modes. +- [ ] A grant, option pick or checkbox in Waits on Operator never scrolls + the page; only `j` and `k` move the view to the cursor. - [ ] In Direct, every grant button acts as today and the tray is hidden. ### Tests - [ ] Unit: view store validation of `approval.mode`; page vm: a grant in - Select toggles `ui.selected` without a post, a grant in Direct posts, a - grant of a non-selectable item stays direct, the tray counts. + Select toggles `ui.selected` without a post, a grant in Direct posts, + an option pick collects with its label, a rule and a red-gate review + collect and get their own signature after the batch, the tray counts. - [ ] Integration: n/a: the server and the signing path stay unchanged (decision 6). - [ ] E2E: Chromium and Firefox at 1920, 1366 and 390: the continuous diff diff --git a/orchestrator/templates/page-grant.js b/orchestrator/templates/page-grant.js index 5b34ba9..2005e2b 100644 --- a/orchestrator/templates/page-grant.js +++ b/orchestrator/templates/page-grant.js @@ -1,41 +1,74 @@ const GRANT_SELECT = "select"; const GRANT_MODES = { direct: ["Direct", "bi-lightning-charge", "Direct mode", "Direct: every grant button grants at once"], - [GRANT_SELECT]: ["Select", "bi-check2-square", "Select mode", "Select: every grant button adds its item to the selection; Grant grants the selection under one passkey signature"], + [GRANT_SELECT]: ["Select", "bi-check2-square", "Select mode", "Select: every grant button and option adds its item to the selection; Grant grants the selection under one passkey signature, each rule and red-gate review under its own"], }; const PICKED_HINT = "In the selection: take it out with ✕ in the Grant menu"; - const DIRECT_WHY = {rule: "a rule is accepted one at a time", review: "a red gate is never granted in a selection"}; + const SOLO_HINT = "Select: press to add it to the selection; Grant asks its own passkey signature for it"; const grantView = {tray: null, sig: "", open: false}; + const choices = new Map(); const grantMode = () => (typeof ViewStore === "object" && ViewStore ? ViewStore.get("approval.mode") : "direct"); - const collecting = (item) => grantMode() === GRANT_SELECT && selectable(item); + const chosenLabel = (item) => (ui.selected.has(keyOf(item)) ? choices.get(keyOf(item)) : undefined); + const solo = (item) => !item.held && (item.kind === "rule" || (item.kind === "review" && item.gate !== "pass")); + const batchable = (item) => selectable(item) || (!item.held && chosenLabel(item) !== undefined); + const collectable = (item) => batchable(item) || solo(item); + const collecting = (item) => grantMode() === GRANT_SELECT && collectable(item); + const picking = (item) => grantMode() === GRANT_SELECT && !item.held; + + /** + * @param {Object} item a batchable inbox item. + * @returns {string} the label its grant carries: the picked option, else a decision's recommendation, else "". + */ + function labelOf(item) { + const label = chosenLabel(item); + if (label !== undefined) { + return label; + } + return item.kind === "decision" ? item.recommended : ""; + } function regrant() { render(false); drawStream(); } - function collect(item) { - const key = keyOf(item); + function flip(key) { + choices.delete(key); if (ui.selected.has(key)) { ui.selected.delete(key); } else { ui.selected.add(key); } + } + + function collect(item) { + flip(keyOf(item)); + regrant(); + } + + /** + * @param {Object} item a decision or a decision row. + * @param {string} label the picked answer; picking the same answer again takes the item out of the selection. + */ + function collectPick(item, label) { + const key = keyOf(item); + if (chosenLabel(item) === label) { + collect(item); + return; + } + choices.set(key, label); + ui.selected.add(key); regrant(); } /** * @param button - the grant button of item. * @param item - a waiting inbox item. - * @returns button; a picked item's button turns pale green and disabled, and in Select it says why a grant still acts at once. + * @returns button; a picked item's button turns pale green and disabled, and in Select a rule or red-gate review says it gets its own signature. */ function grantPress(button, item) { - const select = grantMode() === GRANT_SELECT; - if (!selectable(item)) { - if (select) { - button.setAttribute("title", `${button.getAttribute("title")}: acts at once, ${DIRECT_WHY[item.kind]}`); - } + if (!collectable(item)) { return button; } const picked = ui.selected.has(keyOf(item)); @@ -44,10 +77,10 @@ button.setAttribute("class", `${button.getAttribute("class")} picked`); button.setAttribute("title", PICKED_HINT); } - if (select) { + if (grantMode() === GRANT_SELECT) { button.setAttribute("aria-pressed", String(picked)); if (!picked) { - button.setAttribute("title", "Select: press to add it to the selection; Grant grants it"); + button.setAttribute("title", solo(item) ? SOLO_HINT : "Select: press to add it to the selection; Grant grants it"); } } return button; diff --git a/orchestrator/templates/page-inbox.js b/orchestrator/templates/page-inbox.js index e445d49..88ad402 100644 --- a/orchestrator/templates/page-inbox.js +++ b/orchestrator/templates/page-inbox.js @@ -104,7 +104,9 @@ return submit([entryOf(item, "approve", "")], `${item.kind === "operator" ? "Run" : "Grant"}: ${short(item.title)}`); } - const chooseOne = (item, label) => submit([entryOf(item, "approve", label)], `Choice: ${shownPick(label)}`); + const chooseOne = (item, label) => (picking(item) ? collectPick(item, label) : submit([entryOf(item, "approve", label)], `Choice: ${shownPick(label)}`)); + const answerPick = (item, label) => (picking(item) ? collectPick(item, label) : answerRow(item, label)); + const grantSolo = (item) => (item.kind === "rule" ? acceptRule(item) : submit([entryOf(item, "approve", "")], `Grant: ${short(item.title)}`)); const asked = (item) => item.kind === "operator" && item.check === "decision"; const answers = new Map(); const answerOf = (item) => answers.get(keyOf(item)) || item.answered || ""; @@ -136,13 +138,14 @@ */ const choiceOf = (item, after) => { if (item.kind === "decision") { - return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: "", locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT}); + return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? labelOf(item) : "", locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT}); } if (item.kind === "ask") { return choiceDialog(askDialog(item.id), {pick: (answer, typed) => { after(); answerAsk(item, answer, typed); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? ALLOW : "", locked: item.held, hint: `your passkey signs it, the answer goes to ${item.to || "its session"}`, group: "", other: TELL}); } const told = answerOf(item); - return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerRow(item, label); }, toggled: new Set(), chosen: told, locked: item.held || Boolean(told), hint: signsFor(item), group: "", other: OTHER_PROMPT})] : null; + const shown = told || (ui.selected.has(keyOf(item)) ? labelOf(item) : ""); + return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerPick(item, label); }, toggled: new Set(), chosen: shown, locked: item.held || Boolean(told), hint: signsFor(item), group: "", other: OTHER_PROMPT})] : null; }; /** @@ -153,29 +156,37 @@ const deniable = (item) => item.deniable || item.kind === "review"; const denialOf = (item, reason) => ({...entryOf(item, "reject", ""), channel: "post", reason, to: item.to}); - const pickable = (item) => !item.held && (selectable(item) || deniable(item)); + const pickable = (item) => !item.held && (collectable(item) || deniable(item)); function bulk(items, label, deny) { - const usable = items.filter(deny ? deniable : selectable); - if (!usable.length) { + const usable = items.filter(deny ? deniable : batchable); + const alone = deny ? [] : items.filter(solo); + if (!usable.length && !alone.length) { toast(`${label}: nothing to ${deny ? "deny" : "grant"}`, [], false); return; } - const rows = usable.map((item) => h("li", {}, - h("div", {class: "row"}, pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), item.kind === "decision" && !deny ? h("span", {class: "muted"}, revealed(`→ ${shownPick(item.recommended)}`)) : null), + const rows = [...usable, ...alone].map((item) => h("li", {}, + h("div", {class: "row"}, pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), !deny && labelOf(item) ? h("span", {class: "muted"}, revealed(`→ ${shownPick(labelOf(item))}`)) : null), h("strong", {}, revealed(item.title)), item.kind === "operator" ? h("div", {class: "command"}, h("code", {}, revealed(item.command))) : null, item.kind === "operator" ? h("span", {class: "muted"}, revealed(`in ${item.directory}`)) : null, item.kind === "ask" ? h("div", {class: "command"}, h("code", {}, revealed(item.command))) : null)); - const confirm = h("button", {type: "button", class: deny ? "btn danger" : "btn primary"}, `${deny ? "Deny" : "Grant"} ${usable.length}`); + const confirm = h("button", {type: "button", class: deny ? "btn danger" : "btn primary"}, `${deny ? "Deny" : "Grant"} ${usable.length + alone.length}`); const reason = deny ? h("textarea", {class: "field", maxlength: DENY_REASON, rows: 3, placeholder: "e.g. make the gate green first"}) : null; - confirm.addEventListener("click", () => { + confirm.addEventListener("click", async () => { closeSheet(); - submit(usable.map((item) => (deny ? denialOf(item, reason.value) : entryOf(item, "approve", item.kind === "decision" ? item.recommended : ""))), `${label}: ${usable.length} entries`); + if (usable.length && !(await submit(usable.map((item) => (deny ? denialOf(item, reason.value) : entryOf(item, "approve", labelOf(item)))), `${label}: ${usable.length} entries`))) { + return; + } + for (const item of alone) { + if (!(await grantSolo(item))) { + return; + } + } }); const note = deny ? "Every entry and every full command that gets denied; each requester gets its denial and the reason by post. After the click the passkey signs the whole selection once; then 3 s remain to undo." - : "Every entry and every full command that gets granted. After the click the passkey signs the whole selection once; then 3 s remain to undo."; + : `Every entry and every full command that gets granted. After the click the passkey signs the whole selection once; then 3 s remain to undo.${alone.length ? ` Each rule and each red-gate review then asks its own signature, one after the other (${alone.length}).` : ""}`; openSheet(label, [h("p", {class: "muted"}, note), h("ul", {class: "mini"}, rows), ...(deny ? [reasonChips(reason), h("label", {class: "deny-reason"}, "Reason (optional, every requester reads it)", reason)] : []), h("div", {class: "actions"}, h("span", {class: "spacer"}), btn("Cancel", "btn ghost", closeSheet), confirm)], false); (reason || confirm).focus(); @@ -188,7 +199,7 @@ const green = items.filter(isGreen); const chosen = items.filter((item) => ui.selected.has(keyOf(item))); const denials = chosen.filter(deniable); - const grantable = chosen.filter(selectable); + const grantable = chosen.filter(collectable); return { chosen, grant: h("button", {type: "button", class: "btn small primary", ...named(`Grant selection (${grantable.length})`), disabled: !grantable.length || ui.busy, on: {click: () => bulk(chosen, "Grant selection", false)}}, icon("bi-check2-square"), `Grant ${grantable.length}`), @@ -217,11 +228,7 @@ return; } const key = keyOf(item); - if (ui.selected.has(key)) { - ui.selected.delete(key); - } else { - ui.selected.add(key); - } + flip(key); ui.cursor = Math.max(visibleInbox().findIndex((entry) => keyOf(entry) === key), 0); drawInbox(); drawGrant(); @@ -317,7 +324,7 @@ } } const mode = grantMode(); - const sig = JSON.stringify([mode, items.map(withoutOutput), [...ui.selected], [...answers], ui.cursor, ui.snoozed, ui.busy, Math.floor(nowSeconds() / 60), diffView.version, state.messages.map((message) => message.id)]); + const sig = JSON.stringify([mode, items.map(withoutOutput), [...ui.selected], [...choices], [...answers], ui.cursor, ui.snoozed, ui.busy, Math.floor(nowSeconds() / 60), diffView.version, state.messages.map((message) => message.id)]); if (sig === inboxSig) { repaintConsoles(items); return; @@ -334,10 +341,6 @@ onLocalhost() ? "" : h("p", {class: "muted"}, "The passkey signs grants only under ", localLink()), items.length ? h("ol", {class: "inbox-list"}, items.map(inboxItem)) : emptyState("All done", "Nothing is waiting for you right now."))); settleConsoles(items); - const current = inboxDom.querySelector(`.item[data-index="${ui.cursor}"]`); - if (current && document.activeElement === document.body) { - current.scrollIntoView({block: "nearest"}); - } } function openItem(item) { diff --git a/orchestrator/templates/page-rule-request.js b/orchestrator/templates/page-rule-request.js index 88935b1..1bcbb04 100644 --- a/orchestrator/templates/page-rule-request.js +++ b/orchestrator/templates/page-rule-request.js @@ -11,18 +11,36 @@ h("p", {class: "muted"}, RULE_HINTS[rule.kind])); } + /** + * @param {Object} item a rule request. + * @param {string} label the toast and passkey prompt label. + * @returns {Promise} the accept body with the rule and its passkey assertion, null when the server refused or the operator cancelled. + */ + async function signRule(item, label) { + const prepared = await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/sign`, {}); + if (!prepared.ok || !prepared.data) { + if (!closeGone(prepared, [keyOf(item)], label)) { + toast(`${label}: not possible`, fail(prepared), false); + } + return null; + } + const signed = await assertion(prepared.data, label); + return signed ? {rule: prepared.data.payload, assertion: signed} : null; + } + + /** + * @param {Object} item a rule request. + * @returns {Promise} whether the rule was created. + */ async function acceptRule(item) { const label = `Rule: ${short(item.title)}`; ui.busy = true; - const prepared = await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/sign`, {}); - const signed = prepared.ok && prepared.data ? await assertion(prepared.data, label) : null; - if ((!prepared.ok || !prepared.data) && !closeGone(prepared, [keyOf(item)], label)) { - toast(`${label}: not possible`, fail(prepared), false); - } - const result = signed ? await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/accept`, {rule: prepared.data.payload, assertion: signed}) : null; + const body = await signRule(item, label); + const result = body ? await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/accept`, body) : null; ui.busy = false; if (result && !closeGone(result, [keyOf(item)], label)) { toast(result.ok ? `Created: ${short(item.title)}` : `${label}: not created`, result.ok ? [] : fail(result), result.ok); } await load(); + return Boolean(result && result.ok); } diff --git a/tests/test_hub_grant_mode.py b/tests/test_hub_grant_mode.py index 049a4d2..d4f0a0c 100644 --- a/tests/test_hub_grant_mode.py +++ b/tests/test_hub_grant_mode.py @@ -24,7 +24,8 @@ class El { append(...nodes) { this.children.push(...nodes); } replaceChildren(...nodes) { this.children = nodes; } addEventListener(name, handler) { this.handlers[name] = handler; } - click() { this.handlers.click({stopPropagation() {}, preventDefault() {}}); } + click() { return this.handlers.click({stopPropagation() {}, preventDefault() {}}); } + focus() {} remove() {} } const all = (node) => [node, ...(node.children || []).filter((child) => child instanceof El).flatMap(all)]; @@ -42,8 +43,10 @@ const items = { red: {...base, kind: "review", id: "r-red", title: "feat: red", gate: "fail"}, ask: {...base, kind: "ask", id: "a-1", title: "git push: ask", command: "git push"}, run: {...base, kind: "operator", id: "operator/run", title: "make install", command: "make install", runnable: true, deniable: true}, - pick: {...base, kind: "decision", id: "d-1", title: "Which?", recommended: "A", options: [{label: "A", description: ""}]}, + pick: {...base, kind: "decision", id: "d-1", title: "Which?", recommended: "A", options: [{label: "A", description: ""}, {label: "B", description: ""}]}, rule: {...base, kind: "rule", id: "1123456789abcdef", title: "Rule ask Bash make deploy"}, + open: {...base, kind: "decision", id: "d-2", title: "Open?", options: [{label: "A", description: ""}, {label: "B", description: ""}]}, + row: {...base, kind: "operator", id: "operator/ask", title: "Ship it?", command: "Ship it?", check: "decision", deniable: true, options: [{label: "Yes", description: ""}]}, }; const mode = {value: "select"}; const sets = []; @@ -62,16 +65,26 @@ const context = { const source = names.map((name) => fs.readFileSync(`${dir}/${name}`, "utf8")).join("\n"); const probe = ` const proofs = []; +const sent = []; const accepts = []; +const sheets = []; let renders = 0; let streams = 0; -proofFor = async (entries) => { proofs.push(entries.map((entry) => entry.kind + ":" + entry.id)); return null; }; -acceptRule = (item) => { accepts.push(item.id); }; +let signing = false; +proofFor = async (entries) => { proofs.push(entries.map((entry) => entry.kind + ":" + entry.id)); sent.push(entries.map((entry) => entry.label)); return signing ? {proof: "p"} : null; }; +sendJson = async () => ({ok: true, data: {id: `b${proofs.length}`, due: 0}}); +undoToast = () => {}; +acceptRule = async (item) => { accepts.push(item.id); return true; }; +openSheet = (title, body) => { sheets.push(body); }; +closeSheet = () => {}; render = () => { renders += 1; }; drawStream = () => { streams += 1; }; toast = () => ({remove() {}}); const results = {}; -const take = () => ({selected: [...ui.selected].sort(), proofs: proofs.splice(0), accepts: accepts.splice(0), renders, streams}); +const take = () => ({selected: [...ui.selected].sort(), proofs: proofs.splice(0), labels: sent.splice(0), accepts: accepts.splice(0), renders, streams}); +const dialogOf = (item) => { const made = choiceOf(item, () => {}); return Array.isArray(made) ? made[1] : made; }; +const option = (item, label) => buttons(dialogOf(item)).find((button) => (button.getAttribute("title") || "").startsWith(`${label}: `)); +const pressedOptions = (item) => buttons(dialogOf(item)).filter((button) => button.getAttribute("aria-pressed") === "true").map((button) => button.getAttribute("title").split(": ")[0]); const press = (item) => { const first = actionsFor(item)[0]; return {pressed: first.getAttribute("aria-pressed"), title: first.getAttribute("title"), disabled: Boolean(first.disabled), picked: (first.getAttribute("class") || "").split(" ").includes("picked")}; @@ -91,10 +104,14 @@ const byName = (node, label) => buttons(node).find((button) => button.getAttribu await approveOne(of(key)); } results.collected = take(); + results.solo_titles = [press(of("red")).title, press(of("rule")).title]; await approveOne(of("red")); results.red = {...take(), press: press(of("red"))}; await approveOne(of("rule")); results.rule = {...take(), press: press(of("rule"))}; + await approveOne(of("red")); + await approveOne(of("rule")); + results.solo_out = take(); grantBoot(); const bar = grantView.tray; const summary = () => all(bar).find((node) => node.tag === "summary").getAttribute("aria-label"); @@ -115,6 +132,30 @@ const byName = (node, label) => buttons(node).find((button) => button.getAttribu drawGrant(); results.direct_selection = {main: buttons(bar)[0].getAttribute("aria-label"), labels: labels(bar)}; ui.selected.clear(); + results.direct_pick = {before: take()}; + await option(of("open"), "B").click(); + results.direct_pick.after = take(); + mode.value = "select"; + await option(of("open"), "B").click(); + results.option_added = {...take(), pressed: pressedOptions(of("open"))}; + await option(of("open"), "B").click(); + results.option_removed = {...take(), pressed: pressedOptions(of("open"))}; + await option(of("open"), "B").click(); + await option(of("pick"), "B").click(); + await option(of("row"), "Yes").click(); + results.option_row = {pressed: pressedOptions(of("row")), batchable: batchable(of("row"))}; + await approveOne(of("green")); + await approveOne(of("red")); + await approveOne(of("rule")); + results.all = take(); + const actions = selectionActions(state.inbox); + results.all_grant = actions.grant.getAttribute("aria-label"); + await actions.grant.click(); + const sheet = sheets.splice(0)[0]; + results.all_note = text(sheet[0]); + signing = true; + await buttons(sheet[2]).find((button) => text(button).startsWith("Grant ")).click(); + results.all_granted = take(); console.log(JSON.stringify(results)); })().catch((error) => { console.error(error && error.stack || error); process.exit(1); }); `; @@ -155,13 +196,33 @@ class TestGrantMode(unittest.TestCase): self.assertEqual(self.data["direct_selection"]["main"], "Grant selection (1)") self.assertEqual(self.data["direct_selection"]["labels"][-1], "Select") - def test_a_red_gate_and_a_rule_stay_direct_in_select_and_say_why(self): - self.assertEqual(self.data["red"]["proofs"], [["review:r-red"]]) - self.assertEqual(self.data["red"]["press"]["pressed"], None) - self.assertEqual(self.data["red"]["press"]["title"], "Grant: acts at once, a red gate is never granted in a selection") - self.assertEqual(self.data["rule"]["accepts"], ["1123456789abcdef"]) - self.assertEqual(self.data["rule"]["proofs"], []) - self.assertTrue(self.data["rule"]["press"]["title"].endswith(": acts at once, a rule is accepted one at a time"), self.data["rule"]) + def test_a_red_gate_and_a_rule_collect_in_select_and_say_they_sign_alone(self): + self.assertEqual(self.data["solo_titles"], ["Select: press to add it to the selection; Grant asks its own passkey signature for it"] * 2) + self.assertIn("review:r-red", self.data["red"]["selected"]) + self.assertEqual((self.data["red"]["proofs"], self.data["red"]["press"]["pressed"]), ([], "true")) + self.assertIn("rule:1123456789abcdef", self.data["rule"]["selected"]) + self.assertEqual((self.data["rule"]["proofs"], self.data["rule"]["accepts"], self.data["rule"]["press"]["pressed"]), ([], [], "true")) + self.assertEqual(self.data["solo_out"]["selected"], ["ask:a-1", "decision:d-1", "operator:operator/run", "review:r-green"]) + + def test_an_option_pick_posts_at_once_in_direct(self): + self.assertEqual((self.data["direct_pick"]["after"]["proofs"], self.data["direct_pick"]["after"]["labels"]), ([["decision:d-2"]], [["B"]])) + self.assertEqual(self.data["direct_pick"]["after"]["selected"], []) + + def test_an_option_pick_collects_with_its_label_in_select_and_the_same_pick_takes_it_out(self): + self.assertEqual(self.data["option_added"]["selected"], ["decision:d-2"]) + self.assertEqual((self.data["option_added"]["proofs"], self.data["option_added"]["pressed"]), ([], ["B"])) + self.assertEqual((self.data["option_removed"]["selected"], self.data["option_removed"]["pressed"]), ([], [])) + self.assertEqual(self.data["option_row"], {"pressed": ["Yes"], "batchable": True}) + + def test_grant_n_signs_the_batch_once_then_each_rule_and_red_gate_alone(self): + self.assertEqual(self.data["all"]["selected"], ["decision:d-1", "decision:d-2", "operator:operator/ask", "review:r-green", "review:r-red", "rule:1123456789abcdef"]) + self.assertEqual((self.data["all"]["proofs"], self.data["all"]["accepts"]), ([], [])) + self.assertEqual(self.data["all_grant"], "Grant selection (6)") + self.assertTrue(self.data["all_note"].endswith("Each rule and each red-gate review then asks its own signature, one after the other (2)."), self.data["all_note"]) + granted = self.data["all_granted"] + self.assertEqual(granted["proofs"], [["review:r-green", "decision:d-1", "decision:d-2", "operator:operator/ask"], ["review:r-red"]]) + self.assertEqual(granted["labels"], [["", "B", "B", "Yes"], [""]]) + self.assertEqual((granted["accepts"], granted["selected"]), (["1123456789abcdef"], [])) def test_one_split_grants_the_selection_and_its_menu_holds_the_rest(self): tray = self.data["tray"]