mirror of https://github.com/openclaw/openclaw.git
test: localize browser config env helper
This commit is contained in:
parent
a5b23f17fb
commit
4528f8779e
|
|
@ -1,9 +1,34 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { withEnv } from "../../test-support.js";
|
||||
import { resolveUserPath } from "../utils.js";
|
||||
import { resolveBrowserConfig, resolveProfile, shouldStartLocalBrowserServer } from "./config.js";
|
||||
import { getBrowserProfileCapabilities } from "./profile-capabilities.js";
|
||||
|
||||
function withEnv<T>(env: Record<string, string | undefined>, fn: () => T): T {
|
||||
const snapshot = new Map<string, string | undefined>();
|
||||
for (const [key] of Object.entries(env)) {
|
||||
snapshot.set(key, process.env[key]);
|
||||
}
|
||||
|
||||
try {
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (value === undefined) {
|
||||
delete process.env[key];
|
||||
} else {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
return fn();
|
||||
} finally {
|
||||
for (const [key, value] of snapshot) {
|
||||
if (value === undefined) {
|
||||
delete process.env[key];
|
||||
} else {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe("browser config", () => {
|
||||
it("defaults to enabled with loopback defaults and lobster-orange color", () => {
|
||||
const resolved = resolveBrowserConfig(undefined);
|
||||
|
|
|
|||
Loading…
Reference in New Issue