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
Share integration browser default helper
rcourtman2cde5c71ec88
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex 4a4d0a1a06..87bf43ff35 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -292,6 +292,10 @@ explicit base URL, runtime-state file, and any active managed `hot-dev`session. If `hot-dev-bg` is already running, ad hoc Playwright/browser helpersmust prefer the managed shell on `http://127.0.0.1:5173` instead of silentlyteaching the backend port as the default local browser target.+That defaulting rule must live in one shared integration helper rather than+being duplicated between config and helper files, so future browser-target+changes cannot leave Playwright navigation and browser/API helper calls+disagreeing about whether the managed shell or embedded frontend is canonical.That runtime-guidance rule also applies to successful launcher startup output:`hot-dev-bg` must identify `http://127.0.0.1:5173` as the browser entrypointand present `7655` as the managed backend dependency, rather than advertisingdiff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.shindex 5b51a8e8bd..ab2da68f44 100755--- a/scripts/tests/test-hot-dev-bg.sh+++ b/scripts/tests/test-hot-dev-bg.sh@@ -616,19 +616,27 @@ test_playwright_defaults_prefer_managed_hot_dev_runtime() {local outputoutput="$(cat "${ROOT_DIR}/tests/integration/playwright.config.ts")"- assert_contains "playwright config checks managed hot-dev pid" "${output}" "managedHotDevPidPath"- assert_contains "playwright config computes managed browser base url" "${output}" "managedDevBrowserBaseURL"- assert_contains "playwright config prefers runtime-state first" "${output}" "loadRuntimeBaseURL() ||"- assert_contains "playwright config prefers managed dev browser before embedded fallback" "${output}" "managedDevBrowserBaseURL() ||"+ assert_contains "playwright config imports shared browser default helper" "${output}" "import { preferredBrowserBaseURL } from './tests/runtime-defaults';"+ assert_contains "playwright config delegates base url to shared helper" "${output}" "baseURL: preferredBrowserBaseURL(),"}test_integration_helpers_prefer_managed_hot_dev_runtime() {local outputoutput="$(cat "${ROOT_DIR}/tests/integration/tests/helpers.ts")"- assert_contains "integration helpers check managed hot-dev pid" "${output}" "managedHotDevPidPath"- assert_contains "integration helpers compute managed browser base url" "${output}" "managedDevBrowserBaseURL"- assert_contains "integration helpers prefer managed browser before embedded fallback" "${output}" "managedDevBrowserBaseURL() ||"+ assert_contains "integration helpers import shared browser defaults" "${output}" "import { preferredBrowserBaseURL, readRuntimeState } from './runtime-defaults';"+ assert_contains "integration helpers delegate browser context base url to shared helper" "${output}" "baseURL: preferredBrowserBaseURL(),"+ assert_contains "integration helpers delegate api request base url to shared helper" "${output}" "const baseURL = preferredBrowserBaseURL().replace(/\\/+\$/, '');"+}++test_integration_runtime_defaults_centralize_managed_browser_detection() {+ local output+ output="$(cat "${ROOT_DIR}/tests/integration/tests/runtime-defaults.ts")"++ assert_contains "runtime defaults declare managed hot-dev pid path" "${output}" "managedHotDevPidPath"+ assert_contains "runtime defaults expose runtime-state reader" "${output}" "export const readRuntimeState ="+ assert_contains "runtime defaults expose managed browser detection" "${output}" "export const managedDevBrowserBaseURL ="+ assert_contains "runtime defaults expose preferred browser base url" "${output}" "export const preferredBrowserBaseURL ="}test_clean_mock_alerts_prefers_managed_runtime() {diff --git a/tests/integration/README.md b/tests/integration/README.mdindex 930bb1c7b2..4dba8e6a5f 100644--- a/tests/integration/README.md+++ b/tests/integration/README.md@@ -148,7 +148,7 @@ npm test -- tests/16-dev-runtime-recovery.spec.ts tests/17-recovery-layout.spec.This mode attaches Playwright to the canonical dev browser entrypoint on `http://127.0.0.1:5173`, uses the repo-root managed runtime wrappers as the control surface, and writes browser runtime connection state for Playwright instead of targeting the backend port directly. Those wrappers are backed by `scripts/hot-dev-bg.sh`, but the wrapper surface is the canonical operator contract.When you run the wrapper as `npm run dev:verify`, the managed launcher hands a verification-lock path into the integration runner, and the runner holds that lock for the actual pretest, Playwright, and posttest lifetime so unrelated backend source churn does not invalidate the recovery proofs mid-run.-When no explicit `PULSE_BASE_URL`, `PLAYWRIGHT_BASE_URL`, or runtime-state file is present, the integration browser defaults now prefer the managed hot-dev browser shell on `http://127.0.0.1:5173` whenever `hot-dev-bg` is already running, and only fall back to the embedded frontend on `:7655` when there is no managed dev session to attach to.+When no explicit `PULSE_BASE_URL`, `PLAYWRIGHT_BASE_URL`, or runtime-state file is present, the shared integration browser-default helper now prefers the managed hot-dev browser shell on `http://127.0.0.1:5173` whenever `hot-dev-bg` is already running, and only falls back to the embedded frontend on `:7655` when there is no managed dev session to attach to.If the managed runtime is not already running, the harness starts it. If you need the harness to reclaim existing unmanaged `5173`/`7655` listeners first, add `PULSE_E2E_HOT_DEV_TAKEOVER=1`.diff --git a/tests/integration/playwright.config.ts b/tests/integration/playwright.config.tsindex de381fc2ae..c8d09bc1fe 100644--- a/tests/integration/playwright.config.ts+++ b/tests/integration/playwright.config.ts@@ -1,47 +1,5 @@-import fs from 'node:fs';-import path from 'node:path';-import { fileURLToPath } from 'node:url';import { defineConfig, devices } from '@playwright/test';--const configDir = path.dirname(fileURLToPath(import.meta.url));-const repoRoot = path.resolve(configDir, '..', '..');-const managedHotDevPidPath = path.join(repoRoot, 'tmp', 'hot-dev.bg.pid');-const runtimeStatePath = (() => {- const configuredPath = String(process.env.PULSE_E2E_RUNTIME_STATE_PATH || '').trim();- if (configuredPath === '') {- return path.resolve(repoRoot, 'tmp', 'e2e-runtime-state.json');- }- return path.isAbsolute(configuredPath) ? configuredPath : path.resolve(repoRoot, configuredPath);-})();--const trim = (value: unknown): string => String(value ?? '').trim();--const loadRuntimeBaseURL = (): string | null => {- try {- const raw = fs.readFileSync(runtimeStatePath, 'utf8');- const parsed = JSON.parse(raw) as { baseURL?: string };- return typeof parsed.baseURL === 'string' && parsed.baseURL.trim() !== ''- ? parsed.baseURL.trim()- : null;- } catch {- return null;- }-};--const managedDevBrowserBaseURL = (): string | null => {- try {- const pid = Number.parseInt(fs.readFileSync(managedHotDevPidPath, 'utf8').trim(), 10);- if (!Number.isInteger(pid) || pid <= 0) {- return null;- }- process.kill(pid, 0);- const host = trim(process.env.FRONTEND_DEV_HOST) || '127.0.0.1';- const port = trim(process.env.FRONTEND_DEV_PORT) || '5173';- return `http://${host}:${port}`;- } catch {- return null;- }-};+import { preferredBrowserBaseURL } from './tests/runtime-defaults';/*** Playwright configuration for Pulse update integration tests@@ -78,12 +36,7 @@ export default defineConfig({/* Shared settings for all projects */use: {/* Base URL for all tests */- baseURL:- process.env.PULSE_BASE_URL ||- process.env.PLAYWRIGHT_BASE_URL ||- loadRuntimeBaseURL() ||- managedDevBrowserBaseURL() ||- 'http://localhost:7655',+ baseURL: preferredBrowserBaseURL(),/* Allow testing against self-signed TLS when explicitly enabled */ignoreHTTPSErrors: ['1', 'true', 'yes', 'on'].includes(diff --git a/tests/integration/tests/helpers.ts b/tests/integration/tests/helpers.tsindex 963c8d6ef7..8c714b37f0 100644--- a/tests/integration/tests/helpers.ts+++ b/tests/integration/tests/helpers.ts@@ -1,59 +1,5 @@-/**- * Test helpers for Pulse update integration tests- */--import fs from 'node:fs';-import path from 'node:path';-import { fileURLToPath } from 'node:url';-import { Browser, Page, expect } from '@playwright/test';--const __dirname = path.dirname(fileURLToPath(import.meta.url));-const repoRoot = path.resolve(__dirname, '..', '..', '..');-const managedHotDevPidPath = path.join(repoRoot, 'tmp', 'hot-dev.bg.pid');-const runtimeStatePath = (() => {- const configuredPath = String(process.env.PULSE_E2E_RUNTIME_STATE_PATH || '').trim();- if (configuredPath === '') {- return path.resolve(repoRoot, 'tmp', 'e2e-runtime-state.json');- }- return path.isAbsolute(configuredPath) ? configuredPath : path.resolve(repoRoot, configuredPath);-})();--type RuntimeState = {- baseURL?: string;- primaryAPIToken?: string;-};--const readRuntimeState = (): RuntimeState | null => {- try {- const raw = fs.readFileSync(runtimeStatePath, 'utf8');- return JSON.parse(raw) as RuntimeState;- } catch {- return null;- }-};--const runtimeBaseURL = (): string | null => {- const parsed = readRuntimeState();- return typeof parsed?.baseURL === 'string' && parsed.baseURL.trim() !== ''- ? parsed.baseURL.trim()- : null;-};--const managedDevBrowserBaseURL = (): string | null => {- try {- const pid = Number.parseInt(fs.readFileSync(managedHotDevPidPath, 'utf8').trim(), 10);- if (!Number.isInteger(pid) || pid <= 0) {- return null;- }- process.kill(pid, 0);- const host = String(process.env.FRONTEND_DEV_HOST || '').trim() || '127.0.0.1';- const port = String(process.env.FRONTEND_DEV_PORT || '').trim() || '5173';- return `http://${host}:${port}`;- } catch {- return null;- }-};+import { preferredBrowserBaseURL, readRuntimeState } from './runtime-defaults';const runtimePrimaryAPIToken = (): string => {const parsed = readRuntimeState();@@ -394,12 +340,7 @@ export async function createAuthenticatedStorageState(storageStatePath: string,): Promise<void> {const context = await browser.newContext({- baseURL:- process.env.PULSE_BASE_URL ||- process.env.PLAYWRIGHT_BASE_URL ||- runtimeBaseURL() ||- managedDevBrowserBaseURL() ||- 'http://localhost:7655',+ baseURL: preferredBrowserBaseURL(),});const page = await context.newPage();try {@@ -632,13 +573,7 @@ export async function resetTestEnvironment() {* Make API request to Pulse backend*/export async function apiRequest(page: Page, endpoint: string, options: any = {}) {- const baseURL = (- process.env.PULSE_BASE_URL ||- process.env.PLAYWRIGHT_BASE_URL ||- runtimeBaseURL() ||- managedDevBrowserBaseURL() ||- 'http://localhost:7655'- ).replace(/\/+$/, '');+ const baseURL = preferredBrowserBaseURL().replace(/\/+$/, '');const method = String(options.method || 'GET').toUpperCase();const headers = { ...(options.headers || {}) } as Record<string, string>;diff --git a/tests/integration/tests/runtime-defaults.ts b/tests/integration/tests/runtime-defaults.tsnew file mode 100644index 0000000000..a495826981--- /dev/null+++ b/tests/integration/tests/runtime-defaults.ts@@ -0,0 +1,68 @@+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const repoRoot = path.resolve(__dirname, '..', '..', '..');+const managedHotDevPidPath = path.join(repoRoot, 'tmp', 'hot-dev.bg.pid');++export type RuntimeState = {+ baseURL?: string;+ primaryAPIToken?: string;+};++const trim = (value: unknown): string => String(value ?? '').trim();++export const runtimeStatePath = (env: NodeJS.ProcessEnv = process.env): string => {+ const configuredPath = trim(env.PULSE_E2E_RUNTIME_STATE_PATH);+ if (configuredPath === '') {+ return path.resolve(repoRoot, 'tmp', 'e2e-runtime-state.json');+ }+ return path.isAbsolute(configuredPath) ? configuredPath : path.resolve(repoRoot, configuredPath);+};++export const readRuntimeState = (+ env: NodeJS.ProcessEnv = process.env,+): RuntimeState | null => {+ try {+ const raw = fs.readFileSync(runtimeStatePath(env), 'utf8');+ return JSON.parse(raw) as RuntimeState;+ } catch {+ return null;+ }+};++export const loadRuntimeBaseURL = (+ env: NodeJS.ProcessEnv = process.env,+): string | null => {+ const parsed = readRuntimeState(env);+ return typeof parsed?.baseURL === 'string' && parsed.baseURL.trim() !== ''+ ? parsed.baseURL.trim()+ : null;+};++export const managedDevBrowserBaseURL = (+ env: NodeJS.ProcessEnv = process.env,+): string | null => {+ try {+ const pid = Number.parseInt(fs.readFileSync(managedHotDevPidPath, 'utf8').trim(), 10);+ if (!Number.isInteger(pid) || pid <= 0) {+ return null;+ }+ process.kill(pid, 0);+ const host = trim(env.FRONTEND_DEV_HOST) || '127.0.0.1';+ const port = trim(env.FRONTEND_DEV_PORT) || '5173';+ return `http://${host}:${port}`;+ } catch {+ return null;+ }+};++export const preferredBrowserBaseURL = (+ env: NodeJS.ProcessEnv = process.env,+): string =>+ trim(env.PULSE_BASE_URL) ||+ trim(env.PLAYWRIGHT_BASE_URL) ||+ loadRuntimeBaseURL(env) ||+ managedDevBrowserBaseURL(env) ||+ 'http://localhost:7655';