@@ -12,15 +12,13 @@ import { FetchHttpClient } from "effect/unstable/http"
1212import { FetchUse } from "../src/fetch-use"
1313
1414const haveProxySetting = ! ! process . env . BROWSER_USE_FETCH_URL || ! ! process . env . BROWSER_USE_FETCH_TOKEN
15- const haveCredential =
16- ( ! ! process . env . BROWSER_USE_FETCH_URL && ! ! process . env . BROWSER_USE_FETCH_TOKEN ) ||
17- ( ! haveProxySetting && ! ! process . env . BROWSER_USE_API_KEY )
15+ const fetchUseSelected = haveProxySetting || ! ! process . env . BROWSER_USE_API_KEY
1816
19- test ( "layer constructs and exposes `enabled` reflecting env " , async ( ) => {
17+ test ( "layer selects fetch-use for direct or scoped-proxy configuration " , async ( ) => {
2018 const enabled = await Effect . gen ( function * ( ) {
2119 return ( yield * FetchUse . Service ) . enabled
2220 } ) . pipe ( Effect . provide ( FetchUse . layer . pipe ( Layer . provide ( FetchHttpClient . layer ) ) ) , Effect . runPromise )
23- expect ( enabled ) . toBe ( haveCredential )
21+ expect ( enabled ) . toBe ( fetchUseSelected )
2422} )
2523
2624test . skipIf ( ! process . env . BROWSER_USE_API_KEY ) ( "live: fetches httpbin and returns body + content-type" , async ( ) => {
@@ -79,7 +77,8 @@ test.each([
7977] ) ( "partial proxy configuration fails closed" , async ( options ) => {
8078 const result = await Effect . gen ( function * ( ) {
8179 const service = yield * FetchUse . Service
82- expect ( service . enabled ) . toBe ( false )
80+ // Keep this route selected so webfetch cannot silently use native HTTP.
81+ expect ( service . enabled ) . toBe ( true )
8382 return yield * Effect . flip ( service . fetch ( "https://example.com" , { timeoutMs : 1_000 } ) )
8483 } ) . pipe (
8584 Effect . provide ( FetchUse . makeLayer ( options ) . pipe ( Layer . provide ( FetchHttpClient . layer ) ) ) ,
0 commit comments