web: add omni-search results and routing (S1/S2)
This commit is contained in:
@@ -98,6 +98,74 @@ async function openRunDetail(runId) {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Omni-search (S1/S2) ---------------------------------------------------
|
||||
// The page's own search UI drives every one of the helpers below; nothing is
|
||||
// stubbed. `searchTargets` opens the panel (if it is not already open), types the
|
||||
// query, applies the kind filter and returns the `data-target` of every row of
|
||||
// that kind once one has rendered.
|
||||
|
||||
async function searchTargets(query, kind) {
|
||||
await ensureConnected();
|
||||
if (!(await page.evaluate(`!!document.querySelector("#searchInput")`))) {
|
||||
await page.click("#searchToggle");
|
||||
await page.waitForSelector("#searchInput", { timeout: 15000 });
|
||||
}
|
||||
await page.fill("#searchInput", query);
|
||||
await page.evaluate(`(() => {
|
||||
const select = document.querySelector("#searchKind");
|
||||
select.value = ${JSON.stringify(kind)};
|
||||
select.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
})()`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`[...document.querySelectorAll("#searchResults .search-row")].some((r) => r.dataset.kind === ${JSON.stringify(kind)})`,
|
||||
),
|
||||
{ timeout: 25000, what: `a ${kind} search result` },
|
||||
);
|
||||
return page.evaluate(
|
||||
`[...document.querySelectorAll("#searchResults .search-row")]
|
||||
.filter((r) => r.dataset.kind === ${JSON.stringify(kind)})
|
||||
.map((r) => r.dataset.target ?? "")`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click one search row by its exact data-target; routing closes the panel. The
|
||||
* lookup and the click happen in one evaluate so a reply landing between them
|
||||
* cannot replace the row first. This drives the row's own click handler, exactly
|
||||
* as a mouse click would.
|
||||
*/
|
||||
async function clickSearchTarget(target) {
|
||||
return page.evaluate(`(() => {
|
||||
const row = [...document.querySelectorAll("#searchResults .search-row")]
|
||||
.find((r) => (r.dataset.target ?? "") === ${JSON.stringify(target)});
|
||||
if (!row) return false;
|
||||
row.click();
|
||||
return true;
|
||||
})()`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Route candidate rows of `kind` until the expected destination renders (routing
|
||||
* always closes the panel, so each attempt reopens and re-queries). Live data can
|
||||
* change between runs, so up to `attempts` rows are tried before giving up;
|
||||
* returns the target that landed or null.
|
||||
*/
|
||||
async function routeSearchKind(query, kind, landed, attempts = 4) {
|
||||
const targets = await searchTargets(query, kind);
|
||||
for (const target of targets.slice(0, attempts)) {
|
||||
await searchTargets(query, kind);
|
||||
if (!(await clickSearchTarget(target))) continue;
|
||||
if (await landed()) return target;
|
||||
await page.evaluate(`document.querySelector(".stage-pane-back")?.click()`);
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
|
||||
timeout: 5000,
|
||||
}).catch(() => {});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// The mounted graph's current transform, read back so the pan/zoom clamp checks
|
||||
// assert the real rendered state rather than a claim.
|
||||
const graphState = () =>
|
||||
@@ -1325,6 +1393,322 @@ try {
|
||||
shots.push(await page.screenshot(`${out}/34-run-${pendingRunId}-changes-pending.png`));
|
||||
}
|
||||
|
||||
// S1/S2: omni-search over the real server. The panel is opened from the top
|
||||
// bar; the query is typed through the page's own field, the flat result list
|
||||
// and its controls are asserted, a kind filter is applied and captured, and one
|
||||
// result of each kind is routed to its real destination. Every capture below is
|
||||
// a real screenshot of the rendered page.
|
||||
step("opening omni-search from the top bar (S1)");
|
||||
await ensureConnected();
|
||||
await page.clickText("nav.tabs button.tab", "Runs");
|
||||
await page.waitForSelector(".list.runs .run-row", { timeout: 25000 });
|
||||
const viewSnapshot = () =>
|
||||
page.evaluate(`(() => ({
|
||||
tab: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "",
|
||||
detail: document.querySelector("#content .detail h2")?.textContent ?? "",
|
||||
}))()`);
|
||||
const beforeOpen = await viewSnapshot();
|
||||
await page.click("#searchToggle");
|
||||
await page.waitForSelector("#searchInput", { timeout: 15000 });
|
||||
const chrome = await page.evaluate(`(() => {
|
||||
const input = document.querySelector("#searchInput");
|
||||
return {
|
||||
placeholder: input?.getAttribute("placeholder") ?? "",
|
||||
autofocused: document.activeElement === input,
|
||||
close: document.querySelector("#searchClose")?.textContent ?? "",
|
||||
};
|
||||
})()`);
|
||||
if (chrome.placeholder !== "Search pipelines, runs and artifacts") {
|
||||
throw new Error(`search placeholder is wrong: ${chrome.placeholder}`);
|
||||
}
|
||||
if (!chrome.autofocused) throw new Error("the search field was not autofocused on open");
|
||||
if (chrome.close !== "Close search") throw new Error(`the close control is wrong: ${chrome.close}`);
|
||||
const afterOpen = await viewSnapshot();
|
||||
if (afterOpen.tab !== beforeOpen.tab || afterOpen.detail !== beforeOpen.detail) {
|
||||
throw new Error(`opening search changed the view: ${JSON.stringify({ beforeOpen, afterOpen })}`);
|
||||
}
|
||||
console.log(
|
||||
` field autofocused, placeholder "${chrome.placeholder}", "${chrome.close}" present; view stayed ${afterOpen.tab}`,
|
||||
);
|
||||
|
||||
const SEARCH_QUERY = "plan";
|
||||
step(`running a real query ("${SEARCH_QUERY}") and capturing the flat result list (S1)`);
|
||||
await page.fill("#searchInput", SEARCH_QUERY);
|
||||
await page.waitForSelector("#searchResults .search-row", { timeout: 25000 });
|
||||
const list = await page.evaluate(`(() => ({
|
||||
kinds: [...document.querySelectorAll("#searchKind option")].map((o) => o.textContent),
|
||||
sorts: [...document.querySelectorAll("#searchSort option")].map((o) => o.textContent),
|
||||
kindValue: document.querySelector("#searchKind")?.value ?? "",
|
||||
sortValue: document.querySelector("#searchSort")?.value ?? "",
|
||||
summary: document.querySelector("#searchSummary")?.textContent ?? "",
|
||||
clear: document.querySelector("#searchClearFilter")?.textContent ?? "",
|
||||
rows: document.querySelectorAll("#searchResults .search-row").length,
|
||||
headers: document.querySelectorAll("#searchResults h1, #searchResults h2, #searchResults h3").length,
|
||||
kindsPresent: [...new Set([...document.querySelectorAll("#searchResults .search-row")].map((r) => r.dataset.kind))],
|
||||
matchedSpans: document.querySelectorAll("#searchResults .search-match").length,
|
||||
}))()`);
|
||||
if (
|
||||
JSON.stringify(list.kinds) !==
|
||||
JSON.stringify(["All kinds", "Pipelines", "Runs", "Steps", "Fields", "Artifacts", "Versions"])
|
||||
) {
|
||||
throw new Error(`kind options are wrong: ${list.kinds.join(",")}`);
|
||||
}
|
||||
if (JSON.stringify(list.sorts) !== JSON.stringify(["Relevance", "Newest first", "Name"])) {
|
||||
throw new Error(`sort options are wrong: ${list.sorts.join(",")}`);
|
||||
}
|
||||
if (list.kindValue !== "" || list.sortValue !== "relevance") {
|
||||
throw new Error(`the default controls are wrong: kind=${list.kindValue} sort=${list.sortValue}`);
|
||||
}
|
||||
if (list.summary !== "All kinds · Relevance") throw new Error(`the summary line is wrong: ${list.summary}`);
|
||||
if (list.clear !== "Clear filter") throw new Error(`the reset control is wrong: ${list.clear}`);
|
||||
if (!list.rows) throw new Error("the query rendered no result rows");
|
||||
if (list.headers !== 0) throw new Error("the result list carries grouping headers, not a flat list");
|
||||
if (list.kindsPresent.length < 2) {
|
||||
throw new Error(`the query returned only ${list.kindsPresent.join(",")}, expected a mixed list`);
|
||||
}
|
||||
console.log(
|
||||
` ${list.rows} flat rows across ${list.kindsPresent.join(",")}; summary "${list.summary}"; ` +
|
||||
`${list.matchedSpans} emphasised snippet span(s)`,
|
||||
);
|
||||
await page.rect("#searchPanel");
|
||||
await shot("01-search-results.png");
|
||||
|
||||
step("applying a kind filter and capturing it (S1)");
|
||||
await page.evaluate(`(() => {
|
||||
const select = document.querySelector("#searchKind");
|
||||
select.value = "pipeline";
|
||||
select.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
})()`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(`(() => {
|
||||
const rows = [...document.querySelectorAll("#searchResults .search-row")];
|
||||
return rows.length > 0 && rows.every((r) => r.dataset.kind === "pipeline");
|
||||
})()`),
|
||||
{ timeout: 25000, what: "the kind filter to narrow the list to pipelines" },
|
||||
);
|
||||
const filteredSummary = await text("#searchSummary");
|
||||
if (filteredSummary !== "Pipelines · Relevance") {
|
||||
throw new Error(`the filtered summary is wrong: ${filteredSummary}`);
|
||||
}
|
||||
const filteredRows = await page.evaluate(`document.querySelectorAll("#searchResults .search-row").length`);
|
||||
console.log(` Pipelines filter: ${filteredRows} row(s), summary "${filteredSummary}"`);
|
||||
await page.rect("#searchPanel");
|
||||
await shot("02-search-kind-filter.png");
|
||||
|
||||
step("Clear filter returns the kind to All kinds");
|
||||
await page.click("#searchClearFilter");
|
||||
await eventually(async () => (await text("#searchSummary")) === "All kinds · Relevance", {
|
||||
timeout: 15000,
|
||||
what: "Clear filter to reset the kind",
|
||||
});
|
||||
console.log(' Clear filter reset the kind to "All kinds"');
|
||||
|
||||
step("a Fields filter emphasises the matched snippet in the page, never as markup (S1)");
|
||||
await page.evaluate(`(() => {
|
||||
const select = document.querySelector("#searchKind");
|
||||
select.value = "field";
|
||||
select.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
})()`);
|
||||
await eventually(
|
||||
() => page.evaluate(`!!document.querySelector("#searchResults .search-row .search-match")`),
|
||||
{ timeout: 25000, what: "an emphasised snippet span" },
|
||||
);
|
||||
const emphasis = await page.evaluate(`(() => {
|
||||
const node = document.querySelector("#searchResults .search-row .search-match");
|
||||
return {
|
||||
tag: node?.tagName ?? "",
|
||||
inner: node?.firstElementChild?.tagName ?? "",
|
||||
text: node?.textContent ?? "",
|
||||
kind: node?.closest(".search-row")?.dataset.kind ?? "",
|
||||
};
|
||||
})()`);
|
||||
if (emphasis.tag !== "STRONG" || emphasis.inner !== "U") {
|
||||
throw new Error(`the matched span is not <strong><u>: ${JSON.stringify(emphasis)}`);
|
||||
}
|
||||
if (!emphasis.text) throw new Error("the emphasised span carries no text");
|
||||
if (emphasis.kind !== "field") throw new Error(`the emphasis is not on a field hit: ${emphasis.kind}`);
|
||||
console.log(` matched snippet emphasised as <${emphasis.tag}><${emphasis.inner}>: "${emphasis.text}"`);
|
||||
// Back to every kind for the routing steps.
|
||||
await page.evaluate(`(() => {
|
||||
const select = document.querySelector("#searchKind");
|
||||
select.value = "";
|
||||
select.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
})()`);
|
||||
await eventually(() => page.evaluate(`!!document.querySelector("#searchResults .search-row")`), {
|
||||
timeout: 25000,
|
||||
what: "the unfiltered list",
|
||||
});
|
||||
|
||||
step("routing a pipeline hit to its detail (S2)");
|
||||
const pipelineTarget = await routeSearchKind(SEARCH_QUERY, "pipeline", async () => {
|
||||
await page.waitForSelector("#content .detail h2", { timeout: 25000 });
|
||||
await page.waitForSelector("#content .detail .monospace", { timeout: 25000 });
|
||||
return true;
|
||||
});
|
||||
if (!pipelineTarget) throw new Error("no pipeline result routed to a pipeline detail");
|
||||
const pipelineView = await page.evaluate(`(() => ({
|
||||
active: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "",
|
||||
title: document.querySelector("#content .detail h2")?.textContent ?? "",
|
||||
searchOpen: !!document.querySelector("#searchInput"),
|
||||
}))()`);
|
||||
if (!pipelineView.active.startsWith("Pipelines")) {
|
||||
throw new Error(`a pipeline hit landed on ${pipelineView.active}`);
|
||||
}
|
||||
if (!pipelineView.title) throw new Error("the routed pipeline detail has no heading");
|
||||
if (pipelineView.searchOpen) throw new Error("selecting a result did not close the search panel");
|
||||
console.log(` ${pipelineTarget} -> Pipelines detail "${pipelineView.title}"`);
|
||||
await page.rect("#content .detail");
|
||||
await shot("03-search-route-pipeline.png");
|
||||
|
||||
step("routing a run hit to its detail (S2)");
|
||||
const runTarget = await routeSearchKind(SEARCH_QUERY, "run", async () => {
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(`(() => {
|
||||
const tab = document.querySelector("nav.tabs button.tab.active")?.textContent ?? "";
|
||||
return tab.startsWith("Runs") && !!document.querySelector("#content .detail .detail-tabs");
|
||||
})()`),
|
||||
{ timeout: 25000, what: "the routed run detail" },
|
||||
);
|
||||
return true;
|
||||
});
|
||||
if (!runTarget) throw new Error("no run result routed to a run detail");
|
||||
const runView = await page.evaluate(`(() => ({
|
||||
active: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "",
|
||||
title: document.querySelector("#content .detail h2")?.textContent ?? "",
|
||||
tabs: [...document.querySelectorAll("#content .detail .detail-tabs .detail-tab")].map((n) => n.textContent),
|
||||
}))()`);
|
||||
if (!runView.active.startsWith("Runs")) throw new Error(`a run hit landed on ${runView.active}`);
|
||||
if (!runView.tabs.includes("Summary")) throw new Error(`the routed run detail has no tabs: ${runView.tabs}`);
|
||||
console.log(` ${runTarget} -> Runs detail "${runView.title}" (${runView.tabs.join("/")})`);
|
||||
await page.rect("#content .detail");
|
||||
await shot("04-search-route-run.png");
|
||||
|
||||
step("routing a field hit to the run-detail tab holding the match (S2)");
|
||||
const fieldTargets = await searchTargets(SEARCH_QUERY, "field");
|
||||
let fieldRoute = null;
|
||||
for (const target of fieldTargets.slice(0, 4)) {
|
||||
// data-target is run:{id}:{sequence}:{matchedField}.
|
||||
const matchedField = target.split(":")[3] ?? "";
|
||||
const expectedTab = matchedField === "input" ? "Input" : matchedField === "output" ? "Output" : "Summary";
|
||||
await searchTargets(SEARCH_QUERY, "field");
|
||||
if (!(await clickSearchTarget(target))) continue;
|
||||
const landed = await eventually(
|
||||
() =>
|
||||
page.evaluate(`(() => {
|
||||
const tab = document.querySelector("nav.tabs button.tab.active")?.textContent ?? "";
|
||||
const active = document.querySelector("#content .detail .detail-tabs .detail-tab.active")?.textContent ?? "";
|
||||
return tab.startsWith("Runs") && active === ${JSON.stringify(expectedTab)};
|
||||
})()`),
|
||||
{ timeout: 25000, what: `the ${expectedTab} run-detail tab` },
|
||||
)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
if (landed) {
|
||||
fieldRoute = { target, matchedField, expectedTab };
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fieldRoute) throw new Error("no field result opened the run-detail tab holding its match");
|
||||
console.log(` ${fieldRoute.target} (matched_field ${fieldRoute.matchedField}) -> ${fieldRoute.expectedTab} tab`);
|
||||
await page.rect("#content .detail");
|
||||
await shot("05-search-route-field.png");
|
||||
|
||||
step("routing a step hit to the visit's stage pane (S2)");
|
||||
const stepTarget = await routeSearchKind(SEARCH_QUERY, "step", async () => {
|
||||
await eventually(() => page.evaluate(`!!document.querySelector(".stage-pane")`), {
|
||||
timeout: 20000,
|
||||
what: "the routed visit stage pane",
|
||||
});
|
||||
return true;
|
||||
});
|
||||
if (!stepTarget) throw new Error("no step result opened a visit stage pane");
|
||||
const stepPane = await page.evaluate(`(() => ({
|
||||
title: document.querySelector(".stage-pane-title")?.textContent ?? "",
|
||||
tab: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "",
|
||||
}))()`);
|
||||
if (!stepPane.title) throw new Error("the routed stage pane named no stage");
|
||||
if (!stepPane.tab.startsWith("Runs")) throw new Error(`the step route landed on ${stepPane.tab}`);
|
||||
console.log(` ${stepTarget} -> run stage pane "${stepPane.title}"`);
|
||||
await page.rect(".stage-pane-sheet");
|
||||
await shot("06-search-route-step.png");
|
||||
await page.click(".stage-pane-back");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
|
||||
timeout: 5000,
|
||||
what: "the step stage pane to close",
|
||||
});
|
||||
|
||||
step("routing an artifact hit to the same visit pane (S2)");
|
||||
const artifactTarget = await routeSearchKind(SEARCH_QUERY, "artifact", async () => {
|
||||
await eventually(() => page.evaluate(`!!document.querySelector(".stage-pane")`), {
|
||||
timeout: 20000,
|
||||
what: "the routed artifact visit pane",
|
||||
});
|
||||
return true;
|
||||
});
|
||||
if (artifactTarget) {
|
||||
const artifactPane = await page.evaluate(
|
||||
`document.querySelector(".stage-pane-title")?.textContent ?? ""`,
|
||||
);
|
||||
console.log(` ${artifactTarget} -> run stage pane "${artifactPane}"`);
|
||||
await page.rect(".stage-pane-sheet");
|
||||
await shot("07-search-route-artifact.png");
|
||||
await page.click(".stage-pane-back");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
|
||||
timeout: 5000,
|
||||
what: "the artifact stage pane to close",
|
||||
});
|
||||
} else {
|
||||
console.log(" -- no artifact hit routed to a visit pane; skipped the artifact capture");
|
||||
}
|
||||
|
||||
step("routing a version hit to its pipeline detail (S2)");
|
||||
const versionTarget = await routeSearchKind(SEARCH_QUERY, "version", async () => {
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(`(() => {
|
||||
const tab = document.querySelector("nav.tabs button.tab.active")?.textContent ?? "";
|
||||
return tab.startsWith("Pipelines") && !!document.querySelector("#content .detail h2");
|
||||
})()`),
|
||||
{ timeout: 25000, what: "the pipeline detail for the version" },
|
||||
);
|
||||
return true;
|
||||
});
|
||||
if (versionTarget) {
|
||||
const versionTitle = await text("#content .detail h2");
|
||||
console.log(` ${versionTarget} -> Pipelines detail "${versionTitle}"`);
|
||||
await page.rect("#content .detail");
|
||||
await shot("08-search-route-version.png");
|
||||
} else {
|
||||
console.log(" -- no version hit routed; skipped the version capture");
|
||||
}
|
||||
|
||||
step("Closing search clears the query and leaves the view intact (S1)");
|
||||
await searchTargets("release", "field");
|
||||
const beforeClose = await viewSnapshot();
|
||||
await page.click("#searchClose");
|
||||
await eventually(() => page.evaluate(`!document.querySelector("#searchInput")`), {
|
||||
timeout: 10000,
|
||||
what: "the search panel to close",
|
||||
});
|
||||
const afterClose = await viewSnapshot();
|
||||
if (afterClose.tab !== beforeClose.tab || afterClose.detail !== beforeClose.detail) {
|
||||
throw new Error(`closing search changed the view: ${JSON.stringify({ beforeClose, afterClose })}`);
|
||||
}
|
||||
await page.click("#searchToggle");
|
||||
await page.waitForSelector("#searchInput", { timeout: 15000 });
|
||||
const reopenedQuery = await page.evaluate(`document.querySelector("#searchInput")?.value ?? ""`);
|
||||
if (reopenedQuery !== "") throw new Error(`closing search did not clear the query: "${reopenedQuery}"`);
|
||||
await page.evaluate(
|
||||
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
|
||||
);
|
||||
await eventually(() => page.evaluate(`!document.querySelector("#searchInput")`), {
|
||||
timeout: 10000,
|
||||
what: "Escape to close the search",
|
||||
});
|
||||
console.log(" Close search cleared the query and kept the view; Escape also closed the field");
|
||||
|
||||
console.log("\nUI SMOKE PASS");
|
||||
for (const shot of shots) console.log(` ${shot}`);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user