From 86df1df8e74f4d5c0b33a07d9eb1f5ce0161e073 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 4 May 2021 18:59:39 +0000 Subject: [PATCH] test: update download test expectations (#6394) --- tests/config/utils.ts | 12 ++++++++++++ tests/download.spec.ts | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/config/utils.ts b/tests/config/utils.ts index 4c2d0f863a..4e24a05619 100644 --- a/tests/config/utils.ts +++ b/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; +} \ No newline at end of file diff --git a/tests/download.spec.ts b/tests/download.spec.ts index 0ab8f27906..723ab26a74 100644 --- a/tests/download.spec.ts +++ b/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) => {