From 97ae1d5cb648655a111b4a4f46e4444ea4394607 Mon Sep 17 00:00:00 2001 From: "Ross A. Wollman" Date: Wed, 22 Apr 2020 14:03:56 -0700 Subject: [PATCH] Add failing tests The fail with: ``` NON-TEST ERROR #1: UNHANDLED PROMISE REJECTION Error: Pass { acceptDownloads: true } when you are creating your browser context. ``` which shows the issue we were running into. --- package-lock.json | 15 ++++++++++++++- package.json | 1 + test/download.spec.js | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 9015275e9b54d1..bc1c3970f0bb8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "playwright-core", - "version": "0.13.0-post", + "version": "0.14.0-post", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -417,6 +417,11 @@ "type-fest": "^0.8.1" } }, + "ansi-font": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/ansi-font/-/ansi-font-0.0.2.tgz", + "integrity": "sha1-iQMBvVhBRi/TnAt3Ca/R9SUUMzE=" + }, "ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", @@ -5044,6 +5049,14 @@ } } }, + "test": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/test/-/test-0.6.0.tgz", + "integrity": "sha1-WYasRF7Bd1QyJRLRBLoyyKY+k44=", + "requires": { + "ansi-font": "0.0.2" + } + }, "text-diff": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/text-diff/-/text-diff-1.0.1.tgz", diff --git a/package.json b/package.json index 400604e3763ab8..363b94dfaa9cd6 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "progress": "^2.0.3", "proxy-from-env": "^1.1.0", "rimraf": "^3.0.2", + "test": "^0.6.0", "ws": "^6.1.0" }, "devDependencies": { diff --git a/test/download.spec.js b/test/download.spec.js index bc79ae47e0695c..9160805c45ff43 100644 --- a/test/download.spec.js +++ b/test/download.spec.js @@ -70,6 +70,20 @@ describe('Download', function() { expect(fs.readFileSync(path).toString()).toBe('Hello world'); await page.close(); }); + fit(`should report download path within page.on('download', …) handler`, async({browser, server}) => { + const page = await browser.newPage({ acceptDownloads: true }); + const onDownloadPathPath = new Promise((res, rej) => { + setTimeout(() => { rej('failed to find path quickly'); }, 1000); + + page.on('download', dl => { + dl.path().then(res); + }); + }); + await page.setContent(`download`); + await page.click('a'); + const path = await onDownloadPathPath; + expect(fs.readFileSync(path).toString()).toBe('Hello world'); + }) it.skip(FFOX).fail(CHROMIUM || WEBKIT)('should report alt-click downloads', async({browser, server}) => { // Firefox does not download on alt-click by default. // Our WebKit embedder does not download on alt-click, although Safari does.