Files
skills/tests/test_hub_match_release_last.py
T
Kevin Veen-BirkenbachandClaude Opus 5.5 6323f087bc feat(orchestrator): hub page for requirements 085 to 099
085 calm Match deck: no header hourglass, centred bare empty state, the
release card as a deck card (Cancel, Skip, Release), fixed card height.
086 motion: vanish() fade everywhere with a lint test, view transitions,
a lub-dub heartbeat for working objects, confetti that lands and fades.
087 time readout under the pivot of every analog clock.
088 prune dialog grouped by prefix with tri-state boxes, search, stepper
and sticky footer.
089 one-row task toolbar with Filter and Actions menus and a filter chip.
090 card border by state colour with a soft glow and owner avatars.
091 draggable limit lines with staged changes and one Save, a Limits menu
with the matrix, View toggles, the GPU cause in its tooltip.
093 request chips Open, Expired, Stale, Failed, All and a signed Delete.
094 closed cards leave the deck within 5 s; open in Claude stamps.
095 compact agent message box with Post/Call, attach, mic and Send in
the field.
096 Reject on an expired card drops it silently as Drop (expired).
097 Show filter in Match's right-click menu.
098 docked speech bubbles carry the speaker's avatar and a skip button.
099 Match card headlines cut to 120 characters with the full title in
the tooltip; the code box keeps the whole command.
tests/test_hub_path_links.py: a unicode fixture without German.

Full make test green through the queue (2605 tests, ruff, shellcheck,
markdownlint). Gate missed on the operator's word: break 7 %, the E2E
specs (13 new, 15 updated) run next.

🎯 Fix: 92 %
💥 Break: 7 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ⛔ break 7 % > 5

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

103 lines
4.0 KiB
Python

from __future__ import annotations
import json
import re
import subprocess
import unittest
from hub_support import HUB
MATCH = HUB / "templates" / "page-match.js"
NAMES = ("toBack", "releaseLast", "matchOrder", "decisionOf")
PROBE = r"""
const vm = require("vm");
const sandbox = {RELEASE: "release", matchView: {order: [], decisions: new Map()}, out: {}};
vm.runInNewContext(process.argv[1], sandbox);
vm.runInNewContext(`
const card = (id, ts) => ({id, hash: id, created_ts: ts, stale: false, blocked: ""});
const ids = () => matchView.order.join(",");
matchView.order = ["a", "b", "release"];
matchView.decisions.set("a", {verdict: "accept", hash: "a"});
matchOrder([card("a", 1), card("b", 2), card("c", 3)]);
out.fresh = ids();
toBack("b");
out.later = ids();
matchView.order = ["release", "b", "c"];
matchOrder([card("a", 1), card("b", 2), card("c", 3), card("d", 4)]);
out.shown = ids();
toBack("release");
out.back = ids();
`, sandbox);
console.log(JSON.stringify(sandbox.out));
"""
def extracted() -> str:
source = MATCH.read_text(encoding="utf-8")
parts = []
for name in NAMES:
found = re.search(rf"^ (?:function {name}\(|const {name} = ).*?^ }};?$", source, re.MULTILINE | re.DOTALL)
if found is None:
raise AssertionError(f"{name} not found in {MATCH}")
parts.append(found.group(0).replace(f"const {name} = ", f"var {name} = "))
return "\n".join(parts)
STAMP_PROBE = r"""
const vm = require("vm");
const sandbox = {};
vm.runInNewContext(process.argv[1], sandbox);
console.log(JSON.stringify(vm.runInNewContext(`[
greyStamp({stale: false, blocked: ""}),
greyStamp({stale: false, blocked: "runs", blocked_kind: "running"}),
greyStamp({stale: false, blocked: "waits", blocked_kind: "queued"}),
greyStamp({stale: false, blocked: "no dir", blocked_kind: "unrunnable"}),
greyStamp({stale: true, blocked: "runs", blocked_kind: "running"}),
greyStamp({stale: false, blocked: "ask held"}),
greyStamp({stale: false, blocked: "too late", blocked_kind: "expired"}),
greyStamp({stale: false, blocked: "answer it there", blocked_kind: "claude"}),
].map((key) => [key, key ? MATCH_STAMPS[key] : ""])`, sandbox)));
"""
def stamp_source() -> str:
source = MATCH.read_text(encoding="utf-8")
table = re.search(r"^ const MATCH_STAMPS = .*;$", source, re.MULTILINE)
function = re.search(r"^ function greyStamp\(.*?^ }$", source, re.MULTILINE | re.DOTALL)
if table is None or function is None:
raise AssertionError(f"MATCH_STAMPS or greyStamp not found in {MATCH}")
return table.group(0).replace("const ", "var ", 1) + "\n" + function.group(0)
class TestGreyedCardStamp(unittest.TestCase):
def test_every_greyed_card_names_its_reason_and_an_active_card_has_none(self):
done = subprocess.run(["node", "-e", STAMP_PROBE, stamp_source()], capture_output=True, text=True, timeout=60, check=True)
self.assertEqual(json.loads(done.stdout), [
["", ""], ["running", "RUNNING"], ["queued", "QUEUED"], ["blocked", "BLOCKED"], ["stale", "STALE"], ["blocked", "BLOCKED"], ["expired", "EXPIRED"], ["claude", "IN CLAUDE"],
])
class TestReleaseCardLast(unittest.TestCase):
@classmethod
def setUpClass(cls):
done = subprocess.run(["node", "-e", PROBE, extracted()], capture_output=True, text=True, timeout=60, check=False)
if done.returncode != 0:
raise AssertionError(done.stderr[-4000:])
cls.data = json.loads(done.stdout)
def test_a_new_card_queues_before_the_release_card(self):
self.assertEqual(self.data["fresh"], "a,b,c,release")
def test_later_puts_a_card_behind_the_release_card(self):
self.assertEqual(self.data["later"], "a,c,release,b")
def test_a_shown_release_card_stays_in_front_and_new_cards_queue_behind_it(self):
self.assertEqual(self.data["shown"], "release,b,c,a,d")
def test_sending_the_release_card_back_puts_it_last(self):
self.assertEqual(self.data["back"], "b,c,a,d,release")
if __name__ == "__main__":
unittest.main()