Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Port the inline selection scroll E2E spec to the platform pages
rcourtmanb2d69b75694f
diff --git a/tests/integration/e2e-tiering.mjs b/tests/integration/e2e-tiering.mjsindex 0e5d4fd37e..64b49b9054 100644--- a/tests/integration/e2e-tiering.mjs+++ b/tests/integration/e2e-tiering.mjs@@ -9,7 +9,6 @@ export const QUARANTINED_SPECS = [// the default org. CI runs a multi-tenant environment, so delisting this// spec turns that open bug into a permanent red.'**/03-multi-tenant.spec.ts',- '**/47-inline-selection-scroll-stability.spec.ts',];/**@@ -50,6 +49,7 @@ export const PROBATION_SPECS = ['**/44-workloads-chart-spacing.spec.ts','**/45-workloads-memory-tail.spec.ts','**/46-storage-summary-continuity.spec.ts',+ '**/47-inline-selection-scroll-stability.spec.ts','**/49-demo-scenario-curation.spec.ts','**/50-storage-physical-disk-io-history.spec.ts','**/52-ai-settings-provider-setup.spec.ts',diff --git a/tests/integration/tests/47-inline-selection-scroll-stability.spec.ts b/tests/integration/tests/47-inline-selection-scroll-stability.spec.tsindex f019514398..d251d6a95f 100644--- a/tests/integration/tests/47-inline-selection-scroll-stability.spec.ts+++ b/tests/integration/tests/47-inline-selection-scroll-stability.spec.ts@@ -9,7 +9,6 @@ import {} from "@playwright/test";import {- apiRequest,createAuthenticatedStorageState,getMockMode,setMockMode,@@ -21,8 +20,32 @@ type WorkerFixtures = {authStorageStatePath: string;};-type ResourceSummary = {- name?: string;+type LayoutObserverOptions = {+ rowSelector: string;+ detailSelector: string;+ // Whether the row's inline detail must be showing (after opening) or gone+ // (after closing) before the layout can count as settled.+ detailOpen: boolean;+ // Opening near the bottom edge: a layout where the row has not risen more+ // than 150 px above this parked top is not a result yet.+ revealFrom?: number;+ // Closing: the row must never move more than 2 px from this top.+ holdRowAt?: number;+ // Draining only: movement after settling restarts settling, not a failure.+ restartOnMovement?: boolean;+};++type ObservedLayout = {+ rowTop: number | null;+ detailTop: number | null;+ viewportTop: number;+ viewportBottom: number;+ viewportHeight: number;+};++type LayoutObservation = {+ settled: ObservedLayout | null;+ violations: string[];};let mockModeWasEnabled: boolean | null = null;@@ -63,66 +86,6 @@ async function ensureMockModeEnabled(page: Page): Promise<void> {}}-async function fetchMockInfrastructureResourceName(- page: Page,-): Promise<string> {- const response = await apiRequest(- page,- "/api/resources?source=proxmox&limit=200&type=agent",- );- expect(response.ok()).toBeTruthy();- const payload = (await response.json()) as { data?: ResourceSummary[] };- const resources = Array.isArray(payload.data) ? payload.data : [];- const chosen = resources.find((resource) => resource.name?.trim());- if (!chosen?.name?.trim()) {- throw new Error(- "Expected at least one Proxmox mock infrastructure resource",- );- }- return chosen.name.trim();-}--async function scrollSectionIntoView(- page: Page,- locator: Locator,- offset = 180,-): Promise<number> {- const top = await locator.evaluate(- (element, sectionOffset) =>- (() => {- const shell = document.querySelector<HTMLElement>(".app-scroll-shell");- if (shell && shell.contains(element)) {- const shellRect = shell.getBoundingClientRect();- return Math.max(- 0,- shell.scrollTop +- element.getBoundingClientRect().top -- shellRect.top -- sectionOffset,- );- }- return Math.max(- 0,- window.scrollY + element.getBoundingClientRect().top - sectionOffset,- );- })(),- offset,- );- await page.evaluate((nextTop) => {- const shell = document.querySelector<HTMLElement>(".app-scroll-shell");- if (shell) {- shell.scrollTop = nextTop;- return;- }- window.scrollTo(0, nextTop);- }, top);- await page.waitForTimeout(150);- return page.evaluate(() => {- const shell = document.querySelector<HTMLElement>(".app-scroll-shell");- return shell ? shell.scrollTop : window.scrollY;- });-}-async function readPrimaryViewportScrollTop(page: Page): Promise<number> {return page.evaluate(() => {const shell = document.querySelector<HTMLElement>(".app-scroll-shell");@@ -170,77 +133,333 @@ async function positionElementNearViewportBottom(return locator.evaluate((element) => element.getBoundingClientRect().top);}-async function readPrimaryViewportBounds(+// Starts one in-page observer that samples the row, its inline detail and the+// scroll shell on every animation frame from before the action until a+// verdict. An element that is absent, renders no box or is not visible counts+// as missing. Positions compare with a 1 px tolerance against a fixed+// reference, so drift cannot accumulate. The layout settles once every frame+// in a 400 ms window agrees (a frame gap over 100 ms, a busy main thread,+// restarts the window). The settled layout must then hold for a further+// 1.2 s, which outlasts the longest the shared reveal keeps working on a+// focus change (summaryTableFocus.ts), ending with at least ten frames after+// the last gap.+//+// Reveal observers also catch a second scroll. The reveal is one smooth+// movement: once the row has moved 20 px or more and no sample has seen it+// move by over 1 px for 200 ms of wall time, that position is the rest+// position, and any later excursion beyond 8 px from it is a late jump, even+// one that lands inside the accepted band or returns. Close observers must not scroll at all, so a+// `scroll` event on the shell, which the browser delivers even for a move that+// is undone before the next frame, fails them as well. Every violation is+// latched and final, nothing is retried, and a timer enforces the 30 s+// deadline whether or not frames keep arriving.+//+// The model assumes ordinary frame cadence. Two things it cannot see: a jump+// that happens and is undone entirely inside one starved frame gap (about+// 150 ms or more), and a jump within about a quarter second of the reveal+// ending when a starved frame hid that ending, which reads as part of the+// reveal. The ten-frames-after-a-gap rule only stops starved stretches from+// counting towards a pass.+async function startLayoutObserver(page: Page,-): Promise<{ top: number; bottom: number; height: number }> {- return page.evaluate(() => {- const shell = document.querySelector<HTMLElement>(".app-scroll-shell");- if (shell) {- const rect = shell.getBoundingClientRect();+ options: LayoutObserverOptions,+): Promise<void> {+ await page.evaluate((observerOptions) => {+ type Layout = {+ rowTop: number | null;+ detailTop: number | null;+ viewportTop: number;+ viewportBottom: number;+ viewportHeight: number;+ };+ const visibleTop = (selector: string): number | null => {+ const element = document.querySelector<HTMLElement>(selector);+ if (!element) return null;+ const rect = element.getBoundingClientRect();+ const visible =+ rect.width > 0 &&+ rect.height > 0 &&+ getComputedStyle(element).visibility === "visible";+ return visible ? rect.top : null;+ };+ const read = (): Layout => {+ const shell = document.querySelector<HTMLElement>(".app-scroll-shell");+ const shellRect = shell?.getBoundingClientRect();return {- top: rect.top,- bottom: rect.bottom,- height: shell.clientHeight,+ rowTop: visibleTop(observerOptions.rowSelector),+ detailTop: visibleTop(observerOptions.detailSelector),+ viewportTop: shellRect ? shellRect.top : 0,+ viewportBottom: shellRect ? shellRect.bottom : window.innerHeight,+ viewportHeight: shell ? shell.clientHeight : window.innerHeight,};- }- return {- top: 0,- bottom: window.innerHeight,- height: window.innerHeight,};+ const near = (left: number | null, right: number | null) =>+ left === null || right === null+ ? left === right+ : Math.abs(left - right) <= 1;+ const same = (left: Layout, right: Layout) =>+ near(left.rowTop, right.rowTop) &&+ near(left.detailTop, right.detailTop) &&+ near(left.viewportTop, right.viewportTop) &&+ near(left.viewportHeight, right.viewportHeight);+ const isResult = (layout: Layout) =>+ layout.rowTop !== null &&+ (observerOptions.detailOpen+ ? layout.detailTop !== null+ : layout.detailTop === null) &&+ (observerOptions.revealFrom === undefined ||+ layout.rowTop < observerOptions.revealFrom - 150);++ const violations: string[] = [];+ let candidate: { layout: Layout; since: number } | null = null;+ let settled: Layout | null = null;+ let settledAt = 0;+ let framesSinceGap = 0;+ let lastLayout: Layout | null = null;+ // The row starts parked, so the first sample is measured against that.+ let previousRowTop: number | null = observerOptions.revealFrom ?? null;+ let scrollPhase: "before" | "moving" | "rested" = "before";+ let movedInPhase = 0;+ let lastMovementAt = performance.now();+ let restTop = 0;+ let finished = false;+ const startedAt = performance.now();+ let previousFrameAt = startedAt;+ // Frame statistics, reported when the observer runs out of time so that a starved+ // run can be told apart from a layout that really never held still.+ let frameCount = 0;+ let longGaps = 0;+ let maxGap = 0;+ const frameStats = () =>+ `frames=${frameCount} gapsOver100ms=${longGaps} maxGapMs=${Math.round(maxGap)}`;+ const scrollTarget: EventTarget =+ document.querySelector<HTMLElement>(".app-scroll-shell") ?? window;++ const done = new Promise<{ settled: Layout | null; violations: string[] }>(+ (resolve) => {+ const onScroll = () => {+ violations.push("the shell scrolled while the row was closing");+ finish();+ };+ const finish = () => {+ if (finished) return;+ finished = true;+ window.clearTimeout(deadlineTimer);+ scrollTarget.removeEventListener("scroll", onScroll);+ resolve({ settled, violations });+ };+ const deadlineTimer = window.setTimeout(() => {+ violations.push(+ settled+ ? `settled layout was not observed for the whole hold; ${frameStats()}`+ : `layout never settled; last ${JSON.stringify(lastLayout)}; ${frameStats()}`,+ );+ finish();+ }, 30_000);+ if (observerOptions.holdRowAt !== undefined) {+ scrollTarget.addEventListener("scroll", onScroll, { passive: true });+ }++ const step = (now: number) => {+ if (finished) return;+ const frameGap = now - previousFrameAt;+ previousFrameAt = now;+ frameCount += 1;+ if (frameGap > 100) longGaps += 1;+ maxGap = Math.max(maxGap, frameGap);+ const layout = read();+ lastLayout = layout;++ const holdRowAt = observerOptions.holdRowAt;+ if (+ holdRowAt !== undefined &&+ (layout.rowTop === null || Math.abs(layout.rowTop - holdRowAt) > 2)+ ) {+ violations.push(`row moved from ${holdRowAt} to ${layout.rowTop}`);+ finish();+ return;+ }++ if (observerOptions.revealFrom !== undefined) {+ if (scrollPhase === "rested") {+ if (+ layout.rowTop === null ||+ Math.abs(layout.rowTop - restTop) > 8+ ) {+ violations.push(+ `row moved after it had come to rest: ${restTop} -> ${layout.rowTop}`,+ );+ finish();+ return;+ }+ } else if (layout.rowTop !== null) {+ if (+ previousRowTop !== null &&+ Math.abs(layout.rowTop - previousRowTop) > 1+ ) {+ movedInPhase += Math.abs(layout.rowTop - previousRowTop);+ // The move happened somewhere since the previous sample; date+ // it to the start of that interval, so a long gap cannot push+ // the end of the reveal later than it really was.+ lastMovementAt = now - frameGap;+ if (movedInPhase >= 20) scrollPhase = "moving";+ } else if (now - lastMovementAt >= 200) {+ if (scrollPhase === "moving") {+ scrollPhase = "rested";+ restTop = layout.rowTop;+ } else {+ movedInPhase = 0;+ }+ }+ }+ if (layout.rowTop !== null) previousRowTop = layout.rowTop;+ }++ if (settled && !same(layout, settled)) {+ if (!observerOptions.restartOnMovement) {+ violations.push(+ `layout moved after settling: ${JSON.stringify(settled)} -> ${JSON.stringify(layout)}`,+ );+ finish();+ return;+ }+ settled = null;+ candidate = null;+ }++ if (settled) {+ framesSinceGap = frameGap > 100 ? 0 : framesSinceGap + 1;+ if (now - settledAt >= 1_200 && framesSinceGap >= 10) {+ finish();+ return;+ }+ } else if (+ !isResult(layout) ||+ frameGap > 100 ||+ !candidate ||+ !same(layout, candidate.layout)+ ) {+ candidate = isResult(layout) ? { layout, since: now } : null;+ } else if (now - candidate.since >= 400) {+ settled = candidate.layout;+ settledAt = now;+ framesSinceGap = 0;+ }+ requestAnimationFrame(step);+ };+ requestAnimationFrame(step);+ },+ );+ (+ window as unknown as { __pulseLayoutObserver?: Promise<unknown> }+ ).__pulseLayoutObserver = done;+ }, options);+}++async function finishLayoutObserver(page: Page): Promise<LayoutObservation> {+ return page.evaluate(async () => {+ const host = window as unknown as {+ __pulseLayoutObserver?: Promise<LayoutObservation>;+ };+ const observer = host.__pulseLayoutObserver;+ delete host.__pulseLayoutObserver;+ return observer+ ? await observer+ : { settled: null, violations: ["layout observer was not running"] };});}-async function startAppSuspenseFallbackProbe(page: Page): Promise<void> {+// Opening a row near the bottom edge must bring its inline detail into view+// by lifting the row to an anchor in the upper part of the scroll shell: not+// pinned to the top edge, not hard-centred, not left where it was. The+// observer only settles on a row that has risen at least 150 px from where it+// was parked, so "left where it was" already fails there.+function expectInlineDetailRevealedBelowTop(+ observation: LayoutObservation,+): number {+ expect(observation.violations).toEqual([]);+ const { rowTop, detailTop, viewportTop, viewportBottom, viewportHeight } =+ observation.settled!;+ expect(rowTop!).toBeGreaterThan(viewportTop + 96);+ expect(rowTop!).toBeLessThan(viewportTop + viewportHeight * 0.42);+ expect(detailTop!).toBeGreaterThan(rowTop!);+ expect(detailTop!).toBeLessThan(viewportBottom - 48);+ return rowTop!;+}++// Row expansion is local state: it must not touch the URL or the history at+// all. Record every same-document navigation the page starts from here on+// (pushState and replaceState included, whatever URL they write), so a write+// that is later undone, or that restores the same URL, still fails the test.+async function startUrlWriteProbe(page: Page): Promise<void> {await page.evaluate(() => {- const marker = "__pulseSuspenseFallbackProbe";- const existing = (window as Window & Record<string, unknown>)[marker] as- | { flashed: boolean; observer?: MutationObserver }- | undefined;- existing?.observer?.disconnect();- const state = { flashed: false, observer: undefined as MutationObserver | undefined };- const sample = () => {- if (document.body.textContent?.includes("Loading view...")) {- state.flashed = true;- }+ type NavigateEvent = Event & { destination: { url: string } };+ const host = window as unknown as {+ navigation?: EventTarget;+ __pulseInlineSelectionUrlWrites?: { writes: string[]; stop: () => void };+ };+ const navigation = host.navigation;+ if (!navigation) {+ throw new Error("Navigation API unavailable");+ }+ const writes: string[] = [];+ const record = (event: Event) => {+ writes.push((event as NavigateEvent).destination.url);+ };+ navigation.addEventListener("navigate", record);+ host.__pulseInlineSelectionUrlWrites = {+ writes,+ stop: () => navigation.removeEventListener("navigate", record),};- sample();- state.observer = new MutationObserver(sample);- state.observer.observe(document.body, { subtree: true, childList: true, characterData: true });- (window as Window & Record<string, unknown>)[marker] = state;});}-async function stopAppSuspenseFallbackProbe(page: Page): Promise<boolean> {+async function stopUrlWriteProbe(page: Page): Promise<string[]> {return page.evaluate(() => {- const marker = "__pulseSuspenseFallbackProbe";- const state = (window as Window & Record<string, unknown>)[marker] as- | { flashed: boolean; observer?: MutationObserver }- | undefined;- state?.observer?.disconnect();- delete (window as Window & Record<string, unknown>)[marker];- return Boolean(state?.flashed);+ const host = window as unknown as {+ __pulseInlineSelectionUrlWrites?: { writes: string[]; stop: () => void };+ };+ const probe = host.__pulseInlineSelectionUrlWrites;+ probe?.stop();+ delete host.__pulseInlineSelectionUrlWrites;+ return probe ? [...probe.writes] : ["URL write probe was not running"];});}-async function findLegacyScopedWorkloadRow(page: Page): Promise<Locator> {- const rows = page.locator("tr[data-guest-id]");- const rowCount = await rows.count();- for (let index = 0; index < rowCount; index += 1) {- const row = rows.nth(index);- if (!(await row.isVisible())) {- continue;- }- const guestId = ((await row.getAttribute("data-guest-id")) || "").trim();- if (- /^([^:]+):([^:]+):(\d+)$/.test(guestId) &&- !guestId.startsWith("app-container:") &&- !guestId.startsWith("pod:")- ) {- return row;+// Returns the first rendered row that starts below the first screen, so that+// parking it near the bottom edge needs a genuinely scrolled shell. The row is+// re-located by its own id because windowed tables re-render as they scroll,+// which would move a positional nth() match to a different row; ids that+// appear on more than one row are skipped so the selector names one row.+async function findRowBelowFirstScreen(+ rows: Locator,+ idAttribute: string,+): Promise<{ id: string; selector: string; row: Locator }> {+ const id = await rows.evaluateAll((elements, attribute) => {+ const shell = document.querySelector<HTMLElement>(".app-scroll-shell");+ const viewportTop = shell ? shell.getBoundingClientRect().top : 0;+ const scrollTop = shell ? shell.scrollTop : window.scrollY;+ const viewportHeight = shell ? shell.clientHeight : window.innerHeight;+ const idCounts = new Map<string, number>();+ for (const element of elements) {+ const value = element.getAttribute(attribute) ?? "";+ idCounts.set(value, (idCounts.get(value) ?? 0) + 1);}- }- throw new Error("Expected one visible legacy-scoped workload row");+ const match = elements.find((element) => {+ const rect = element.getBoundingClientRect();+ const value = element.getAttribute(attribute) ?? "";+ return (+ value !== "" &&+ idCounts.get(value) === 1 &&+ rect.height > 0 &&+ rect.top - viewportTop + scrollTop > viewportHeight+ );+ });+ return match?.getAttribute(attribute) ?? "";+ }, idAttribute);+ expect(id, "a row starts below the first screen").not.toBe("");+ const selector = `tr[${idAttribute}="${id}"]`;+ return { id, selector, row: rows.page().locator(selector) };}test.describe.serial("Inline selection scroll stability", () => {@@ -261,94 +480,7 @@ test.describe.serial("Inline selection scroll stability", () => {}});- test("reveals infrastructure inline detail without hard-centering the selected row", async ({- page,- }, testInfo) => {- test.skip(- testInfo.project.name.startsWith("mobile-"),- "Desktop-only drawer stability proof",- );-- await ensureMockModeEnabled(page);- const resourceName = await fetchMockInfrastructureResourceName(page);-- await page.goto("/infrastructure?source=proxmox-pve", {- waitUntil: "domcontentloaded",- });- await expect(page.getByTestId("infrastructure-page")).toBeVisible();-- const table = page- .locator('[data-testid="infrastructure-page"] table')- .first();- const beforeScroll = await scrollSectionIntoView(page, table);- expect(beforeScroll).toBeGreaterThan(10);-- const row = table- .locator("tbody tr")- .filter({ hasText: resourceName })- .first();- await expect(row).toBeVisible();- const beforeRowTop = await positionElementNearViewportBottom(page, row);- expect(beforeRowTop).toBeGreaterThan(500);- await startAppSuspenseFallbackProbe(page);- await row.click();-- await expect(page).toHaveURL(- /\/infrastructure\?source=proxmox-pve&resource=/,- );- const detailRow = row.locator("xpath=following-sibling::tr[1]");- await expect(- page.getByRole("button", { name: /show access|hide access/i }),- ).toBeVisible();- await expect(detailRow).toBeVisible();- await page.waitForTimeout(350);-- const viewportBounds = await readPrimaryViewportBounds(page);- const afterRowTop = await row.evaluate((element) => element.getBoundingClientRect().top);- const detailTop = await detailRow.evaluate((element) => element.getBoundingClientRect().top);-- expect(afterRowTop).toBeLessThan(beforeRowTop - 150);- expect(afterRowTop).toBeLessThan(viewportBounds.top + viewportBounds.height * 0.42);- expect(detailTop).toBeLessThan(viewportBounds.bottom - 48);- expect(await stopAppSuspenseFallbackProbe(page)).toBe(false);- });-- test("keeps the recovery viewport stable when selecting a protected item", async ({- page,- }, testInfo) => {- test.skip(- testInfo.project.name.startsWith("mobile-"),- "Desktop-only recovery interaction proof",- );-- await ensureMockModeEnabled(page);-- await page.goto("/recovery", { waitUntil: "domcontentloaded" });- await expect(page.getByTestId("recovery-page")).toBeVisible();-- const protectedItemsTable = page- .locator('[data-testid="recovery-page"] table')- .first();- const beforeScroll = await scrollSectionIntoView(page, protectedItemsTable);- expect(beforeScroll).toBeGreaterThan(10);-- const row = protectedItemsTable.locator("tbody tr").first();- await expect(row).toBeVisible();- await row.click();-- await expect(page).toHaveURL(/\/recovery\?rollupId=/);- await expect(- page.getByRole("tab", { name: /recovery events/i }),- ).toHaveAttribute("aria-selected", "true");- await expect(- page.getByTestId("recovery-history-item-filter-trigger"),- ).not.toContainText("Any Item");-- const afterScroll = await readPrimaryViewportScrollTop(page);- expect(afterScroll).toBeGreaterThanOrEqual(Math.max(10, beforeScroll - 60));- });-- test("keeps workload inline detail visible without hard-centering the selected row", async ({+ test("reveals workload inline detail without hard-centering the selected row", async ({page,}, testInfo) => {test.skip(@@ -358,46 +490,50 @@ test.describe.serial("Inline selection scroll stability", () => {await ensureMockModeEnabled(page);- await page.goto("/workloads", { waitUntil: "domcontentloaded" });- await expect(page.locator("tr[data-guest-id]").first()).toBeVisible();+ await page.goto("/proxmox/overview", { waitUntil: "domcontentloaded" });+ const rows = page.locator("tr[data-guest-id]");+ await expect(rows.first()).toBeVisible({ timeout: 60_000 });- const row = await findLegacyScopedWorkloadRow(page);- const beforeScroll = await scrollSectionIntoView(page, row);- expect(beforeScroll).toBeGreaterThan(10);+ const {+ id: workloadId,+ selector: rowSelector,+ row,+ } = await findRowBelowFirstScreen(rows, "data-guest-id");const beforeRowTop = await positionElementNearViewportBottom(page, row);+ expect(await readPrimaryViewportScrollTop(page)).toBeGreaterThan(10);expect(beforeRowTop).toBeGreaterThan(500);- const workloadId = (await row.getAttribute("data-guest-id")) ?? "";- expect(workloadId).not.toBe("");-+ const detailSelector = `[data-inline-detail-for="${workloadId}"]`;+ const detailRow = page.locator(detailSelector);+ await startUrlWriteProbe(page);+ await startLayoutObserver(page, {+ rowSelector,+ detailSelector,+ detailOpen: true,+ revealFrom: beforeRowTop,+ });await row.click();- await expect(page).toHaveURL(/\/workloads\?(?:.*&)?resource=/);- {- const openedUrl = new URL(page.url());- expect(openedUrl.searchParams.get("resource")).toBe(workloadId);- expect(openedUrl.searchParams.has("agent")).toBe(false);- }- const detailRow = row.locator("xpath=following-sibling::tr[1]");- await expect(detailRow).toContainText(- "Overview",+ await expect(detailRow).toBeVisible();+ await expect(row.locator("button[aria-controls]").first()).toHaveAttribute(+ "aria-expanded",+ "true",+ );+ const openRowTop = expectInlineDetailRevealedBelowTop(+ await finishLayoutObserver(page),);- await page.waitForTimeout(350);-- const viewportBounds = await readPrimaryViewportBounds(page);- const afterRowTop = await row.evaluate((element) => element.getBoundingClientRect().top);- const detailTop = await detailRow.evaluate((element) => element.getBoundingClientRect().top);-- expect(afterRowTop).toBeGreaterThan(viewportBounds.top + 96);- expect(detailTop).toBeLessThan(viewportBounds.bottom - 48);+ // Collapsing holds the row where the operator left it.+ await startLayoutObserver(page, {+ rowSelector,+ detailSelector,+ detailOpen: false,+ holdRowAt: openRowTop,+ });await row.click();- await expect.poll(() => page.url()).not.toContain("resource=");- {- const closedUrl = new URL(page.url());- expect(closedUrl.searchParams.has("resource")).toBe(false);- expect(closedUrl.searchParams.has("agent")).toBe(false);- }+ await expect(detailRow).toHaveCount(0);+ expect((await finishLayoutObserver(page)).violations).toEqual([]);+ expect(await stopUrlWriteProbe(page)).toEqual([]);});test("supports keyboard open-close for workload rows without leaking filter state", async ({@@ -410,36 +546,54 @@ test.describe.serial("Inline selection scroll stability", () => {await ensureMockModeEnabled(page);- await page.goto("/workloads", { waitUntil: "domcontentloaded" });- const row = page.locator("tr[data-guest-id]").first();- await expect(row).toBeVisible();- const workloadId = (await row.getAttribute("data-guest-id")) ?? "";+ await page.goto("/proxmox/overview", { waitUntil: "domcontentloaded" });+ const firstRow = page.locator("tr[data-guest-id]").first();+ await expect(firstRow).toBeVisible({ timeout: 60_000 });+ const workloadId = (await firstRow.getAttribute("data-guest-id")) ?? "";expect(workloadId).not.toBe("");+ // Pin the row by id: the reveal scrolls, and windowing can re-render.+ const rowSelector = `tr[data-guest-id="${workloadId}"]`;+ const row = page.locator(rowSelector);+ const detailSelector = `[data-inline-detail-for="${workloadId}"]`;+ const detailRow = page.locator(detailSelector);const toggleButton = row.locator("button[aria-controls]").first();await expect(toggleButton).toBeVisible();+ const controlsId = (await toggleButton.getAttribute("aria-controls")) ?? "";+ expect(controlsId).not.toBe("");++ await startUrlWriteProbe(page);await toggleButton.focus();await expect(toggleButton).toBeFocused();+ // This test owns keyboard toggling, not the reveal geometry, so the open+ // observer only waits for the layout to settle.+ await startLayoutObserver(page, {+ rowSelector,+ detailSelector,+ detailOpen: true,+ restartOnMovement: true,+ });await page.keyboard.press("Enter");- await expect(page).toHaveURL(/\/workloads\?(?:.*&)?resource=/);- {- const openedUrl = new URL(page.url());- expect(openedUrl.searchParams.get("resource")).toBe(workloadId);- expect(openedUrl.searchParams.has("agent")).toBe(false);- }-- const detailRow = row.locator("xpath=following-sibling::tr[1]");- await expect(detailRow).toContainText("Overview");+ await expect(toggleButton).toHaveAttribute("aria-expanded", "true");+ await expect(detailRow).toBeVisible();+ await expect(detailRow.locator(`[id="${controlsId}"]`)).toHaveCount(1);+ const opened = await finishLayoutObserver(page);+ expect(opened.violations).toEqual([]);+ // Collapsing from the keyboard holds the row in place too.await toggleButton.focus();+ await startLayoutObserver(page, {+ rowSelector,+ detailSelector,+ detailOpen: false,+ holdRowAt: opened.settled!.rowTop!,+ });await toggleButton.press("Space");- await expect.poll(() => page.url()).not.toContain("resource=");- {- const closedUrl = new URL(page.url());- expect(closedUrl.searchParams.has("resource")).toBe(false);- expect(closedUrl.searchParams.has("agent")).toBe(false);- }+ await expect(toggleButton).toHaveAttribute("aria-expanded", "false");+ await expect(detailRow).toHaveCount(0);+ expect((await finishLayoutObserver(page)).violations).toEqual([]);+ expect(await stopUrlWriteProbe(page)).toEqual([]);});test("reveals storage inline detail without hard-centering the selected row", async ({@@ -452,27 +606,35 @@ test.describe.serial("Inline selection scroll stability", () => {await ensureMockModeEnabled(page);- await page.goto("/storage", { waitUntil: "domcontentloaded" });- const row = page.locator("tr[data-summary-series-id]").first();- await expect(row).toBeVisible();-- const beforeScroll = await scrollSectionIntoView(page, row);- expect(beforeScroll).toBeGreaterThan(10);+ // The default Priority sort breaks ties on live utilisation, so a mock+ // update can reorder pools mid-check. Host order (ties by name) is static.+ await page.goto("/proxmox/storage?sort=host&order=asc", {+ waitUntil: "domcontentloaded",+ });+ const rows = page.locator("tr[data-summary-series-id]");+ await expect(rows.first()).toBeVisible({ timeout: 60_000 });++ const {+ id: seriesId,+ selector: rowSelector,+ row,+ } = await findRowBelowFirstScreen(rows, "data-summary-series-id");const beforeRowTop = await positionElementNearViewportBottom(page, row);+ expect(await readPrimaryViewportScrollTop(page)).toBeGreaterThan(10);expect(beforeRowTop).toBeGreaterThan(500);+ const detailSelector = `[data-inline-detail-for="${seriesId}"]`;+ await startUrlWriteProbe(page);+ await startLayoutObserver(page, {+ rowSelector,+ detailSelector,+ detailOpen: true,+ revealFrom: beforeRowTop,+ });await row.click();- const detailRow = row.locator("xpath=following-sibling::tr[1]");- await expect(detailRow).toBeVisible();- await page.waitForTimeout(350);-- const viewportBounds = await readPrimaryViewportBounds(page);- const afterRowTop = await row.evaluate((element) => element.getBoundingClientRect().top);- const detailTop = await detailRow.evaluate((element) => element.getBoundingClientRect().top);-- expect(afterRowTop).toBeLessThan(beforeRowTop - 150);- expect(afterRowTop).toBeLessThan(viewportBounds.top + viewportBounds.height * 0.42);- expect(detailTop).toBeLessThan(viewportBounds.bottom - 48);+ await expect(page.locator(detailSelector)).toBeVisible();+ expectInlineDetailRevealedBelowTop(await finishLayoutObserver(page));+ expect(await stopUrlWriteProbe(page)).toEqual([]);});});