diff --git a/.distignore b/.distignore index d53c6838112c..bafb6689992a 100644 --- a/.distignore +++ b/.distignore @@ -34,11 +34,11 @@ codecov.yml composer.json composer.lock CONTRIBUTING.md +jest-puppeteer.config.js package.json package-lock.json phpcs.xml phpstan.neon.dist phpunit.xml.dist -puppeteer.config.js README.md webpack.config.js diff --git a/.eslintrc b/.eslintrc index 09b0e4586b3a..b72ff63b1614 100644 --- a/.eslintrc +++ b/.eslintrc @@ -217,7 +217,7 @@ { "files": [ "babel.config.js", - "puppeteer.config.js", + "jest-puppeteer.config.js", "webpack.config.js", ".storybook/*.js", "tests/js/*.js", diff --git a/.travis.yml b/.travis.yml index b73610a07967..ac1204bd5b88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,6 +45,10 @@ install: nvm install npm ci fi + - | + if ! [ -z $PUPPETEER_PRODUCT ] ; then + npm ci puppeteer + fi - | if [ "$LINT" = "1" ] || [ "$PHP" = "1" ] || [ "$E2E" = "1" ] || [ "$DEPLOY_PLUGIN" = "1" ]; then composer install --no-interaction @@ -114,7 +118,7 @@ script: if [ "$E2E" = "1" ]; then npm run build:js npm run env:start - npm run test:e2e:ci + npm run test:e2e npm run env:stop fi - set +e @@ -151,9 +155,12 @@ jobs: - name: PHP and JavaScript unit tests (7.4, WordPress latest, with code coverage) php: 7.4 env: JS=1 PHP=1 COVERAGE=1 WP_VERSION=latest - - name: E2E tests + - name: E2E tests (Chromium) php: 7.4 env: E2E=1 WP_VERSION=latest PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= + - name: E2E tests (Firefox) + php: 7.4 + env: E2E=1 WP_VERSION=latest PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= PUPPETEER_PRODUCT=firefox - stage: deploy if: (NOT type IN (pull_request)) AND (branch = master) php: 7.3 diff --git a/bin/local-env/install-wordpress.sh b/bin/local-env/install-wordpress.sh index f0d19923b2b1..9c66975458d0 100755 --- a/bin/local-env/install-wordpress.sh +++ b/bin/local-env/install-wordpress.sh @@ -102,11 +102,6 @@ if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then wp option update siteurl "http://localhost:$HOST_PORT" --quiet fi -# Install a dummy favicon to avoid 404 errors. -echo -e $(status_message "Installing a dummy favicon...") -container touch /var/www/html/favicon.ico -container chmod 767 /var/www/html/favicon.ico - # Activate Web Stories plugin. echo -e $(status_message "Activating Web Stories plugin...") wp plugin activate web-stories --quiet diff --git a/puppeteer.config.js b/jest-puppeteer.config.js similarity index 91% rename from puppeteer.config.js rename to jest-puppeteer.config.js index aded1acb5564..a8fbb4d4c2e3 100644 --- a/puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -18,5 +18,7 @@ module.exports = { launch: { headless: process.env.PUPPETEER_HEADLESS !== 'false', slowMo: parseInt(process.env.PUPPETEER_SLOWMO) || 0, + dumpio: true, + product: process.env.PUPPETEER_PRODUCT || 'chrome', }, }; diff --git a/package-lock.json b/package-lock.json index d851b0018266..fc5c9d1b2b2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7276,6 +7276,16 @@ "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==", "dev": true }, + "@types/yauzl": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz", + "integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==", + "dev": true, + "optional": true, + "requires": { + "@types/node": "*" + } + }, "@webassemblyjs/ast": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz", @@ -9420,6 +9430,40 @@ "file-uri-to-path": "1.0.0" } }, + "bl": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.2.tgz", + "integrity": "sha512-j4OH8f6Qg2bGuWfRiltT2HYGx0e1QcBTrK9KAHNMwMZdQnDZFk0ZSYIpADjYCB3U12nicC5tVJwSIhwOWjb4RQ==", + "dev": true, + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "buffer": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", + "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -13200,40 +13244,25 @@ } }, "extract-zip": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", - "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.0.tgz", + "integrity": "sha512-i42GQ498yibjdvIhivUsRslx608whtGoFIhF26Z7O4MYncBxp8CwalOs1lnHy21A9sIohWO2+uiE4SRtC9JXDg==", "dev": true, "requires": { - "concat-stream": "^1.6.2", - "debug": "^2.6.9", - "mkdirp": "^0.5.4", + "@types/yauzl": "^2.9.1", + "debug": "^4.1.1", + "get-stream": "^5.1.0", "yauzl": "^2.10.0" }, "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" - } - }, - "mkdirp": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz", - "integrity": "sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw==", + "get-stream": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", + "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "pump": "^3.0.0" } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true } } }, @@ -13764,6 +13793,12 @@ "readable-stream": "^2.0.0" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true + }, "fs-exists-sync": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", @@ -21905,6 +21940,12 @@ "minimist": "^1.2.5" } }, + "mkdirp-classic": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.2.tgz", + "integrity": "sha512-ejdnDQcR75gwknmMw/tx02AuRs8jCtqFoFqDZMjiNxsu85sRIJVXDKHuLYvUUPRBUtV2FpSZa9bL1BUa3BdR2g==", + "dev": true + }, "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", @@ -24042,21 +24083,23 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "puppeteer": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-2.1.1.tgz", - "integrity": "sha512-LWzaDVQkk1EPiuYeTOj+CZRIjda4k2s5w4MK4xoH2+kgWV/SDlkYHmxatDdtYrciHUKSXTsGgPgPP8ILVdBsxg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-3.0.1.tgz", + "integrity": "sha512-DxNnI9n4grVHC+9irUfNK2T6YFuRECJnvG7VzdVolxpVwWC5DQqI5ho9Z0af48K5MQW4sJY5cq3qQ5g6NkAjvw==", "dev": true, "requires": { "@types/mime-types": "^2.1.0", "debug": "^4.1.0", - "extract-zip": "^1.6.6", + "extract-zip": "^2.0.0", "https-proxy-agent": "^4.0.0", "mime": "^2.0.3", "mime-types": "^2.1.25", "progress": "^2.0.1", "proxy-from-env": "^1.0.0", - "rimraf": "^2.6.1", - "ws": "^6.1.0" + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" }, "dependencies": { "mime": { @@ -24065,13 +24108,13 @@ "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==", "dev": true }, - "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "requires": { - "async-limiter": "~1.0.0" + "glob": "^7.1.3" } } } @@ -27629,6 +27672,44 @@ "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", "dev": true }, + "tar-fs": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz", + "integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==", + "dev": true, + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.0.0" + } + }, + "tar-stream": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.2.tgz", + "integrity": "sha512-UaF6FoJ32WqALZGOIAApXx+OdxhekNMChu6axLJR85zMMjXKWFGjbIRe+J6P4UnRGg9rAwWvbTT0oI7hD/Un7Q==", + "dev": true, + "requires": { + "bl": "^4.0.1", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "telejson": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/telejson/-/telejson-3.3.0.tgz", @@ -28264,6 +28345,28 @@ "dev": true, "optional": true }, + "unbzip2-stream": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.2.tgz", + "integrity": "sha512-pZMVAofMrrHX6Ik39hCk470kulCbmZ2SWfQLPmTWqfJV/oUm0gn1CblvHdUu4+54Je6Jq34x8kY6XjTy6dMkOg==", + "dev": true, + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + }, + "dependencies": { + "buffer": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", + "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + } + } + }, "unfetch": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.1.0.tgz", diff --git a/package.json b/package.json index cc6719e01d36..c53f6ea925d3 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,7 @@ "npm-run-all": "^4.1.5", "optimize-css-assets-webpack-plugin": "^5.0.3", "prettier": "^2.0.5", - "puppeteer": "^2.1.1", + "puppeteer": "^3.0.1", "react-test-renderer": "^16.13.1", "rtlcss-webpack-plugin": "^4.0.3", "source-map-loader": "^0.2.4", @@ -170,7 +170,8 @@ "test:e2e:help": "npm run test:e2e -- --help", "test:e2e:watch": "npm run test:e2e -- --watch", "test:e2e:interactive": "PUPPETEER_HEADLESS=false PUPPETEER_SLOWMO=80 npm run test:e2e", - "test:e2e:ci": "npm run test:e2e -- --runInBand" + "test:e2e:firefox": "PUPPETEER_PRODUCT=firefox WP_BASE_URL=http://localhost:8899 jest --runInBand --config=tests/e2e/jest.config.js", + "test:e2e:firefox:interactive": "PUPPETEER_PRODUCT=firefox PUPPETEER_HEADLESS=false PUPPETEER_SLOWMO=80 npm run test:e2e" }, "husky": { "hooks": { diff --git a/tests/e2e/config/bootstrap.js b/tests/e2e/config/bootstrap.js index 4da395ebc59a..6022b99af39a 100644 --- a/tests/e2e/config/bootstrap.js +++ b/tests/e2e/config/bootstrap.js @@ -105,6 +105,25 @@ function observeConsoleLogging() { return; } + // Firefox warns about this issue in WordPress admin. + if (text.includes('This page uses the non standard property “zoom”')) { + return; + } + + // Firefox warns about this issue when there's no proper favicon. + if ( + text.includes( + 'Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIContentSniffer.getMIMETypeFromContent]' + ) + ) { + return; + } + + // Firefox warns about this issue on the login screen. + if (text.includes('wp-includes/js/zxcvbn.min.js')) { + return; + } + const logFunction = OBSERVED_CONSOLE_MESSAGE_TYPES[type]; // As of Puppeteer 1.6.1, `message.text()` wrongly returns an object of