test: add test for PDF download per navigation (#16687)

* test: add test for PDF download per click

* Update download.spec.ts
This commit is contained in:
Max Schmitt 2022-08-24 17:45:15 +02:00 committed by GitHub
parent c4e91bded1
commit 553ecce4f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(`
<a href="/empty.pdf">open</a>
`);
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');