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
Wait for resolved workspace routes before browser journeys
rcourtman12d050a5be83
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex 146765c011..c1933dfc44 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -3017,13 +3017,18 @@ artifact-selection behaviour.API as a fallback only when the UI wizard fails to complete cleanly under themanaged hot-dev runtime.A successful token probe and a protected workspace URL do not establish- completed browser bootstrap. Token, cookie reuse and password login wait for the mounted- authenticated app shell before returning control to a journey, so a pending- workspace redirect cannot overwrite its next deep link. Browser rejection+ completed browser bootstrap. Token, cookie reuse and password login wait for+ the mounted authenticated app shell on its resolved workspace destination+ before returning control to a journey. A mounted shell at `/`, `/login` or+ `/infrastructure` still has a default redirect pending and cannot admit the+ next deep link. Browser rejectionremains an authentication failure rather than a reason to accept the URL orretry login. `tests/integration/scripts/fixture-auth.test.mjs` exercises theactual token helper with delayed and rejected bootstrap; the runtime-homeonboarding browser contract also holds a real protected-state request.+ Its cookie control withholds the admission facet and resource snapshot,+ proves a mounted entry still fails admission, then releases the snapshot+ and follows the requested install handoff without being redirected away.That regression creates and revokes its own token through the admittedsession and shared browser-token helper. It must work with cookie-only andprimary-token fixtures without replacing their remembered credential.@@ -3049,7 +3054,9 @@ artifact-selection behaviour.`tests/integration/scripts/settings-scroll-audit.test.mjs` retains nativeChromium/WebKit traversal of short and 30,000px content plus the positivehorizontal-overflow control; the live mobile audit keeps its bottom and- overflow assertions.+ overflow assertions. Infrastructure onboarding uses this same content-owner+ audit, including its bottom-position assertion. Its SPA route assertions+ observe the requested URL rather than wait for the document's load event.Bottom position and horizontal width are judged from the same browser snapshot.If content reflows after traversal, the audit finishes the changed extent beforeaccepting that snapshot. A scroll reset with an unchanged extent remains andiff --git a/tests/integration/scripts/fixture-auth.test.mjs b/tests/integration/scripts/fixture-auth.test.mjsindex 0469d942fd..95c74f3981 100644--- a/tests/integration/scripts/fixture-auth.test.mjs+++ b/tests/integration/scripts/fixture-auth.test.mjs@@ -96,6 +96,11 @@ function fixture(t, options = {}) {navigations.push(target);url = new URL(target, 'http://127.0.0.1:7655').href;bootstrapState = options.delayedBootstrap ? 'loading' : 'ready';+ if (bootstrapState === 'ready' && !options.holdWorkspaceRedirect &&+ !options.browserRejectSession && !options.bootstrapFailure && validSession(cookies) &&+ new URL(url).pathname === '/infrastructure') {+ url = 'http://127.0.0.1:7655/proxmox/overview';+ }},url: () => url,navigations,@@ -103,6 +108,13 @@ function fixture(t, options = {}) {rememberLoginHint: () => { hasLoginHint = true; },completeBootstrap: () => {bootstrapState = 'ready';+ if (!options.holdWorkspaceRedirect) {+ url = 'http://127.0.0.1:7655/proxmox/overview';+ pendingBootstrap?.();+ }+ },+ completeWorkspaceRedirect: () => {+ url = 'http://127.0.0.1:7655/proxmox/overview';pendingBootstrap?.();},waitForFunction: async (predicate, arg, settings) => {@@ -113,6 +125,7 @@ function fixture(t, options = {}) {// Run the shipped predicate against a DOM-shaped boundary. Rejection// leaves the requested URL unchanged, just as the real app does.const evaluate = () => runInNewContext(`(${predicate.toString()})()`, {+ window: { location: new URL(url) },document: { querySelector: selector => {if (bootstrapState !== 'ready' || options.bootstrapFailure) return null;const present = selector === '.app-scroll-shell' ? admitted() : !admitted();@@ -120,9 +133,12 @@ function fixture(t, options = {}) {} },getComputedStyle: () => ({ visibility: 'visible' }),});- bootstrapChecks.push(evaluate());+ const initial = evaluate();+ bootstrapChecks.push(initial);resolveWaitStarted();- if (bootstrapState === 'loading') await new Promise(resolve => { pendingBootstrap = resolve; });+ if (!initial && (bootstrapState === 'loading' || options.holdWorkspaceRedirect)) {+ await new Promise(resolve => { pendingBootstrap = resolve; });+ }const value = evaluate();if (!value) throw new Error('browser bootstrap timed out');return { jsonValue: async () => value, dispose: async () => {} };@@ -203,7 +219,7 @@ test('cookie-only reuse enters the protected workspace without manufacturing a lconst page = f.createPage();await f.ensureAuthenticated(page);assert.deepEqual(page.navigations, ['/infrastructure']);- assert.equal(page.url(), 'http://127.0.0.1:7655/infrastructure');+ assert.equal(page.url(), 'http://127.0.0.1:7655/proxmox/overview');assert.deepEqual(f.bootstrapChecks, ['authenticated']);assert.deepEqual(f.counts(), { loginCalls: 0, probeCalls: 1, disposed: 1, primaryRevoked: false });});@@ -226,6 +242,24 @@ test('a protected URL and mounted loading root cannot complete delayed cookie boassert.equal(f.counts().loginCalls, 0);});+test('a mounted cookie shell waits for its pending workspace redirect before admitting a deep link', async t => {+ const f = fixture(t, { holdWorkspaceRedirect: true });+ f.save([cookie('pulse_session', 'saved-live')]);+ const page = f.createPage();+ let completed = false;+ const authentication = f.ensureAuthenticated(page).then(() => { completed = true; });+ await page.waitStarted;+ assert.equal(page.url(), 'http://127.0.0.1:7655/infrastructure');+ assert.deepEqual(f.bootstrapChecks, [false], 'a mounted shell on the entry route is still pending');+ assert.equal(completed, false);+ page.completeWorkspaceRedirect();+ await authentication;+ assert.equal(completed, true);+ assert.equal(f.counts().loginCalls, 0);+ await page.goto('/settings/infrastructure?add=agent');+ assert.equal(page.url(), 'http://127.0.0.1:7655/settings/infrastructure?add=agent');+});+test('API admission cannot hide browser rejection at the unchanged protected URL', async t => {const f = fixture(t, { browserRejectSession: true });f.save([cookie('pulse_session', 'saved-live')]);@@ -320,6 +354,7 @@ function primaryBootstrapFixture({ rejected = false, passwordLogin = false } = {waitForResponse: async () => response(200),waitForFunction: async predicate => {const evaluate = () => runInNewContext(`(${predicate.toString()})()`, {+ window: { location: new URL(currentURL) },document: { querySelector: selector => {if (!ready) return null;const present = selector === '.app-scroll-shell' ? !rejected : rejected;diff --git a/tests/integration/tests/62-runtime-home-onboarding-contract.spec.ts b/tests/integration/tests/62-runtime-home-onboarding-contract.spec.tsindex 9067b6c271..b49acb4a51 100644--- a/tests/integration/tests/62-runtime-home-onboarding-contract.spec.ts+++ b/tests/integration/tests/62-runtime-home-onboarding-contract.spec.ts@@ -7,6 +7,7 @@ import {apiRequest,authenticateWithAPIToken,ensureAuthenticated,+ waitForAuthenticatedAppShell,} from "./helpers";const __dirname = path.dirname(fileURLToPath(import.meta.url));@@ -156,6 +157,60 @@ test.describe("runtime-home onboarding contract", () => {}});+ test("waits for a mounted cookie workspace to finish its default redirect", async ({ page }) => {+ await ensureAuthenticated(page);+ const workspacePage = await page.context().newPage();+ let released = false;+ const frames: Array<{+ socket: import("@playwright/test").WebSocketRoute;+ message: string | Buffer;+ }> = [];+ try {+ // A missing first admission facet leaves navigation dependent on the+ // resource snapshot. Hold that snapshot after the shell has mounted.+ await workspacePage.route("**/api/resources?**", async route => {+ const url = new URL(route.request().url());+ if (url.searchParams.get("limit") !== "1" || url.searchParams.get("page") !== "1") {+ await route.continue();+ return;+ }+ const response = await route.fetch();+ expect(response.ok()).toBeTruthy();+ const payload = await response.json();+ expect(payload.aggregations?.platformAdmission).toBeTruthy();+ delete payload.aggregations.platformAdmission;+ await route.fulfill({ response, json: payload });+ });+ await workspacePage.routeWebSocket("**/ws*", socket => {+ const server = socket.connectToServer();+ server.onMessage(message => {+ if (released) socket.send(message);+ else frames.push({ socket, message });+ });+ });+ await workspacePage.goto("/infrastructure", { waitUntil: "domcontentloaded" });+ await expect(workspacePage.locator(".app-scroll-shell")).toBeVisible();+ await expect(workspacePage).toHaveURL(/\/infrastructure$/);+ // This is a bounded negative control, not a larger authentication+ // deadline. A mounted entry must still fail admission while unresolved.+ await expect(waitForAuthenticatedAppShell(workspacePage, 250)).rejects.toThrow(/Timeout/);+ await expect.poll(() => frames.length).toBeGreaterThan(0);+ released = true;+ for (const { socket, message } of frames.splice(0)) socket.send(message);+ await waitForAuthenticatedAppShell(workspacePage);+ expect(["/", "/login", "/infrastructure"]).not.toContain(new URL(workspacePage.url()).pathname);+ await workspacePage.goto("/settings/infrastructure?add=agent", { waitUntil: "domcontentloaded" });+ await expect(workspacePage).toHaveURL(/\/settings\/infrastructure\?add=agent$/);+ await expect(workspacePage.getByRole("dialog").getByRole("heading", {+ name: "Add Pulse Agent", exact: true,+ })).toBeVisible();+ } finally {+ released = true;+ frames.length = 0;+ await workspacePage.close();+ }+ });+test("retires legacy platform-management paths to the not-found page", async ({page,}) => {diff --git a/tests/integration/tests/68-infrastructure-onboarding.spec.ts b/tests/integration/tests/68-infrastructure-onboarding.spec.tsindex 81c1bc47ff..6e5ebe9d24 100644--- a/tests/integration/tests/68-infrastructure-onboarding.spec.ts+++ b/tests/integration/tests/68-infrastructure-onboarding.spec.ts@@ -2,6 +2,7 @@ import fs from "node:fs";import path from "node:path";import { fileURLToPath } from "node:url";import { expect, test as base, type Page } from "@playwright/test";+import { auditSettingsAtBottom } from "../scripts/settings-scroll-audit.mjs";import {createAuthenticatedStorageState,ensureAuthenticated,@@ -13,13 +14,6 @@ type WorkerFixtures = {authStorageStatePath: string;};-type OverflowAudit = {- viewportWidth: number;- pageWidth: number;- overflowPx: number;- offenders: Array<{ tag: string; className: string; overflow: number }>;-};-const test = base.extend<{}, WorkerFixtures>({storageState: async ({ authStorageStatePath }, use) => {await use(authStorageStatePath);@@ -70,71 +64,6 @@ async function prepareOnboardingPage(page: Page): Promise<void> {await ensureAuthenticated(page);}-async function scrollToBottom(page: 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);- }-}--async function auditHorizontalOverflow(page: Page): Promise<OverflowAudit> {- return 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,- };- });-}-test.describe("Infrastructure onboarding", () => {test.setTimeout(180_000);@@ -180,7 +109,7 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});@@ -236,7 +165,7 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});@@ -277,7 +206,7 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});@@ -321,7 +250,7 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});@@ -329,14 +258,14 @@ test.describe("Infrastructure onboarding", () => {.getByRole("button", { name: "Add infrastructure", exact: true }).first().click();- await page.waitForURL(/\/settings\/infrastructure\?add=pick$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure\?add=pick$/, {timeout: 15_000,});await page.getByRole("dialog").getByRole("button", { name: /TrueNAS SCALE/i }).click();- await page.waitForURL(/\/settings\/infrastructure\?add=truenas$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure\?add=truenas$/, {timeout: 15_000,});@@ -432,7 +361,7 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});@@ -444,7 +373,7 @@ test.describe("Infrastructure onboarding", () => {await expect(page.getByRole("button", { name: /^Review$/i })).toBeVisible();await page.getByRole("button", { name: /^Review$/i }).click();- await page.waitForURL(/\/settings\/infrastructure\?add=pve$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure\?add=pve$/, {timeout: 15_000,});@@ -532,7 +461,7 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});@@ -546,7 +475,7 @@ test.describe("Infrastructure onboarding", () => {).toBeVisible();await page.getByRole("button", { name: /^Review$/i }).click();- await page.waitForURL(/\/settings\/infrastructure\?add=pve$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure\?add=pve$/, {timeout: 15_000,});@@ -673,18 +602,18 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});await page.getByRole("button", { name: "Add infrastructure", exact: true }).first().click();- await page.waitForURL(/\/settings\/infrastructure\?add=pick$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure\?add=pick$/, {timeout: 15_000,});await page.getByRole("button", { name: /Detect API platform/i }).click();- await page.waitForURL(/\/settings\/infrastructure\?add=detect$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure\?add=detect$/, {timeout: 15_000,});@@ -702,7 +631,7 @@ test.describe("Infrastructure onboarding", () => {await page.getByRole("button", { name: "install Pulse Agent instead", exact: true }).click();- await page.waitForURL(/\/settings\/infrastructure\?add=linux-host$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure\?add=linux-host$/, {timeout: 15_000,});await expect(@@ -726,7 +655,7 @@ test.describe("Infrastructure onboarding", () => {await page.goto("/settings/infrastructure", {waitUntil: "domcontentloaded",});- await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {+ await expect(page).toHaveURL(/\/settings\/infrastructure(?:\?.*)?$/, {timeout: 15_000,});await expect(@@ -739,8 +668,10 @@ test.describe("Infrastructure onboarding", () => {page.getByText(/Supported source types include .*Pulse Agent hosts\./),).toBeVisible();- await scrollToBottom(page);- const audit = await auditHorizontalOverflow(page);+ const audit = await auditSettingsAtBottom(page);+ expect(audit.scrollPosition.scrollTop).toBeGreaterThanOrEqual(+ audit.scrollPosition.maxScrollTop - 3,+ );expect(audit.pageWidth,diff --git a/tests/integration/tests/helpers.ts b/tests/integration/tests/helpers.tsindex b5bc0be2db..9e203b3343 100644--- a/tests/integration/tests/helpers.ts+++ b/tests/integration/tests/helpers.ts@@ -175,7 +175,12 @@ export async function waitForAuthenticatedAppShell(page: Page, timeoutMs = 20_00getComputedStyle(element).visibility !== "hidden";};if (visible('input[name="username"]')) return "login";- return visible(".app-scroll-shell") ? "authenticated" : false;+ // The shell can mount on a workspace entry while platform admission or+ // its default-route transition is still pending. Let that transition+ // finish before another document navigation can race it in WebKit.+ const pathname = window.location.pathname.replace(/\/+$/, "") || "/";+ const workspaceEntry = ["/", "/login", "/infrastructure"].includes(pathname);+ return visible(".app-scroll-shell") && !workspaceEntry ? "authenticated" : false;},undefined,{ timeout: timeoutMs },