@@ -119,28 +119,29 @@ describe('HTTP Request Tool', () => {
119119 expect ( headers2 [ 'content-type' ] ) . toBe ( 'text/plain' )
120120 } )
121121
122- it ( 'should set dynamic Referer header correctly' , async ( ) => {
123- const originalWindow = global . window
124- Object . defineProperty ( global , 'window' , {
125- value : {
126- location : {
127- origin : 'https://sim.ai' ,
128- } ,
129- } ,
130- writable : true ,
122+ it ( 'should not set a default Referer header' , async ( ) => {
123+ tester . setup ( mockHttpResponses . simple )
124+
125+ await tester . execute ( {
126+ url : 'https://api.example.com' ,
127+ method : 'GET' ,
131128 } )
132129
130+ const fetchCall = ( global . fetch as any ) . mock . calls [ 0 ]
131+ expect ( fetchCall [ 1 ] . headers . Referer ) . toBeUndefined ( )
132+ } )
133+
134+ it ( 'should respect a user-provided Referer header' , async ( ) => {
133135 tester . setup ( mockHttpResponses . simple )
134136
135137 await tester . execute ( {
136138 url : 'https://api.example.com' ,
137139 method : 'GET' ,
140+ headers : [ { cells : { Key : 'Referer' , Value : 'https://custom.example.com' } } ] ,
138141 } )
139142
140143 const fetchCall = ( global . fetch as any ) . mock . calls [ 0 ]
141- expect ( fetchCall [ 1 ] . headers . Referer ) . toBe ( 'https://sim.ai' )
142-
143- global . window = originalWindow
144+ expect ( fetchCall [ 1 ] . headers . Referer ) . toBe ( 'https://custom.example.com' )
144145 } )
145146
146147 it ( 'should set dynamic Host header correctly' , async ( ) => {
@@ -193,16 +194,6 @@ describe('HTTP Request Tool', () => {
193194 it ( 'should apply default and dynamic headers to requests' , async ( ) => {
194195 tester . setup ( mockHttpResponses . simple )
195196
196- const originalWindow = global . window
197- Object . defineProperty ( global , 'window' , {
198- value : {
199- location : {
200- origin : 'https://sim.ai' ,
201- } ,
202- } ,
203- writable : true ,
204- } )
205-
206197 await tester . execute ( {
207198 url : 'https://api.example.com/data' ,
208199 method : 'GET' ,
@@ -212,15 +203,13 @@ describe('HTTP Request Tool', () => {
212203 const headers = fetchCall [ 1 ] . headers
213204
214205 expect ( headers . Host ) . toBe ( 'api.example.com' )
215- expect ( headers . Referer ) . toBe ( 'https://sim.ai' )
216- expect ( headers [ 'User-Agent' ] ) . toContain ( 'Mozilla ')
206+ expect ( headers . Referer ) . toBeUndefined ( )
207+ expect ( headers [ 'User-Agent' ] ) . toBe ( 'Sim/1.0 (+https://sim.ai) ')
217208 expect ( headers . Accept ) . toBe ( '*/*' )
218209 expect ( headers [ 'Accept-Encoding' ] ) . toContain ( 'gzip' )
219210 expect ( headers [ 'Cache-Control' ] ) . toBe ( 'no-cache' )
220211 expect ( headers . Connection ) . toBe ( 'keep-alive' )
221- expect ( headers [ 'Sec-Ch-Ua' ] ) . toContain ( 'Chromium' )
222-
223- global . window = originalWindow
212+ expect ( headers [ 'Sec-Ch-Ua' ] ) . toBeUndefined ( )
224213 } )
225214
226215 it ( 'should handle successful GET requests' , async ( ) => {
@@ -434,16 +423,6 @@ describe('HTTP Request Tool', () => {
434423 it ( 'should apply all default headers correctly' , async ( ) => {
435424 tester . setup ( mockHttpResponses . simple )
436425
437- const originalWindow = global . window
438- Object . defineProperty ( global , 'window' , {
439- value : {
440- location : {
441- origin : 'https://sim.ai' ,
442- } ,
443- } ,
444- writable : true ,
445- } )
446-
447426 await tester . execute ( {
448427 url : 'https://api.example.com/data' ,
449428 method : 'GET' ,
@@ -452,18 +431,16 @@ describe('HTTP Request Tool', () => {
452431 const fetchCall = ( global . fetch as any ) . mock . calls [ 0 ]
453432 const headers = fetchCall [ 1 ] . headers
454433
455- expect ( headers [ 'User-Agent' ] ) . toMatch ( / M o z i l l a \/ 5 \. 0 . * C h r o m e . * S a f a r i / )
434+ expect ( headers [ 'User-Agent' ] ) . toBe ( 'Sim/1.0 (+https://sim.ai)' )
456435 expect ( headers . Accept ) . toBe ( '*/*' )
457436 expect ( headers [ 'Accept-Encoding' ] ) . toBe ( 'gzip, deflate, br' )
458437 expect ( headers [ 'Cache-Control' ] ) . toBe ( 'no-cache' )
459438 expect ( headers . Connection ) . toBe ( 'keep-alive' )
460- expect ( headers [ 'Sec-Ch-Ua' ] ) . toMatch ( / C h r o m i u m . * N o t - A \. B r a n d / )
461- expect ( headers [ 'Sec-Ch-Ua-Mobile' ] ) . toBe ( '?0' )
462- expect ( headers [ 'Sec-Ch-Ua-Platform' ] ) . toBe ( '"macOS"' )
463- expect ( headers . Referer ) . toBe ( 'https://sim.ai' )
439+ expect ( headers [ 'Sec-Ch-Ua' ] ) . toBeUndefined ( )
440+ expect ( headers [ 'Sec-Ch-Ua-Mobile' ] ) . toBeUndefined ( )
441+ expect ( headers [ 'Sec-Ch-Ua-Platform' ] ) . toBeUndefined ( )
442+ expect ( headers . Referer ) . toBeUndefined ( )
464443 expect ( headers . Host ) . toBe ( 'api.example.com' )
465-
466- global . window = originalWindow
467444 } )
468445
469446 it ( 'should allow overriding default headers' , async ( ) => {
0 commit comments