fix(gateway-tests): flush gateway config state before server start

What:
- persist unsynced gateway test session config before each fresh startGatewayServer call
- reset config runtime state and clear the session store cache before starting a new gateway server in tests

Why:
- current Linux CI failures span auth, talk, reload, chat, and config behavior at once
- the common seam is fresh test servers starting against stale cached config/session state

Tests:
- sh -n nix/scripts/gateway-postpatch.sh
- targeted transform dry-run against pinned OpenClaw source rev 89535f9313579e791b3ed325b2cb64fecdd978f7
This commit is contained in:
joshp123 2026-04-09 13:43:34 +02:00
parent 254879a568
commit ee4fb6e6d9

View File

@ -63,6 +63,23 @@ PY
fi
fi
if [ -f src/gateway/test-helpers.server.ts ]; then
if ! grep -q "Flush config/session caches before each fresh gateway start." src/gateway/test-helpers.server.ts; then
python3 - <<'PY'
from pathlib import Path
path = Path("src/gateway/test-helpers.server.ts")
text = path.read_text()
old = """export async function startGatewayServer(port: number, opts?: GatewayServerOptions) {\n const mod = await getServerModule();\n"""
new = """export async function startGatewayServer(port: number, opts?: GatewayServerOptions) {\n if (hasUnsyncedGatewayTestSessionConfig()) {\n await persistTestSessionConfig();\n }\n // Flush config/session caches before each fresh gateway start.\n resetConfigRuntimeState();\n clearSessionStoreCacheForTest();\n const mod = await getServerModule();\n"""
if old not in text:
raise SystemExit("expected startGatewayServer helper block not found")
path.write_text(text.replace(old, new, 1))
PY
fi
fi
if [ -f src/plugins/provider-runtime.ts ]; then
if ! grep -q "shouldSkipProviderRuntimeForTest" src/plugins/provider-runtime.ts; then
python3 - <<'PY'