From 553ecce4f9d363bfb9962e5bb7dfe8a5c499a603 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 24 Aug 2022 17:45:15 +0200 Subject: [PATCH] test: add test for PDF download per navigation (#16687) * test: add test for PDF download per click * Update download.spec.ts --- tests/library/download.spec.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/library/download.spec.ts b/tests/library/download.spec.ts index 596eccc2b7..216960187a 100644 --- a/tests/library/download.spec.ts +++ b/tests/library/download.spec.ts @@ -613,7 +613,7 @@ it('should be able to download a PDF file', async ({ browser, server, asset }) = await page.close(); }); -it('should be able to download a inline PDF file', async ({ browser, server, asset, browserName }) => { +it('should be able to download a inline PDF file via response interception', async ({ browser, server, asset, browserName }) => { it.fixme(browserName === 'webkit'); const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); @@ -638,6 +638,21 @@ it('should be able to download a inline PDF file', async ({ browser, server, ass await page.close(); }); +it('should be able to download a inline PDF file via navigation', async ({ browser, server, asset, browserName }) => { + it.fixme(browserName === 'chromium' || browserName === 'webkit'); + const page = await browser.newPage(); + await page.goto(server.EMPTY_PAGE); + await page.setContent(` + open + `); + const [download] = await Promise.all([ + page.waitForEvent('download'), + page.click('a'), + ]); + await assertDownloadToPDF(download, asset('empty.pdf')); + await page.close(); +}); + it('should save to user-specified path', async ({ browser, server, mode }, testInfo) => { server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream');