web: run history list, filter and sort (R1/R2)
Day-grouped run list with sticky day headers (Today / Yesterday / d MMM yyyy / Unknown date), a usage roll-up block, the app's row hierarchy and a bounded filter/sort menu — mirroring RunHistoryScreen.kt, ListFilter.kt and ListSort.kt. New pure helpers live in src/runs.js with focused unit tests; app.js keeps the wiring and sets server strings with textContent. R1 done, R2 partial: no per-row "needs you" mark exists in the Android app; its wording is deferred to R15 (separate attention surface).
This commit is contained in:
+170
-3
@@ -79,10 +79,177 @@ try {
|
||||
await page.waitForSelector(".detail h2");
|
||||
shots.push(await page.screenshot(`${out}/02-pipeline-detail.png`));
|
||||
|
||||
step("switching to Runs and opening a run detail");
|
||||
step("switching to Runs: day-grouped list + usage roll-up");
|
||||
await page.clickText("nav.tabs button.tab", "Runs");
|
||||
await page.waitForSelector(".list button.row", { timeout: 25000 });
|
||||
await page.click(".list button.row");
|
||||
await page.waitForSelector(".list.runs .day-header", { timeout: 25000 });
|
||||
await page.waitForSelector(".metrics .metric", { timeout: 25000 });
|
||||
const usageLabels = await page.evaluate(
|
||||
`[...document.querySelectorAll(".metrics .metric-label")].map((n) => n.textContent)`,
|
||||
);
|
||||
for (const label of ["Total", "Succeeded", "Failed", "Canceled", "Interrupted", "Active"]) {
|
||||
if (!usageLabels.includes(label)) throw new Error(`usage metric missing: ${label}`);
|
||||
}
|
||||
const dayHeaders = await page.evaluate(
|
||||
`[...document.querySelectorAll(".list.runs .day-header")].map((n) => n.textContent)`,
|
||||
);
|
||||
if (!dayHeaders.length) throw new Error("no day header rendered");
|
||||
if (!dayHeaders.includes("Today")) {
|
||||
throw new Error(`the list does not start with Today: ${dayHeaders.join(" | ")}`);
|
||||
}
|
||||
const fullDateHeader = dayHeaders.find((label) => /^\d{1,2} \w{3} \d{4}$/.test(label));
|
||||
if (!fullDateHeader) throw new Error(`no full-date day header: ${dayHeaders.join(" | ")}`);
|
||||
shots.push(await page.screenshot(`${out}/04-runs-day-groups.png`));
|
||||
console.log(` usage: ${usageLabels.join(", ")}`);
|
||||
console.log(` day headers: ${dayHeaders.slice(0, 3).join(" | ")}`);
|
||||
|
||||
step(`scrolling the list to the older day group (${fullDateHeader})`);
|
||||
const scrolledTo = await page.evaluate(`(() => {
|
||||
const scroll = document.querySelector(".run-scroll");
|
||||
const header = [...document.querySelectorAll(".list.runs .day-header")]
|
||||
.find((n) => /^\\d{1,2} \\w{3} \\d{4}$/.test(n.textContent));
|
||||
if (!scroll || !header) return null;
|
||||
scroll.scrollTop += header.getBoundingClientRect().top - scroll.getBoundingClientRect().top;
|
||||
return header.textContent;
|
||||
})()`);
|
||||
if (!scrolledTo) throw new Error("could not scroll to the older day group");
|
||||
shots.push(await page.screenshot(`${out}/07-runs-older-day-group.png`));
|
||||
console.log(` scrolled to: ${scrolledTo}`);
|
||||
|
||||
step("opening the filter menu: it must stay in the viewport and be reachable");
|
||||
await page.click("#runFilterBtn");
|
||||
await page.waitForSelector("#runFilterMenu");
|
||||
const menuLabels = await page.evaluate(
|
||||
`[...document.querySelectorAll("#runFilterMenu .filter-check span")].map((n) => n.textContent)`,
|
||||
);
|
||||
for (const label of [
|
||||
"queued",
|
||||
"running",
|
||||
"waiting",
|
||||
"succeeded",
|
||||
"failed",
|
||||
"canceled",
|
||||
"interrupted",
|
||||
"Any pipeline",
|
||||
"Any time",
|
||||
"Today",
|
||||
"Last 7 days",
|
||||
"Last 30 days",
|
||||
]) {
|
||||
if (!menuLabels.includes(label)) throw new Error(`filter menu missing: ${label}`);
|
||||
}
|
||||
const menuActions = await page.evaluate(
|
||||
`[...document.querySelectorAll("#runFilterMenu .menu-actions button")].map((n) => n.textContent)`,
|
||||
);
|
||||
for (const label of ["Clear filters", "Done"]) {
|
||||
if (!menuActions.includes(label)) throw new Error(`filter menu action missing: ${label}`);
|
||||
}
|
||||
// The gate is reachability, not DOM presence: with a busy history the menu is
|
||||
// taller than the viewport, so it must be bounded and scroll its own box rather
|
||||
// than being clipped by an ancestor with no way for a user to reach the actions.
|
||||
const reach = await page.evaluate(`(() => {
|
||||
const menu = document.querySelector("#runFilterMenu");
|
||||
const overflowY = getComputedStyle(menu).overflowY;
|
||||
const rect = menu.getBoundingClientRect();
|
||||
menu.scrollTop = menu.scrollHeight;
|
||||
const actions = menu.querySelector(".menu-actions").getBoundingClientRect();
|
||||
return {
|
||||
overflowY,
|
||||
height: Math.round(rect.height),
|
||||
viewport: window.innerHeight,
|
||||
fitsViewport: rect.height <= window.innerHeight && rect.bottom <= window.innerHeight + 1,
|
||||
actionsReachable: actions.bottom <= window.innerHeight + 1 && actions.top >= -1,
|
||||
};
|
||||
})()`);
|
||||
if (reach.overflowY !== "auto" && reach.overflowY !== "scroll") {
|
||||
throw new Error(`the filter menu does not scroll its own box: overflow-y=${reach.overflowY}`);
|
||||
}
|
||||
if (!reach.fitsViewport) {
|
||||
throw new Error(`the filter menu overflows the viewport: ${JSON.stringify(reach)}`);
|
||||
}
|
||||
if (!reach.actionsReachable) {
|
||||
throw new Error(`the filter menu actions are unreachable: ${JSON.stringify(reach)}`);
|
||||
}
|
||||
shots.push(await page.screenshot(`${out}/08-runs-filter-menu.png`));
|
||||
console.log(` filter menu ${reach.height}px tall in a ${reach.viewport}px viewport; actions reachable`);
|
||||
|
||||
step("applying a status filter");
|
||||
await page.evaluate(
|
||||
`document.querySelector('#runFilterMenu input[data-status="failed"]').click()`,
|
||||
);
|
||||
const filterLabel = await page.evaluate(`document.querySelector("#runFilterBtn").textContent`);
|
||||
if (!filterLabel.includes("(1)")) {
|
||||
throw new Error(`filter control is missing the active count: ${filterLabel}`);
|
||||
}
|
||||
await page.click("#runFilterBtn"); // close the menu so the list is unobstructed
|
||||
const filteredChips = await page.evaluate(
|
||||
`[...document.querySelectorAll(".list.runs .run-row .run-row-head .chip")].map((n) => n.textContent)`,
|
||||
);
|
||||
if (!filteredChips.length) throw new Error("the status filter produced no rows");
|
||||
if (!filteredChips.every((chip) => chip === "failed")) {
|
||||
throw new Error(`filtered rows are not all failed: ${filteredChips.join(",")}`);
|
||||
}
|
||||
shots.push(await page.screenshot(`${out}/05-runs-filtered.png`));
|
||||
console.log(` filtered rows: ${filteredChips.length}, all failed`);
|
||||
|
||||
step("filtering to a state with no runs: the filtered-empty state + Clear filters");
|
||||
await page.click("#runFilterBtn");
|
||||
await page.waitForSelector("#runFilterMenu");
|
||||
await page.evaluate(
|
||||
`document.querySelector('#runFilterMenu input[data-status="failed"]').click()`,
|
||||
);
|
||||
await page.evaluate(
|
||||
`document.querySelector('#runFilterMenu input[data-status="interrupted"]').click()`,
|
||||
);
|
||||
await page.click("#runFilterBtn"); // close the menu to see the list
|
||||
await page.waitForSelector(".list.runs .empty-state");
|
||||
const emptyMessage = await page.evaluate(
|
||||
`document.querySelector(".list.runs .empty-state span")?.textContent ?? ""`,
|
||||
);
|
||||
if (emptyMessage !== "No runs match the current filters.") {
|
||||
throw new Error(`unexpected filtered-empty message: ${emptyMessage}`);
|
||||
}
|
||||
const clearAction = await page.evaluate(
|
||||
`document.querySelector(".list.runs .empty-state button")?.textContent ?? null`,
|
||||
);
|
||||
if (clearAction !== "Clear filters") {
|
||||
throw new Error(`the filtered-empty state should offer Clear filters, got: ${clearAction}`);
|
||||
}
|
||||
shots.push(await page.screenshot(`${out}/09-runs-filtered-empty.png`));
|
||||
console.log(` empty state: ${emptyMessage} (+ ${clearAction})`);
|
||||
|
||||
step("clearing the filters from the empty state and changing the sort");
|
||||
await page.click(".list.runs .empty-state button");
|
||||
await page.waitForSelector(".list.runs .day-header", { timeout: 25000 });
|
||||
const resetLabel = await page.evaluate(`document.querySelector("#runFilterBtn").textContent`);
|
||||
if (resetLabel.includes("(")) throw new Error(`Clear filters did not reset the count: ${resetLabel}`);
|
||||
await page.click("#runSortBtn");
|
||||
await page.waitForSelector("#runSortMenu");
|
||||
const sortItems = await page.evaluate(
|
||||
`[...document.querySelectorAll("#runSortMenu .menu-item")].map((n) => n.textContent)`,
|
||||
);
|
||||
for (const label of [
|
||||
"Newest first",
|
||||
"Oldest first",
|
||||
"Longest duration",
|
||||
"Shortest duration",
|
||||
"Pipeline name",
|
||||
"Status",
|
||||
"Reset",
|
||||
]) {
|
||||
if (!sortItems.includes(label)) throw new Error(`sort menu missing: ${label}`);
|
||||
}
|
||||
shots.push(await page.screenshot(`${out}/10-runs-sort-menu.png`));
|
||||
await page.clickText("#runSortMenu .menu-item", "Pipeline name");
|
||||
const sortLabel = await page.evaluate(`document.querySelector("#runSortBtn").textContent`);
|
||||
if (!sortLabel.includes("Pipeline name")) {
|
||||
throw new Error(`the sort control did not change: ${sortLabel}`);
|
||||
}
|
||||
await page.waitForSelector(".list.runs .run-row", { timeout: 25000 });
|
||||
shots.push(await page.screenshot(`${out}/06-runs-sorted.png`));
|
||||
console.log(` sort control now: ${sortLabel}`);
|
||||
|
||||
step("opening a run detail");
|
||||
await page.click(".list.runs .run-row");
|
||||
await page.waitForSelector(".detail h2", { timeout: 25000 });
|
||||
shots.push(await page.screenshot(`${out}/03-run-detail.png`));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user