Files
skills/tests/e2e/test_home_dashboard_e2e.py
T
Kevin Veen-BirkenbachandClaude Opus 5.5 0fad1bfae3 feat: hub and skills requirements 032 to 063
Hub: send in the field (032), coherent speak box (033), stream head band (034), Match at full width with its pile (035, 036), Home without the outer box (037), badge to Match (038), rejects that survive a changed or withdrawn card (039), the release card (040), code marks in the review diff (041), why Deny is off (042), the undo window clock (043), widgets without inner boxes (044), the Artifacts head on one line (045), accepting a red gate's risk (046), one code box (047), done rows greyed and folded (048), one control height (049), menus that stay open (050), radio settings in the Device card (051), bubbles beside the modes (052), agent settings on every face and name (053), pin only by menu (054), WASD in Match (055), the flowing card edge (056), Schedules in Controls (057) and the hub poll cost (059).

Skills: the coach leaves for its own repository kevinveenbirkenbach/coach (058; test_install pins its four skills in skills-lock.json and stays red until that repository is published and pinned), hooks and timers start fewer processes (060), council files on hot paths stay bounded and mirror by marker instead of mtime (061), scripts and hooks hand agents less output (062), and block.py builds the commit table and message block in one run (063). Requirement documents 032 to 063 with their implementation amendments.

MEDUSA false positives accepted after kvb-think-criticize (36 lines): MM-SCAN-058 (pla inside replace or plan), JB-SCAN-616/641 (the local clip helper), CODEGEN-SCAN-001 (drop-in paths), CGS-SCAN-029 (systemctl argv from constants), CGS-SCAN-040 (runner poll loop), FLA-SCAN-055 (feedback), WM-SCAN-354, AI-BACKDOOR-006, GENAI-SCAN-1270, B604 (runner shell path for passkey-verified commands), TC004, EXA002, EXA006, EXA010 and WEB-SSRF.

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

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 08:44:15 +00:00

423 lines
22 KiB
Python

from __future__ import annotations
import json
import os
import shutil
import sys
import time
import unittest
from collections.abc import Callable
from pathlib import Path
from unittest import mock
HERE = Path(__file__).resolve().parent
sys.path[:0] = [str(HERE.parent), str(HERE)]
import hub_e2e_kit as base
from hub_case import HubCase
from hub_support import HUB, iso
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-008-shots"))
REAL_STORE = (HUB / "templates" / "view-store.js").exists()
CUE = "e2e-home-change"
PIN_LABELS = ("Pin to Home", "Unpin from Home")
SCREENS = [
"stream", "agents/orbit", "agents/chord", "agents/swimlane", "agents/3d", "agents/tree", "agents/hierarchy",
"artifacts/orbit", "artifacts/chord", "artifacts/swimlane", "artifacts/tree", "artifacts/3d",
"tasks/list", "tasks/board", "tasks/rasci", "tasks/gantt", "tasks/burn", "tasks/3d",
]
STUB = """() => {
const KEY = "e2e-view-store";
const read = () => JSON.parse(sessionStorage.getItem(KEY) || "{}");
const listeners = {};
window.ViewStore = {
get: (path) => read()[path],
update: (path, change) => {
const all = read();
all[path] = change(all[path]);
sessionStorage.setItem(KEY, JSON.stringify(all));
(listeners[path] || []).forEach((listen) => listen(all[path]));
return Promise.resolve(true);
},
set: (path) => {
throw new Error(`${path} holds a list: use update()`);
},
on: (path, listen) => {
listeners[path] = [...(listeners[path] || []), listen];
},
};
}"""
HOME = """
const go = async (hash) => {
location.hash = hash;
await screenShown(8000);
await sleep(500);
};
const PIN_LABELS = ["Pin to Home", "Unpin from Home"];
const shownMenu = () => document.querySelector(".ctx-menu:not([hidden])");
const menuLabel = (node) => text(node.querySelector(".ctx-label"));
const closeMenu = async () => {
const menu = shownMenu();
if (menu) {
menu.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true, cancelable: true}));
await sleep(100);
}
};
const pinItem = async (owner) => {
await closeMenu();
owner.scrollIntoView({block: "center"});
const box = owner.getBoundingClientRect();
owner.dispatchEvent(new MouseEvent("contextmenu", {bubbles: true, cancelable: true, button: 2, clientX: Math.round(box.left + 4), clientY: Math.round(box.top + 4)}));
const menu = await until(shownMenu, 3000);
return menu ? all('[role="group"][data-scope="element"] [role="menuitem"]', menu).find((node) => PIN_LABELS.includes(menuLabel(node))) || null : null;
};
const menuPinOf = async (owner) => {
const item = await pinItem(owner);
const state = item ? [String(menuLabel(item) === PIN_LABELS[1]), `${menuLabel(item)}: ${item.title}`] : null;
await closeMenu();
return state;
};
const pinState = async (selector) => {
const owner = await until(() => document.querySelector(selector), 8000);
return owner ? menuPinOf(owner) : null;
};
const pinOwner = async (owner) => {
const target = Panels.targetOf(owner);
const item = await pinItem(owner);
if (!item) {
await closeMenu();
return null;
}
item.click();
await sleep(200);
return String((ViewStore.get("home.pins") || []).some((pin) => pin.kind === target.kind && pin.id === target.id));
};
const press = async (selector) => {
const owner = await until(() => document.querySelector(selector), 8000);
return owner ? pinOwner(owner) : null;
};
const tiles = () => all("#main .home-tile").map((tile) => tile.dataset.pin);
const tile = (key) => document.querySelector(`#main .home-tile[data-pin="${key}"]`);
const centre = (node) => {
const box = node.getBoundingClientRect();
return {clientX: box.left + box.width / 2, clientY: box.top + box.height / 2};
};
const pointer = (node, type, at) => node.dispatchEvent(new PointerEvent(type, {bubbles: true, cancelable: true, pointerId: 1, button: 0, isPrimary: true, ...at}));
const dragBy = async (handle, dx, dy) => {
handle.scrollIntoView({block: "center"});
const from = centre(handle);
pointer(handle, "pointerdown", from);
pointer(document, "pointermove", {clientX: from.clientX + dx, clientY: from.clientY + dy});
pointer(document, "pointerup", {clientX: from.clientX + dx, clientY: from.clientY + dy});
await sleep(300);
};
const sizeOf = (key) => {
const found = tile(key);
return found ? [Number(found.dataset.w), Number(found.dataset.h)] : null;
};
const grid = () => document.querySelector("#main .home-grid");
const cell = () => {
const look = getComputedStyle(grid());
const gap = parseFloat(look.columnGap);
return {column: (grid().clientWidth - gap * 11) / 12 + gap, row: parseFloat(look.gridAutoRows) + parseFloat(look.rowGap)};
};
const stored = () => (ViewStore.get("home.pins") || []).map((pin) => `${pin.kind}:${pin.id}`);
"""
CLEAR = """(async () => {
sessionStorage.clear();
await ViewStore.update("home.pins", () => []);
sessionStorage.clear();
return true;
})()"""
START_EMPTY = """(async () => {@HELPERS@
await screenShown(8000);
return {hash: location.hash, screen: document.getElementById("main").getAttribute("aria-labelledby"), first: name(document.querySelector("#tabs > .tab-group > button"))};
})()"""
OWNERS = """(async () => {@HELPERS@@HOME@
const seen = [];
const missing = [];
const stars = [];
const menus = [];
const XHTML = "http://www.w3.org/1999/xhtml";
const shown = (node) => node.getClientRects().length > 0 && getComputedStyle(node).visibility !== "hidden" && !node.closest("details:not([open]) > :not(summary)");
const count = async (where) => {
const owners = all("[data-panel], [data-item]").filter((node) => node.namespaceURI === XHTML);
seen.push([where, owners.length]);
missing.push(...owners.filter((node) => !Panels.targetOf(node)).map((node) => `${where}: ${node.outerHTML.slice(0, 120)}`));
stars.push(...all(".star, .star-row").map((node) => `${where}: ${node.outerHTML.slice(0, 120)}`));
const first = owners.filter(shown).find((node) => node.closest("dialog[open]")) || owners.find(shown) || owners[0];
const item = first ? await pinItem(first) : null;
menus.push([where, item ? menuLabel(item) : null]);
await closeMenu();
};
for (const hash of @SCREENS@) {
await go(hash);
await sleep(hash.endsWith("3d") || hash.startsWith("artifacts") ? 1500 : 300);
await count(hash);
}
await go("agents/orbit");
const agent = document.querySelector('#main svg .node.k-session[data-pick]');
if (agent) {
agent.dispatchEvent(new MouseEvent("click", {bubbles: true}));
await until(() => document.querySelector('#popup[open] [data-item^="agent:"]'), 5000);
await count("agent card");
document.getElementById("popup").close();
}
document.getElementById("radio-open").click();
await until(() => document.querySelector('[data-panel="radio-log"]'), 5000);
await count("radio spot");
document.getElementById("radio-open").click();
return {seen, missing, stars, menus, total: seen.reduce((sum, [, size]) => sum + size, 0)};
})()"""
PIN = """(async () => {@HELPERS@@HOME@
await go("tasks/gantt");
const gantt = await press('#main [data-panel="tasks/gantt"]');
await go("tasks/list");
const feature = await press('#main li.task-row[data-task="work/feature"]');
const docs = await press('#main li.task-row[data-task="work/docs"]');
await go("stream");
const streamed = await press('#main [data-panel="stream"]');
await go("home");
const pinned = tiles();
const chart = Boolean(tile("panel:tasks/gantt") && tile("panel:tasks/gantt").querySelector("svg.chart.gantt"));
await go("tasks/gantt");
const off = await press('#main [data-panel="tasks/gantt"]');
await go("home");
const unpinned = tiles();
await go("tasks/gantt");
const again = await press('#main [data-panel="tasks/gantt"]');
await go("home");
return {gantt, feature, docs, streamed, pinned, chart, off, unpinned, again, final: tiles(), stored: stored()};
})()"""
RESIZE = """(async () => {@HELPERS@@HOME@
await go("home");
const key = "panel:tasks/gantt";
const handle = () => tile(key).querySelector(".home-resize");
const before = sizeOf(key);
const {column, row} = cell();
await dragBy(handle(), column * 3, row * 2);
const grown = sizeOf(key);
await dragBy(handle(), column * 40, row * 40);
const most = sizeOf(key);
const wide = [Math.round(tile(key).getBoundingClientRect().width), Math.round(grid().getBoundingClientRect().width)];
await dragBy(handle(), -column * 40, -row * 40);
const least = sizeOf(key);
handle().focus();
for (const key of ["ArrowRight", "ArrowRight", "ArrowDown"]) {
document.activeElement.dispatchEvent(new KeyboardEvent("keydown", {key, bubbles: true, cancelable: true}));
await sleep(100);
}
const keyed = sizeOf(key);
await dragBy(handle(), column * 5, row * 3);
const look = getComputedStyle(tile(key));
const span = [look.gridColumnStart, look.gridColumnEnd];
return {before, grown, most, wide, least, keyed, final: sizeOf(key), span, stored: (ViewStore.get("home.pins") || []).find((pin) => pin.id === "tasks/gantt")};
})()"""
REORDER = """(async () => {@HELPERS@@HOME@
await go("home");
const before = tiles();
const grip = tile(before[0]).querySelector(".home-grip");
grip.scrollIntoView({block: "center"});
const from = centre(grip);
const target = tile(before[2]);
target.scrollIntoView({block: "center"});
const to = centre(target);
pointer(grip, "pointerdown", centre(grip));
pointer(document, "pointermove", to);
pointer(document, "pointerup", to);
await sleep(300);
const dragged = tiles();
const moving = tile(dragged[2]);
moving.focus();
moving.dispatchEvent(new KeyboardEvent("keydown", {key: "ArrowLeft", bubbles: true, cancelable: true}));
await sleep(200);
const keyed = tiles();
const focused = document.activeElement === tile(keyed[1]);
document.activeElement.dispatchEvent(new KeyboardEvent("keydown", {key: "ArrowDown", bubbles: true, cancelable: true}));
await sleep(200);
return {from: Boolean(from), before, dragged, keyed, focused, down: tiles(), stored: stored()};
})()"""
RELOADED = """(async () => {@HELPERS@@HOME@
await screenShown(8000);
await sleep(500);
const narrow = all("#main .home-tile").map((node) => Math.round(node.getBoundingClientRect().width));
return {hash: location.hash, screen: document.getElementById("main").getAttribute("aria-labelledby"), tiles: tiles(), widths: [...new Set(narrow)], grid: Math.round(grid().getBoundingClientRect().width), errors: all("#main .home-error").map(text)};
})()"""
CHANGE = """(async () => {@HELPERS@@HOME@
await go("home");
const lanes = () => all('#main .home-tile[data-pin="panel:tasks/gantt"] text.lane-label').map((node) => node.dataset.task);
const before = lanes();
await fetch("/api/tts", {method: "POST", headers: {"X-Kvb-Orchestrator": "1", "Content-Type": "application/json"}, body: JSON.stringify({text: "@CUE@", voice: ""}), cache: "no-store"});
const grown = await until(() => lanes().includes("work/new") && tile("task:work/docs").classList.contains("gone"), 25000);
const gone = tile("task:work/docs");
const result = {
before, after: lanes(), grown: Boolean(grown), goneWord: gone ? text(gone.querySelector(".home-gone-word")) : null,
unpin: gone ? name(gone.querySelector(".home-gone .home-gone-unpin")) : null,
};
await go("tasks/gantt");
result.source = all('#main [data-panel="tasks/gantt"] text.lane-label').map((node) => node.dataset.task);
await go("home");
return result;
})()"""
GONE_UNPIN = """(async () => {@HELPERS@@HOME@
await go("home");
const button = tile("task:work/docs").querySelector(".home-gone-unpin");
button.click();
await sleep(300);
return {tiles: tiles(), stored: stored()};
})()"""
FULL = """(async () => {@HELPERS@@HOME@
await ViewStore.update("home.pins", () => Array.from({length: 64}, (_, index) => ({kind: "task", id: `work/seed-${index}`, w: 2, h: 1})));
await go("tasks/gantt");
const before = all("#toasts .toast").length;
const pressed = await press('#main [data-panel="tasks/gantt"]');
const toast = await until(() => all("#toasts .toast").slice(before).map(text).find((words) => words.startsWith("Home is full")), 5000);
return {pressed, toast, count: (ViewStore.get("home.pins") || []).length};
})()"""
START_PINNED = """(async () => {@HELPERS@
await screenShown(8000);
await sleep(300);
return {hash: location.hash, screen: document.getElementById("main").getAttribute("aria-labelledby")};
})()"""
def probe(template: str) -> str:
return template.replace("@HELPERS@", base.HELPERS).replace("@HOME@", HOME).replace("@SCREENS@", json.dumps(SCREENS)).replace("@CUE@", CUE)
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
class TestHomeDashboard(HubCase):
seed = base.OrchestratorE2ECase.seed
subagents = base.OrchestratorE2ECase.subagents
drive = base.OrchestratorE2ECase.drive
def setUp(self):
super().setUp()
self.seed()
def cue(self) -> None:
hub = self.httpd.hub
spoken = base.tone(1, 8000)
def synthesize(body: bytes, admit: Callable[[str], None]) -> bytes:
if json.loads(body)["text"] == CUE:
path = self.council / "rasci.json"
register = json.loads(path.read_text(encoding="utf-8"))
register.pop("work/docs", None)
register["work/new"] = {"title": "New line", "status": "running", "worker": "Skills session", "start": iso(time.time() - 1800), "roles": {"Skills session": "RA"}}
path.write_text(json.dumps(register), encoding="utf-8")
return spoken
patch = mock.patch.object(hub.speech, "synthesize", synthesize)
patch.start()
self.addCleanup(patch.stop)
def steps(self, browser: str) -> list[dict]:
OUT.mkdir(parents=True, exist_ok=True)
self.cue()
steps = []
for index, (width, height) in enumerate(base.WIDTHS):
shot = str(OUT / f"{browser}-{width}")
page = f"{self.base}?{width}"
steps += [
{"width": width, "height": height, "url": f"{page}-clear#stream", "wait": 600, "probe": CLEAR, "shot": None},
{"width": width, "height": height, "url": f"{page}-empty", "wait": 1500, "probe": probe(START_EMPTY), "shot": f"{shot}-start-empty.png"},
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(OWNERS), "shot": f"{shot}-owners.png"},
{"width": width, "height": height, "url": f"{page}-pin#stream", "wait": 1200, "probe": probe(PIN), "shot": f"{shot}-pinned.png"},
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(RESIZE), "shot": f"{shot}-resized.png"},
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(REORDER), "shot": f"{shot}-reordered.png"},
{"width": width, "height": height, "url": f"{page}-reloaded", "wait": 1500, "probe": probe(RELOADED), "shot": f"{shot}-reloaded.png"},
]
if index == len(base.WIDTHS) - 1:
steps += [
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(CHANGE), "shot": f"{shot}-gone.png"},
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(GONE_UNPIN), "shot": None},
]
steps += [
{"width": width, "height": height, "url": f"{page}-full#stream", "wait": 1200, "probe": probe(FULL), "shot": f"{shot}-full.png"},
{"width": width, "height": height, "url": f"{page}-start-pinned", "wait": 1500, "probe": probe(START_PINNED), "shot": None},
{"width": width, "height": height, "url": f"{page}-explicit#tasks", "wait": 1500, "probe": probe(START_PINNED), "shot": None},
]
return steps
def check(self, data: dict) -> None:
results = iter(data["results"])
for index, (width, _) in enumerate(base.WIDTHS):
with self.subTest(width=width):
next(results)
empty = next(results)
self.assertEqual((empty["hash"], empty["screen"], empty["first"]), ("", "tab-stream", "Home"), empty)
owners = next(results)
self.assertEqual((owners["missing"], owners["stars"]), ([], []), owners)
self.assertEqual([where for where, label in owners["menus"] if label not in PIN_LABELS], [where for where, size in owners["seen"] if not size], owners)
self.assertGreater(owners["total"], 20, owners)
pinned = next(results)
self.assertEqual((pinned["gantt"], pinned["feature"], pinned["docs"], pinned["streamed"], pinned["chart"], pinned["off"], pinned["again"]), ("true", "true", "true", "true", True, "false", "true"), pinned)
self.assertEqual(pinned["pinned"], ["panel:tasks/gantt", "task:work/feature", "task:work/docs", "panel:stream"])
self.assertEqual(pinned["unpinned"], ["task:work/feature", "task:work/docs", "panel:stream"])
self.assertEqual(pinned["final"], ["task:work/feature", "task:work/docs", "panel:stream", "panel:tasks/gantt"])
self.assertEqual(pinned["stored"], pinned["final"])
resized = next(results)
self.assertEqual((resized["before"], resized["grown"], resized["most"], resized["least"], resized["keyed"], resized["final"]), ([6, 4], [9, 6], [12, 12], [1, 1], [3, 2], [8, 5]), resized)
self.assertEqual(resized["wide"][0], resized["wide"][1], resized)
self.assertEqual(resized["span"], ["1", "-1"] if width == 390 else ["span 8", "auto"], resized)
self.assertEqual((resized["stored"]["w"], resized["stored"]["h"]), (8, 5))
order = next(results)
start = ["task:work/feature", "task:work/docs", "panel:stream", "panel:tasks/gantt"]
self.assertEqual(order["before"], start)
self.assertEqual(order["dragged"], ["task:work/docs", "panel:stream", "task:work/feature", "panel:tasks/gantt"], order)
self.assertEqual(order["keyed"], ["task:work/docs", "task:work/feature", "panel:stream", "panel:tasks/gantt"], order)
self.assertTrue(order["focused"], order)
self.assertEqual(order["down"], ["task:work/docs", "panel:stream", "task:work/feature", "panel:tasks/gantt"], order)
self.assertEqual(order["stored"], order["down"])
reloaded = next(results)
self.assertEqual((reloaded["hash"], reloaded["screen"], reloaded["tiles"], reloaded["errors"]), ("#home", "tab-home", order["down"], []), reloaded)
if width == 390:
self.assertEqual(reloaded["widths"], [reloaded["grid"]], reloaded)
else:
self.assertGreater(len(reloaded["widths"]), 1, reloaded)
if index == len(base.WIDTHS) - 1:
change = next(results)
self.assertTrue(change["grown"], change)
self.assertNotIn("work/new", change["before"])
self.assertIn("work/new", change["after"])
self.assertEqual(sorted(change["after"]), sorted(change["source"]), change)
self.assertEqual((change["goneWord"], change["unpin"]), ("gone", "Unpin"), change)
unpinned = next(results)
self.assertNotIn("task:work/docs", unpinned["tiles"])
self.assertNotIn("task:work/docs", unpinned["stored"])
full = next(results)
self.assertEqual((full["pressed"], full["count"]), ("false", 64), full)
self.assertTrue(full["toast"] and "At most 64 pins" in full["toast"], full)
pinned_start = next(results)
self.assertEqual((pinned_start["hash"], pinned_start["screen"]), ("#home", "tab-home"), pinned_start)
explicit = next(results)
self.assertEqual((explicit["hash"], explicit["screen"]), ("#tasks", "tab-tasks"), explicit)
def init(self) -> str | None:
return None if REAL_STORE else STUB
def test_chromium_pins_by_menu_resizes_reorders_and_marks_gone_tiles_at_three_widths(self):
data = self.drive(self.steps("chromium"), None, init=self.init())
(OUT / "chromium-home.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
self.assertEqual(data["errors"], [])
self.check(data)
@unittest.skipUnless(shutil.which(os.environ.get("FIREFOX", "firefox")), "no Firefox")
def test_firefox_pins_by_menu_resizes_reorders_and_marks_gone_tiles_at_three_widths(self):
data = self.drive(self.steps("firefox"), None, "bidi.mjs", os.environ.get("FIREFOX", "firefox"), init=self.init())
(OUT / "firefox-home.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
self.assertEqual([error for error in data["errors"] if "/favicon.ico" not in error], [])
self.check(data)
@unittest.skipUnless(REAL_STORE, "waits on 007: view-store.js and /api/view are not on this branch yet")
def test_a_second_browser_shows_the_same_layout(self):
first = self.drive([step for step in self.steps("chromium")[:6] if step["probe"] != probe(OWNERS)], None)
second = self.drive([{"width": 1366, "height": 768, "url": f"{self.base}?second", "wait": 2000, "probe": probe(RELOADED), "shot": str(OUT / "chromium-second.png")}], None)
self.assertEqual(second["results"][0]["tiles"], first["results"][-1]["down"])
self.assertEqual((second["results"][0]["hash"], second["results"][0]["screen"]), ("#home", "tab-home"))
if __name__ == "__main__":
unittest.main()