refactor(channels): dedupe transport and gateway test scaffolds

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:15 +00:00
parent f717a13039
commit 93ca0ed54f
95 changed files with 4068 additions and 5221 deletions

View File

@@ -3,35 +3,21 @@ import { fetch as realFetch } from "undici";
import { describe, expect, it } from "vitest";
import { DEFAULT_UPLOAD_DIR } from "./paths.js";
import {
getBrowserControlServerBaseUrl,
installAgentContractHooks,
postJson,
startServerAndBase,
} from "./server.agent-contract.test-harness.js";
import {
getBrowserControlServerTestState,
getPwMocks,
installBrowserControlServerHooks,
setBrowserControlServerEvaluateEnabled,
startBrowserControlServerFromConfig,
} from "./server.control-server.test-harness.js";
const state = getBrowserControlServerTestState();
const pwMocks = getPwMocks();
describe("browser control server", () => {
installBrowserControlServerHooks();
const startServerAndBase = async () => {
await startBrowserControlServerFromConfig();
const base = getBrowserControlServerBaseUrl();
await realFetch(`${base}/start`, { method: "POST" }).then((r) => r.json());
return base;
};
const postJson = async <T>(url: string, body?: unknown): Promise<T> => {
const res = await realFetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: body === undefined ? undefined : JSON.stringify(body),
});
return (await res.json()) as T;
};
installAgentContractHooks();
const slowTimeoutMs = process.platform === "win32" ? 40_000 : 20_000;