Skip to content

Commit

Permalink
test: update download test expectations (#6394)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s authored May 4, 2021
1 parent 5326f39 commit 86df1df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions tests/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ export function expectedSSLError(browserName: string): string {
}
return expectedSSLError;
}

export function chromiumVersionLessThan(a: string, b: string) {
const left: number[] = a.split('.').map(e => Number(e));
const right: number[] = b.split('.').map(e => Number(e));
for (let i = 0; i < 4; i++) {
if (left[i] > right[i])
return false;
if (left[i] < right[i])
return true;
}
return false;
}
8 changes: 6 additions & 2 deletions tests/download.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import fs from 'fs';
import path from 'path';
import util from 'util';
import crypto from 'crypto';
import { chromiumVersionLessThan } from './config/utils';

it.describe('download event', () => {
it.beforeEach(async ({server}) => {
Expand Down Expand Up @@ -361,7 +362,7 @@ it.describe('download event', () => {
expect(fs.existsSync(path.join(path1, '..'))).toBeFalsy();
});

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

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

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

0 comments on commit 86df1df

Please sign in to comment.