feat(hub): deny reason chips, patterned Match card heads and copyable place pills
The deny sheet shows the last five distinct deny reasons as chips (recent_reasons in denying.py, served as reasons in /api/state); a click fills the reason field. Match cards get a per-card pattern (dots, stripes, waves, grid, rings) and a two-hue gradient head, the repo, branch and worktree become copyable pills, Match keeps the last comments and peeks in local storage, and Home gets a slot label. Rebased from its lane base2754568onto96d332a: the scan copy's diff against2aea6d1would have reverted the release-flash fix, so the bundle was re-exported against 2754568; the one conflict in page-match.js keeps matchView.epoch next to the new COMMENTS_KEPT and PATTERNS. node --check passes. Tests: test_deny_reason_chips_e2e plus Match review and waiting e2e and test_hub_deny, test_hub_state updates. Written, not run: the full suite runs once on master after all bundles (operator order). Security: MEDUSA over the staged tree on master: 100, no findings; index.html.j2, style-home.css and style-match.css are not covered and were read by hand (style rules only, no url or import). 🎯 Fix: 90 % 💥 Break: 5 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 86 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
96d332a7cd
commit
f95196ca82
15 files changed
+369
-24
No files matched your search
@@ -0,0 +1,125 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
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 ASK
|
||||
|
||||
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-reason-chips-shots"))
|
||||
SAID = ("make the gate green first", "rebase on main", "", "rebase on main", "split the bundle")
|
||||
SHOWN = ["split the bundle", "rebase on main", "make the gate green first"]
|
||||
COMMON = """
|
||||
const row = (ref) => document.querySelector(`#main .inbox-list > li[data-ref="${ref}"]`);
|
||||
const sheet = () => document.querySelector("#sheet:not([hidden]) .sheet-box");
|
||||
const chips = () => all(".reason-chips .chip", sheet());
|
||||
const wide = () => document.documentElement.scrollWidth > innerWidth + 1;
|
||||
const key = (value) => document.body.dispatchEvent(new KeyboardEvent("keydown", {key: value, bubbles: true}));
|
||||
const pick = async (index, field) => {
|
||||
const shown = chips().map(text);
|
||||
chips()[index].click();
|
||||
const filled = field.value;
|
||||
const focused = document.activeElement === field;
|
||||
field.value += " now";
|
||||
const result = {shown, filled, focused, edited: field.value, inside: chips().every((chip) => chip.getBoundingClientRect().right <= sheet().getBoundingClientRect().right + 1), wide: wide()};
|
||||
key("Escape");
|
||||
await until(() => !sheet(), 4000);
|
||||
return result;
|
||||
};
|
||||
"""
|
||||
INBOX = """(async () => {@HELPERS@@COMMON@
|
||||
if (!(await until(() => row("@ASK@"), 8000))) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
row("@ASK@").querySelector('.deny-split button[aria-haspopup="dialog"]').click();
|
||||
if (!(await until(() => sheet() && chips().length, 4000))) {
|
||||
return {error: text(document.getElementById("sheet"))};
|
||||
}
|
||||
const single = await pick(1, sheet().querySelector(".deny-reason textarea"));
|
||||
const menu = () => document.querySelector("#grant-bar details.grant-menu");
|
||||
const checkbox = row("@ASK@").querySelector('input[type="checkbox"]');
|
||||
if (checkbox && !checkbox.checked) {
|
||||
checkbox.click();
|
||||
}
|
||||
if (!(await until(() => menu(), 3000))) {
|
||||
return {single, error: "no selection menu"};
|
||||
}
|
||||
menu().querySelector("summary").click();
|
||||
await until(() => menu().open, 2000);
|
||||
const deny = all("#grant-bar .menu-item.danger").find((button) => text(button).startsWith("Deny"));
|
||||
deny.click();
|
||||
if (!(await until(() => sheet() && chips().length, 4000))) {
|
||||
return {single, error: text(document.getElementById("sheet"))};
|
||||
}
|
||||
const bulk = await pick(0, sheet().querySelector(".deny-reason textarea"));
|
||||
return {single, bulk};
|
||||
})()"""
|
||||
MATCH = """(async () => {@HELPERS@@COMMON@
|
||||
const card = () => document.querySelector("#main .match-card.front");
|
||||
if (!(await until(card, 8000))) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
key("ArrowLeft");
|
||||
if (!(await until(() => sheet() && sheet().querySelector(".match-feedback") && chips().length, 4000))) {
|
||||
return {error: text(document.getElementById("sheet"))};
|
||||
}
|
||||
return {reject: await pick(2, sheet().querySelector(".match-feedback"))};
|
||||
})()"""
|
||||
|
||||
|
||||
def probe(template: str, ask: str) -> str:
|
||||
return template.replace("@HELPERS@", base.HELPERS).replace("@COMMON@", COMMON).replace("@ASK@", ask)
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
|
||||
class TestReasonChips(HubCase):
|
||||
drive = base.OrchestratorE2ECase.drive
|
||||
authenticator = base.OrchestratorE2ECase.authenticator
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.claim("s1", "Skills session")
|
||||
self.ask = self.create_ask({**ASK, "timeout": 3600})
|
||||
now = time.time()
|
||||
for age, reason in enumerate(SAID):
|
||||
denial = {"channel": "post", "kind": "ask", "reason": reason, "subject": {}, "to": "Skills"}
|
||||
fields = {"to": "Skills", "address": "Skills session", "text": "Denied by the operator.", "upload": None, "voice": None, "voice_sha256": "", "class": "post"}
|
||||
self.httpd.hub.messages.add({**fields, "denial": denial, "proof": None, "created_ts": now - 60 + age})
|
||||
|
||||
def steps(self) -> list[dict]:
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
local = f"http://localhost:{self.port}/"
|
||||
ref = f"ask:{self.ask}"
|
||||
steps = []
|
||||
for width, height in base.WIDTHS:
|
||||
steps.append({"width": width, "height": height, "url": f"{local}?{width}#stream/inbox", "wait": 1200, "probe": probe(INBOX, ref), "shot": str(OUT / f"chromium-{width}-inbox.png")})
|
||||
steps.append({"width": width, "height": height, "url": f"{local}?{width}-match#tasks/match", "wait": 1200, "probe": probe(MATCH, ref), "shot": str(OUT / f"chromium-{width}-match.png")})
|
||||
return steps
|
||||
|
||||
def test_chromium_offers_the_last_reasons_in_every_deny_sheet_at_three_widths(self):
|
||||
data = self.drive(self.steps(), self.authenticator(), "cdp.mjs", os.environ.get("CHROMIUM", "chromium"))
|
||||
(OUT / "chromium-reason-chips.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
||||
self.assertEqual([error for error in data["errors"] if "(style-src-elem)" not in error and "/favicon.ico" not in error], [])
|
||||
results = iter(data["results"])
|
||||
for width, _ in base.WIDTHS:
|
||||
inbox, match = next(results), next(results)
|
||||
with self.subTest(width=width):
|
||||
self.assertNotIn("error", inbox, inbox)
|
||||
self.assertNotIn("error", match, match)
|
||||
for found, index in ((inbox["single"], 1), (inbox["bulk"], 0), (match["reject"], 2)):
|
||||
self.assertEqual(found["shown"], SHOWN, found)
|
||||
self.assertEqual((found["filled"], found["focused"], found["edited"]), (SHOWN[index], True, f"{SHOWN[index]} now"), found)
|
||||
self.assertEqual((found["inside"], found["wide"]), (True, False), found)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -18,6 +18,7 @@ from hub_support import iso
|
||||
|
||||
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-012-shots"))
|
||||
FILES = (("src/app.py", 60), ("src/view.js", 30), ("docs/notes.md", 12))
|
||||
PATTERNS = ("dots", "stripes", "waves", "grid", "rings")
|
||||
CARD = """
|
||||
const card = () => document.querySelector("#main .match-card.front");
|
||||
const body = () => card() && card().querySelector(".match-body");
|
||||
@@ -34,7 +35,8 @@ CARD = """
|
||||
name: text(card().querySelector(".match-name")), age: text(card().querySelector(".match-age")),
|
||||
metrics: all(".match-metric", card()).map((chip) => [chip.dataset.metric, text(chip.querySelector("strong"))]),
|
||||
under: Boolean(card().querySelector(".match-metrics")) && card().querySelector(".match-metrics").getBoundingClientRect().top >= card().querySelector(".match-name").getBoundingClientRect().bottom - 1,
|
||||
place: all(".match-place dt", card()).map(text).map((label, index) => [label, text(all(".match-place dd", card())[index])]),
|
||||
place: all(".match-place .match-where", card()).map((chip) => [chip.dataset.place, text(chip), chip.title]),
|
||||
paint: [card().dataset.pattern, card().style.getPropertyValue("--card-hue"), card().style.getPropertyValue("--card-hue-2"), getComputedStyle(card().querySelector(".match-head")).backgroundImage.includes("radial-gradient")],
|
||||
files: all(".match-file", card()).map((file) => file.dataset.path), accept: card().closest(".match-stack").querySelector(".match-accept").disabled,
|
||||
reason: text(card().querySelector(".match-stale")), peeks: all("#main .match-peek").map((tab) => tab.dataset.card),
|
||||
wide: document.documentElement.scrollWidth > window.innerWidth + 1,
|
||||
@@ -84,7 +86,14 @@ MARK = """(async () => {@HELPERS@@CARD@
|
||||
const pressed = await save("long press note");
|
||||
const marks = all("tr.match-mark", card()).map((mark) => [mark.dataset.line, text(mark.querySelector(".match-mark-text"))]);
|
||||
const marked = all("tr.marked", card()).map((mark) => mark.dataset.line);
|
||||
return {clicked, pressed, marks, marked, count: text(card().querySelector('.match-file[data-path="@FIRST@"] .match-marks'))};
|
||||
const third = row("@FIRST@", 9);
|
||||
third.dispatchEvent(new MouseEvent("contextmenu", {bubbles: true, cancelable: true, clientX: box.left + 40, clientY: box.top + 4, button: 2}));
|
||||
const field = await until(() => card().querySelector(".match-comment textarea"), 3000);
|
||||
const presets = all(".match-comment .reason-chips .chip", card()).map(text);
|
||||
card().querySelector(".match-comment .reason-chips .chip:last-child").click();
|
||||
const preset = [field.value, document.activeElement === field];
|
||||
card().querySelector(".match-comment .btn.ghost").click();
|
||||
return {clicked, pressed, marks, marked, presets, preset, count: text(card().querySelector('.match-file[data-path="@FIRST@"] .match-marks'))};
|
||||
})()"""
|
||||
PICK = """(async () => {@HELPERS@@CARD@
|
||||
const found = await pick("@ID@");
|
||||
@@ -171,13 +180,19 @@ class TestMatchReview(HubCase):
|
||||
def check(self, data: dict, widths: tuple[tuple[int, int], ...]) -> None:
|
||||
results = iter(data["results"])
|
||||
order = [path for path, _ in FILES]
|
||||
paints = set()
|
||||
for width, _ in widths:
|
||||
with self.subTest(width=width):
|
||||
stack = next(results)
|
||||
self.assertEqual((stack["card"], stack["kind"], stack["stale"], stack["face"]), (f"review:{self.commit}", "commit", "false", True), stack)
|
||||
self.assertEqual((stack["name"], stack["age"]), ("Skills", "3 days"), stack)
|
||||
self.assertEqual((stack["metrics"], stack["under"]), ([["fix", "95"], ["break", "3"]], True), stack)
|
||||
self.assertEqual(stack["place"], [["Repository", "/repo"], ["Branch", "feature/match"], ["Worktree", "/repo/.worktrees/feature/match"]], stack)
|
||||
place = [["branch", "feature/match", "Branch: feature/match (click copies)"], ["repo", "repo", "Repository: /repo (click copies)"],
|
||||
["worktree", ".worktrees/feature/match", "Worktree: /repo/.worktrees/feature/match (click copies)"]]
|
||||
self.assertEqual(stack["place"], place, stack)
|
||||
self.assertIn(stack["paint"][0], PATTERNS, stack)
|
||||
self.assertTrue(stack["paint"][1] and stack["paint"][2] and stack["paint"][3], stack)
|
||||
paints.add(tuple(stack["paint"]))
|
||||
self.assertEqual(stack["files"], order)
|
||||
self.assertEqual(stack["peeks"], ["operator:operator/issue", f"review:{self.stale}"], stack)
|
||||
self.assertFalse(stack["accept"], stack)
|
||||
@@ -193,6 +208,7 @@ class TestMatchReview(HubCase):
|
||||
self.assertEqual((mark["clicked"], mark["pressed"]), (True, True), mark)
|
||||
self.assertEqual(mark["marks"], [["3", "use the helper here"], ["6", "long press note"]], mark)
|
||||
self.assertEqual(mark["marked"], ["3", "6"], mark)
|
||||
self.assertEqual((mark["presets"], mark["preset"]), (["long press note", "use the helper here"], ["use the helper here", True]), mark)
|
||||
self.assertEqual(mark["count"], "2", mark)
|
||||
command = next(results)
|
||||
self.assertEqual((command["kind"], command["stale"], command["command"], command["why"]), ("command", "false", self.command, "file the release issue"), command)
|
||||
@@ -202,6 +218,7 @@ class TestMatchReview(HubCase):
|
||||
stale = next(results)
|
||||
self.assertEqual((stale["kind"], stale["stale"], stale["accept"], stale["name"], stale["age"]), ("commit", "true", True, "Stage", "9 days"), stale)
|
||||
self.assertIn("changed", stale["reason"])
|
||||
self.assertEqual(len(paints), 1, paints)
|
||||
|
||||
def test_chromium_shows_face_place_files_on_scroll_and_marks_at_three_widths(self):
|
||||
data = self.drive(self.steps("chromium", base.WIDTHS), None)
|
||||
|
||||
@@ -13,6 +13,7 @@ HERE = Path(__file__).resolve().parent
|
||||
sys.path[:0] = [str(HERE.parent), str(HERE)]
|
||||
|
||||
import hub_e2e_kit as base
|
||||
import test_home_dashboard_e2e as dash
|
||||
from hub_case import HubCase
|
||||
from hub_support import ASK, OPTIONS, iso
|
||||
from kvb_orchestrator import batches, skill_scripts
|
||||
@@ -34,6 +35,30 @@ FRONT = """(async () => {@HELPERS@
|
||||
return {front: node ? node.dataset.card : null, options: node ? all(".match-options .option", node).map((option) => [text(option.querySelector("strong")), option.classList.contains("recommended")]) : [],
|
||||
wide: document.documentElement.scrollWidth > window.innerWidth + 1};
|
||||
})()"""
|
||||
HOME = """(async () => {@HELPERS@@HOME_KIT@
|
||||
await ViewStore.update("home.pins", () => [{kind: "panel", id: "tasks/match", w: 12, h: 8}]);
|
||||
await go("#home");
|
||||
const tile = await until(() => document.querySelector('#main .home-tile[data-id="tasks/match"]'), 8000);
|
||||
if (!tile) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
const slot = await until(() => tile.querySelector(".home-head > .home-slot"), 4000);
|
||||
await until(() => slot && /cards? wait/.test(text(slot)), 6000);
|
||||
const below = () => Boolean(tile.querySelector(".match-actions + .match-peeks .match-peek"));
|
||||
const toggle = slot ? slot.querySelector(".match-peeks-toggle") : null;
|
||||
const peeks = [[Boolean(await until(below, 6000)), toggle && toggle.getAttribute("aria-pressed")]];
|
||||
if (toggle) {
|
||||
toggle.click();
|
||||
await sleep(200);
|
||||
peeks.push([below() || Boolean(tile.querySelector(".match-peeks")), toggle.getAttribute("aria-pressed"), localStorage.getItem("kvb-orchestrator.match-peeks")]);
|
||||
toggle.click();
|
||||
await sleep(200);
|
||||
peeks.push([below(), toggle.getAttribute("aria-pressed"), localStorage.getItem("kvb-orchestrator.match-peeks")]);
|
||||
}
|
||||
return {peeks, slot: slot ? text(slot.querySelector(".muted")) : null, overview: Boolean(slot && slot.querySelector(".match-open-overview")),
|
||||
toolbar: Boolean(tile.querySelector(".home-body .task-toolbar")), card: Boolean(await until(() => tile.querySelector(".match-card.front"), 6000)),
|
||||
head: Math.round(tile.querySelector(".home-head").getBoundingClientRect().height), wide: document.documentElement.scrollWidth > innerWidth + 1};
|
||||
})()"""
|
||||
FLOW = """(async () => {@HELPERS@
|
||||
const posted = [];
|
||||
const send = window.fetch.bind(window);
|
||||
@@ -120,6 +145,8 @@ class TestMatchWaiting(HubCase):
|
||||
url = f"http://localhost:{self.port}/?{width}#tasks/match"
|
||||
front = FRONT.replace("@HELPERS@", base.HELPERS).replace("@PICK@", PICK)
|
||||
flow = FLOW.replace("@HELPERS@", base.HELPERS).replace("@RELEASE@", "true" if width == RELEASE_AT else "false")
|
||||
home = HOME.replace("@HELPERS@", base.HELPERS).replace("@HOME_KIT@", dash.HOME)
|
||||
steps.append({"width": width, "height": height, "url": f"http://localhost:{self.port}/?{width}-home#stream", "wait": 1500, "probe": home, "shot": str(OUT / f"chromium-{width}-home.png")})
|
||||
steps.append({"width": width, "height": height, "url": url, "wait": 1500, "probe": front, "shot": str(OUT / f"chromium-{width}-decision.png")})
|
||||
steps.append({"width": width, "height": height, "url": url, "wait": 1500, "probe": flow, "shot": str(OUT / f"chromium-{width}-overview.png")})
|
||||
return steps
|
||||
@@ -145,7 +172,12 @@ class TestMatchWaiting(HubCase):
|
||||
self.settle(lambda: self.ask_status(self.ask, "0") == "allowed")
|
||||
(OUT / "chromium-waiting.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
||||
self.assertEqual([error for error in data["errors"] if "(style-src-elem)" not in error and "/favicon.ico" not in error], [])
|
||||
fronts, flows = data["results"][0::2], data["results"][1::2]
|
||||
homes, fronts, flows = data["results"][0::3], data["results"][1::3], data["results"][2::3]
|
||||
for home in homes:
|
||||
with self.subTest(home=home):
|
||||
self.assertEqual((home["slot"], home["overview"], home["toolbar"], home["card"], home["wide"]), ("4 cards wait", True, False, True, False), home)
|
||||
self.assertLessEqual(home["head"], 48, home)
|
||||
self.assertEqual(home["peeks"], [[True, "true"], [False, "false", "false"], [True, "true", "true"]], home)
|
||||
for front in fronts:
|
||||
with self.subTest(front=front):
|
||||
self.assertEqual((front["front"], front["options"], front["wide"]), (PICK, [["Merge now", True], ["Wait", False]], False), front)
|
||||
|
||||
Reference in new issue
Block a user