refactor: eliminate jscpd clones and boost tests

This commit is contained in:
Peter Steinberger
2026-02-19 14:59:36 +00:00
parent 71983716ff
commit dcd592a601
16 changed files with 408 additions and 235 deletions

View File

@@ -39,6 +39,14 @@ export function getBrowserControlServerBaseUrl(): string {
return `http://127.0.0.1:${state.testPort}`;
}
export function restoreGatewayPortEnv(prevGatewayPort: string | undefined): void {
if (prevGatewayPort === undefined) {
delete process.env.OPENCLAW_GATEWAY_PORT;
return;
}
process.env.OPENCLAW_GATEWAY_PORT = prevGatewayPort;
}
export function setBrowserControlServerCreateTargetId(targetId: string | null): void {
state.createTargetId = targetId;
}
@@ -332,11 +340,7 @@ export function installBrowserControlServerHooks() {
afterEach(async () => {
vi.unstubAllGlobals();
vi.restoreAllMocks();
if (state.prevGatewayPort === undefined) {
delete process.env.OPENCLAW_GATEWAY_PORT;
} else {
process.env.OPENCLAW_GATEWAY_PORT = state.prevGatewayPort;
}
restoreGatewayPortEnv(state.prevGatewayPort);
if (state.prevGatewayToken === undefined) {
delete process.env.OPENCLAW_GATEWAY_TOKEN;
} else {