@@ -412,6 +412,46 @@ it('should update har.zip for context', async ({ contextFactory, server }, testI
412
412
await expect ( page2 . locator ( 'body' ) ) . toHaveCSS ( 'background-color' , 'rgb(255, 192, 203)' ) ;
413
413
} ) ;
414
414
415
+ it ( 'should ignore boundary when matching multipart/form-data body' , {
416
+ annotation : { type : 'issue' , description : 'https://github.com/microsoft/playwright/issues/31495' }
417
+ } , async ( { contextFactory, server } , testInfo ) => {
418
+ server . setRoute ( '/empty.html' , ( req , res ) => {
419
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
420
+ res . end ( `
421
+ <form id="form" action="form.html" enctype="multipart/form-data" method="POST">
422
+ <input id="file" type="file" multiple />
423
+ <button type="submit">Upload</button>
424
+ </form>` ) ;
425
+ } ) ;
426
+ server . setRoute ( '/form.html' , ( req , res ) => {
427
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
428
+ res . end ( '<div>done</div>' ) ;
429
+ } ) ;
430
+
431
+ const harPath = testInfo . outputPath ( 'har.zip' ) ;
432
+ const context1 = await contextFactory ( ) ;
433
+ await context1 . routeFromHAR ( harPath , { update : true } ) ;
434
+ const page1 = await context1 . newPage ( ) ;
435
+ await page1 . goto ( server . PREFIX + '/empty.html' ) ;
436
+ const reqPromise = server . waitForRequest ( '/form.html' ) ;
437
+ await page1 . locator ( 'button' ) . click ( ) ;
438
+ await expect ( page1 . locator ( 'div' ) ) . toHaveText ( 'done' ) ;
439
+ const req = await reqPromise ;
440
+ expect ( ( await req . postBody ) . toString ( ) ) . toContain ( '---' ) ;
441
+ await context1 . close ( ) ;
442
+
443
+ const context2 = await contextFactory ( ) ;
444
+ await context2 . routeFromHAR ( harPath , { notFound : 'abort' } ) ;
445
+ const page2 = await context2 . newPage ( ) ;
446
+ await page2 . goto ( server . PREFIX + '/empty.html' ) ;
447
+ const requestPromise = page2 . waitForRequest ( / .* f o r m .h t m l / ) ;
448
+ await page2 . locator ( 'button' ) . click ( ) ;
449
+ const request = await requestPromise ;
450
+ expect . soft ( await request . response ( ) ) . toBeTruthy ( ) ;
451
+ expect ( request . failure ( ) ) . toBe ( null ) ;
452
+ await expect ( page2 . locator ( 'div' ) ) . toHaveText ( 'done' ) ;
453
+ } ) ;
454
+
415
455
it ( 'should update har.zip for page' , async ( { contextFactory, server } , testInfo ) => {
416
456
const harPath = testInfo . outputPath ( 'har.zip' ) ;
417
457
const context1 = await contextFactory ( ) ;
@@ -428,7 +468,6 @@ it('should update har.zip for page', async ({ contextFactory, server }, testInfo
428
468
await expect ( page2 . locator ( 'body' ) ) . toHaveCSS ( 'background-color' , 'rgb(255, 192, 203)' ) ;
429
469
} ) ;
430
470
431
-
432
471
it ( 'should update har.zip for page with different options' , async ( { contextFactory, server } , testInfo ) => {
433
472
const harPath = testInfo . outputPath ( 'har.zip' ) ;
434
473
const context1 = await contextFactory ( ) ;
0 commit comments