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(frontend): guard against docs link drift

rcourtmanee847f727ee8
diff --git a/frontend-modern/src/utils/__tests__/docsLinks.test.ts b/frontend-modern/src/utils/__tests__/docsLinks.test.ts
index 7e4df1b909..e75b82c5fa 100644
--- a/frontend-modern/src/utils/__tests__/docsLinks.test.ts
+++ b/frontend-modern/src/utils/__tests__/docsLinks.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { readFileSync } from 'node:fs';
+import { readdirSync, readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import {
@@ -25,6 +25,38 @@ const __dirname = path.dirname(__filename);
const frontendRoot = path.resolve(__dirname, '..', '..', '..');
const repoRoot = path.resolve(frontendRoot, '..');
+function getRuntimeSourceFiles(dir: string): string[] {
+ const entries = readdirSync(dir, { withFileTypes: true });
+ const files: string[] = [];
+
+ for (const entry of entries) {
+ const entryPath = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ if (entry.name === '__tests__') {
+ continue;
+ }
+ files.push(...getRuntimeSourceFiles(entryPath));
+ continue;
+ }
+
+ if (!entry.isFile()) {
+ continue;
+ }
+
+ if (!/\.(ts|tsx)$/.test(entry.name)) {
+ continue;
+ }
+
+ if (/(\.test|\.spec)\.(ts|tsx)$/.test(entry.name)) {
+ continue;
+ }
+
+ files.push(entryPath);
+ }
+
+ return files;
+}
+
describe('docsLinks', () => {
it('returns canonical shipped doc URLs', () => {
expect(SHIPPED_DOCS_ROOT).toBe('/docs');
@@ -82,4 +114,16 @@ describe('docsLinks', () => {
'https://github.com/rcourtman/Pulse/blob/main/TERMS.md',
);
});
+
+ it('keeps non-test frontend runtime files free of GitHub main doc links', () => {
+ const runtimeFiles = getRuntimeSourceFiles(path.join(frontendRoot, 'src'));
+
+ for (const filePath of runtimeFiles) {
+ const source = readFileSync(filePath, 'utf8');
+ expect(
+ source,
+ `${path.relative(frontendRoot, filePath)} should use shipped/local docs owners`,
+ ).not.toContain('https://github.com/rcourtman/Pulse/blob/main/');
+ }
+ });
});