test: isolate browser server auth env (evaluate gating)

This commit is contained in:
Peter Steinberger
2026-02-14 19:41:41 +00:00
parent 31295c8341
commit 91c30f46f7

View File

@@ -4,6 +4,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
let testPort = 0;
let prevGatewayPort: string | undefined;
let prevGatewayToken: string | undefined;
let prevGatewayPassword: string | undefined;
const pwMocks = vi.hoisted(() => ({
cookiesGetViaPlaywright: vi.fn(async () => ({
@@ -82,6 +84,10 @@ describe("browser control evaluate gating", () => {
testPort = await getFreePort();
prevGatewayPort = process.env.OPENCLAW_GATEWAY_PORT;
process.env.OPENCLAW_GATEWAY_PORT = String(testPort - 2);
prevGatewayToken = process.env.OPENCLAW_GATEWAY_TOKEN;
prevGatewayPassword = process.env.OPENCLAW_GATEWAY_PASSWORD;
delete process.env.OPENCLAW_GATEWAY_TOKEN;
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
pwMocks.cookiesGetViaPlaywright.mockClear();
pwMocks.storageGetViaPlaywright.mockClear();
@@ -97,6 +103,16 @@ describe("browser control evaluate gating", () => {
} else {
process.env.OPENCLAW_GATEWAY_PORT = prevGatewayPort;
}
if (prevGatewayToken === undefined) {
delete process.env.OPENCLAW_GATEWAY_TOKEN;
} else {
process.env.OPENCLAW_GATEWAY_TOKEN = prevGatewayToken;
}
if (prevGatewayPassword === undefined) {
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
} else {
process.env.OPENCLAW_GATEWAY_PASSWORD = prevGatewayPassword;
}
await stopBrowserControlServer();
});