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
Tighten the drawer span tests
rcourtman7f83d73cfd39
diff --git a/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsx b/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsxindex f8aa97bd76..989cb28536 100644--- a/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsx@@ -115,7 +115,7 @@ describe('InlineDetailTableRow', () => {expect(detailCell()?.style.width).toBe('');});- it('nudges the detail cell width once when its span grows, not when it shrinks', async () => {+ it('forces one layout of the widened detail cell when its span grows, none when it shrinks', async () => {const [showSystem, setShowSystem] = createSignal(false);render(() => (<Table>@@ -127,39 +127,42 @@ describe('InlineDetailTableRow', () => {</Show><td>Seen</td></tr>- <InlineDetailTableRow colspan={3}>+ <InlineDetailTableRow colspan={showSystem() ? 3 : 2}><div>Growing span detail</div></InlineDetailTableRow></TableBody></Table>));- const detailCell = () => screen.getByText('Growing span detail').closest('td')!;- await waitFor(() => expect(detailCell()).toHaveAttribute('colspan', '2'));+ const detailCell = screen.getByText('Growing span detail').closest('td')!;+ await waitFor(() => expect(detailCell).toHaveAttribute('colspan', '2'));- // jsdom has no layout, so record the style writes Chromium needs to+ // jsdom has no layout, so record the forced layout reads Chromium needs to// recompute fixed-layout column widths for the widened cell.- const previousStyles: string[] = [];- const styleObserver = new MutationObserver((records) => {- for (const record of records) previousStyles.push(record.oldValue ?? '');- });- styleObserver.observe(detailCell(), {- attributes: true,- attributeFilter: ['style'],- attributeOldValue: true,- });-- setShowSystem(true);- await waitFor(() => expect(detailCell()).toHaveAttribute('colspan', '3'));- await new Promise((resolve) => setTimeout(resolve, 0));- expect(previousStyles.some((style) => style.includes('width: 0px'))).toBe(true);- expect(detailCell().style.width).toBe('');+ const layoutReads: Array<{ width: string; colspan: string | null }> = [];+ const offsetWidth = vi+ .spyOn(HTMLElement.prototype, 'offsetWidth', 'get')+ .mockImplementation(function (this: HTMLElement) {+ if (this === detailCell) {+ layoutReads.push({ width: this.style.width, colspan: this.getAttribute('colspan') });+ }+ return 0;+ });+ try {+ // The requested span and the summary cells change in the same update.+ setShowSystem(true);+ await waitFor(() => expect(detailCell).toHaveAttribute('colspan', '3'));+ await new Promise((resolve) => setTimeout(resolve, 0));+ expect(layoutReads).toEqual([{ width: '0px', colspan: '3' }]);+ expect(detailCell.style.width).toBe('');- previousStyles.length = 0;- setShowSystem(false);- await waitFor(() => expect(detailCell()).toHaveAttribute('colspan', '2'));- await new Promise((resolve) => setTimeout(resolve, 0));- expect(previousStyles).toEqual([]);- styleObserver.disconnect();+ layoutReads.length = 0;+ setShowSystem(false);+ await waitFor(() => expect(detailCell).toHaveAttribute('colspan', '2'));+ await new Promise((resolve) => setTimeout(resolve, 0));+ expect(layoutReads).toEqual([]);+ } finally {+ offsetWidth.mockRestore();+ }});it('re-measures for a summary cell span change but not for churn inside a cell', async () => {diff --git a/tests/integration/tests/98-inline-drawer-column-span.spec.ts b/tests/integration/tests/98-inline-drawer-column-span.spec.tsindex 0aea3a4437..b639a2ac10 100644--- a/tests/integration/tests/98-inline-drawer-column-span.spec.ts+++ b/tests/integration/tests/98-inline-drawer-column-span.spec.ts@@ -1,22 +1,17 @@-import {- expect,- test as base,- type Locator,- type Page,-} from "@playwright/test";+import { expect, test as base, type Locator, type Page } from '@playwright/test';import {ensureAuthenticated,getMockMode,setMockMode,waitForDefaultMockRuntimeReady,-} from "./helpers";+} from './helpers';let mockModeWasEnabled: boolean | null = null;const HTTP_CREDENTIALS = {- username: "admin",- password: "adminadminadmin",+ username: 'admin',+ password: 'adminadminadmin',};const test = base;@@ -38,13 +33,11 @@ async function ensureMockModeEnabled(page: Page): Promise<void> {async function readLayout(drawer: Locator) {return drawer.evaluate((row: HTMLTableRowElement) => {- const table = row.closest("table")!;- const headers = Array.from(- table.querySelectorAll<HTMLTableCellElement>("thead th"),- ).filter(- (cell) =>- getComputedStyle(cell).display !== "none" &&- cell.getClientRects().length > 0,+ const table = row.closest('table')!;+ // Only the outer table's own header row: drawer content may hold tables.+ const headerRows = table.tHead!.rows;+ const headers = Array.from(headerRows[headerRows.length - 1].cells).filter(+ (cell) => getComputedStyle(cell).display !== 'none' && cell.getClientRects().length > 0,);return {headerSpan: headers.reduce((total, cell) => total + cell.colSpan, 0),@@ -56,16 +49,11 @@ async function readLayout(drawer: Locator) {});}-async function expectAligned(- drawer: Locator,- headerSpan: number,-): Promise<void> {+async function expectAligned(drawer: Locator, headerSpan: number): Promise<void> {await expect(async () => {const layout = await readLayout(drawer);- expect(layout.headerSpan, "Visible header span").toBe(headerSpan);- expect(layout.drawerSpan, "Drawer colspan matches visible headers").toBe(- layout.headerSpan,- );+ expect(layout.headerSpan, 'Visible header span').toBe(headerSpan);+ expect(layout.drawerSpan, 'Drawer colspan matches visible headers').toBe(layout.headerSpan);expect(Math.abs(layout.drawerRight - layout.tableRight),`Drawer reaches table right edge: ${JSON.stringify(layout)}`,@@ -76,12 +64,12 @@ async function expectAligned().toBeLessThanOrEqual(1);expect(Math.abs(layout.drawerRight - layout.headerRight),- "Drawer and header right edges",+ 'Drawer and header right edges',).toBeLessThanOrEqual(1);}).toPass({ timeout: 10_000 });}-test.describe.serial("Inline machine drawer column span", () => {+test.describe.serial('Inline machine drawer column span', () => {test.setTimeout(240_000);test.afterAll(async ({ browser }) => {@@ -101,49 +89,38 @@ test.describe.serial("Inline machine drawer column span", () => {}});- test("resynchronizes a mounted drawer after hiding and restoring System", async ({+ test('resynchronizes a mounted drawer after hiding and restoring System', async ({page,}, testInfo) => {- test.skip(- testInfo.project.name !== "chromium",- "Chromium fixed-table layout regression",- );+ test.skip(testInfo.project.name !== 'chromium', 'Chromium fixed-table layout regression');await page.setViewportSize({ width: 1440, height: 900 });await ensureMockModeEnabled(page);- await page.goto("/standalone", { waitUntil: "domcontentloaded" });+ await page.goto('/standalone', { waitUntil: 'domcontentloaded' });- const surface = page.getByTestId("standalone-page");+ const surface = page.getByTestId('standalone-page');const summary = surface- .getByRole("row")+ .getByRole('row').filter({has: page.locator('button[aria-controls^="agents-machine-drawer"]'),}).first();- const disclosure = summary.locator(- 'button[aria-controls^="agents-machine-drawer"]',- );+ const disclosure = summary.locator('button[aria-controls^="agents-machine-drawer"]');await expect(disclosure).toBeVisible({ timeout: 60_000 });- await summary.getByRole("cell").nth(1).click();+ await summary.getByRole('cell').nth(1).click();- const drawer = surface.locator(- "tr[data-inline-platform-resource-detail-for]",- );+ const drawer = surface.locator('tr[data-inline-platform-resource-detail-for]');await expect(drawer).toHaveCount(1);await expect(drawer).toBeVisible();const originalRow = (await drawer.elementHandle())!;- await originalRow.evaluate((row) =>- row.setAttribute("data-column-span-test", "original"),- );+ await originalRow.evaluate((row) => row.setAttribute('data-column-span-test', 'original'));const focusTarget = (await drawer- .getByRole("button", { name: /^Collapse .* details$/ })+ .getByRole('button', { name: /^Collapse .* details$/ }).elementHandle())!;- await focusTarget.evaluate((button: HTMLElement) =>- button.focus({ preventScroll: true }),- );+ await focusTarget.evaluate((button: HTMLElement) => button.focus({ preventScroll: true }));const scrollHandle = await drawer.evaluateHandle((row) => {return (- Array.from(row.querySelectorAll<HTMLElement>("*")).find((element) => {+ Array.from(row.querySelectorAll<HTMLElement>('*')).find((element) => {const style = getComputedStyle(element);return (element.getClientRects().length > 0 &&@@ -158,14 +135,8 @@ test.describe.serial("Inline machine drawer column span", () => {const scrollElement = scrollHandle.asElement();const scrollOffset = scrollElement? await scrollElement.evaluate((element) => {- element.scrollTop = Math.min(- 32,- element.scrollHeight - element.clientHeight,- );- element.scrollLeft = Math.min(- 32,- element.scrollWidth - element.clientWidth,- );+ element.scrollTop = Math.min(32, element.scrollHeight - element.clientHeight);+ element.scrollLeft = Math.min(32, element.scrollWidth - element.clientWidth);return { top: element.scrollTop, left: element.scrollLeft };}): null;@@ -174,19 +145,17 @@ test.describe.serial("Inline machine drawer column span", () => {expect(await originalRow.evaluate((row) =>- row.isConnected &&- document.querySelector('[data-column-span-test="original"]') ===- row,+ row.isConnected && document.querySelector('[data-column-span-test="original"]') === row,),- "Original drawer row stays mounted",+ 'Original drawer row stays mounted',).toBe(true);expect(await focusTarget.evaluate((button) =>document.activeElement === button &&- button.closest("tr")?.hasAttribute("data-column-span-test"),+ button.closest('tr')?.hasAttribute('data-column-span-test'),),- "Original interactive element keeps focus inside the drawer",+ 'Original interactive element keeps focus inside the drawer',).toBe(true);if (scrollElement && scrollOffset) {const current = await scrollElement.evaluate((element) => ({@@ -194,38 +163,31 @@ test.describe.serial("Inline machine drawer column span", () => {top: element.scrollTop,left: element.scrollLeft,}));- expect(- current.connected,- "Original inner scroll container stays mounted",- ).toBe(true);- expect(- current.top,- "Inner vertical scroll survives column changes",- ).toBe(scrollOffset.top);- expect(- current.left,- "Inner horizontal scroll survives column changes",- ).toBe(scrollOffset.left);+ expect(current.connected, 'Original inner scroll container stays mounted').toBe(true);+ expect(current.top, 'Inner vertical scroll survives column changes').toBe(scrollOffset.top);+ expect(current.left, 'Inner horizontal scroll survives column changes').toBe(+ scrollOffset.left,+ );}};const initialSpan = (await readLayout(drawer)).headerSpan;- const view = surface.getByRole("button", { name: "View", exact: true });- const preferences = surface.getByRole("region", {- name: "View preferences",+ const view = surface.getByRole('button', { name: 'View', exact: true });+ const preferences = surface.getByRole('region', {+ name: 'View preferences',exact: true,});for (const visible of [false, true]) {await test.step(visible- ? "Show System after the reduced table has laid out"- : "Hide System with the drawer open",+ ? 'Show System after the reduced table has laid out'+ : 'Hide System with the drawer open',async () => {await view.click();- await preferences.getByRole("button", { name: /^Columns\b/ }).click();- const system = preferences.getByRole("checkbox", {- name: "System",+ await preferences.getByRole('button', { name: /^Columns\b/ }).click();+ const system = preferences.getByRole('checkbox', {+ name: 'System',exact: true,});await expect(system).toBeChecked({ checked: !visible });@@ -233,18 +195,14 @@ test.describe.serial("Inline machine drawer column span", () => {button.focus({ preventScroll: true }),);// Native checkbox activation preserves drawer focus during the column mutation.- await system.evaluate((checkbox: HTMLInputElement) =>- checkbox.click(),- );+ await system.evaluate((checkbox: HTMLInputElement) => checkbox.click());await expect(system).toBeChecked({ checked: visible });await drawer.evaluate((row) =>new Promise<void>((resolve) => {// Force the reduced table to lay out before restoring the column.void row.getBoundingClientRect().width;- requestAnimationFrame(() =>- requestAnimationFrame(() => resolve()),- );+ requestAnimationFrame(() => requestAnimationFrame(() => resolve()));}),);await expectAligned(drawer, initialSpan - (visible ? 0 : 1));