#23055: test: clear gateway env vars in beforeEach to prevent leakage
gateway
size: XS
Add beforeEach hooks in these test files to ensure a clean environment:
- src/gateway/server-runtime-config.test.ts
- src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts
This prevents OPENCLAW_GATEWAY_TOKEN and OPENCLAW_GATEWAY_PASSWORD from the outer environment from interfering with auth-related test expectations, making tests deterministic and reliable.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `beforeEach` hooks to clear `OPENCLAW_GATEWAY_TOKEN` and `OPENCLAW_GATEWAY_PASSWORD` environment variables in two test files to prevent environment leakage.
- `src/gateway/server-runtime-config.test.ts`: properly imports `beforeEach` from vitest and clears env vars to ensure auth-related tests run with predictable state
- `src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts`: adds redundant env cleanup in first describe block (already handled by `installBrowserControlServerHooks()`), and the second describe block (`profile CRUD endpoints`) still lacks proper env var cleanup/restoration
<h3>Confidence Score: 3/5</h3>
- safe to merge but with minor issues that should be addressed
- the change properly addresses env var leakage in `server-runtime-config.test.ts`, but has redundant cleanup in one test file and incomplete cleanup in another describe block that could still allow env var leakage
- pay attention to `src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts` - the second describe block needs env var cleanup
<sub>Last reviewed commit: 874a422</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
82.5%
#23139: test: fix flaky auth tests when OPENCLAW_GATEWAY_TOKEN is present
by Imccccc · 2026-02-22
79.8%
#16658: test: isolate env-dependent gateway/auth fixtures
by sauerdaniel · 2026-02-15
78.9%
#19937: fix(gateway): validate token/password auth modes and isolate gatewa...
by NewdlDewdl · 2026-02-18
78.4%
#21164: feat(config): add lenient mode to resolveConfigEnvVars — preserve g...
by Mellowambience · 2026-02-19
75.9%
#21459: fix(gateway): resolve port from profile config, not inherited env
by kkeeling · 2026-02-19
74.1%
#10258: fix(config): preserve ${ENV_VAR} references when writing config (#9...
by nu-gui · 2026-02-06
73.8%
#14197: fix(security): harden browser API auth, token comparisons, and hook...
by leecarollyn-gif · 2026-02-11
73.8%
#22671: Preserve custom env vars in LaunchAgent plist across updates
by Clawborn · 2026-02-21
73.3%
#22658: Fix onboard ignoring OPENCLAW_GATEWAY_TOKEN env var
by Clawborn · 2026-02-21
72.8%