Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: update download test expectations (#6394)

Yury Semikhatsky86df1df8e74f
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) => {