@@ -11,7 +11,7 @@ test.describe('network signals - fetch', () => {
1111 await indexPage . loadAndWait ( page , basicEdgeFn )
1212 } )
1313
14- test ( 'should not emit non-json requests without the body ' , async ( ) => {
14+ test ( 'should not emit non-json requests' , async ( ) => {
1515 await indexPage . network . mockTestRoute ( 'http://localhost/upload' , {
1616 body : JSON . stringify ( { foo : 'test' } ) ,
1717 } )
@@ -27,12 +27,10 @@ test.describe('network signals - fetch', () => {
2727 ( el ) => el . properties ! . data . action === 'request'
2828 )
2929
30- expect ( requests ) . toHaveLength ( 1 )
31- expect ( requests [ 0 ] . properties ! . data . url ) . toBe ( 'http://localhost/upload' )
32- expect ( requests [ 0 ] . properties ! . data . data ) . toBeNull ( )
30+ expect ( requests ) . toHaveLength ( 0 )
3331 } )
3432
35- test ( 'should handle text/plain' , async ( ) => {
33+ test ( 'should try to parse the body of text/plain requests ' , async ( ) => {
3634 await indexPage . network . mockTestRoute ( 'http://localhost/test' , {
3735 body : JSON . stringify ( { foo : 'test' } ) ,
3836 contentType : 'application/json' ,
@@ -61,7 +59,7 @@ test.describe('network signals - fetch', () => {
6159 } )
6260 } )
6361
64- test ( 'should send the body as string if it cant be parsed to json' , async ( ) => {
62+ test ( 'should send the raw string if the request body cannot be parsed as json' , async ( ) => {
6563 await indexPage . network . mockTestRoute ( 'http://localhost/test' , {
6664 body : JSON . stringify ( { foo : 'test' } ) ,
6765 contentType : 'application/json' ,
@@ -170,39 +168,6 @@ test.describe('network signals - fetch', () => {
170168 } )
171169 } )
172170
173- test ( 'should emit response but not request if request content-type is not json but response is' , async ( ) => {
174- await indexPage . network . mockTestRoute ( 'http://localhost/test' , {
175- body : JSON . stringify ( { foo : 'test' } ) ,
176- contentType : 'application/json' ,
177- } )
178-
179- await indexPage . network . makeFetchCall ( 'http://localhost/test' , {
180- method : 'POST' ,
181- body : 'hello world' ,
182- contentType : 'text/plain' ,
183- } )
184-
185- await indexPage . waitForSignalsApiFlush ( )
186-
187- const networkEvents = indexPage . signalsAPI . getEvents ( 'network' )
188-
189- const responses = networkEvents . filter (
190- ( el ) => el . properties ! . data . action === 'response'
191- )
192- expect ( responses ) . toHaveLength ( 1 )
193- expect ( responses [ 0 ] . properties ! . data ) . toMatchObject ( {
194- action : 'response' ,
195- url : 'http://localhost/test' ,
196- data : { foo : 'test' } ,
197- } )
198-
199- // Ensure no request was captured
200- const requests = networkEvents . filter (
201- ( el ) => el . properties ! . data . action === 'request'
202- )
203- expect ( requests ) . toHaveLength ( 0 )
204- } )
205-
206171 test . describe ( 'errors' , ( ) => {
207172 test ( 'will handle a json error response' , async ( ) => {
208173 await indexPage . network . mockTestRoute ( 'http://localhost/test' , {
@@ -286,11 +251,7 @@ test.describe('network signals - fetch', () => {
286251 status : 400 ,
287252 } )
288253
289- await indexPage . network . makeFetchCall ( 'http://localhost/test' , {
290- method : 'POST' ,
291- body : 'hello world' ,
292- contentType : 'text/plain' ,
293- } )
254+ await indexPage . network . makeFileUploadRequest ( 'http://localhost/test' )
294255
295256 await indexPage . waitForSignalsApiFlush ( )
296257
0 commit comments