test(e2e): cover the open label checks of 001-003

The browser suites now check the tab and panel labels that requirements 001 to 003 list but no e2e test reached: every hub tab hash including #home and #resources, and the workbench sheets without an accessible name. Committed below the bar on the operator's word; the unify e2e run proves it.

🎯 Fix: 75 %
💥 Break: 8 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 69
🚦 Gate: ⛔ fix 75 % < 90, break 8 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 18:49:32 +00:00
1 parent 590b430d37
commit 594d185197
4 files changed
+206 -27

No files matched your search

+102 -10
View File
@@ -437,8 +437,10 @@ MEDIA_LOG = """() => {
}
};
const play = HTMLMediaElement.prototype.play;
window.e2eMedia = new Set();
HTMLMediaElement.prototype.play = function () {
window.e2eAudio = this;
window.e2eMedia.add(this);
const src = this.getAttribute("src") || "";
const result = play.call(this);
result.then(() => keep({play: "ok", src}), (error) => keep({play: error.name, src}));
@@ -522,6 +524,26 @@ RADIO_CLICK = """(async () => {@HELPERS@@MEDIA@
const now = document.querySelector('#radio-spot [data-station="0"]');
return {clicked, state: now.dataset.state, note: text(now.querySelector(".station-note")), media, log: log()};
})()""".replace("@HELPERS@", HELPERS).replace("@MEDIA@", MEDIA)
RADIO_STOP = """(async () => {@HELPERS@@MEDIA@
const row = () => document.querySelector('#radio-spot [data-station="0"]');
const stop = row() ? row().querySelector('button[data-action="stop"]') : null;
if (!stop) {
return {error: "no Stop button on the playing station", state: row() ? row().dataset.state : null, media: sample(), log: log()};
}
const button = [stop.getAttribute("aria-label"), stop.title, text(stop), Boolean(stop.querySelector('svg.bi use[href="#bi-stop-fill"]'))];
stop.click();
const paused = Boolean(await until(() => sample() && sample().paused, 8000));
const media = await advancing();
const now = row();
const action = now ? now.querySelector("button[data-action]") : null;
const elements = [...new Set([...(window.e2eMedia || []), ...all("audio, video")])];
return {
button, paused, media, tracked: (window.e2eMedia || new Set()).size,
state: now ? now.dataset.state : null, note: now ? text(now.querySelector(".station-note")) : null,
action: action ? [action.dataset.action, action.getAttribute("aria-label")] : null,
playing: elements.filter((element) => !element.paused).map((element) => element.getAttribute("src") || element.currentSrc || element.tagName),
};
})()""".replace("@HELPERS@", HELPERS).replace("@MEDIA@", MEDIA)
SPEAKING = """
const caption = () => {
const node = document.querySelector("#radio-spot:not([hidden]) .radio-caption");
@@ -804,7 +826,7 @@ RADIO_JUMP = """(async () => {@HELPERS@
await sleep(200);
const focused = document.activeElement === spot.querySelector("textarea");
const tabs = [];
for (const hash of ["#stream/inbox", "#agents/orbit", "#artifacts/tree", "#tasks/list"]) {
for (const hash of ["#home", "#stream/inbox", "#agents/orbit", "#artifacts/tree", "#tasks/list", "#resources"]) {
location.hash = hash;
await sleep(500);
const main = document.getElementById("main");
@@ -818,6 +840,19 @@ RADIO_JUMP = """(async () => {@HELPERS@
header: all("header.top button").map((button) => [button.id, name(button), text(button)]), radioTab: Boolean(document.getElementById("tab-radio")),
};
})()""".replace("@HELPERS@", HELPERS)
CANCELED = """() => {
window.e2ePasskeys = 0;
if (navigator.credentials) {
navigator.credentials.get = () => {
window.e2ePasskeys += 1;
return Promise.reject(new DOMException("The operator canceled.", "NotAllowedError"));
};
}
}"""
JUMPED = {
"hash": "#stream", "focused": True, "tabs": [[tab, True, True] for tab in ("#home", "#stream/inbox", "#agents/orbit", "#artifacts/tree", "#tasks/list", "#resources")], "closed": [True, "false"],
"header": [["radio-open", "Radio", ""], ["bubbles-toggle", "Speech bubbles", ""], ["palette-open", "Commands", ""], ["settings-open", "Settings", ""]], "radioTab": False,
}
PRESENCE_HELPERS = """
const states = () => all("#main .presence:not(label)").map((node) => node.dataset.state).sort();
const statusMenu = () => {
@@ -1015,8 +1050,10 @@ class Station(http.server.BaseHTTPRequestHandler):
return
LABELS = """
const unlabelled = (root) => all("svg.bi", root).filter((svg) => !svg.closest(".sprite")).map((svg) => svg.parentElement).filter((owner) => !text(owner) && !(owner.getAttribute("title") && owner.getAttribute("aria-label"))).map((owner) => owner.outerHTML.slice(0, 160));
UNLABELLED = """
const unlabelled = (root, skip) => all("svg.bi", root).filter((svg) => !svg.closest(".sprite") && !(skip && skip.contains(svg))).map((svg) => svg.parentElement).filter((owner) => !text(owner) && !(owner.getAttribute("title") && owner.getAttribute("aria-label"))).map((owner) => owner.outerHTML.slice(0, 160));
"""
LABELS = UNLABELLED + """
const wide = () => document.documentElement.scrollWidth > window.innerWidth + 1;
const rowOf = (words) => all("#main .inbox-list > li").find((li) => li.textContent.includes(words));
const askOf = (command) => all("#main .inbox-list > li.k-ask").find((li) => text(li.querySelector(".command code")) === command);
@@ -1679,10 +1716,11 @@ class TestOrchestratorE2E(HubCase):
first,
{"width": 390, "height": 844, "url": None, "wait": 3000, "probe": RADIO_VIEW, "shot": str(OUT / f"{browser}-390-radio-station.png")},
{"width": 1366, "height": 768, "url": None, "wait": 0, "probe": RADIO_CLICK, "shot": str(OUT / f"{browser}-1366-radio-playing.png"), "gesture": True},
{"width": 1366, "height": 768, "url": None, "wait": 0, "probe": RADIO_STOP, "shot": str(OUT / f"{browser}-1366-radio-stopped.png")},
]
data = self.drive(steps, self.authenticator() if signs else None, driver, binary, MEDIA_LOG)
(OUT / f"{browser}-radio.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
saved, view, click = data["results"]
saved, view, click, stopped = data["results"]
if signs:
self.assertTrue(any(toast.startswith("New station") for toast in saved["toasts"]), saved)
self.assertNotIn("error", view)
@@ -1699,6 +1737,15 @@ class TestOrchestratorE2E(HubCase):
self.assertTrue(click["media"]["playing"], click)
self.assertEqual(click["state"], "playing", click)
self.assertEqual([entry for entry in click["log"] if entry.get("csp") == "media-src"], [])
with self.subTest(browser=browser, part="station stop"):
self.assertNotIn("error", stopped, stopped)
self.assertEqual(stopped["button"], ["Stop", f"Stop: pause {STATION_NAME}", "", True])
self.assertTrue(stopped["paused"], stopped)
self.assertFalse(stopped["media"]["playing"], stopped)
self.assertEqual((stopped["media"]["second"]["paused"], stopped["media"]["second"]["src"]), (True, None), stopped)
self.assertEqual((stopped["state"], stopped["note"], stopped["action"]), ("stopped", "stopped", ["play", "Play"]), stopped)
self.assertGreater(stopped["tracked"], 0, stopped)
self.assertEqual(stopped["playing"], [], "an audio element still plays after Stop")
return data
def popped(self, result: dict, title: str) -> None:
@@ -1986,7 +2033,7 @@ class TestOrchestratorE2E(HubCase):
def test_chromium_sends_every_class_from_the_radio_spot_and_keeps_its_gear_settings_through_a_reload_at_three_widths(self):
local = f"http://localhost:{self.port}/"
values = {1920: ("0.35", "false", "true"), 1366: ("0.45", "true", "false"), 390: ("0.55", "false", "true")}
steps = [{"width": 1366, "height": 768, "url": f"{local}#stream/radio", "wait": 1200, "probe": RADIO_JUMP, "shot": self.shot("1366-radio-header-spot-every-tab")}]
steps = [{"width": width, "height": height, "url": f"{local}?{width}-jump#stream/radio", "wait": 1200, "probe": RADIO_JUMP, "shot": self.shot(f"{width}-radio-header-spot-every-tab")} for width, height in WIDTHS]
for width, height in WIDTHS:
squelch, tone, post = values[width]
gear = GEAR_SAVE.replace("@SQUELCH@", squelch).replace("@TONE@", tone).replace("@POST@", post)
@@ -2000,11 +2047,10 @@ class TestOrchestratorE2E(HubCase):
self.assertEqual(data["errors"], [])
labels = dict(zip(CHOICE_CHANNELS, ["Post", "Call", "Newsletter", "Broadcast", "Pan-Pan", "Sécurité", "Mayday"], strict=True))
mayday = "Send a mayday to all? All agents pause writing steps until you cancel it."
jump, *walked = data["results"]
self.assertEqual(jump, {
"hash": "#stream", "focused": True, "tabs": [[tab, True, True] for tab in ("#stream/inbox", "#agents/orbit", "#artifacts/tree", "#tasks/list")], "closed": [True, "false"],
"header": [["radio-open", "Radio", ""], ["bubbles-toggle", "Speech bubbles", ""], ["palette-open", "Commands", ""], ["settings-open", "Settings", ""]], "radioTab": False,
})
jumps, walked = data["results"][: len(WIDTHS)], data["results"][len(WIDTHS) :]
for jump, (width, _) in zip(jumps, WIDTHS, strict=True):
with self.subTest(width=width, part="radio spot on every tab"):
self.assertEqual(jump, JUMPED)
for index, (width, _) in enumerate(WIDTHS):
sent, saved, read = walked[3 * index : 3 * (index + 1)]
squelch, tone, post = values[width]
@@ -2038,6 +2084,52 @@ class TestOrchestratorE2E(HubCase):
self.assertTrue(args[-1].endswith(f"] spot {width} {cls}"), args)
self.assertEqual(self.httpd.hub.settings.get()["speech"], {"threshold": 50})
@unittest.skipUnless(shutil.which(os.environ.get("FIREFOX", "firefox")), "no Firefox")
def test_firefox_opens_the_radio_spot_on_every_tab_and_asks_the_passkey_for_every_class_and_cancel_mayday_sending_nothing_unsigned_at_three_widths(self):
self.pin()
local = f"http://localhost:{self.port}/"
steps = []
for width, height in WIDTHS:
shot = str(OUT / f"firefox-{width}-radio-spot")
steps += [
{"width": width, "height": height, "url": f"{local}?{width}-jump#stream/radio", "wait": 1200, "probe": RADIO_JUMP, "shot": f"{shot}-every-tab.png"},
{"width": width, "height": height, "url": f"{local}?{width}#agents/orbit", "wait": 1200, "probe": SPOT_SEND.replace("@TEXT@", f"spot {width}"), "shot": f"{shot}-unsigned.png"},
{"width": width, "height": height, "url": f"{local}?{width}-mayday#agents/orbit", "wait": 1200, "probe": CLEAR_MAYDAY, "shot": f"{shot}-mayday-kept.png"},
]
data = self.drive(steps, None, "bidi.mjs", os.environ.get("FIREFOX", "firefox"), CANCELED)
(OUT / "firefox-radio-spot.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], [])
labels = dict(zip(CHOICE_CHANNELS, ["Post", "Call", "Newsletter", "Broadcast", "Pan-Pan", "Sécurité", "Mayday"], strict=True))
mayday = "Send a mayday to all? All agents pause writing steps until you cancel it."
question = "Lift the radio silence of the active mayday?"
hint = "Cancel mayday: lift the radio silence so the agents write again; your passkey signs it"
results = iter(data["results"])
for width, _ in WIDTHS:
jump, sent, cleared = next(results), next(results), next(results)
with self.subTest(browser="firefox", width=width, part="radio spot on every tab"):
self.assertEqual(jump, JUMPED)
with self.subTest(browser="firefox", width=width, part="every class unsigned"):
self.assertNotIn("error", sent, sent)
self.assertEqual((sent["closed"], sent["open"], sent["inline"]), ([True, "false"], [False, "true", True], ["static", True, True]))
self.assertEqual((sent["toolbar"], sent["channels"], sent["record"]), (["Priority", "Day/Night", "Status"], CHOICE_CHANNELS, ["Record"]))
self.assertEqual(sent["heads"], [["Read aloud", "Read aloud: the classes and agents the radio sounds for"], ["Cancel mayday", hint]])
self.assertEqual((sent["tall"], sent["wide"]), (False, False))
self.assertEqual([run["cls"] for run in sent["runs"]], CHOICE_CHANNELS)
for run in sent["runs"]:
direct = run["cls"] in ("post", "call")
self.assertEqual((run["direct"], run["question"], run["left"]), (direct, [mayday] if run["cls"] == "mayday" else [], f"spot {width} {run['cls']}"), run)
self.assertTrue((run["toast"] or "").startswith(f"{labels[run['cls']]} to {'Stage' if direct else 'all'}: not signed"), run)
self.assertIn("NotAllowedError", run["toast"], run)
with self.subTest(browser="firefox", width=width, part="icon-only cancel mayday unsigned"):
self.assertNotIn("error", cleared, cleared)
self.assertEqual(cleared["toolbar"], ["Priority", "Day/Night", "Drain", "Suspend", "Resume", "Status"])
self.assertEqual((cleared["title"], cleared["shown"]), (hint, ""))
self.assertEqual(cleared["declined"], {"question": [question], "posted": [], "toasts": []})
self.assertEqual(cleared["accepted"], {"question": [question], "posted": ["/api/board/sign"]})
self.assertTrue((cleared["done"] or "").startswith("Cancel mayday: not signed"), cleared)
self.assertEqual(self.scripts.calls, [])
self.assertTrue((self.council / "radio-silence.json").exists())
def test_chromium_keeps_the_3d_camera_through_two_state_refreshes_at_three_widths(self):
steps = [{"width": width, "height": height, "url": f"{self.base}?{width}#agents/3d", "wait": 900, "probe": CAMERA, "shot": self.shot(f"{width}-agents-3d-steady-camera")} for width, height in WIDTHS]
data = self.drive(steps, None, init=GRAPH_HOOK)
+15 -4
View File
@@ -24,7 +24,7 @@ DIFF = [
{"path": "big.txt", "status": "M", "mode": "100644", "additions": 401, "deletions": 0, "patch": "@@ -0,0 +1,401 @@\n" + "\n".join(f"+line {n}" for n in range(401)), "note": ""},
{"path": "key.txt", "status": "A", "mode": "100755", "additions": 3, "deletions": 0, "patch": "", "note": WITHHELD},
]
OPERATOR = """(async () => {@HELPERS@
OPERATOR = """(async () => {@HELPERS@@UNLABELLED@
navigator.credentials.get = @SIGNS@ ? navigator.credentials.get.bind(navigator.credentials) : () => Promise.reject(new DOMException("The operator canceled.", "NotAllowedError"));
window.e2ePosted = [];
const send = window.fetch.bind(window);
@@ -59,10 +59,13 @@ OPERATOR = """(async () => {@HELPERS@
};
["@TAG@ review", "@TAG@ ship", "@TAG@ commit"].forEach((words) => mine(words).querySelector('input[type="checkbox"]').click());
await sleep(300);
found.unlabelled = {main: unlabelled(document.getElementById("main"))};
const grant = all("#main .inbox-actions button").find((button) => name(button).startsWith("Grant selection"));
found.grant = name(grant);
grant.click();
await until(() => document.querySelector(".sheet-box .actions"), 4000);
const granting = document.querySelector("#sheet .sheet-box");
found.unlabelled.sheet = granting ? unlabelled(granting) : null;
const confirm = all(".sheet-box .actions button").find((button) => text(button).startsWith("Grant "));
found.confirm = text(confirm);
found.listed = all(".sheet-box ul.mini > li").length;
@@ -72,7 +75,7 @@ OPERATOR = """(async () => {@HELPERS@
found.posted = window.e2ePosted.filter(([path]) => ["/api/sign", "/api/inbox/approve"].includes(path)).map(([path, body]) => [path, body.items.map((item) => item.kind).sort()]);
return found;
})()"""
FEEDBACK = """(async () => {@HELPERS@
FEEDBACK = """(async () => {@HELPERS@@UNLABELLED@
const card = await until(() => all("#main .inbox-list > li").find((li) => li.textContent.includes("@TAG@ second") && li.querySelector(".diff-file tr.add")), 10000);
if (!card) {
return {error: text(document.getElementById("main"))};
@@ -103,8 +106,11 @@ FEEDBACK = """(async () => {@HELPERS@
rows[1].querySelector("td.code").dispatchEvent(new MouseEvent("contextmenu", {bubbles: true, cancelable: true, clientX: box.left + 4, clientY: box.top + 4}));
await sleep(200);
const menu = floating && floating.getAttribute("role");
const labels = {float: floating ? unlabelled(floating) : null};
floating.querySelector("button").click();
const sheet = await until(() => document.querySelector(".sheet-box textarea"), 4000);
const writing = document.querySelector("#sheet .sheet-box");
labels.sheet = writing ? unlabelled(writing) : null;
const title = text(document.querySelector(".sheet-head .panel-title"));
const range = text(document.querySelector(".sheet-box .who code"));
sheet.value = "right-click note";
@@ -126,12 +132,12 @@ FEEDBACK = """(async () => {@HELPERS@
keyed.value = "key f note";
all(".sheet-box button").find((button) => name(button) === "Send feedback").click();
await sleep(1500);
return {nearby, menu, title, range, keyRange, shown: shown || "", posted: window.e2eFeedback, wide: document.documentElement.scrollWidth > window.innerWidth + 1};
return {nearby, menu, title, range, keyRange, labels, shown: shown || "", posted: window.e2eFeedback, wide: document.documentElement.scrollWidth > window.innerWidth + 1};
})()"""
def probe(template: str, tag: str, signs: bool) -> str:
return template.replace("@HELPERS@", base.HELPERS).replace("@TAG@", tag).replace("@SIGNS@", "true" if signs else "false")
return template.replace("@HELPERS@", base.HELPERS).replace("@UNLABELLED@", base.UNLABELLED).replace("@TAG@", tag).replace("@SIGNS@", "true" if signs else "false")
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
@@ -173,6 +179,11 @@ class TestWorkbenchOperatorTasks(HubCase):
for width, _ in base.WIDTHS:
tag = f"w{width}"
tasks, feedback = next(results), next(results)
with self.subTest(browser=browser, width=width, part="unlabelled controls"):
self.assertNotIn("error", tasks, tasks)
self.assertNotIn("error", feedback, feedback)
self.assertEqual(tasks["unlabelled"], {"main": [], "sheet": []})
self.assertEqual(feedback["labels"], {"float": [], "sheet": []})
with self.subTest(browser=browser, width=width):
self.assertNotIn("error", tasks, tasks)
self.assertEqual((tasks["hash"], tasks["tabs"], tasks["subs"], tasks["streamInbox"], tasks["current"]), ("#tasks/operator", base.TABS, ["Firewall"], False, ["Tasks"]))
+77 -8
View File
@@ -21,7 +21,7 @@ GATES_SPEC = importlib.util.spec_from_file_location("kvb_gates_for_e2e", REPO_RO
gates = importlib.util.module_from_spec(GATES_SPEC)
GATES_SPEC.loader.exec_module(gates)
KEPT_TIP = "0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d"
CLEAN_ALL = """(async () => {@HELPERS@
CLEAN_ALL = """(async () => {@HELPERS@@UNLABELLED@
const every = await until(() => document.querySelector('#main button[aria-label="Delete all merged"]'), 8000);
await until(() => document.querySelector("#main svg.ancestry"), 8000);
const token = all("#main .delete-all span.state").map(name);
@@ -30,14 +30,17 @@ CLEAN_ALL = """(async () => {@HELPERS@
every.click();
const sheet = await until(() => document.querySelector("#sheet:not([hidden]) li.dry-run") && document.getElementById("sheet"), 8000);
const rows = all("li.dry-run", sheet).map((row) => [text(row.querySelector("code")), row.dataset.token || (row.dataset.held ? "held" : null), text(row.querySelector("pre")).split("\\n")[0]]);
const dry = sheet.querySelector('ul[aria-label="Dry run"]');
const note = dry ? dry.previousElementSibling : null;
const labels = {sheet: unlabelled(sheet), note: note ? [note.tagName.toLowerCase(), note.className, text(note).startsWith("Dry run of pkgmgr branch cleanup")] : null};
const confirm = all("#sheet button").find((button) => name(button) === "Delete");
confirm.click();
const outcome = await until(() => sheet.querySelector("[data-cleanup]") || all("#sheet p.muted").find((node) => text(node).startsWith("Not signed")), 15000);
const tokenClick = store ? (store.click(), await until(() => all("#toasts .toast").map(text).find((line) => line.startsWith("Token")), 8000)) : null;
return {before, token, store: store ? [store.title, store.getAttribute("aria-label")] : null, rows, outcome: outcome ? (outcome.dataset.cleanup ? "queued" : "unsigned") : null, tokenClick,
return {before, token, store: store ? [store.title, store.getAttribute("aria-label")] : null, rows, outcome: outcome ? (outcome.dataset.cleanup ? "queued" : "unsigned") : null, tokenClick, labels,
wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
ANCESTRY = """(async () => {@HELPERS@
ANCESTRY = """(async () => {@HELPERS@@UNLABELLED@
const svg = await until(() => document.querySelector('#main svg.ancestry[aria-label="Ancestry of github.com/me/demo"]'), 8000);
if (!svg) {
return {error: "no ancestry"};
@@ -48,7 +51,7 @@ ANCESTRY = """(async () => {@HELPERS@
const row = all("#main .branch-row").find((entry) => text(entry.querySelector(".branch-name strong")) === branch);
return row ? all(".gate-mark", row).map((button) => [button.dataset.action, button.dataset.level, button.classList.contains("inherited"), button.title, Number(getComputedStyle(button).opacity) < 1]) : null;
};
return {nodes, edges, done: marks("feature/done"), main: marks("main"), wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
return {nodes, edges, done: marks("feature/done"), main: marks("main"), unlabelled: unlabelled(document.getElementById("main")), wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
STAGE = """(async () => {@HELPERS@
const svg = await until(() => document.querySelector("#main svg.ancestry"), 8000);
@@ -89,7 +92,7 @@ TOKENLESS = """(async () => {@HELPERS@
const rows = all("#main .branch-row").map((row) => [text(row.querySelector(".branch-name strong")), Boolean(row.querySelector('span.state[aria-label="token needed"]')), Boolean(row.querySelector('button[aria-label="Delete"]'))]);
return {every: [every.disabled, every.title], token: all("#main .delete-all span.state").map(name), store: store ? store.getAttribute("aria-label") : null, rows};
})()"""
AGENTS = """(async () => {@HELPERS@
AGENTS = """(async () => {@HELPERS@@UNLABELLED@
const svg = await until(() => document.querySelector('#main svg.ancestry[aria-label="Ancestry: operator, chair, sessions, subagents"]'), 8000);
if (!svg) {
return {error: "no agent ancestry"};
@@ -97,12 +100,62 @@ AGENTS = """(async () => {@HELPERS@
await until(() => svg.querySelector('g.ancestry-node[data-kind="twig"]') || document.querySelector('#main svg.ancestry g[data-kind="twig"]'), 8000);
const fresh = document.querySelector("#main svg.ancestry");
const nodes = all("g.ancestry-node", fresh).map((node) => [node.dataset.kind, Number(node.dataset.generation), node.getBoundingClientRect().top]);
return {nodes, edges: all("path.ancestry-edge", fresh).length, list: all("#main .spawn-tree li").length, wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
return {nodes, edges: all("path.ancestry-edge", fresh).length, list: all("#main .spawn-tree li").length, unlabelled: unlabelled(document.getElementById("main")), wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
POPUP_GATES = """(async () => {@HELPERS@@UNLABELLED@
const id = `branch:${@REPO@}\\u0000feature/done`;
const dialog = document.getElementById("popup");
const marks = (group) => all(".gate-mark", group).map((button) => [button.dataset.action, button.dataset.level, button.classList.contains("inherited"), button.title, Number(getComputedStyle(button).opacity) < 1]);
const shut = async () => {
(document.activeElement || document.body).dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));
await until(() => !dialog.open, 4000);
};
const read = async (view) => {
const group = await until(() => dialog.open && dialog.querySelector(".popup-box .gates"), 6000);
const found = group ? {view, title: text(dialog.querySelector(".popup-box .panel-title")), group: group.getAttribute("aria-label"), marks: marks(group), unlabelled: unlabelled(group)} : {view, error: "no gate marks in the popup", open: dialog.open};
await shut();
return found;
};
const shown = [];
for (const view of ["orbit", "chord", "swimlane"]) {
location.hash = `#artifacts/${view}`;
await screenShown(8000);
const picker = await until(() => document.querySelector('#main select[aria-label="Repository"]'), 8000);
if (picker && picker.value !== @REPO@) {
picker.value = @REPO@;
picker.dispatchEvent(new Event("change", {bubbles: true}));
}
const target = await until(() => all("#main svg [data-pick]").find((node) => node.dataset.pick === id), 8000);
if (!target) {
shown.push({view, error: text(document.getElementById("main"))});
continue;
}
target.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
shown.push(await read(view));
}
if (@THREE@) {
location.hash = "#artifacts/3d";
await screenShown(8000);
const field = await until(() => document.querySelector('#main input[aria-label="Find a node"]'), 8000);
await until(() => document.querySelector("#main .graph3d canvas") && !text(document.querySelector("#main .space-note")).startsWith("Loading"), 8000);
if (field) {
field.value = "feature/done";
field.dispatchEvent(new Event("input", {bubbles: true}));
}
const chip = await until(() => all("#main .hits .chip").find((node) => node.dataset.hit === id), 4000);
if (chip) {
chip.click();
shown.push(await read("3d"));
} else {
shown.push({view: "3d", error: "no hit chip", hits: all("#main .hits .chip").map((node) => node.dataset.hit)});
}
}
return {shown, wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
def probe(template: str) -> str:
return template.replace("@HELPERS@", base.HELPERS)
return template.replace("@HELPERS@", base.HELPERS).replace("@UNLABELLED@", base.UNLABELLED)
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
@@ -142,13 +195,29 @@ class TestWorkbenchArtifacts(HubCase):
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(STAGE), "shot": f"{shot}-staged.png"},
{"width": width, "height": height, "url": f"{self.base}?{width}-clean#artifacts/tree", "wait": 1200, "probe": probe(CLEAN_ALL), "shot": f"{shot}-clean-all.png"},
{"width": width, "height": height, "url": f"{self.base}?{width}#agents/tree", "wait": 1200, "probe": probe(AGENTS), "shot": f"{shot}-agents-ancestry.png"},
{"width": width, "height": height, "url": f"{self.base}?{width}-popups#artifacts/orbit", "wait": 1200, "probe": probe(POPUP_GATES).replace("@REPO@", json.dumps(self.repo)).replace("@THREE@", "true" if width == 1366 else "false"), "shot": f"{shot}-popup-gates.png"},
]
return steps
def check(self, data: dict, browser: str, signs: bool) -> None:
results = iter(data["results"])
for width, _ in base.WIDTHS:
ancestry, staged, clean, agents = next(results), next(results), next(results), next(results)
ancestry, staged, clean, agents, popups = next(results), next(results), next(results), next(results), next(results)
with self.subTest(browser=browser, width=width, part="popup gate marks"):
self.assertNotIn("error", popups, popups)
views = ["orbit", "chord", "swimlane", *(["3d"] if width == 1366 else [])]
self.assertEqual([found["view"] for found in popups["shown"]], views)
for found in popups["shown"]:
self.assertNotIn("error", found, found)
self.assertEqual((found["title"], found["group"], found["unlabelled"]), ("feature/done", "Gates of feature/done", []), found)
self.assertEqual([mark[:3] for mark in found["marks"]], [["commit", "test", True], ["merge", "none", True], ["push", "none", True], ["pr", "e2e", False]], found)
self.assertEqual(found["marks"][0][3], "commit: test · from main", found)
self.assertEqual([mark[4] for mark in found["marks"]], [True, True, True, False], found)
self.assertEqual(found["marks"], ancestry["done"], "a popup shows other gate levels than the Tree row")
self.assertFalse(popups["wide"])
with self.subTest(browser=browser, width=width, part="unlabelled controls"):
self.assertEqual((ancestry["unlabelled"], agents["unlabelled"]), ([], []))
self.assertEqual(clean["labels"], {"sheet": [], "note": ["p", "muted", True]})
with self.subTest(browser=browser, width=width):
for found in (ancestry, agents):
self.assertNotIn("error", found, found)
+12 -5
View File
@@ -200,17 +200,21 @@ BUBBLES_3D = """(async () => {@HELPERS@@READ@
const graph = document.querySelector("#main .graph3d").getBoundingClientRect();
return {canvas, first, later, graph: {left: graph.left, top: graph.top, right: graph.right, bottom: graph.bottom}, mode: text(document.querySelector("#main .space-note"))};
})()"""
BUBBLES_KEPT = """(async () => {@HELPERS@@READ@
BUBBLES_KEPT = """(async () => {@HELPERS@@READ@@UNLABELLED@
await sleep(300);
const kept = [toggle.getAttribute("aria-pressed"), layer.hidden, toggle.title, toggle.getAttribute("aria-label")];
const control = [Boolean(toggle.querySelector('svg.bi use[href="#bi-chat-quote"]')), text(toggle)];
const head = document.querySelector("header.top");
const labels = {header: head ? unlabelled(head) : null, layer: unlabelled(layer)};
toggle.click();
const off = Boolean(await until(() => toggle.getAttribute("aria-pressed") === "false" && layer.hidden, 8000));
return {kept, off, display: getComputedStyle(layer).display, bubbles: layer.querySelectorAll(".speech-bubble").length, violations: window.e2eViolations || null};
return {kept, control, labels, off, display: getComputedStyle(layer).display, bubbles: layer.querySelectorAll(".speech-bubble").length, violations: window.e2eViolations || null};
})()"""
SWITCHED = {"kept": ["true", False, "Speech bubbles", "Speech bubbles"], "control": [True, ""], "labels": {"header": [], "layer": []}, "off": True, "display": "none", "bubbles": 0, "violations": []}
def probe(template: str, cue: str = CUE) -> str:
return template.replace("@HELPERS@", base.HELPERS).replace("@READ@", READ).replace("@CUE@", cue).replace("@FADE@", str(FADE_MS))
return template.replace("@HELPERS@", base.HELPERS).replace("@READ@", READ).replace("@UNLABELLED@", base.UNLABELLED).replace("@CUE@", cue).replace("@FADE@", str(FADE_MS))
def quiet(found: dict) -> dict:
@@ -300,6 +304,9 @@ class TestWorkbenchBubbles(HubCase):
kept = next(results)
stream = [next(results), next(results), next(results)] if width == 1366 else None
first_key, second_key = self.keys["Stage"], self.keys[SECOND_FROM[width]]
with self.subTest(browser=browser, width=width, part="unlabelled controls"):
self.assertNotIn("error", kept, kept)
self.assertEqual((kept["control"], kept["labels"]), (SWITCHED["control"], SWITCHED["labels"]), kept)
with self.subTest(browser=browser, width=width, part="anchor"):
self.assertNotIn("error", on, on)
self.assertEqual(on["layer"]["position"], "fixed")
@@ -330,7 +337,7 @@ class TestWorkbenchBubbles(HubCase):
else:
self.aimed(found)
self.assertTrue(quiet(cleared)["cleared"], cleared)
self.assertEqual(quiet(switched), {"kept": ["true", False, "Speech bubbles", "Speech bubbles"], "off": True, "display": "none", "bubbles": 0, "violations": []})
self.assertEqual(quiet(switched), SWITCHED)
with self.subTest(browser=browser, width=width):
self.assertNotIn("error", on, on)
self.assertEqual((on["before"], on["on"]), (["false", True], True))
@@ -353,7 +360,7 @@ class TestWorkbenchBubbles(HubCase):
self.assertEqual((grown["who"], grown["scale"], grown["rendered"], grown["state"]), (second_key, 1, 1, "speaking"), grown)
self.assertEqual(grown["text"], " ".join(SECOND.split()[: grown["words"]]))
self.assertEqual(quiet(done), {"cleared": True, "faces": ["loaded"], "hidden": False, "violations": []})
self.assertEqual(quiet(kept), {"kept": ["true", False, "Speech bubbles", "Speech bubbles"], "off": True, "display": "none", "bubbles": 0, "violations": []})
self.assertEqual(quiet(kept), SWITCHED)
if long is not None:
with self.subTest(browser=browser, width=width, bubble="long"):
self.assertNotIn("error", long, long)