refactor(test): share gateway server start helper

This commit is contained in:
Peter Steinberger
2026-02-15 23:02:27 +00:00
parent 1b455b6d9f
commit 99909f7bc7
4 changed files with 175 additions and 169 deletions

View File

@@ -3,10 +3,9 @@ import { resolveMainSessionKeyFromConfig } from "../config/sessions.js";
import { drainSystemEvents, peekSystemEvents } from "../infra/system-events.js";
import {
cronIsolatedRun,
getFreePort,
installGatewayTestHooks,
startGatewayServer,
testState,
withGatewayServer,
waitForSystemEvent,
} from "./test-helpers.js";
@@ -14,16 +13,6 @@ installGatewayTestHooks({ scope: "suite" });
const resolveMainKey = () => resolveMainSessionKeyFromConfig();
async function withGatewayServer<T>(fn: (ctx: { port: number }) => Promise<T>): Promise<T> {
const port = await getFreePort();
const server = await startGatewayServer(port);
try {
return await fn({ port });
} finally {
await server.close();
}
}
describe("gateway server hooks", () => {
test("handles auth, wake, and agent flows", async () => {
testState.hooksConfig = { enabled: true, token: "hook-secret" };