refactor(test): dedupe gateway and web scaffolding

This commit is contained in:
Peter Steinberger
2026-02-22 20:02:05 +00:00
parent 5e8b1f5ac8
commit 2dcb244985
17 changed files with 375 additions and 498 deletions

View File

@@ -19,6 +19,24 @@ type TestCase = {
expected: ExpectedCredentialSet;
};
const gatewayEnv = {
OPENCLAW_GATEWAY_TOKEN: "env-token",
OPENCLAW_GATEWAY_PASSWORD: "env-password",
} as NodeJS.ProcessEnv;
function makeRemoteGatewayConfig(remote: { token?: string; password?: string }): OpenClawConfig {
return {
gateway: {
mode: "remote",
remote,
auth: {
token: "local-token",
password: "local-password",
},
},
} as OpenClawConfig;
}
function withGatewayAuthEnv<T>(env: NodeJS.ProcessEnv, fn: () => T): T {
const keys = [
"OPENCLAW_GATEWAY_TOKEN",
@@ -76,23 +94,11 @@ describe("gateway credential precedence parity", () => {
},
{
name: "remote mode with remote token configured",
cfg: {
gateway: {
mode: "remote",
remote: {
token: "remote-token",
password: "remote-password",
},
auth: {
token: "local-token",
password: "local-password",
},
},
} as OpenClawConfig,
env: {
OPENCLAW_GATEWAY_TOKEN: "env-token",
OPENCLAW_GATEWAY_PASSWORD: "env-password",
} as NodeJS.ProcessEnv,
cfg: makeRemoteGatewayConfig({
token: "remote-token",
password: "remote-password",
}),
env: gatewayEnv,
expected: {
call: { token: "remote-token", password: "env-password" },
probe: { token: "remote-token", password: "env-password" },
@@ -102,22 +108,10 @@ describe("gateway credential precedence parity", () => {
},
{
name: "remote mode without remote token keeps remote probe/status strict",
cfg: {
gateway: {
mode: "remote",
remote: {
password: "remote-password",
},
auth: {
token: "local-token",
password: "local-password",
},
},
} as OpenClawConfig,
env: {
OPENCLAW_GATEWAY_TOKEN: "env-token",
OPENCLAW_GATEWAY_PASSWORD: "env-password",
} as NodeJS.ProcessEnv,
cfg: makeRemoteGatewayConfig({
password: "remote-password",
}),
env: gatewayEnv,
expected: {
call: { token: "env-token", password: "env-password" },
probe: { token: undefined, password: "env-password" },