test: move and rename private-network check to tests/private_network.test.ts; make diagnostic

This commit is contained in:
Scott Idem
2026-02-24 16:42:10 -05:00
parent f2c426b595
commit a7f6101cce

View File

@@ -1,8 +1,9 @@
import { test, expect } from '@playwright/test';
// Combined private-network detection test.
// Keeps both high-level request observation and low-level CDP capture in one
// place so you can run this when troubleshooting PNA / localhost access issues.
// Private-network detection test.
// Captures both Playwright-level request events and CDP Network events where
// available. Keep under `tests/` when you want CI or local runs to check for
// accidental private-network requests.
function isPrivateHostname(hostname: string) {
if (!hostname) return false;
@@ -11,7 +12,7 @@ function isPrivateHostname(hostname: string) {
return false;
}
test('detect private/local network requests and PNA preflights (combined)', async ({ page }) => {
test('detect private/local network requests and PNA preflights', async ({ page }) => {
const privateRequests: Array<any> = [];
const cdpPrivateRequests: Array<any> = [];
const consoleMessages: string[] = [];
@@ -80,5 +81,11 @@ test('detect private/local network requests and PNA preflights (combined)', asyn
}
}
expect(privateRequests.length + cdpPrivateRequests.length, 'No private/local network requests or PNA preflights should be made').toBe(0);
const total = privateRequests.length + cdpPrivateRequests.length;
if (total > 0) {
console.error(`Private-network test detected ${total} items; see logs above.`);
} else {
console.log('Private-network test: no private/local requests or PNA preflights detected.');
}
// This test is diagnostic by default; it logs issues but does not fail the run.
});