Improve contextual help and download filter grouping

Open contextual help from wrapper hover and focus, close it only after pointer or focus exits the shared trigger-popover region, and make clicks open-only. Remove the standalone package title and present the existing download filters as the first compact neutral sidebar group without changing filter behavior. Extend the visual driver and manifest with hover, leave, focus, blur, internal-focus, and real headless Chromium regression coverage.
This commit is contained in:
Sucukdeluxe
2026-08-22 11:46:56 +02:00
parent 9cdd0310a5
commit 7f3030ecc5
9 changed files with 272 additions and 25 deletions
+60 -1
View File
@@ -189,13 +189,72 @@
"viewport": { "width": 2560, "height": 1369 },
"activeView": "downloads",
"interactions": [
{ "type": "click", "role": "button", "name": "Informationen" }
{ "type": "hover", "role": "button", "name": "Informationen" },
{ "type": "wait-visible", "role": "region", "name": "Informationen zu Downloads" }
],
"assertions": [
{ "type": "visible", "role": "region", "name": "Informationen zu Downloads" },
{ "type": "nonempty", "role": "region", "name": "Informationen zu Downloads" }
]
},
{
"name": "info-closed-after-leave",
"scenario": "dense",
"viewport": { "width": 2560, "height": 1369 },
"activeView": "downloads",
"interactions": [
{ "type": "hover", "role": "button", "name": "Informationen" },
{ "type": "wait-visible", "role": "region", "name": "Informationen zu Downloads" },
{ "type": "leave", "role": "button", "name": "Informationen" },
{ "type": "wait-absent", "role": "region", "name": "Informationen zu Downloads" }
],
"assertions": [
{ "type": "absent", "role": "region", "name": "Informationen zu Downloads" }
]
},
{
"name": "info-open-focus",
"scenario": "dense",
"viewport": { "width": 2560, "height": 1369 },
"activeView": "downloads",
"interactions": [
{ "type": "focus", "role": "button", "name": "Informationen" },
{ "type": "wait-visible", "role": "region", "name": "Informationen zu Downloads" }
],
"assertions": [
{ "type": "visible", "role": "region", "name": "Informationen zu Downloads" }
]
},
{
"name": "info-closed-after-blur",
"scenario": "dense",
"viewport": { "width": 2560, "height": 1369 },
"activeView": "downloads",
"interactions": [
{ "type": "focus", "role": "button", "name": "Informationen" },
{ "type": "wait-visible", "role": "region", "name": "Informationen zu Downloads" },
{ "type": "blur", "role": "button", "name": "Informationen" },
{ "type": "wait-absent", "role": "region", "name": "Informationen zu Downloads" }
],
"assertions": [
{ "type": "absent", "role": "region", "name": "Informationen zu Downloads" }
]
},
{
"name": "info-open-focus-inside",
"scenario": "dense",
"viewport": { "width": 2560, "height": 1369 },
"activeView": "downloads",
"interactions": [
{ "type": "focus", "role": "button", "name": "Informationen" },
{ "type": "wait-visible", "role": "region", "name": "Informationen zu Downloads" },
{ "type": "focus", "role": "button", "name": "Kontextaktion" },
{ "type": "wait-visible", "role": "region", "name": "Informationen zu Downloads" }
],
"assertions": [
{ "type": "visible", "role": "region", "name": "Informationen zu Downloads" }
]
},
{
"name": "info-absent",
"scenario": "empty",
@@ -36,6 +36,16 @@ type ToolbarMeasurement = {
schedule: DOMRect;
};
type ContextInfoMeasurement = {
afterHover: boolean;
afterPopover: boolean;
afterLeave: boolean;
afterFocus: boolean;
afterBlur: boolean;
afterFirstClick: boolean;
afterSecondClick: boolean;
};
class CdpClient {
private nextId = 0;
private readonly pending = new Map<number, {
@@ -246,6 +256,24 @@ describe("download disclosure in the headless visual harness", () => {
throw new Error("Visual harness did not reach its ready state");
}
async function loadDriverCapture(name: string): Promise<void> {
if (!client) throw new Error("Chrome DevTools client is missing");
await client.send("Page.navigate", {
url: `http://127.0.0.1:${visualPort}/driver-test.html?capture=${encodeURIComponent(name)}&run=${Date.now()}`
});
const deadline = Date.now() + 20_000;
while (Date.now() < deadline) {
const state = await client.evaluate<{ error: string; ready: boolean }>(`({
error: document.getElementById('root')?.textContent || '',
ready: document.documentElement.dataset.visualReady === 'true'
})`);
if (state.ready) return;
if (state.error.startsWith("Visual-Harness-Fehler:")) throw new Error(state.error);
await delay(50);
}
throw new Error(`Visual driver capture did not reach its ready state: ${name}`);
}
async function measureDisclosure(action: "einklappen" | "ausklappen"): Promise<DisclosureSample[]> {
if (!client) throw new Error("Chrome DevTools client is missing");
return client.evaluate<DisclosureSample[]>(`(async () => {
@@ -348,4 +376,79 @@ describe("download disclosure in the headless visual harness", () => {
expect(measurement.toggle.right).toBeLessThanOrEqual(measurement.toolbar.right + 1);
expect(measurement.toolbar.right - measurement.toggle.right).toBeLessThanOrEqual(12);
}, 30_000);
it("opens context info on hover and focus, stays open over the popover and closes outside", async () => {
await loadDenseDownloads(1120);
if (!client) throw new Error("Chrome DevTools client is missing");
const trigger = await client.evaluate<DOMRect>(`(() => {
const element = document.querySelector('.ui-context-info-trigger');
if (!(element instanceof HTMLButtonElement)) throw new Error('Context info trigger is missing');
return element.getBoundingClientRect().toJSON();
})()`);
await client.send("Input.dispatchMouseEvent", {
type: "mouseMoved",
x: trigger.left + trigger.width / 2,
y: trigger.top + trigger.height / 2
});
await delay(50);
const afterHover = await client.evaluate<boolean>("Boolean(document.querySelector('.ui-context-info-region'))");
const popover = await client.evaluate<DOMRect>(`(() => {
const element = document.querySelector('.ui-context-info-region');
if (!(element instanceof HTMLElement)) throw new Error('Context info region is missing after hover');
return element.getBoundingClientRect().toJSON();
})()`);
await client.send("Input.dispatchMouseEvent", {
type: "mouseMoved",
x: popover.left + popover.width / 2,
y: popover.top + popover.height / 2
});
await delay(50);
const afterPopover = await client.evaluate<boolean>("Boolean(document.querySelector('.ui-context-info-region'))");
await client.send("Input.dispatchMouseEvent", { type: "mouseMoved", x: 1110, y: 10 });
await delay(50);
const afterLeave = await client.evaluate<boolean>("Boolean(document.querySelector('.ui-context-info-region'))");
const focusStates = await client.evaluate<Omit<ContextInfoMeasurement, "afterHover" | "afterPopover" | "afterLeave">>(`(async () => {
const wait = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
const trigger = document.querySelector('.ui-context-info-trigger');
const outside = document.querySelector('.md-shell-navigation-item');
if (!(trigger instanceof HTMLButtonElement) || !(outside instanceof HTMLButtonElement)) {
throw new Error('Context info focus targets are missing');
}
trigger.focus();
await wait();
const afterFocus = Boolean(document.querySelector('.ui-context-info-region'));
outside.focus();
await wait();
const afterBlur = Boolean(document.querySelector('.ui-context-info-region'));
trigger.click();
await wait();
const afterFirstClick = Boolean(document.querySelector('.ui-context-info-region'));
trigger.click();
await wait();
const afterSecondClick = Boolean(document.querySelector('.ui-context-info-region'));
return { afterFocus, afterBlur, afterFirstClick, afterSecondClick };
})()`);
const measurement: ContextInfoMeasurement = { afterHover, afterPopover, afterLeave, ...focusStates };
expect(measurement).toEqual({
afterHover: true,
afterPopover: true,
afterLeave: false,
afterFocus: true,
afterBlur: false,
afterFirstClick: true,
afterSecondClick: true
});
}, 30_000);
it("executes the context info hover, leave, focus and blur manifest captures", async () => {
for (const name of ["info-open", "info-closed-after-leave", "info-open-focus", "info-closed-after-blur", "info-open-focus-inside"]) {
await loadDriverCapture(name);
if (name === "info-open-focus-inside") {
if (!client) throw new Error("Chrome DevTools client is missing");
const transitions = await client.evaluate<string>("document.querySelector('[data-context-info-transitions]')?.getAttribute('data-context-info-transitions') || ''");
expect(transitions.split(",")).not.toContain("closed");
}
}
}, 30_000);
});
+12 -2
View File
@@ -1,5 +1,6 @@
import { useState } from "react";
import { createRoot } from "react-dom/client";
import { ContextInfoButton } from "../../src/renderer/ui/ContextInfoButton";
import {
loadVisualCapture,
prepareVisualCapture,
@@ -23,6 +24,7 @@ function DriverTestApp({ updateAvailable }: { updateAvailable: boolean }) {
const [updateDialogOpen, setUpdateDialogOpen] = useState(updateAvailable);
const [updateTooltipOpen, setUpdateTooltipOpen] = useState(false);
const [infoOpen, setInfoOpen] = useState(false);
const [infoTransitions, setInfoTransitions] = useState<boolean[]>([]);
return (
<>
@@ -48,8 +50,16 @@ function DriverTestApp({ updateAvailable }: { updateAvailable: boolean }) {
<div role="row">Dokumentation Staffel 1</div>
</div>
<div data-visual-region="downloads-pagination">Seite 1 von 1</div>
<button type="button" onClick={() => setInfoOpen((open) => !open)}>Informationen</button>
{infoOpen && <section aria-label="Informationen zu Downloads">Drei Downloads sind sichtbar.</section>}
<ContextInfoButton
content={<><span>Drei Downloads sind sichtbar.</span><button type="button">Kontextaktion</button></>}
contextName="Downloads"
onOpenChange={(open) => {
setInfoTransitions((transitions) => [...transitions, open]);
setInfoOpen(open);
}}
open={infoOpen}
/>
<output data-context-info-transitions={infoTransitions.map((open) => open ? "open" : "closed").join(",")} />
</>
)}
{activeView === "collector" && (
+21 -2
View File
@@ -3,7 +3,7 @@ import { VISUAL_SCENARIOS, type VisualScenario } from "./fixtures";
export type MainViewId = "downloads" | "collector" | "settings" | "history" | "statistics";
export interface VisualInteraction {
type: "click" | "hover" | "fill" | "press" | "wait-visible" | "wait-absent";
type: "click" | "hover" | "leave" | "focus" | "blur" | "fill" | "press" | "wait-visible" | "wait-absent";
role?: string;
name?: string;
value?: string;
@@ -33,7 +33,7 @@ export interface VisualCapture {
}
const MAIN_VIEWS = ["downloads", "collector", "settings", "history", "statistics"] as const;
const INTERACTION_TYPES = ["click", "hover", "fill", "press", "wait-visible", "wait-absent"] as const;
const INTERACTION_TYPES = ["click", "hover", "leave", "focus", "blur", "fill", "press", "wait-visible", "wait-absent"] as const;
const ASSERTION_TYPES = ["active-view", "visible", "absent", "nonempty", "minimum-row-count", "layer-above"] as const;
const REGION_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
const VIEW_NAMES: Record<MainViewId, string> = {
@@ -366,6 +366,19 @@ function hoverElement(targetDocument: Document, element: Element): void {
dispatch(element, createEvent(targetDocument, "mouseenter", "mouse"));
}
function leaveElement(targetDocument: Document, element: Element): void {
dispatch(element, createEvent(targetDocument, "pointerout", "pointer"));
dispatch(element, createEvent(targetDocument, "pointerleave", "pointer"));
dispatch(element, createEvent(targetDocument, "mouseout", "mouse"));
dispatch(element, createEvent(targetDocument, "mouseleave", "mouse"));
}
function blurElement(element: Element): void {
if ("blur" in element && typeof element.blur === "function") {
element.blur();
}
}
function setNativeValue(targetDocument: Document, element: Element, value: string): void {
const view = targetDocument.defaultView;
if (!view) {
@@ -447,6 +460,12 @@ async function runInteraction(interaction: VisualInteraction, targetDocument: Do
clickElement(targetDocument, element);
} else if (interaction.type === "hover") {
hoverElement(targetDocument, element);
} else if (interaction.type === "leave") {
leaveElement(targetDocument, element);
} else if (interaction.type === "focus") {
focusElement(element);
} else if (interaction.type === "blur") {
blurElement(element);
} else if (interaction.type === "fill") {
setNativeValue(targetDocument, element, interaction.value as string);
} else {