From 25bc4c4ac7a189e2616d21ddbd42241853b0b3f9 Mon Sep 17 00:00:00 2001 From: Ross Wollman Date: Tue, 21 Jun 2022 16:53:36 -0700 Subject: [PATCH] tests: async fallback handlers (#15027) --- tests/library/browsercontext-route.spec.ts | 21 +++++++++++++++++++++ tests/page/page-request-fallback.spec.ts | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tests/library/browsercontext-route.spec.ts b/tests/library/browsercontext-route.spec.ts index 8b7ae35a4e..80e0f7a020 100644 --- a/tests/library/browsercontext-route.spec.ts +++ b/tests/library/browsercontext-route.spec.ts @@ -330,3 +330,24 @@ it('should chain fallback into page', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); expect(intercepted).toEqual([6, 5, 4, 3, 2, 1]); }); + +it('should fall back async', async ({ page, context, server }) => { + const intercepted = []; + await context.route('**/empty.html', async route => { + intercepted.push(1); + await new Promise(r => setTimeout(r, 100)); + route.fallback(); + }); + await context.route('**/empty.html', async route => { + intercepted.push(2); + await new Promise(r => setTimeout(r, 100)); + route.fallback(); + }); + await context.route('**/empty.html', async route => { + intercepted.push(3); + await new Promise(r => setTimeout(r, 100)); + route.fallback(); + }); + await page.goto(server.EMPTY_PAGE); + expect(intercepted).toEqual([3, 2, 1]); +}); diff --git a/tests/page/page-request-fallback.spec.ts b/tests/page/page-request-fallback.spec.ts index 9b14617f7e..2e4093c641 100644 --- a/tests/page/page-request-fallback.spec.ts +++ b/tests/page/page-request-fallback.spec.ts @@ -40,6 +40,27 @@ it('should fall back', async ({ page, server }) => { expect(intercepted).toEqual([3, 2, 1]); }); +it('should fall back async', async ({ page, server }) => { + const intercepted = []; + await page.route('**/empty.html', async route => { + intercepted.push(1); + await new Promise(r => setTimeout(r, 100)); + route.fallback(); + }); + await page.route('**/empty.html', async route => { + intercepted.push(2); + await new Promise(r => setTimeout(r, 100)); + route.fallback(); + }); + await page.route('**/empty.html', async route => { + intercepted.push(3); + await new Promise(r => setTimeout(r, 100)); + route.fallback(); + }); + await page.goto(server.EMPTY_PAGE); + expect(intercepted).toEqual([3, 2, 1]); +}); + it('should not chain fulfill', async ({ page, server }) => { let failed = false; await page.route('**/empty.html', route => {