Browse Source

test: update download test expectations (#6394)

pull/6408/head
Yury Semikhatsky 1 week ago
committed by GitHub
parent
commit
86df1df8e7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      tests/config/utils.ts
  2. 8
      tests/download.spec.ts

12
tests/config/utils.ts

@ -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
tests/download.spec.ts

@ -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}) => {
@ -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 });
@ -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) => {

Loading…
Cancel
Save