test: add debugging output for downloads tests (#5673)
This commit is contained in:
parent
f925a033e2
commit
850e3c5aa3
|
|
@ -45,15 +45,20 @@ fixtures.persistentDownloadsContext.init(async ({ server, launchPersistent, test
|
||||||
res.setHeader('Content-Disposition', 'attachment; filename=file.txt');
|
res.setHeader('Content-Disposition', 'attachment; filename=file.txt');
|
||||||
res.end(`Hello world`);
|
res.end(`Hello world`);
|
||||||
});
|
});
|
||||||
|
console.log('--- launching persistent context ---');
|
||||||
const { context, page } = await launchPersistent(
|
const { context, page } = await launchPersistent(
|
||||||
{
|
{
|
||||||
downloadsPath: testInfo.outputPath(''),
|
downloadsPath: testInfo.outputPath(''),
|
||||||
acceptDownloads: true
|
acceptDownloads: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
console.log('--- setting content for the page ---');
|
||||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||||
|
console.log('--- launching test ---');
|
||||||
await test(context);
|
await test(context);
|
||||||
|
console.log('--- closing context ---');
|
||||||
await context.close();
|
await context.close();
|
||||||
|
console.log('--- DONE ---');
|
||||||
});
|
});
|
||||||
|
|
||||||
const { it, expect } = fixtures.build();
|
const { it, expect } = fixtures.build();
|
||||||
|
|
@ -99,25 +104,49 @@ it('should report downloads in downloadsPath folder', async ({downloadsBrowser,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept downloads in persistent context', async ({persistentDownloadsContext, testInfo, server}) => {
|
it('should accept downloads in persistent context', async ({persistentDownloadsContext, testInfo, server}) => {
|
||||||
|
console.log('----- 1.1');
|
||||||
const page = persistentDownloadsContext.pages()[0];
|
const page = persistentDownloadsContext.pages()[0];
|
||||||
|
console.log('----- 1.2');
|
||||||
const [ download ] = await Promise.all([
|
const [ download ] = await Promise.all([
|
||||||
page.waitForEvent('download'),
|
page.waitForEvent('download').then(d => {
|
||||||
page.click('a')
|
console.log('----- 1.3');
|
||||||
|
return d;
|
||||||
|
}),
|
||||||
|
page.click('a').then(d => {
|
||||||
|
console.log('----- 1.4');
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
|
console.log('----- 1.5');
|
||||||
expect(download.url()).toBe(`${server.PREFIX}/download`);
|
expect(download.url()).toBe(`${server.PREFIX}/download`);
|
||||||
|
console.log('----- 1.6');
|
||||||
expect(download.suggestedFilename()).toBe(`file.txt`);
|
expect(download.suggestedFilename()).toBe(`file.txt`);
|
||||||
|
console.log('----- 1.7');
|
||||||
const path = await download.path();
|
const path = await download.path();
|
||||||
|
console.log('----- 1.8');
|
||||||
expect(path.startsWith(testInfo.outputPath(''))).toBeTruthy();
|
expect(path.startsWith(testInfo.outputPath(''))).toBeTruthy();
|
||||||
|
console.log('----- 1.9');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete downloads when persistent context closes', async ({persistentDownloadsContext}) => {
|
it('should delete downloads when persistent context closes', async ({persistentDownloadsContext}) => {
|
||||||
|
console.log('----- 2.1');
|
||||||
const page = persistentDownloadsContext.pages()[0];
|
const page = persistentDownloadsContext.pages()[0];
|
||||||
|
console.log('----- 2.2');
|
||||||
const [ download ] = await Promise.all([
|
const [ download ] = await Promise.all([
|
||||||
page.waitForEvent('download'),
|
page.waitForEvent('download').then(d => {
|
||||||
page.click('a')
|
console.log('----- 2.3');
|
||||||
|
return d;
|
||||||
|
}),
|
||||||
|
page.click('a').then(() => {
|
||||||
|
console.log('----- 2.4');
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
|
console.log('----- 2.5');
|
||||||
const path = await download.path();
|
const path = await download.path();
|
||||||
|
console.log('----- 2.6');
|
||||||
expect(fs.existsSync(path)).toBeTruthy();
|
expect(fs.existsSync(path)).toBeTruthy();
|
||||||
|
console.log('----- 2.7');
|
||||||
await persistentDownloadsContext.close();
|
await persistentDownloadsContext.close();
|
||||||
|
console.log('----- 2.8');
|
||||||
expect(fs.existsSync(path)).toBeFalsy();
|
expect(fs.existsSync(path)).toBeFalsy();
|
||||||
|
console.log('----- 2.9');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue