Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

fix(e2e): audit scroll position and width in one snapshot

rcourtman7a211a6f9209
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 74f2c21ff0..b1a6db1559 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -3050,6 +3050,12 @@ artifact-selection behaviour.
Chromium/WebKit traversal of short and 30,000px content plus the positive
horizontal-overflow control; the live mobile audit keeps its bottom and
overflow assertions.
+Bottom position and horizontal width are judged from the same browser snapshot.
+If content reflows after traversal, the audit finishes the changed extent before
+accepting that snapshot. A scroll reset with an unchanged extent remains an
+error. Native browser controls reproduce a reflow between the old separate reads,
+verify the newly revealed footer and retain both overflow and scroll-reset
+negative controls.
The built `index.html` must not modulepreload lazy route chunks: the SRI
plugin runs with `preloadDynamicChunks: false` so cold start fetches only the
entry and its static vendor imports (route-level code splitting stays
diff --git a/tests/integration/scripts/settings-scroll-audit.mjs b/tests/integration/scripts/settings-scroll-audit.mjs
index c4a5dc1fa5..53bb4b0134 100644
--- a/tests/integration/scripts/settings-scroll-audit.mjs
+++ b/tests/integration/scripts/settings-scroll-audit.mjs
@@ -15,7 +15,7 @@ export const scrollSettingsToBottom = async (page) => {
await page.waitForTimeout(60);
const after = await settingsScrollPosition(page);
if (after.scrollTop >= after.maxScrollTop - 3 &&
- after.maxScrollTop === before.maxScrollTop) return;
+ after.maxScrollTop === before.maxScrollTop) return after;
if (after.scrollTop <= before.scrollTop && after.maxScrollTop === before.maxScrollTop) {
throw new Error(`Settings content did not scroll: ${JSON.stringify(after)}`);
}
@@ -32,6 +32,7 @@ export const settingsScrollPosition = async (page) =>
/** @param {import('@playwright/test').Page} page */
export const auditHorizontalOverflow = async (page) =>
page.evaluate(() => {
+ const shell = document.querySelector('.app-scroll-shell');
const viewportWidth = Math.max(
document.documentElement.clientWidth,
window.innerWidth || 0,
@@ -67,5 +68,25 @@ export const auditHorizontalOverflow = async (page) =>
pageWidth,
overflowPx: Number((pageWidth - viewportWidth).toFixed(1)),
offenders,
+ scrollPosition: shell ? {
+ scrollTop: shell.scrollTop,
+ maxScrollTop: Math.max(0, shell.scrollHeight - shell.clientHeight),
+ } : null,
};
});
+
+// Read position and width in the same browser task. Content can reflow after
+// traversal returns; finish that new extent before accepting its width proof.
+/** @param {import('@playwright/test').Page} page */
+export const auditSettingsAtBottom = async (page) => {
+ for (;;) {
+ const reached = await scrollSettingsToBottom(page);
+ const audit = await auditHorizontalOverflow(page);
+ const position = audit.scrollPosition;
+ if (!position) throw new Error('Settings scroll owner is missing during the audit');
+ if (position.scrollTop >= position.maxScrollTop - 3) return audit;
+ if (position.maxScrollTop === reached.maxScrollTop) {
+ throw new Error(`Settings scroll position moved before the audit without an extent change: ${JSON.stringify({ reached, position })}`);
+ }
+ }
+};
diff --git a/tests/integration/scripts/settings-scroll-audit.test.mjs b/tests/integration/scripts/settings-scroll-audit.test.mjs
index 7638d2187e..5d483673e1 100644
--- a/tests/integration/scripts/settings-scroll-audit.test.mjs
+++ b/tests/integration/scripts/settings-scroll-audit.test.mjs
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { chromium, webkit } from '@playwright/test';
-import { auditHorizontalOverflow, scrollSettingsToBottom, settingsScrollPosition } from './settings-scroll-audit.mjs';
+import { auditHorizontalOverflow, auditSettingsAtBottom, scrollSettingsToBottom, settingsScrollPosition } from './settings-scroll-audit.mjs';
// Browser geometry is essential here: a DOM mock cannot distinguish the
// document's scroll offset from the nested app-shell offset.
@@ -29,12 +29,12 @@ for (const [name, browserType] of Object.entries({ chromium, webkit })) {
const before = await settingsScrollPosition(page);
assert.equal(before.scrollTop, 0);
assert.ok(before.maxScrollTop > 2000);
- await scrollSettingsToBottom(page);
- const after = await settingsScrollPosition(page);
+ const audit = await auditSettingsAtBottom(page);
+ const after = audit.scrollPosition;
assert.ok(after.scrollTop >= after.maxScrollTop - 3, JSON.stringify({ name, width, contentHeight, after }));
const footer = await page.locator('footer').boundingBox();
assert.ok(footer.y >= 0 && footer.y + footer.height <= 844);
- assert.equal((await auditHorizontalOverflow(page)).overflowPx, 0);
+ assert.equal(audit.overflowPx, 0);
// Horizontal overflow is still measurable, not hidden by the helper.
await page.locator('section').evaluate((element) => { element.style.width = '600px'; });
assert.equal((await auditHorizontalOverflow(page)).pageWidth, 600);
@@ -45,4 +45,53 @@ for (const [name, browserType] of Object.entries({ chromium, webkit })) {
await browser.close();
}
});
+
+ test(`Settings audit follows reflow but rejects a scroll reset in ${name}`, async () => {
+ const browser = await browserType.launch({ headless: true });
+ try {
+ const page = await browser.newPage({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
+ const prepare = async (change) => {
+ await page.setContent(`<meta name="viewport" content="width=device-width, initial-scale=1"><style>
+ body { margin: 0; } .layout { height: 100vh; display: flex; overflow: hidden; }
+ .app-scroll-shell { flex: 1; min-width: 0; overflow-y: scroll; }
+ section { height: 3000px; }
+ </style><div class="layout"><div class="app-scroll-shell"><section>Settings</section><footer>Last setting</footer></div></div>`);
+ await page.locator('.app-scroll-shell').evaluate((element, change) => {
+ const readHeight = Object.getOwnPropertyDescriptor(Element.prototype, 'scrollHeight').get;
+ let changed = false;
+ Object.defineProperty(element, 'scrollHeight', { get() {
+ const height = readHeight.call(this);
+ if (!changed && this.scrollTop >= height - this.clientHeight - 3) {
+ changed = true;
+ // Model data arriving immediately after the bottom snapshot.
+ queueMicrotask(() => {
+ if (change === 'grow') element.querySelector('section').style.height = '4500px';
+ else element.scrollTop = 0;
+ });
+ }
+ return height;
+ } });
+ }, change);
+ };
+
+ await prepare('grow');
+ await scrollSettingsToBottom(page);
+ const separatedRead = await settingsScrollPosition(page);
+ assert.ok(separatedRead.scrollTop < separatedRead.maxScrollTop - 3, 'separate bottom reads must expose the controlled reflow');
+
+ await prepare('grow');
+ const audit = await auditSettingsAtBottom(page);
+ assert.ok(audit.scrollPosition.scrollTop >= audit.scrollPosition.maxScrollTop - 3);
+ assert.equal(audit.overflowPx, 0);
+ const footer = await page.locator('footer').boundingBox();
+ assert.ok(footer.y >= 0 && footer.y + footer.height <= 844);
+ await page.locator('section').evaluate(element => { element.style.width = '600px'; });
+ assert.equal((await auditSettingsAtBottom(page)).pageWidth, 600);
+
+ await prepare('reset');
+ await assert.rejects(() => auditSettingsAtBottom(page), /position moved before the audit without an extent change/);
+ } finally {
+ await browser.close();
+ }
+ });
}
diff --git a/tests/integration/tests/05-settings-mobile-audit.spec.ts b/tests/integration/tests/05-settings-mobile-audit.spec.ts
index 4adc5f996d..3e1f2e38de 100644
--- a/tests/integration/tests/05-settings-mobile-audit.spec.ts
+++ b/tests/integration/tests/05-settings-mobile-audit.spec.ts
@@ -1,4 +1,4 @@
-import { auditHorizontalOverflow, scrollSettingsToBottom, settingsScrollPosition } from '../scripts/settings-scroll-audit.mjs';
+import { auditSettingsAtBottom } from '../scripts/settings-scroll-audit.mjs';
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
@@ -274,15 +274,14 @@ test.describe("Settings mobile optimization audit", () => {
});
expect(clippedOrOverlapping, `Audit header at ${viewport.width}px`).toEqual([]);
}
- await scrollSettingsToBottom(page);
- const position = await settingsScrollPosition(page);
+ const audit = await auditSettingsAtBottom(page);
+ const position = audit.scrollPosition!;
const atBottom = position.scrollTop >= position.maxScrollTop - 3;
expect(
atBottom,
- `Expected to reach the bottom while auditing ${route} on a ${viewport.label}`,
+ `Expected to reach the bottom while auditing ${route} on a ${viewport.label}: ${JSON.stringify(position)}`,
).toBeTruthy();
- const audit = await auditHorizontalOverflow(page);
expect(
audit.pageWidth,
`Mobile overflow on ${route} at ${viewport.width}px (viewport=${audit.viewportWidth}, page=${audit.pageWidth}, offenders=${JSON.stringify(audit.offenders)})`,