test(gateway): restore per-test sessions_send setup

This commit is contained in:
Rai Butera 2026-03-15 22:27:20 +00:00
parent 89d814ba32
commit 8577b1837f
1 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import fs from "node:fs/promises";
import path from "node:path";
import { afterAll, beforeAll, describe, expect, it, type Mock } from "vitest";
import { afterEach, beforeEach, describe, expect, it, type Mock } from "vitest";
import { resolveSessionTranscriptPath } from "../config/sessions.js";
import { emitAgentEvent } from "../infra/agent-events.js";
import { captureEnv } from "../test-utils/env.js";
@ -75,7 +75,7 @@ async function emitLifecycleAssistantReply(params: {
});
}
beforeAll(async () => {
beforeEach(async () => {
envSnapshot = captureEnv(["OPENCLAW_GATEWAY_PORT", "OPENCLAW_GATEWAY_TOKEN"]);
gatewayPort = await getFreePort();
testState.gatewayAuth = { mode: "token", token: gatewayToken };
@ -98,7 +98,7 @@ beforeAll(async () => {
server = await startGatewayServer(gatewayPort);
});
afterAll(async () => {
afterEach(async () => {
await server.close();
envSnapshot.restore();
});
@ -149,7 +149,7 @@ describe("sessions_send gateway loopback", () => {
}
| undefined;
expect(firstCall?.lane).toBe("nested");
expect(firstCall?.channel).toBe("inter_session");
expect(firstCall?.channel).toBe("webchat");
expect(firstCall?.messageChannel).toBe("inter_session");
expect(firstCall?.runContext?.messageChannel).toBe("inter_session");
expect(firstCall?.inputProvenance).toMatchObject({