mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 02:04:34 +00:00
refactor(test): standardize env helpers across suites
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withEnv } from "../test-utils/env.js";
|
||||
import { resolveBrowserConfig, resolveProfile, shouldStartLocalBrowserServer } from "./config.js";
|
||||
|
||||
describe("browser config", () => {
|
||||
@@ -25,9 +26,7 @@ describe("browser config", () => {
|
||||
});
|
||||
|
||||
it("derives default ports from OPENCLAW_GATEWAY_PORT when unset", () => {
|
||||
const prev = process.env.OPENCLAW_GATEWAY_PORT;
|
||||
process.env.OPENCLAW_GATEWAY_PORT = "19001";
|
||||
try {
|
||||
withEnv({ OPENCLAW_GATEWAY_PORT: "19001" }, () => {
|
||||
const resolved = resolveBrowserConfig(undefined);
|
||||
expect(resolved.controlPort).toBe(19003);
|
||||
const chrome = resolveProfile(resolved, "chrome");
|
||||
@@ -38,19 +37,11 @@ describe("browser config", () => {
|
||||
const openclaw = resolveProfile(resolved, "openclaw");
|
||||
expect(openclaw?.cdpPort).toBe(19012);
|
||||
expect(openclaw?.cdpUrl).toBe("http://127.0.0.1:19012");
|
||||
} finally {
|
||||
if (prev === undefined) {
|
||||
delete process.env.OPENCLAW_GATEWAY_PORT;
|
||||
} else {
|
||||
process.env.OPENCLAW_GATEWAY_PORT = prev;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("derives default ports from gateway.port when env is unset", () => {
|
||||
const prev = process.env.OPENCLAW_GATEWAY_PORT;
|
||||
delete process.env.OPENCLAW_GATEWAY_PORT;
|
||||
try {
|
||||
withEnv({ OPENCLAW_GATEWAY_PORT: undefined }, () => {
|
||||
const resolved = resolveBrowserConfig(undefined, { gateway: { port: 19011 } });
|
||||
expect(resolved.controlPort).toBe(19013);
|
||||
const chrome = resolveProfile(resolved, "chrome");
|
||||
@@ -61,13 +52,7 @@ describe("browser config", () => {
|
||||
const openclaw = resolveProfile(resolved, "openclaw");
|
||||
expect(openclaw?.cdpPort).toBe(19022);
|
||||
expect(openclaw?.cdpUrl).toBe("http://127.0.0.1:19022");
|
||||
} finally {
|
||||
if (prev === undefined) {
|
||||
delete process.env.OPENCLAW_GATEWAY_PORT;
|
||||
} else {
|
||||
process.env.OPENCLAW_GATEWAY_PORT = prev;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes hex colors", () => {
|
||||
|
||||
Reference in New Issue
Block a user