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.

test(settings): audit the app shell's scrollable content

pulse-triage[bot]b72d81bbd8c2
diff --git a/tests/integration/scripts/settings-scroll-audit.d.mts b/tests/integration/scripts/settings-scroll-audit.d.mts
new file mode 100644
index 0000000000..12a014345c
--- /dev/null
+++ b/tests/integration/scripts/settings-scroll-audit.d.mts
@@ -0,0 +1,15 @@
+import type { Page } from '@playwright/test';
+
+export type OverflowAudit = {
+ viewportWidth: number;
+ pageWidth: number;
+ overflowPx: number;
+ offenders: Array<{ tag: string; className: string; overflow: number }>;
+};
+
+export function scrollSettingsToBottom(page: Page): Promise<void>;
+export function settingsScrollPosition(page: Page): Promise<{
+ scrollTop: number;
+ maxScrollTop: number;
+}>;
+export function auditHorizontalOverflow(page: Page): Promise<OverflowAudit>;
diff --git a/tests/integration/scripts/settings-scroll-audit.md b/tests/integration/scripts/settings-scroll-audit.md
new file mode 100644
index 0000000000..26ec4c7a6e
--- /dev/null
+++ b/tests/integration/scripts/settings-scroll-audit.md
@@ -0,0 +1,20 @@
+# Settings scroll audit helper
+
+The Settings overflow audit must scroll and measure `.app-scroll-shell`,
+not the document. The root is outside the app's independently scrolling
+`h-screen` layout; mobile WebKit also does not support Playwright mouse wheels.
+
+The helper keeps the bounded incremental traversal and bottom tolerance used
+by the audit. Horizontal width includes the shell's scrollable width, so content
+overflow inside the shell cannot pass merely because the document fits.
+
+Run from the repository root:
+
+```sh
+pulse-heavy-run -- node --test tests/integration/scripts/settings-scroll-audit.test.mjs
+```
+
+This uses synthetic markup matching the app's scroll ownership in Chromium and
+WebKit at 320, 390 and 430 pixels. It proves the window-scroll negative control,
+the final setting's visibility, and detection of deliberately oversized content.
+It does not establish a real-backend Settings pass or touch-gesture behaviour.
diff --git a/tests/integration/scripts/settings-scroll-audit.mjs b/tests/integration/scripts/settings-scroll-audit.mjs
new file mode 100644
index 0000000000..8793c874cc
--- /dev/null
+++ b/tests/integration/scripts/settings-scroll-audit.mjs
@@ -0,0 +1,62 @@
+// Settings lives inside the app's independently scrolling shell. Scrolling
+// window (including the mobile WebKit wheel fallback) leaves its content at top.
+/** @param {import('@playwright/test').Page} page */
+export const scrollSettingsToBottom = async (page) => {
+ const shell = page.locator('.app-scroll-shell');
+ await shell.waitFor({ state: 'visible' });
+ const step = await shell.evaluate((element) =>
+ Math.max(240, Math.floor(element.clientHeight * 0.75)),
+ );
+ for (let i = 0; i < 20; i += 1) {
+ await shell.evaluate((element, deltaY) => element.scrollBy(0, deltaY), step);
+ await page.waitForTimeout(60);
+ }
+};
+
+/** @param {import('@playwright/test').Page} page */
+export const settingsScrollPosition = async (page) =>
+ page.locator('.app-scroll-shell').evaluate((element) => ({
+ scrollTop: element.scrollTop,
+ maxScrollTop: Math.max(0, element.scrollHeight - element.clientHeight),
+ }));
+
+/** @param {import('@playwright/test').Page} page */
+export const auditHorizontalOverflow = async (page) =>
+ page.evaluate(() => {
+ const viewportWidth = Math.max(
+ document.documentElement.clientWidth,
+ window.innerWidth || 0,
+ );
+ const pageWidth = Math.max(
+ document.querySelector(".app-scroll-shell")?.scrollWidth || 0,
+ document.body.scrollWidth,
+ document.documentElement.scrollWidth,
+ document.body.offsetWidth,
+ document.documentElement.offsetWidth,
+ );
+
+ const offenders = Array.from(document.querySelectorAll("body *"))
+ .map((el) => {
+ const rect = el.getBoundingClientRect();
+ if (rect.width <= 0 || rect.height <= 0) return null;
+ const style = window.getComputedStyle(el);
+ if (style.position === "fixed" || style.position === "absolute")
+ return null;
+ const overflow = rect.right - viewportWidth;
+ if (overflow <= 1) return null;
+ return {
+ tag: el.tagName.toLowerCase(),
+ className: (el.getAttribute("class") || "").trim().slice(0, 120),
+ overflow: Number(overflow.toFixed(1)),
+ };
+ })
+ .filter(Boolean)
+ .slice(0, 8);
+
+ return {
+ viewportWidth,
+ pageWidth,
+ overflowPx: Number((pageWidth - viewportWidth).toFixed(1)),
+ offenders,
+ };
+ });
diff --git a/tests/integration/scripts/settings-scroll-audit.test.mjs b/tests/integration/scripts/settings-scroll-audit.test.mjs
new file mode 100644
index 0000000000..1fb09799e8
--- /dev/null
+++ b/tests/integration/scripts/settings-scroll-audit.test.mjs
@@ -0,0 +1,46 @@
+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';
+
+// Browser geometry is essential here: a DOM mock cannot distinguish the
+// document's scroll offset from the nested app-shell offset.
+for (const [name, browserType] of Object.entries({ chromium, webkit })) {
+ test(`Settings audit scrolls the content owner in ${name}`, async () => {
+ const browser = await browserType.launch({ headless: true });
+ try {
+ for (const width of [320, 390, 430]) {
+ const page = await browser.newPage({
+ viewport: { width, height: 844 }, isMobile: true, hasTouch: true,
+ });
+ // Match App.tsx's h-screen/overflow-hidden parent and independently
+ // scrolling flex child, with content taller than a phone viewport.
+ await page.setContent(`<meta name="viewport" content="width=device-width, initial-scale=1"><style>
+ body { margin: 0; overflow-x: hidden; overflow-y: auto; }
+ .layout { display: flex; height: 100vh; 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 data-settings-content>Settings</section><footer>Last setting</footer>
+ </div></div>`);
+ // The old WebKit fallback cannot reach the actual content bottom.
+ await page.evaluate(() => window.scrollBy(0, 12660));
+ const before = await settingsScrollPosition(page);
+ assert.equal(before.scrollTop, 0);
+ assert.ok(before.maxScrollTop > 2000);
+ await scrollSettingsToBottom(page);
+ const after = await settingsScrollPosition(page);
+ assert.ok(after.scrollTop >= after.maxScrollTop - 3, JSON.stringify({ name, width, 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);
+ // 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);
+ await page.close();
+ }
+ } 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 bc19799499..1d2fe20e8f 100644
--- a/tests/integration/tests/05-settings-mobile-audit.spec.ts
+++ b/tests/integration/tests/05-settings-mobile-audit.spec.ts
@@ -1,3 +1,4 @@
+import { auditHorizontalOverflow, scrollSettingsToBottom, settingsScrollPosition } from '../scripts/settings-scroll-audit.mjs';
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
@@ -196,80 +197,6 @@ const test = base.extend<{}, WorkerFixtures>({
],
});
-type OverflowAudit = {
- viewportWidth: number;
- pageWidth: number;
- overflowPx: number;
- offenders: Array<{ tag: string; className: string; overflow: number }>;
-};
-
-const auditHorizontalOverflow = async (
- page: import("@playwright/test").Page,
-): Promise<OverflowAudit> =>
- page.evaluate(() => {
- const viewportWidth = Math.max(
- document.documentElement.clientWidth,
- window.innerWidth || 0,
- );
- const pageWidth = Math.max(
- document.body.scrollWidth,
- document.documentElement.scrollWidth,
- document.body.offsetWidth,
- document.documentElement.offsetWidth,
- );
-
- const offenders = Array.from(document.querySelectorAll("body *"))
- .map((el) => {
- const rect = el.getBoundingClientRect();
- if (rect.width <= 0 || rect.height <= 0) return null;
- const style = window.getComputedStyle(el);
- if (style.position === "fixed" || style.position === "absolute")
- return null;
- const overflow = rect.right - viewportWidth;
- if (overflow <= 1) return null;
- return {
- tag: el.tagName.toLowerCase(),
- className: (el.getAttribute("class") || "").trim().slice(0, 120),
- overflow: Number(overflow.toFixed(1)),
- };
- })
- .filter(
- (
- entry,
- ): entry is { tag: string; className: string; overflow: number } =>
- Boolean(entry),
- )
- .slice(0, 8);
-
- return {
- viewportWidth,
- pageWidth,
- overflowPx: Number((pageWidth - viewportWidth).toFixed(1)),
- offenders,
- };
- });
-
-const scrollToBottom = async (
- page: import("@playwright/test").Page,
-): Promise<void> => {
- const viewportHeight = await page.evaluate(() => window.innerHeight || 800);
- const step = Math.max(240, Math.floor(viewportHeight * 0.75));
- let wheelSupported = true;
- for (let i = 0; i < 20; i += 1) {
- if (wheelSupported) {
- try {
- await page.mouse.wheel(0, step);
- } catch {
- wheelSupported = false;
- await page.evaluate((deltaY) => window.scrollBy(0, deltaY), step);
- }
- } else {
- await page.evaluate((deltaY) => window.scrollBy(0, deltaY), step);
- }
- await page.waitForTimeout(60);
- }
-};
-
test.describe("Settings mobile optimization audit", () => {
test.setTimeout(180_000);
@@ -314,15 +241,10 @@ test.describe("Settings mobile optimization audit", () => {
).toBeVisible();
}
- await scrollToBottom(page);
- const atBottom = await page.evaluate(() => {
- const scrollTop = window.scrollY;
- const maxScrollTop = Math.max(
- 0,
- document.documentElement.scrollHeight - window.innerHeight,
- );
- return scrollTop >= maxScrollTop - 3;
- });
+ await expect(page.locator("[data-settings-content]")).toBeVisible();
+ await scrollSettingsToBottom(page);
+ const position = await settingsScrollPosition(page);
+ const atBottom = position.scrollTop >= position.maxScrollTop - 3;
expect(
atBottom,
`Expected to reach the bottom while auditing ${route} on a ${viewport.label}`,