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.

Run Node fixture tests on their runner without dropping coverage

pulse-triage[bot]b9f686071975
diff --git a/frontend-modern/browser-tests/README.md b/frontend-modern/browser-tests/README.md
index 31fb421a88..2ea8606785 100644
--- a/frontend-modern/browser-tests/README.md
+++ b/frontend-modern/browser-tests/README.md
@@ -67,6 +67,14 @@ node browser-tests/build-publication-fixtures.mjs
node --test browser-tests/publication-fixture-server.test.cjs
```
+The server regression uses Node's built-in test runner. Vitest excludes only
+that test body from discovery and awaits its standalone run through
+`src/__tests__/publicationFixtureServer.test.ts`. A Node failure still fails
+`npm test`; the command above also runs it independently. This preserves the
+binding, listener and cleanup checks without importing a Node suite as a
+Vitest file with no Vitest tests. The server checks exercise only a locally
+owned loopback listener and synthetic temporary files.
+
The four corresponding browser runners use the resulting static bundles in
`tmp/publication-final-static` at the repository root. They no longer compile
or start Vite inside the browser process tree. Rebuild after source changes:
diff --git a/frontend-modern/src/__tests__/publicationFixtureServer.test.ts b/frontend-modern/src/__tests__/publicationFixtureServer.test.ts
new file mode 100644
index 0000000000..9918ee11f0
--- /dev/null
+++ b/frontend-modern/src/__tests__/publicationFixtureServer.test.ts
@@ -0,0 +1,26 @@
+import { execFile } from 'node:child_process';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { promisify } from 'node:util';
+import { expect, it } from 'vitest';
+
+const run = promisify(execFile);
+const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
+
+// Keep the server's existing node:test suite on its own runner, but make its
+// exit part of npm test. The suite owns its synthetic files, listener and
+// cleanup checks.
+it('passes the standalone publication fixture server suite', async () => {
+ const { stdout, stderr } = await run(
+ process.execPath,
+ ['--test', 'browser-tests/publication-fixture-server.test.cjs'],
+ { cwd: root, timeout: 25000, maxBuffer: 1024 * 1024 },
+ );
+ expect(stdout).toContain('# fail 0');
+ expect(stdout).toContain(
+ 'serves only verified bytes, explicit routes and GET/HEAD; closes the listener',
+ );
+ // Retain the Node test count and outcomes beside the enclosing Vitest result.
+ process.stdout.write(stdout);
+ if (stderr) process.stderr.write(stderr);
+}, 30000);
diff --git a/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts b/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts
index 418e659446..ba30befcd2 100644
--- a/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts
+++ b/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts
@@ -83,6 +83,12 @@ describe('notification evidence privacy help', () => {
'#inspect-notification-logs',
'notification log precautions',
],
+ [
+ 'TROUBLESHOOTING',
+ 'TROUBLESHOOTING',
+ '#inspect-notification-logs',
+ 'log-sharing precautions',
+ ],
[
'WEBHOOKS',
'TROUBLESHOOTING',
@@ -91,8 +97,10 @@ describe('notification evidence privacy help', () => {
],
];
for (const [from, to, href, label] of cases) {
- const link = guides[from].querySelector(`a[href="${href}"]`);
- expect(link?.textContent).toBe(label);
+ // Different entry points can name the same precaution section. Verify
+ // each intended labelled link, not whichever happens to be first.
+ const links = Array.from(guides[from].querySelectorAll(`a[href="${href}"]`));
+ expect(links.map((link) => link.textContent)).toContain(label);
expect(guides[to].querySelector(href.slice(href.indexOf('#')))).not.toBeNull();
}
});
diff --git a/frontend-modern/vite.config.ts b/frontend-modern/vite.config.ts
index f139dd251d..f26a901720 100644
--- a/frontend-modern/vite.config.ts
+++ b/frontend-modern/vite.config.ts
@@ -14,10 +14,7 @@ const frontendDevPort = Number(
const backendProtocol = process.env.PULSE_DEV_API_PROTOCOL ?? 'http';
const backendHost = process.env.PULSE_DEV_API_HOST ?? '127.0.0.1';
const backendPort = Number(
- process.env.PULSE_DEV_API_PORT ??
- process.env.FRONTEND_PORT ??
- process.env.PORT ??
- 7655,
+ process.env.PULSE_DEV_API_PORT ?? process.env.FRONTEND_PORT ?? process.env.PORT ?? 7655,
);
const backendUrl =
@@ -31,9 +28,7 @@ const backendWsUrl =
parsed.protocol = parsed.protocol === 'https:' ? 'wss:' : 'ws:';
return parsed.toString();
} catch {
- return backendUrl
- .replace(/^http:\/\//i, 'ws://')
- .replace(/^https:\/\//i, 'wss://');
+ return backendUrl.replace(/^http:\/\//i, 'ws://').replace(/^https:\/\//i, 'wss://');
}
})();
@@ -51,11 +46,7 @@ export default defineConfig(({ mode }) => ({
// the whole app incl. all Settings panels and every locale) at cold start,
// defeating route-level code splitting on slow devices. Dynamic-import SRI
// is still enforced through the generated import map integrity block.
- plugins: [
- tailwindcss(),
- solid(),
- sri({ algorithm: 'sha384', preloadDynamicChunks: false }),
- ],
+ plugins: [tailwindcss(), solid(), sri({ algorithm: 'sha384', preloadDynamicChunks: false })],
resolve: {
alias: {
'@': srcAlias,
@@ -300,6 +291,10 @@ export default defineConfig(({ mode }) => ({
...configDefaults.exclude,
'tests/integration/**',
'**/tests/integration/**',
+ // Uses node:test, with its own loopback server and cleanup assertions.
+ // The Vitest bridge awaits its node --test exit; README documents the
+ // standalone command too. Do not discover the Node test body as Vitest.
+ 'browser-tests/publication-fixture-server.test.cjs',
],
},
}));