mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:18:26 +00:00
refactor(channels): dedupe transport and gateway test scaffolds
This commit is contained in:
26
src/browser/server.agent-contract.test-harness.ts
Normal file
26
src/browser/server.agent-contract.test-harness.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { fetch as realFetch } from "undici";
|
||||
import {
|
||||
getBrowserControlServerBaseUrl,
|
||||
installBrowserControlServerHooks,
|
||||
startBrowserControlServerFromConfig,
|
||||
} from "./server.control-server.test-harness.js";
|
||||
|
||||
export function installAgentContractHooks() {
|
||||
installBrowserControlServerHooks();
|
||||
}
|
||||
|
||||
export async function startServerAndBase(): Promise<string> {
|
||||
await startBrowserControlServerFromConfig();
|
||||
const base = getBrowserControlServerBaseUrl();
|
||||
await realFetch(`${base}/start`, { method: "POST" }).then((r) => r.json());
|
||||
return base;
|
||||
}
|
||||
|
||||
export async function postJson<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;
|
||||
}
|
||||
Reference in New Issue
Block a user