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:
程序员阿江(Relakkes)
2026-08-04 20:42:53 +08:00
parent 1aefc402ce
commit 965fd6ebe8
@@ -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 {