mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 20:03:13 +08:00
test(market): restore HAHA_MARKET_DISABLE_PROVIDERS instead of deleting it
afterEach deleted the variable outright, so a developer who exported it to silence a provider lost it after the first test file ran. The essential-traffic variable next to it was already saved and restored; this makes both behave the same way, since neither belongs to the test. 19 pass / 0 fail with the variable inherited from `.env`, with an explicit CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1, and with HAHA_MARKET_DISABLE_PROVIDERS=skillhub set in the environment — the case that previously came back unset.
This commit is contained in:
@@ -16,6 +16,7 @@ type FetchStub = (url: string) => { status?: number; body: string; contentType?:
|
||||
|
||||
let requestedUrls: string[] = []
|
||||
let originalNonEssentialTrafficEnv: string | undefined
|
||||
let originalDisableProvidersEnv: string | undefined
|
||||
const originalFetch = globalThis.fetch
|
||||
|
||||
function stubFetch(handler: FetchStub) {
|
||||
@@ -35,6 +36,7 @@ beforeEach(() => {
|
||||
requestedUrls = []
|
||||
resetMarketCacheForTests()
|
||||
resetClawhubOwnerCacheForTests()
|
||||
originalDisableProvidersEnv = process.env.HAHA_MARKET_DISABLE_PROVIDERS
|
||||
delete process.env.HAHA_MARKET_DISABLE_PROVIDERS
|
||||
// These tests stub upstreams and must not inherit the developer shell's
|
||||
// essential-traffic env (which would block the market providers entirely).
|
||||
@@ -44,7 +46,12 @@ beforeEach(() => {
|
||||
|
||||
afterEach(() => {
|
||||
globalThis.fetch = originalFetch
|
||||
delete process.env.HAHA_MARKET_DISABLE_PROVIDERS
|
||||
// Restore rather than delete: these are the developer's variables, not ours.
|
||||
if (originalDisableProvidersEnv === undefined) {
|
||||
delete process.env.HAHA_MARKET_DISABLE_PROVIDERS
|
||||
} else {
|
||||
process.env.HAHA_MARKET_DISABLE_PROVIDERS = originalDisableProvidersEnv
|
||||
}
|
||||
if (originalNonEssentialTrafficEnv === undefined) {
|
||||
delete process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user