Files
skills/tests/test_hub_speak_card.py
T
Kevin Veen-BirkenbachandClaude Opus 5.5 2722cda1b5 feat(hub): requirements 023 to 031 and line comments on grant-time code
023 box heads: one head band per box under its top border; in widget mode
its controls join the widget title band.
024 Match card content: merge cards show their diff (the runner previews a
review's tree against its worktree HEAD), every card carries legal and
architecture scores, the null under command cards is gone.
025 Radio speak card: no hint text, a rounder flowing card, a MAYDAY toggle
beside push to talk.
026 widget zoom: zoom a widget's content by keyboard and the context menu.
027 slash skill suggestions: every field that messages agents suggests
skills after a slash, from a skills index the tree timer writes.
028 Resources accounts: an Accounts panel (provider, renewal, resets, usage
and remaining, host-local, emails never in git) and panel checkboxes.
029 Controls layout: Rules and Groups pages laid out.
030 Yes/No answers as buttons, and nothing hides: rows the runner cannot
run stay greyed with the reason.
031 mic in fields.
Line comments (operator 2026-11-24): wherever code waits for a grant
(Waits on Operator, the stream, the review overlay) selected lines or a
right-clicked row take a comment that marks its lines and collects on the
card; Deny opens with them as the reason and Call preselected, Grant sends
them after the signed grant as one post. Requirement 003 decision 4 and
its contract follow.

Tests are written for every requirement and run once on this head.

🎯 Fix: 80 %
💥 Break: 20 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: ~95 %
🏆 Score: 61
🚦 Gate: ⛔ fix 80 % < 90, break 20 % > 5; security ~95 % < 100: ask the operator before the commit

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 01:22:03 +00:00

85 lines
3.9 KiB
Python

from __future__ import annotations
import json
import re
import subprocess
import unittest
from hub_support import HUB
TEMPLATES = HUB / "templates"
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-board.js", "page-composer.js"]
PROBE = r"""
const fs = require("fs");
const vm = require("vm");
const [dir, names] = [process.argv[1], JSON.parse(process.argv[2])];
class El {
constructor(tag) { Object.assign(this, {tag, children: [], attrs: {}, dataset: {}, style: {}}); }
setAttribute(key, value) { this.attrs[key] = String(value); }
getAttribute(key) { return Object.hasOwn(this.attrs, key) ? this.attrs[key] : null; }
append(...nodes) { this.children.push(...nodes); }
replaceChildren(...nodes) { this.children = nodes; }
addEventListener() {}
}
const document = {
currentScript: null, body: new El("body"),
getElementById: () => Object.assign(new El("div"), {textContent: "[]"}),
createElement: (tag) => new El(tag), createElementNS: (ns, tag) => new El(tag),
};
const context = {
console, document, JSON, Math, Date, Intl, Promise, Set, Map, Number, String, Array, Object, RegExp, Boolean, Error,
El, Node: El, Element: El, HTMLElement: El,
window: {location: {hash: ""}, setTimeout: () => 0, matchMedia: () => ({matches: false})},
state: {inbox: [], radio: [], silence: null}, ui: {}, settings: {},
};
const source = names.map((name) => fs.readFileSync(`${dir}/${name}`, "utf8")).join("\n");
const probe = `
const toggle = new El("button");
state.silence = null;
drawMayday(toggle);
const idle = [toggle.attrs["aria-pressed"], toggle.children[1], toggle.title];
state.silence = {since: 1, by: "Docs", text: "disk full"};
drawMayday(toggle);
const active = [toggle.attrs["aria-pressed"], toggle.children[1], toggle.title];
JSON.stringify({idle, active, channels: CHANNELS.map(([id]) => id), titled: CHANNELS.every(([id]) => typeof CHANNEL_HINTS[id] === "string" && CHANNEL_HINTS[id].length > 0)});
`;
console.log(vm.runInNewContext(`${source}\n${probe}`, context));
"""
class TestSpeakCard(unittest.TestCase):
def probe(self) -> dict:
done = subprocess.run(["node", "-e", PROBE, str(TEMPLATES), json.dumps(MODULES)], capture_output=True, text=True, timeout=60, check=False)
self.assertEqual(done.returncode, 0, done.stderr)
return json.loads(done.stdout)
def test_the_toggle_reads_mayday_until_one_holds_the_radio_silent_then_cancel_mayday(self):
out = self.probe()
self.assertEqual(out["idle"][:2], ["false", "MAYDAY"])
self.assertTrue(out["idle"][2].startswith("MAYDAY: "), out)
self.assertEqual(out["active"], ["true", "Cancel mayday", "Cancel mayday: lift the radio silence so the agents write again; your passkey signs it"])
def test_the_channel_select_holds_no_mayday_and_every_option_has_a_title(self):
out = self.probe()
self.assertEqual(out["channels"], ["post", "call", "newsletter", "broadcast", "pan-pan", "security"])
self.assertTrue(out["titled"], out)
def test_the_card_has_no_hint_sentence_and_no_browser_confirm(self):
composer = (TEMPLATES / "page-composer.js").read_text(encoding="utf-8")
self.assertNotIn("window.confirm", composer)
self.assertNotIn("Your passkey signs every message", composer)
self.assertNotIn("composer-hint", composer)
self.assertRegex(composer, r"status, h\(\"div\", \{class: \"ptt-split\".*\), mayday\)\);")
def test_the_card_is_one_rounded_surface(self):
css = (TEMPLATES / "style-ui.css").read_text(encoding="utf-8")
self.assertRegex(css, r"\.radio-card\.radio-speak \{ border-radius: 14px; \}")
self.assertRegex(css, r"\.composer-grid \{[^}]*border-radius: 10px;")
self.assertRegex(css, r"\.composer textarea \{[^}]*border-radius: 10px;")
self.assertNotIn(".radio-cancel", css)
self.assertIsNone(re.search(r'class: "[^"]*\bcard\b', (TEMPLATES / "page-composer.js").read_text(encoding="utf-8")))
if __name__ == "__main__":
unittest.main()