From baaac7dd38f34bb05557eb4eb0df6ec759cc710a Mon Sep 17 00:00:00 2001 From: iseulde Date: Fri, 2 Aug 2019 10:35:00 +0200 Subject: [PATCH 01/15] Add e2e test --- .../__snapshots__/rich-text.test.js.snap | 6 +++++ packages/e2e-tests/specs/rich-text.test.js | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap index 3c7044b5fb8053..714b0f92ce2286 100644 --- a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap @@ -65,3 +65,9 @@ exports[`RichText should transform backtick to code 2`] = `

A \`backtick\`

" `; + +exports[`RichText should update internal selection after fresh focus 1`] = ` +" +

12

+" +`; diff --git a/packages/e2e-tests/specs/rich-text.test.js b/packages/e2e-tests/specs/rich-text.test.js index a7acef1d2aeaf0..b0660249dc53c5 100644 --- a/packages/e2e-tests/specs/rich-text.test.js +++ b/packages/e2e-tests/specs/rich-text.test.js @@ -216,4 +216,30 @@ describe( 'RichText', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); + + it( 'should update internal selection after fresh focus', async () => { + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '1' ); + // Focus the address bar (move focus out of the window). + await pressKeyWithModifier( 'primary', 'l' ); + // Ensure the element lost focus. + // Stangely enough, this is not needed when testing manually. + await page.evaluate( () => { + document.querySelector( '.wp-block-paragraph' ).blur(); + } ); + // Focus the rich text instance again (not at the start). + await page.click( '.wp-block-paragraph', { button: 'middle' } ); + // Wait for animation frame. + await page.evaluate( async () => { + await new Promise( ( resolve ) => { + window.requestAnimationFrame( resolve ); + } ); + } ); + // Should internally set bold at selection. + await pressKeyWithModifier( 'primary', 'b' ); + // "2" should be bold. + await page.keyboard.type( '2' ); + + expect( await getEditedPostContent() ).toMatchSnapshot(); + } ); } ); From f7addc33752f92b00d39b0bb38215422efae8c8e Mon Sep 17 00:00:00 2001 From: iseulde Date: Fri, 2 Aug 2019 11:30:17 +0200 Subject: [PATCH 02/15] Update selection on mouseup/keyup/touchend --- packages/e2e-tests/specs/rich-text.test.js | 6 ------ packages/e2e-tests/specs/writing-flow.test.js | 1 - packages/rich-text/src/component/index.js | 15 ++++++++------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/e2e-tests/specs/rich-text.test.js b/packages/e2e-tests/specs/rich-text.test.js index b0660249dc53c5..ab10c297506c5d 100644 --- a/packages/e2e-tests/specs/rich-text.test.js +++ b/packages/e2e-tests/specs/rich-text.test.js @@ -229,12 +229,6 @@ describe( 'RichText', () => { } ); // Focus the rich text instance again (not at the start). await page.click( '.wp-block-paragraph', { button: 'middle' } ); - // Wait for animation frame. - await page.evaluate( async () => { - await new Promise( ( resolve ) => { - window.requestAnimationFrame( resolve ); - } ); - } ); // Should internally set bold at selection. await pressKeyWithModifier( 'primary', 'b' ); // "2" should be bold. diff --git a/packages/e2e-tests/specs/writing-flow.test.js b/packages/e2e-tests/specs/writing-flow.test.js index 3c8c4b39e1b36b..f96b1f1602e661 100644 --- a/packages/e2e-tests/specs/writing-flow.test.js +++ b/packages/e2e-tests/specs/writing-flow.test.js @@ -316,7 +316,6 @@ describe( 'Writing Flow', () => { it( 'should navigate empty paragraph', async () => { await clickBlockAppender(); await page.keyboard.press( 'Enter' ); - await page.waitForFunction( () => document.activeElement.isContentEditable ); await page.keyboard.press( 'ArrowLeft' ); await page.keyboard.type( '1' ); await page.keyboard.press( 'ArrowRight' ); diff --git a/packages/rich-text/src/component/index.js b/packages/rich-text/src/component/index.js index 513cb480279049..ca4c1c9550092d 100644 --- a/packages/rich-text/src/component/index.js +++ b/packages/rich-text/src/component/index.js @@ -288,7 +288,7 @@ class RichText extends Component { this.recalculateBoundaryStyle(); // We know for certain that on focus, the old selection is invalid. It - // will be recalculated on the next animation frame. + // will be recalculated on the next mouseup, keyup, or touchend event. const index = undefined; const activeFormats = undefined; @@ -301,12 +301,6 @@ class RichText extends Component { this.props.onSelectionChange( index, index ); this.setState( { activeFormats } ); - // Update selection as soon as possible, which is at the next animation - // frame. The event listener for selection changes may be added too late - // at this point, but this focus event is still too early to calculate - // the selection. - this.rafId = window.requestAnimationFrame( this.onSelectionChange ); - document.addEventListener( 'selectionchange', this.onSelectionChange ); } @@ -911,6 +905,13 @@ class RichText extends Component { onMouseDown={ this.onPointerDown } onTouchStart={ this.onPointerDown } setRef={ this.setRef } + // Selection updates must be done at these events as they + // happen before the `selectionchange` event. In some cases, + // the `selectionchange` event may not even fire, for + // example when the window receives focus again on click. + onKeyUp={ this.onSelectionChange } + onMouseUp={ this.onSelectionChange } + onTouchEnd={ this.onSelectionChange } /> { isSelected && Date: Fri, 2 Aug 2019 14:32:32 +0200 Subject: [PATCH 03/15] Try to fix e2e tests --- packages/rich-text/src/component/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/rich-text/src/component/index.js b/packages/rich-text/src/component/index.js index ca4c1c9550092d..e762b192ba8073 100644 --- a/packages/rich-text/src/component/index.js +++ b/packages/rich-text/src/component/index.js @@ -386,8 +386,17 @@ class RichText extends Component { /** * Handles the `selectionchange` event: sync the selection to local state. + * + * @param {Event} event `selectionchange` event. */ - onSelectionChange() { + onSelectionChange( event ) { + if ( + event.type !== 'selectionchange' && + ! this.props.__unstableIsSelected + ) { + return; + } + const { start, end } = this.createRecord(); const value = this.getRecord(); From 419d83227c0b1286cc7982652638a57044783946 Mon Sep 17 00:00:00 2001 From: iseulde Date: Fri, 2 Aug 2019 16:47:59 +0200 Subject: [PATCH 04/15] Attempt to upgrade Puppeteer --- package-lock.json | 479 ++++++++++++------ package.json | 1 + packages/e2e-test-utils/README.md | 4 - packages/e2e-test-utils/package.json | 2 +- .../e2e-test-utils/src/press-key-times.js | 26 +- packages/e2e-tests/package.json | 4 +- .../plugins/deprecated-node-matcher/index.js | 2 - packages/jest-puppeteer-axe/package.json | 2 +- packages/scripts/package.json | 4 +- 9 files changed, 322 insertions(+), 202 deletions(-) diff --git a/package-lock.json b/package-lock.json index 83fca7b32a5d4c..006fb4190fcbdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4705,8 +4705,16 @@ "@wordpress/jest-console": "file:packages/jest-console", "@wordpress/jest-puppeteer-axe": "file:packages/jest-puppeteer-axe", "@wordpress/scripts": "file:packages/scripts", - "expect-puppeteer": "^4.0.0", + "expect-puppeteer": "^4.3.0", "lodash": "^4.17.14" + }, + "dependencies": { + "expect-puppeteer": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/expect-puppeteer/-/expect-puppeteer-4.3.0.tgz", + "integrity": "sha512-p8N/KSVPG9PAOJlftK5f1n3JrULJ6Qq1EQ8r/n9xzkX2NmXbK8PcnJnkSAEzEHrMycELKGnlJV7M5nkgm+wEWA==", + "dev": true + } } }, "@wordpress/edit-post": { @@ -5015,10 +5023,10 @@ "cross-spawn": "^5.1.0", "eslint": "^5.16.0", "jest": "^24.7.1", - "jest-puppeteer": "^4.0.0", + "jest-puppeteer": "^4.3.0", "minimist": "^1.2.0", "npm-package-json-lint": "^3.6.0", - "puppeteer": "1.6.1", + "puppeteer": "1.19.0", "read-pkg-up": "^1.0.1", "resolve-bin": "^0.4.0", "source-map-loader": "^0.2.4", @@ -5029,6 +5037,161 @@ "webpack-bundle-analyzer": "^3.3.2", "webpack-cli": "^3.1.2", "webpack-livereload-plugin": "^2.2.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "expect-puppeteer": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/expect-puppeteer/-/expect-puppeteer-4.3.0.tgz", + "integrity": "sha512-p8N/KSVPG9PAOJlftK5f1n3JrULJ6Qq1EQ8r/n9xzkX2NmXbK8PcnJnkSAEzEHrMycELKGnlJV7M5nkgm+wEWA==", + "dev": true + }, + "find-process": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/find-process/-/find-process-1.4.2.tgz", + "integrity": "sha512-O83EVJr4dWvHJ7QpUzANNAMeQVKukRzRqRx4AIzdLYRrQorRdbqDwLPigkd9PYPhJRhmNPAoVjOm9bcwSmcZaw==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "commander": "^2.11.0", + "debug": "^2.6.8" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "jest-dev-server": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/jest-dev-server/-/jest-dev-server-4.3.0.tgz", + "integrity": "sha512-bC9flKY2G1honQ/UI0gEhb0wFnDhpFr7xidC8Nk+evi7TgnNtfsGIzzF2dcIhF1G9BGF0n/M7CJrMAzwQhyTPA==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "cwd": "^0.10.0", + "find-process": "^1.4.2", + "prompts": "^2.1.0", + "spawnd": "^4.0.0", + "tree-kill": "^1.2.1", + "wait-on": "^3.3.0" + }, + "dependencies": { + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + } + } + }, + "jest-environment-puppeteer": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/jest-environment-puppeteer/-/jest-environment-puppeteer-4.3.0.tgz", + "integrity": "sha512-ZighMsU39bnacn2ylyHb88CB+ldgCfXGD3lS78k4PEo8A8xyt6+2mxmSR62FH3Y7K+W2gPDu5+QM3/LZuq42fQ==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "cwd": "^0.10.0", + "jest-dev-server": "^4.3.0", + "merge-deep": "^3.0.2" + }, + "dependencies": { + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + } + } + }, + "jest-puppeteer": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/jest-puppeteer/-/jest-puppeteer-4.3.0.tgz", + "integrity": "sha512-WXhaWlbQl01xadZyNmdZntrtIr8uWUmgjPogDih7dOnr3G/xRr3A034SCqdjwV6fE0tqz7c5hwO8oBTyGZPRgA==", + "dev": true, + "requires": { + "expect-puppeteer": "^4.3.0", + "jest-environment-puppeteer": "^4.3.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "prompts": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz", + "integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==", + "dev": true, + "requires": { + "kleur": "^3.0.2", + "sisteransi": "^1.0.0" + } + }, + "puppeteer": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.19.0.tgz", + "integrity": "sha512-2S6E6ygpoqcECaagDbBopoSOPDv0pAZvTbnBgUY+6hq0/XDFDOLEMNlHF/SKJlzcaZ9ckiKjKDuueWI3FN/WXw==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "extract-zip": "^1.6.6", + "https-proxy-agent": "^2.2.1", + "mime": "^2.0.3", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^2.6.1", + "ws": "^6.1.0" + } + }, + "tree-kill": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.1.tgz", + "integrity": "sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q==", + "dev": true + }, + "ws": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } + } } }, "@wordpress/server-side-render": { @@ -10915,12 +11078,6 @@ "jest-regex-util": "^24.3.0" } }, - "expect-puppeteer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/expect-puppeteer/-/expect-puppeteer-4.0.0.tgz", - "integrity": "sha512-K7D6WRUWR0CtQLqf9ZMBQNkpbhQzxWkKEt9/PnVl+aWMF0xcdV7JW9AClxNprzXkrUq/ILws3H2u6dWcEEjRSQ==", - "dev": true - }, "express": { "version": "4.16.3", "resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", @@ -11473,35 +11630,6 @@ "find-file-up": "^0.1.2" } }, - "find-process": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/find-process/-/find-process-1.2.1.tgz", - "integrity": "sha512-z4RXYStNAcoi4+smpKbzJXbMT8DdvwqTE7wL7DWZMD0SkTRfQ49z9S7YaK24kuRseKr23YSZlnyL/TaJZtgM1g==", - "dev": true, - "requires": { - "chalk": "^2.0.1", - "commander": "^2.11.0", - "debug": "^2.6.8", - "lodash": "^4.17.11" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true - } - } - }, "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", @@ -14599,91 +14727,6 @@ } } }, - "jest-dev-server": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jest-dev-server/-/jest-dev-server-4.0.0.tgz", - "integrity": "sha512-tq3fHPM8BDbu/71yIxgGgZW62s1Em6rLNDce0/ff/4No093OyjUEPM8yIUaoBt4pxwwRGkaS1EZB5PzCmRLGkg==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "cwd": "^0.10.0", - "find-process": "^1.2.1", - "inquirer": "^6.2.2", - "spawnd": "^4.0.0", - "tree-kill": "^1.2.1", - "wait-port": "^0.2.2" - }, - "dependencies": { - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true - }, - "ansi-regex": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.0.0.tgz", - "integrity": "sha512-iB5Dda8t/UqpPI/IjsejXu5jOGDrzn41wJyljwPH65VCIbk6+1BzFIMJGFwTNrYXT1CrD+B4l19U7awiQ8rk7w==", - "dev": true - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "inquirer": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.2.tgz", - "integrity": "sha512-Z2rREiXA6cHRR9KBOarR3WuLlFzlIfAEIiB45ll5SSadMg7WqOh1MKEjjndfuH5ewXdixWCxqnVfGOQzPeiztA==", - "dev": true, - "requires": { - "ansi-escapes": "^3.2.0", - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.11", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rxjs": "^6.4.0", - "string-width": "^2.1.0", - "strip-ansi": "^5.0.0", - "through": "^2.3.6" - } - }, - "rxjs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", - "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, - "strip-ansi": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.0.0.tgz", - "integrity": "sha512-Uu7gQyZI7J7gn5qLn1Np3G9vcYGTVqB+lFTytnDJv83dd8T22aGH451P3jueT2/QemInJDfxHB5Tde5OzgG1Ow==", - "dev": true, - "requires": { - "ansi-regex": "^4.0.0" - } - }, - "tree-kill": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.1.tgz", - "integrity": "sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q==", - "dev": true - } - } - }, "jest-diff": { "version": "24.7.0", "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-24.7.0.tgz", @@ -14753,31 +14796,6 @@ "jest-util": "^24.7.1" } }, - "jest-environment-puppeteer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jest-environment-puppeteer/-/jest-environment-puppeteer-4.0.0.tgz", - "integrity": "sha512-IdbfZW1TjT1lmdPlvlHi4S+CAHuGk63fzGUpQAUeadm77saSJISDMuYS5b7kZ6lXZtc4myu53TkMWDYhh60XOA==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "cwd": "^0.10.0", - "jest-dev-server": "^4.0.0", - "merge-deep": "^3.0.2" - }, - "dependencies": { - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - } - } - }, "jest-get-type": { "version": "24.3.0", "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.3.0.tgz", @@ -14908,16 +14926,6 @@ "integrity": "sha512-pgFw2tm54fzgYvc/OHrnysABEObZCUNFnhjoRjaVOCN8NYc032/gVjPaHD4Aq6ApkSieWtfKAFQtmDKAmhupnQ==", "dev": true }, - "jest-puppeteer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jest-puppeteer/-/jest-puppeteer-4.0.0.tgz", - "integrity": "sha512-B/5BlePsYmxTVmWD0E3zEuYfrTPk66EZskRlZhdDuXLoUAWPRu2+J/egnXh5GO+pUqkELffn5gfPulpn21rY7A==", - "dev": true, - "requires": { - "expect-puppeteer": "^4.0.0", - "jest-environment-puppeteer": "^4.0.0" - } - }, "jest-regex-util": { "version": "24.3.0", "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-24.3.0.tgz", @@ -21122,25 +21130,40 @@ "dev": true }, "puppeteer": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.6.1.tgz", - "integrity": "sha512-qz6DLwK+PhlBMjJZOMOsgVCnweYLtmiqnmJYUDPT++ElMz+cQgbsCNKPw4YDVpg3RTbsRX/pqQqr20zrp0cuKw==", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.19.0.tgz", + "integrity": "sha512-2S6E6ygpoqcECaagDbBopoSOPDv0pAZvTbnBgUY+6hq0/XDFDOLEMNlHF/SKJlzcaZ9ckiKjKDuueWI3FN/WXw==", "dev": true, "requires": { - "debug": "^3.1.0", + "debug": "^4.1.0", "extract-zip": "^1.6.6", "https-proxy-agent": "^2.2.1", "mime": "^2.0.3", - "progress": "^2.0.0", + "progress": "^2.0.1", "proxy-from-env": "^1.0.0", "rimraf": "^2.6.1", - "ws": "^5.1.1" + "ws": "^6.1.0" }, "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "ws": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", - "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", "dev": true, "requires": { "async-limiter": "~1.0.0" @@ -25813,6 +25836,128 @@ "browser-process-hrtime": "^0.1.2" } }, + "wait-on": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-3.3.0.tgz", + "integrity": "sha512-97dEuUapx4+Y12aknWZn7D25kkjMk16PbWoYzpSdA8bYpVfS6hpl2a2pOWZ3c+Tyt3/i4/pglyZctG3J4V1hWQ==", + "dev": true, + "requires": { + "@hapi/joi": "^15.0.3", + "core-js": "^2.6.5", + "minimist": "^1.2.0", + "request": "^2.88.0", + "rx": "^4.1.0" + }, + "dependencies": { + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true + }, + "core-js": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz", + "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==", + "dev": true + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, + "rx": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", + "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=", + "dev": true + } + } + }, "wait-port": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/wait-port/-/wait-port-0.2.2.tgz", diff --git a/package.json b/package.json index d6404161ab9a7c..fa0ac847f1952b 100644 --- a/package.json +++ b/package.json @@ -126,6 +126,7 @@ "phpegjs": "1.0.0-beta7", "postcss": "7.0.13", "progress": "2.0.3", + "puppeteer": "1.19.0", "react": "16.8.4", "react-dom": "16.8.4", "react-native": "0.60.0", diff --git a/packages/e2e-test-utils/README.md b/packages/e2e-test-utils/README.md index 71c4380f8a9387..c874edd521d564 100644 --- a/packages/e2e-test-utils/README.md +++ b/packages/e2e-test-utils/README.md @@ -353,10 +353,6 @@ _Parameters_ - _key_ `string`: Key to press. - _count_ `number`: Number of times to press. -_Returns_ - -- `Promise`: Promise resolving when key presses complete. - # **pressKeyWithModifier** Performs a key press with modifier (Shift, Control, Meta, Alt), where each modifier diff --git a/packages/e2e-test-utils/package.json b/packages/e2e-test-utils/package.json index f773eb99a82750..3ae0f0c26ee764 100644 --- a/packages/e2e-test-utils/package.json +++ b/packages/e2e-test-utils/package.json @@ -36,7 +36,7 @@ }, "peerDependencies": { "jest": ">=24", - "puppeteer": ">=1.6" + "puppeteer": ">=1.19.0" }, "publishConfig": { "access": "public" diff --git a/packages/e2e-test-utils/src/press-key-times.js b/packages/e2e-test-utils/src/press-key-times.js index f78b66d09dede4..750e8aafa96c4f 100644 --- a/packages/e2e-test-utils/src/press-key-times.js +++ b/packages/e2e-test-utils/src/press-key-times.js @@ -1,31 +1,11 @@ -/** - * External dependencies - */ -import { times } from 'lodash'; - -/** - * Given an array of functions, each returning a promise, performs all - * promises in sequence (waterfall) order. - * - * @param {Function[]} sequence Array of promise creators. - * - * @return {Promise} Promise resolving once all in the sequence complete. - */ -async function promiseSequence( sequence ) { - return sequence.reduce( - ( current, next ) => current.then( next ), - Promise.resolve() - ); -} - /** * Presses the given keyboard key a number of times in sequence. * * @param {string} key Key to press. * @param {number} count Number of times to press. - * - * @return {Promise} Promise resolving when key presses complete. */ export async function pressKeyTimes( key, count ) { - return promiseSequence( times( count, () => () => page.keyboard.press( key ) ) ); + for ( let i = 0; i < count; i++ ) { + await page.keyboard.press( key ); + } } diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 17ec9ba8188c88..b74cc44e18fa1a 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -26,12 +26,12 @@ "@wordpress/jest-console": "file:../jest-console", "@wordpress/jest-puppeteer-axe": "file:../jest-puppeteer-axe", "@wordpress/scripts": "file:../scripts", - "expect-puppeteer": "^4.0.0", + "expect-puppeteer": "^4.3.0", "lodash": "^4.17.14" }, "peerDependencies": { "jest": ">=24", - "puppeteer": ">=1.6" + "puppeteer": ">=1.19.0" }, "publishConfig": { "access": "public" diff --git a/packages/e2e-tests/plugins/deprecated-node-matcher/index.js b/packages/e2e-tests/plugins/deprecated-node-matcher/index.js index 5eba1b8ec67128..0cb60aeff9a614 100644 --- a/packages/e2e-tests/plugins/deprecated-node-matcher/index.js +++ b/packages/e2e-tests/plugins/deprecated-node-matcher/index.js @@ -2,7 +2,6 @@ var registerBlockType = wp.blocks.registerBlockType; var RichText = wp.blockEditor.RichText; var el = wp.element.createElement; - var el = wp.element.createElement; registerBlockType( 'core/deprecated-children-matcher', { title: 'Deprecated Children Matcher', @@ -82,4 +81,3 @@ }, } ); } )(); - diff --git a/packages/jest-puppeteer-axe/package.json b/packages/jest-puppeteer-axe/package.json index eaf4025995ad47..18b43faa6a967e 100644 --- a/packages/jest-puppeteer-axe/package.json +++ b/packages/jest-puppeteer-axe/package.json @@ -34,7 +34,7 @@ }, "peerDependencies": { "jest": ">=24", - "puppeteer": ">=1.6" + "puppeteer": ">=1.19.0" }, "publishConfig": { "access": "public" diff --git a/packages/scripts/package.json b/packages/scripts/package.json index b1ab422f0af068..8880595864e34d 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -44,10 +44,10 @@ "cross-spawn": "^5.1.0", "eslint": "^5.16.0", "jest": "^24.7.1", - "jest-puppeteer": "^4.0.0", + "jest-puppeteer": "^4.3.0", "minimist": "^1.2.0", "npm-package-json-lint": "^3.6.0", - "puppeteer": "1.6.1", + "puppeteer": "1.19.0", "read-pkg-up": "^1.0.1", "resolve-bin": "^0.4.0", "source-map-loader": "^0.2.4", From f6ff4ec66d4e03b317db380cf66897dd19297884 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 5 Aug 2019 08:50:11 +0200 Subject: [PATCH 05/15] Fix package-lock.json file --- package-lock.json | 270 ++++++++++++++++++---------------------------- 1 file changed, 107 insertions(+), 163 deletions(-) diff --git a/package-lock.json b/package-lock.json index 006fb4190fcbdc..556ca1bb192725 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4707,14 +4707,6 @@ "@wordpress/scripts": "file:packages/scripts", "expect-puppeteer": "^4.3.0", "lodash": "^4.17.14" - }, - "dependencies": { - "expect-puppeteer": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/expect-puppeteer/-/expect-puppeteer-4.3.0.tgz", - "integrity": "sha512-p8N/KSVPG9PAOJlftK5f1n3JrULJ6Qq1EQ8r/n9xzkX2NmXbK8PcnJnkSAEzEHrMycELKGnlJV7M5nkgm+wEWA==", - "dev": true - } } }, "@wordpress/edit-post": { @@ -5037,161 +5029,6 @@ "webpack-bundle-analyzer": "^3.3.2", "webpack-cli": "^3.1.2", "webpack-livereload-plugin": "^2.2.0" - }, - "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "expect-puppeteer": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/expect-puppeteer/-/expect-puppeteer-4.3.0.tgz", - "integrity": "sha512-p8N/KSVPG9PAOJlftK5f1n3JrULJ6Qq1EQ8r/n9xzkX2NmXbK8PcnJnkSAEzEHrMycELKGnlJV7M5nkgm+wEWA==", - "dev": true - }, - "find-process": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/find-process/-/find-process-1.4.2.tgz", - "integrity": "sha512-O83EVJr4dWvHJ7QpUzANNAMeQVKukRzRqRx4AIzdLYRrQorRdbqDwLPigkd9PYPhJRhmNPAoVjOm9bcwSmcZaw==", - "dev": true, - "requires": { - "chalk": "^2.0.1", - "commander": "^2.11.0", - "debug": "^2.6.8" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "jest-dev-server": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/jest-dev-server/-/jest-dev-server-4.3.0.tgz", - "integrity": "sha512-bC9flKY2G1honQ/UI0gEhb0wFnDhpFr7xidC8Nk+evi7TgnNtfsGIzzF2dcIhF1G9BGF0n/M7CJrMAzwQhyTPA==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "cwd": "^0.10.0", - "find-process": "^1.4.2", - "prompts": "^2.1.0", - "spawnd": "^4.0.0", - "tree-kill": "^1.2.1", - "wait-on": "^3.3.0" - }, - "dependencies": { - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - } - } - }, - "jest-environment-puppeteer": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/jest-environment-puppeteer/-/jest-environment-puppeteer-4.3.0.tgz", - "integrity": "sha512-ZighMsU39bnacn2ylyHb88CB+ldgCfXGD3lS78k4PEo8A8xyt6+2mxmSR62FH3Y7K+W2gPDu5+QM3/LZuq42fQ==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "cwd": "^0.10.0", - "jest-dev-server": "^4.3.0", - "merge-deep": "^3.0.2" - }, - "dependencies": { - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - } - } - }, - "jest-puppeteer": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/jest-puppeteer/-/jest-puppeteer-4.3.0.tgz", - "integrity": "sha512-WXhaWlbQl01xadZyNmdZntrtIr8uWUmgjPogDih7dOnr3G/xRr3A034SCqdjwV6fE0tqz7c5hwO8oBTyGZPRgA==", - "dev": true, - "requires": { - "expect-puppeteer": "^4.3.0", - "jest-environment-puppeteer": "^4.3.0" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "prompts": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz", - "integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==", - "dev": true, - "requires": { - "kleur": "^3.0.2", - "sisteransi": "^1.0.0" - } - }, - "puppeteer": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.19.0.tgz", - "integrity": "sha512-2S6E6ygpoqcECaagDbBopoSOPDv0pAZvTbnBgUY+6hq0/XDFDOLEMNlHF/SKJlzcaZ9ckiKjKDuueWI3FN/WXw==", - "dev": true, - "requires": { - "debug": "^4.1.0", - "extract-zip": "^1.6.6", - "https-proxy-agent": "^2.2.1", - "mime": "^2.0.3", - "progress": "^2.0.1", - "proxy-from-env": "^1.0.0", - "rimraf": "^2.6.1", - "ws": "^6.1.0" - } - }, - "tree-kill": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.1.tgz", - "integrity": "sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q==", - "dev": true - }, - "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", - "dev": true, - "requires": { - "async-limiter": "~1.0.0" - } - } } }, "@wordpress/server-side-render": { @@ -11078,6 +10915,12 @@ "jest-regex-util": "^24.3.0" } }, + "expect-puppeteer": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/expect-puppeteer/-/expect-puppeteer-4.3.0.tgz", + "integrity": "sha512-p8N/KSVPG9PAOJlftK5f1n3JrULJ6Qq1EQ8r/n9xzkX2NmXbK8PcnJnkSAEzEHrMycELKGnlJV7M5nkgm+wEWA==", + "dev": true + }, "express": { "version": "4.16.3", "resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", @@ -11630,6 +11473,28 @@ "find-file-up": "^0.1.2" } }, + "find-process": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/find-process/-/find-process-1.4.2.tgz", + "integrity": "sha512-O83EVJr4dWvHJ7QpUzANNAMeQVKukRzRqRx4AIzdLYRrQorRdbqDwLPigkd9PYPhJRhmNPAoVjOm9bcwSmcZaw==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "commander": "^2.11.0", + "debug": "^2.6.8" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", @@ -14727,6 +14592,50 @@ } } }, + "jest-dev-server": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/jest-dev-server/-/jest-dev-server-4.3.0.tgz", + "integrity": "sha512-bC9flKY2G1honQ/UI0gEhb0wFnDhpFr7xidC8Nk+evi7TgnNtfsGIzzF2dcIhF1G9BGF0n/M7CJrMAzwQhyTPA==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "cwd": "^0.10.0", + "find-process": "^1.4.2", + "prompts": "^2.1.0", + "spawnd": "^4.0.0", + "tree-kill": "^1.2.1", + "wait-on": "^3.3.0" + }, + "dependencies": { + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "prompts": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz", + "integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==", + "dev": true, + "requires": { + "kleur": "^3.0.2", + "sisteransi": "^1.0.0" + } + }, + "tree-kill": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.1.tgz", + "integrity": "sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q==", + "dev": true + } + } + }, "jest-diff": { "version": "24.7.0", "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-24.7.0.tgz", @@ -14796,6 +14705,31 @@ "jest-util": "^24.7.1" } }, + "jest-environment-puppeteer": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/jest-environment-puppeteer/-/jest-environment-puppeteer-4.3.0.tgz", + "integrity": "sha512-ZighMsU39bnacn2ylyHb88CB+ldgCfXGD3lS78k4PEo8A8xyt6+2mxmSR62FH3Y7K+W2gPDu5+QM3/LZuq42fQ==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "cwd": "^0.10.0", + "jest-dev-server": "^4.3.0", + "merge-deep": "^3.0.2" + }, + "dependencies": { + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + } + } + }, "jest-get-type": { "version": "24.3.0", "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.3.0.tgz", @@ -14926,6 +14860,16 @@ "integrity": "sha512-pgFw2tm54fzgYvc/OHrnysABEObZCUNFnhjoRjaVOCN8NYc032/gVjPaHD4Aq6ApkSieWtfKAFQtmDKAmhupnQ==", "dev": true }, + "jest-puppeteer": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/jest-puppeteer/-/jest-puppeteer-4.3.0.tgz", + "integrity": "sha512-WXhaWlbQl01xadZyNmdZntrtIr8uWUmgjPogDih7dOnr3G/xRr3A034SCqdjwV6fE0tqz7c5hwO8oBTyGZPRgA==", + "dev": true, + "requires": { + "expect-puppeteer": "^4.3.0", + "jest-environment-puppeteer": "^4.3.0" + } + }, "jest-regex-util": { "version": "24.3.0", "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-24.3.0.tgz", From 9774d67746092350ad21f788a133ef7643289ac2 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 23 Apr 2019 19:43:45 +0200 Subject: [PATCH 06/15] Update demo test to make it work with Vimeo mock --- packages/e2e-tests/specs/demo.test.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/e2e-tests/specs/demo.test.js b/packages/e2e-tests/specs/demo.test.js index 73fc77966cf6de..f5181a8a0e9683 100644 --- a/packages/e2e-tests/specs/demo.test.js +++ b/packages/e2e-tests/specs/demo.test.js @@ -1,7 +1,12 @@ /** * WordPress dependencies */ -import { visitAdminPage, createURLMatcher, setUpResponseMocking, mockOrTransform } from '@wordpress/e2e-test-utils'; +import { + createEmbeddingMatcher, + createJSONResponse, + setUpResponseMocking, + visitAdminPage, +} from '@wordpress/e2e-test-utils'; const MOCK_VIMEO_RESPONSE = { url: 'https://vimeo.com/22439234', @@ -12,20 +17,12 @@ const MOCK_VIMEO_RESPONSE = { version: '1.0', }; -const couldNotBePreviewed = ( embedObject ) => { - return 'Embed Handler' === embedObject.provider_name; -}; - -const stripIframeFromEmbed = ( embedObject ) => { - return { ...embedObject, html: embedObject.html.replace( /src=[^\s]+/, '' ) }; -}; - describe( 'new editor state', () => { beforeAll( async () => { await setUpResponseMocking( [ { - match: createURLMatcher( 'oembed%2F1.0%2Fproxy' ), - onRequestMatch: mockOrTransform( couldNotBePreviewed, MOCK_VIMEO_RESPONSE, stripIframeFromEmbed ), + match: createEmbeddingMatcher( 'https://vimeo.com/22439234' ), + onRequestMatch: createJSONResponse( MOCK_VIMEO_RESPONSE ), }, ] ); await visitAdminPage( 'post-new.php', 'gutenberg-demo' ); From ff3a0c80c2f07363d3bb914612f0467c42f62d30 Mon Sep 17 00:00:00 2001 From: iseulde Date: Mon, 5 Aug 2019 14:30:39 +0200 Subject: [PATCH 07/15] Fix preview e2e --- packages/e2e-tests/specs/preview.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/e2e-tests/specs/preview.test.js b/packages/e2e-tests/specs/preview.test.js index f7ad7d830bf452..8b9a9f484e0ff4 100644 --- a/packages/e2e-tests/specs/preview.test.js +++ b/packages/e2e-tests/specs/preview.test.js @@ -45,9 +45,8 @@ async function openPreviewPage( editorPage ) { * @return {Promise} Promise resolving once navigation completes. */ async function waitForPreviewNavigation( previewPage ) { - const navigationCompleted = previewPage.waitForNavigation(); await page.click( '.editor-post-preview' ); - return navigationCompleted; + return previewPage.waitForNavigation(); } /** From a87c6ae8dc82a757d4d132cc33c5266a72f720bc Mon Sep 17 00:00:00 2001 From: iseulde Date: Mon, 5 Aug 2019 14:32:26 +0200 Subject: [PATCH 08/15] Update snapshot --- .../specs/plugins/__snapshots__/plugins-api.test.js.snap | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap b/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap index 0d8533597b0411..b6c3dee913ed20 100644 --- a/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap +++ b/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap @@ -1,8 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Using Plugins API Document Setting Custom Panel Should render a custom panel inside Document Setting sidebar 1`] = ` -" -My Custom Panel +"My Custom Panel " `; From 95c7de6359d3a3cdd90b39d5bcde5d661a80d68a Mon Sep 17 00:00:00 2001 From: iseulde Date: Mon, 5 Aug 2019 17:07:09 +0200 Subject: [PATCH 09/15] Stabilise block hierarchy tests --- packages/e2e-tests/specs/block-hierarchy-navigation.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/e2e-tests/specs/block-hierarchy-navigation.test.js b/packages/e2e-tests/specs/block-hierarchy-navigation.test.js index 378180b58cd824..e54fffb8cd8930 100644 --- a/packages/e2e-tests/specs/block-hierarchy-navigation.test.js +++ b/packages/e2e-tests/specs/block-hierarchy-navigation.test.js @@ -11,6 +11,7 @@ import { async function openBlockNavigator() { await pressKeyWithModifier( 'access', 'o' ); + await page.waitForSelector( '.block-editor-block-navigation__item-button.is-selected' ); } describe( 'Navigating the block hierarchy', () => { @@ -90,6 +91,7 @@ describe( 'Navigating the block hierarchy', () => { await openBlockNavigator(); await pressKeyTimes( 'Tab', 4 ); await page.keyboard.press( 'Enter' ); + await page.waitForSelector( '.is-selected[data-type="core/column"]' ); // Insert text in the last column block await pressKeyTimes( 'Tab', 3 ); // Tab to inserter. @@ -116,7 +118,6 @@ describe( 'Navigating the block hierarchy', () => { // Return to first block. await openBlockNavigator(); - await page.waitForSelector( '.editor-block-navigation__container' ); await page.keyboard.press( 'Space' ); // Replace its content. From 0defbb7b1a0d377a2e66c7780d88887d0c51194b Mon Sep 17 00:00:00 2001 From: iseulde Date: Mon, 5 Aug 2019 17:11:43 +0200 Subject: [PATCH 10/15] Remove new e2e test --- .../__snapshots__/rich-text.test.js.snap | 6 ------ .../__snapshots__/plugins-api.test.js.snap | 5 +---- packages/e2e-tests/specs/rich-text.test.js | 20 ------------------- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap index 714b0f92ce2286..3c7044b5fb8053 100644 --- a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap @@ -65,9 +65,3 @@ exports[`RichText should transform backtick to code 2`] = `

A \`backtick\`

" `; - -exports[`RichText should update internal selection after fresh focus 1`] = ` -" -

12

-" -`; diff --git a/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap b/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap index b6c3dee913ed20..2faff688fbd77a 100644 --- a/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap +++ b/packages/e2e-tests/specs/plugins/__snapshots__/plugins-api.test.js.snap @@ -1,8 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Using Plugins API Document Setting Custom Panel Should render a custom panel inside Document Setting sidebar 1`] = ` -"My Custom Panel -" -`; +exports[`Using Plugins API Document Setting Custom Panel Should render a custom panel inside Document Setting sidebar 1`] = `"My Custom Panel"`; exports[`Using Plugins API Sidebar Should open plugins sidebar using More Menu item and render content 1`] = `"
Sidebar title plugin
"`; diff --git a/packages/e2e-tests/specs/rich-text.test.js b/packages/e2e-tests/specs/rich-text.test.js index ab10c297506c5d..a7acef1d2aeaf0 100644 --- a/packages/e2e-tests/specs/rich-text.test.js +++ b/packages/e2e-tests/specs/rich-text.test.js @@ -216,24 +216,4 @@ describe( 'RichText', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); - - it( 'should update internal selection after fresh focus', async () => { - await page.keyboard.press( 'Enter' ); - await page.keyboard.type( '1' ); - // Focus the address bar (move focus out of the window). - await pressKeyWithModifier( 'primary', 'l' ); - // Ensure the element lost focus. - // Stangely enough, this is not needed when testing manually. - await page.evaluate( () => { - document.querySelector( '.wp-block-paragraph' ).blur(); - } ); - // Focus the rich text instance again (not at the start). - await page.click( '.wp-block-paragraph', { button: 'middle' } ); - // Should internally set bold at selection. - await pressKeyWithModifier( 'primary', 'b' ); - // "2" should be bold. - await page.keyboard.type( '2' ); - - expect( await getEditedPostContent() ).toMatchSnapshot(); - } ); } ); From a98e04fa23ca2cbaf61ee2f9b04cb1507e48e04f Mon Sep 17 00:00:00 2001 From: iseulde Date: Tue, 6 Aug 2019 09:29:52 +0200 Subject: [PATCH 11/15] Simplify loop --- packages/e2e-test-utils/src/press-key-times.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e-test-utils/src/press-key-times.js b/packages/e2e-test-utils/src/press-key-times.js index 750e8aafa96c4f..6930e6021894d4 100644 --- a/packages/e2e-test-utils/src/press-key-times.js +++ b/packages/e2e-test-utils/src/press-key-times.js @@ -5,7 +5,7 @@ * @param {number} count Number of times to press. */ export async function pressKeyTimes( key, count ) { - for ( let i = 0; i < count; i++ ) { + while ( count-- ) { await page.keyboard.press( key ); } } From bb406e6e4eeaadb0ff10e0f258bf5ef0035bc21f Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 6 Aug 2019 11:52:11 +0200 Subject: [PATCH 12/15] Remove puppeteer from devDependencies --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index fa0ac847f1952b..d6404161ab9a7c 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,6 @@ "phpegjs": "1.0.0-beta7", "postcss": "7.0.13", "progress": "2.0.3", - "puppeteer": "1.19.0", "react": "16.8.4", "react-dom": "16.8.4", "react-native": "0.60.0", From c7dc0ae5973b1a1b0089641a312ccdcf52da0fe2 Mon Sep 17 00:00:00 2001 From: iseulde Date: Tue, 6 Aug 2019 12:17:15 +0200 Subject: [PATCH 13/15] Remove cancelAnimationFrame --- packages/rich-text/src/component/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/rich-text/src/component/index.js b/packages/rich-text/src/component/index.js index e762b192ba8073..ea1cd08e954b5d 100644 --- a/packages/rich-text/src/component/index.js +++ b/packages/rich-text/src/component/index.js @@ -132,7 +132,6 @@ class RichText extends Component { componentWillUnmount() { document.removeEventListener( 'selectionchange', this.onSelectionChange ); - window.cancelAnimationFrame( this.rafId ); } setRef( node ) { From d531ea82c73f813de0239a1da8598576ce64304d Mon Sep 17 00:00:00 2001 From: iseulde Date: Tue, 6 Aug 2019 14:03:16 +0200 Subject: [PATCH 14/15] Add e2e test for #16857 --- .../specs/__snapshots__/rich-text.test.js.snap | 6 ++++++ packages/e2e-tests/specs/rich-text.test.js | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap index 3c7044b5fb8053..714b0f92ce2286 100644 --- a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap @@ -65,3 +65,9 @@ exports[`RichText should transform backtick to code 2`] = `

A \`backtick\`

" `; + +exports[`RichText should update internal selection after fresh focus 1`] = ` +" +

12

+" +`; diff --git a/packages/e2e-tests/specs/rich-text.test.js b/packages/e2e-tests/specs/rich-text.test.js index a7acef1d2aeaf0..45c35a7b4de069 100644 --- a/packages/e2e-tests/specs/rich-text.test.js +++ b/packages/e2e-tests/specs/rich-text.test.js @@ -216,4 +216,16 @@ describe( 'RichText', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); + + it( 'should update internal selection after fresh focus', async () => { + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '1' ); + await page.keyboard.press( 'Tab' ); + await pressKeyWithModifier( 'shift', 'Tab' ); + await pressKeyWithModifier( 'primary', 'b' ); + await page.keyboard.type( '2' ); + await pressKeyWithModifier( 'primary', 'b' ); + + expect( await getEditedPostContent() ).toMatchSnapshot(); + } ); } ); From 260a79a018e039836c8739703c73da147bffb318 Mon Sep 17 00:00:00 2001 From: iseulde Date: Tue, 6 Aug 2019 18:18:44 +0200 Subject: [PATCH 15/15] Restore animation frame fix --- .../specs/__snapshots__/rich-text.test.js.snap | 6 ++++++ packages/e2e-tests/specs/rich-text.test.js | 17 +++++++++++++++++ packages/rich-text/src/component/index.js | 7 +++++++ 3 files changed, 30 insertions(+) diff --git a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap index 714b0f92ce2286..c2013529d0a3f8 100644 --- a/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/rich-text.test.js.snap @@ -30,6 +30,12 @@ exports[`RichText should handle change in tag name gracefully 1`] = ` " `; +exports[`RichText should keep internal selection after blur 1`] = ` +" +

12

+" +`; + exports[`RichText should not format text after code backtick 1`] = ` "

A backtick and more.

diff --git a/packages/e2e-tests/specs/rich-text.test.js b/packages/e2e-tests/specs/rich-text.test.js index 45c35a7b4de069..d9b674b7940e06 100644 --- a/packages/e2e-tests/specs/rich-text.test.js +++ b/packages/e2e-tests/specs/rich-text.test.js @@ -228,4 +228,21 @@ describe( 'RichText', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); + + it( 'should keep internal selection after blur', async () => { + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '1' ); + // Simulate moving focus to a different app, then moving focus back, + // without selection being changed. + await page.evaluate( () => { + const activeElement = document.activeElement; + activeElement.blur(); + activeElement.focus(); + } ); + await pressKeyWithModifier( 'primary', 'b' ); + await page.keyboard.type( '2' ); + await pressKeyWithModifier( 'primary', 'b' ); + + expect( await getEditedPostContent() ).toMatchSnapshot(); + } ); } ); diff --git a/packages/rich-text/src/component/index.js b/packages/rich-text/src/component/index.js index ea1cd08e954b5d..1689efc01056d2 100644 --- a/packages/rich-text/src/component/index.js +++ b/packages/rich-text/src/component/index.js @@ -132,6 +132,7 @@ class RichText extends Component { componentWillUnmount() { document.removeEventListener( 'selectionchange', this.onSelectionChange ); + window.cancelAnimationFrame( this.rafId ); } setRef( node ) { @@ -300,6 +301,12 @@ class RichText extends Component { this.props.onSelectionChange( index, index ); this.setState( { activeFormats } ); + // Update selection as soon as possible, which is at the next animation + // frame. The event listener for selection changes may be added too late + // at this point, but this focus event is still too early to calculate + // the selection. + this.rafId = window.requestAnimationFrame( this.onSelectionChange ); + document.addEventListener( 'selectionchange', this.onSelectionChange ); }