Skip to content

Commit 86df1df

Browse files
authored
test: update download test expectations (#6394)
1 parent 5326f39 commit 86df1df

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/config/utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,15 @@ export function expectedSSLError(browserName: string): string {
5858
}
5959
return expectedSSLError;
6060
}
61+
62+
export function chromiumVersionLessThan(a: string, b: string) {
63+
const left: number[] = a.split('.').map(e => Number(e));
64+
const right: number[] = b.split('.').map(e => Number(e));
65+
for (let i = 0; i < 4; i++) {
66+
if (left[i] > right[i])
67+
return false;
68+
if (left[i] < right[i])
69+
return true;
70+
}
71+
return false;
72+
}

tests/download.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import fs from 'fs';
1919
import path from 'path';
2020
import util from 'util';
2121
import crypto from 'crypto';
22+
import { chromiumVersionLessThan } from './config/utils';
2223

2324
it.describe('download event', () => {
2425
it.beforeEach(async ({server}) => {
@@ -361,7 +362,7 @@ it.describe('download event', () => {
361362
expect(fs.existsSync(path.join(path1, '..'))).toBeFalsy();
362363
});
363364

364-
it('should close the context without awaiting the failed download', async ({browser, server, httpsServer, browserName}, testInfo) => {
365+
it('should close the context without awaiting the failed download', async ({browser, server, httpsServer, browserName, browserVersion}, testInfo) => {
365366
it.skip(browserName !== 'chromium', 'Only Chromium downloads on alt-click');
366367

367368
const page = await browser.newPage({ acceptDownloads: true });
@@ -379,7 +380,10 @@ it.describe('download event', () => {
379380
page.context().close(),
380381
]);
381382
expect(downloadPath).toBe(null);
382-
expect(saveError.message).toContain('File deleted upon browser context closure.');
383+
if (chromiumVersionLessThan(browserVersion, '91.0.4472.0'))
384+
expect(saveError.message).toContain('File deleted upon browser context closure.');
385+
else
386+
expect(saveError.message).toContain('File not found on disk. Check download.failure() for details.');
383387
});
384388

385389
it('should close the context without awaiting the download', async ({browser, server, browserName, platform}, testInfo) => {

0 commit comments

Comments
 (0)