feat(FN-2322): centralize loopback integration test gating

- Add a shared createLoopbackIntegrationTest helper that probes 127.0.0.1 binding once and caches the result
- Use the helper in webhook, websocket, and static asset integration tests to replace duplicated loopback detection logic
- Improve skip diagnostics by including a consistent skip reason and integration scope in skipped test names
This commit is contained in:
Fusion
2026-04-23 10:09:26 -07:00
committed by gsxdsm
parent f401d0df7d
commit cc3ade1bde
4 changed files with 43 additions and 39 deletions

View File

@@ -1,19 +1,8 @@
import express from "express";
import { describe, expect, it } from "vitest";
import http from "node:http";
import { createLoopbackIntegrationTest } from "./__tests__/loopback-integration-test.js";
async function detectLoopbackBinding(): Promise<boolean> {
return await new Promise((resolve) => {
const server = http.createServer();
server.once("error", () => resolve(false));
server.listen(0, "127.0.0.1", () => {
server.close(() => resolve(true));
});
});
}
const loopbackBindingAvailable = await detectLoopbackBinding();
const staticAssetIntegrationTest = loopbackBindingAvailable ? it : it.skip;
const staticAssetIntegrationTest = await createLoopbackIntegrationTest("static asset serving");
describe("static asset serving", () => {
staticAssetIntegrationTest("returns 404 for missing asset paths instead of falling back to index.html", async () => {