From 73c3563290eabcd29548b56ec05f32e307016857 Mon Sep 17 00:00:00 2001 From: Rodel Date: Thu, 4 Nov 2021 02:48:30 +0800 Subject: [PATCH 1/7] Added WSL instructions --- plugins/woocommerce/tests/e2e/README.md | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/plugins/woocommerce/tests/e2e/README.md b/plugins/woocommerce/tests/e2e/README.md index 30dbdb08310..4104e614fb4 100644 --- a/plugins/woocommerce/tests/e2e/README.md +++ b/plugins/woocommerce/tests/e2e/README.md @@ -356,3 +356,58 @@ In the example above, you can see that `allows customer to see downloads` part o The test sequencer (`npx wc-e2e test:e2e`) includes support for saving [screenshots on test errors](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env#test-screenshots) which can be sent to a Slack channel via a [Slackbot](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env#slackbot-setup). For Puppeteer debugging, follow [Google's documentation](https://developers.google.com/web/tools/puppeteer/debugging). + +## Running E2E Tests in the Windows Subsystem for Linux (WSL) + +The best way to setup your local development environment if you're on Windows is through the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/). The following steps are for the Ubuntu 20.04 Linux distribution. + +### Pre-requisites + +You should have the following already set up on your Windows computer: +- **Docker Desktop for Windows** - https://docs.docker.com/docker-for-windows/install/ +- **WSL 2** - https://docs.microsoft.com/en-us/windows/wsl/install +- **Ubuntu 20.04 set as default Linux distribution** - https://docs.microsoft.com/en-us/windows/wsl/wsl-config#list-installed-distributions + +### Setup Steps + +In Ubuntu 20.04, update and upgrade packages. +```bash +sudo apt update -y && sudo apt upgrade -y +``` + +In order for Composer commands to work later on, install PHP, Composer, `php-xml` and `php-mbstring`. +```bash +sudo apt install php-cli unzip -y + +cd ~ + +curl -sS https://getcomposer.org/installer -o composer-setup.php + +HASH=`curl -sS https://composer.github.io/installer.sig` + +echo $HASH + +php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" + +sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer + +composer --version --no-interaction # Verify that Composer installation was successful + +sudo apt install php-xml -y + +sudo apt install php-mbstring -y +``` + +For Puppeteer to run in headless mode, install these packages: +```bash +sudo apt install -y ca-certificates fonts-liberation gconf-service libappindicator1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils +``` + +Add your username to the `docker` group to avoid having to type `sudo` when you run Docker commands +```bash +sudo usermod -aG docker ${YOUR_USERNAME} + +su - ${YOUR_USERNAME} +``` + +At this point, you're now ready to proceed with the steps in [Running tests](#running-tests). From 906afa8a67530ac73ed6aa929d9973a223e4426e Mon Sep 17 00:00:00 2001 From: Rodel Date: Fri, 5 Nov 2021 20:10:03 +0800 Subject: [PATCH 2/7] Separate readme for WSL instructions --- plugins/woocommerce/tests/e2e/README.md | 60 ++---------------- .../tests/e2e/WSL_SETUP_INSTRUCTIONS.md | 61 +++++++++++++++++++ 2 files changed, 66 insertions(+), 55 deletions(-) create mode 100644 plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md diff --git a/plugins/woocommerce/tests/e2e/README.md b/plugins/woocommerce/tests/e2e/README.md index 4104e614fb4..5c96612b27b 100644 --- a/plugins/woocommerce/tests/e2e/README.md +++ b/plugins/woocommerce/tests/e2e/README.md @@ -21,6 +21,7 @@ Automated end-to-end tests for WooCommerce. - [How to run an individual test](#how-to-run-an-individual-test) - [How to skip tests](#how-to-skip-tests) - [How to run tests using custom WordPress, PHP and MariaDB versions](#how-to-run-tests-using-custom-wordpress,-php-and-mariadb-versions) + - [How to run tests in Windows Subsystem for Linux (WSL)](#how-to-run-tests-in-windows-subsystem-for-linux-wsl) - [Guide for writing e2e tests](#guide-for-writing-e2e-tests) - [Tools for writing tests](#tools-for-writing-tests) - [Creating test structure](#creating-test-structure) @@ -254,6 +255,10 @@ The full command to build the site will look as follows: TRAVIS_MARIADB_VERSION=10.5.3 TRAVIS_PHP_VERSION=7.4.5 WP_VERSION=5.4.1 npx wc-e2e docker:up ``` +### How to run tests in Windows Subsystem for Linux (WSL) + +Please see the instructions in [WSL_SETUP_INSTRUCTIONS.md](./WSL_SETUP_INSTRUCTIONS.md). + ## Guide for writing e2e tests ### Tools for writing tests @@ -356,58 +361,3 @@ In the example above, you can see that `allows customer to see downloads` part o The test sequencer (`npx wc-e2e test:e2e`) includes support for saving [screenshots on test errors](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env#test-screenshots) which can be sent to a Slack channel via a [Slackbot](https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/env#slackbot-setup). For Puppeteer debugging, follow [Google's documentation](https://developers.google.com/web/tools/puppeteer/debugging). - -## Running E2E Tests in the Windows Subsystem for Linux (WSL) - -The best way to setup your local development environment if you're on Windows is through the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/). The following steps are for the Ubuntu 20.04 Linux distribution. - -### Pre-requisites - -You should have the following already set up on your Windows computer: -- **Docker Desktop for Windows** - https://docs.docker.com/docker-for-windows/install/ -- **WSL 2** - https://docs.microsoft.com/en-us/windows/wsl/install -- **Ubuntu 20.04 set as default Linux distribution** - https://docs.microsoft.com/en-us/windows/wsl/wsl-config#list-installed-distributions - -### Setup Steps - -In Ubuntu 20.04, update and upgrade packages. -```bash -sudo apt update -y && sudo apt upgrade -y -``` - -In order for Composer commands to work later on, install PHP, Composer, `php-xml` and `php-mbstring`. -```bash -sudo apt install php-cli unzip -y - -cd ~ - -curl -sS https://getcomposer.org/installer -o composer-setup.php - -HASH=`curl -sS https://composer.github.io/installer.sig` - -echo $HASH - -php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" - -sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer - -composer --version --no-interaction # Verify that Composer installation was successful - -sudo apt install php-xml -y - -sudo apt install php-mbstring -y -``` - -For Puppeteer to run in headless mode, install these packages: -```bash -sudo apt install -y ca-certificates fonts-liberation gconf-service libappindicator1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils -``` - -Add your username to the `docker` group to avoid having to type `sudo` when you run Docker commands -```bash -sudo usermod -aG docker ${YOUR_USERNAME} - -su - ${YOUR_USERNAME} -``` - -At this point, you're now ready to proceed with the steps in [Running tests](#running-tests). diff --git a/plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md b/plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md new file mode 100644 index 00000000000..6e7c310ca2b --- /dev/null +++ b/plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md @@ -0,0 +1,61 @@ +# Setup Instructions for Windows Subsystem for Linux (WSL) + +You can set up a local development environment on Windows with [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/). + +## Ubuntu 20.04 +The following instructions are for Ubuntu 20.04. + +### Pre-requisites + +You should have the following already set up on your Windows computer: +- **Docker Desktop for Windows** - https://docs.docker.com/docker-for-windows/install/ +- **WSL 2** - https://docs.microsoft.com/en-us/windows/wsl/install +- **Ubuntu 20.04 set as default Linux distribution** - https://docs.microsoft.com/en-us/windows/wsl/wsl-config#list-installed-distributions + +### Setup Steps + +Update and upgrade packages. +```bash +sudo apt update -y && sudo apt upgrade -y +``` + +In order for Composer commands to work later on, you have to install the following: +- PHP +- Composer +- `php-xml` +- `php-mbstring` +```bash +sudo apt install php-cli unzip -y + +cd ~ + +curl -sS https://getcomposer.org/installer -o composer-setup.php + +HASH=`curl -sS https://composer.github.io/installer.sig` + +echo $HASH + +php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" + +sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer + +composer --version --no-interaction # Verify that Composer installation was successful + +sudo apt install php-xml -y + +sudo apt install php-mbstring -y +``` + +For Puppeteer to run in headless mode you'll need to install additional packages: +```bash +sudo apt install -y ca-certificates fonts-liberation gconf-service libappindicator1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils +``` + +Add your username to the `docker` group to avoid having to type `sudo` when you run Docker commands. +```bash +sudo usermod -aG docker ${YOUR_USERNAME} + +su - ${YOUR_USERNAME} +``` + +At this point, you're now ready to proceed with the steps in [Prep work for running tests](./README.md#prep-work-for-running-tests). From df85aa293c5e36c5e363e151079e0a63835e4e5c Mon Sep 17 00:00:00 2001 From: Rodel Date: Fri, 5 Nov 2021 20:23:37 +0800 Subject: [PATCH 3/7] Minor changes --- plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md b/plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md index 6e7c310ca2b..7e6b7e88dfe 100644 --- a/plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md +++ b/plugins/woocommerce/tests/e2e/WSL_SETUP_INSTRUCTIONS.md @@ -1,18 +1,15 @@ # Setup Instructions for Windows Subsystem for Linux (WSL) -You can set up a local development environment on Windows with [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/). +You can set up a local development environment on Windows with [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/). The following instructions are for Ubuntu 20.04. -## Ubuntu 20.04 -The following instructions are for Ubuntu 20.04. - -### Pre-requisites +## Pre-requisites You should have the following already set up on your Windows computer: - **Docker Desktop for Windows** - https://docs.docker.com/docker-for-windows/install/ - **WSL 2** - https://docs.microsoft.com/en-us/windows/wsl/install - **Ubuntu 20.04 set as default Linux distribution** - https://docs.microsoft.com/en-us/windows/wsl/wsl-config#list-installed-distributions -### Setup Steps +## Setup Steps Update and upgrade packages. ```bash From 1b60740e5748e320fed7f4e9a447bfb2025e8482 Mon Sep 17 00:00:00 2001 From: Rodel Date: Fri, 5 Nov 2021 20:40:54 +0800 Subject: [PATCH 4/7] Reference to WSL md at the beginning of Running tests section --- plugins/woocommerce/tests/e2e/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce/tests/e2e/README.md b/plugins/woocommerce/tests/e2e/README.md index 5c96612b27b..7055b9031b7 100644 --- a/plugins/woocommerce/tests/e2e/README.md +++ b/plugins/woocommerce/tests/e2e/README.md @@ -21,7 +21,6 @@ Automated end-to-end tests for WooCommerce. - [How to run an individual test](#how-to-run-an-individual-test) - [How to skip tests](#how-to-skip-tests) - [How to run tests using custom WordPress, PHP and MariaDB versions](#how-to-run-tests-using-custom-wordpress,-php-and-mariadb-versions) - - [How to run tests in Windows Subsystem for Linux (WSL)](#how-to-run-tests-in-windows-subsystem-for-linux-wsl) - [Guide for writing e2e tests](#guide-for-writing-e2e-tests) - [Tools for writing tests](#tools-for-writing-tests) - [Creating test structure](#creating-test-structure) @@ -98,6 +97,8 @@ Puppeteer will still automatically download Chromium when needed. ## Running tests +If you're using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/), follow the instructions in [./WSL_SETUP_INSTRUCTIONS.md] first before proceeding with the steps below. + ### Prep work for running tests Run the following in a terminal/command line window From 8c8385fccec7283e5c9782dd390273790fd6cf95 Mon Sep 17 00:00:00 2001 From: Rodel Date: Fri, 5 Nov 2021 20:42:12 +0800 Subject: [PATCH 5/7] Remove earlier WSL section --- plugins/woocommerce/tests/e2e/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/woocommerce/tests/e2e/README.md b/plugins/woocommerce/tests/e2e/README.md index 7055b9031b7..f8b8d1c89b6 100644 --- a/plugins/woocommerce/tests/e2e/README.md +++ b/plugins/woocommerce/tests/e2e/README.md @@ -256,10 +256,6 @@ The full command to build the site will look as follows: TRAVIS_MARIADB_VERSION=10.5.3 TRAVIS_PHP_VERSION=7.4.5 WP_VERSION=5.4.1 npx wc-e2e docker:up ``` -### How to run tests in Windows Subsystem for Linux (WSL) - -Please see the instructions in [WSL_SETUP_INSTRUCTIONS.md](./WSL_SETUP_INSTRUCTIONS.md). - ## Guide for writing e2e tests ### Tools for writing tests From f37bc08a44cde019daba25c6dcfafb7d67df57e0 Mon Sep 17 00:00:00 2001 From: Rodel Date: Fri, 5 Nov 2021 20:44:31 +0800 Subject: [PATCH 6/7] Corrected reference to WSL instructions --- plugins/woocommerce/tests/e2e/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/tests/e2e/README.md b/plugins/woocommerce/tests/e2e/README.md index f8b8d1c89b6..6ce89e61f06 100644 --- a/plugins/woocommerce/tests/e2e/README.md +++ b/plugins/woocommerce/tests/e2e/README.md @@ -97,7 +97,7 @@ Puppeteer will still automatically download Chromium when needed. ## Running tests -If you're using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/), follow the instructions in [./WSL_SETUP_INSTRUCTIONS.md] first before proceeding with the steps below. +If you're using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/), follow the [WSL Setup Instructions](./WSL_SETUP_INSTRUCTIONS.md) first before proceeding with the steps below. ### Prep work for running tests From 7c1888ddad65be0dc81a6563c17a872c2ec3ffb9 Mon Sep 17 00:00:00 2001 From: Rodel Date: Tue, 9 Nov 2021 00:45:34 +0800 Subject: [PATCH 7/7] Better phrasing in Running Tests opening statement --- plugins/woocommerce/tests/e2e/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/tests/e2e/README.md b/plugins/woocommerce/tests/e2e/README.md index 6ce89e61f06..9ec2cb5c686 100644 --- a/plugins/woocommerce/tests/e2e/README.md +++ b/plugins/woocommerce/tests/e2e/README.md @@ -97,7 +97,7 @@ Puppeteer will still automatically download Chromium when needed. ## Running tests -If you're using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/), follow the [WSL Setup Instructions](./WSL_SETUP_INSTRUCTIONS.md) first before proceeding with the steps below. +If you are using Windows, we recommend using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) for End-to-end testing. Follow the [WSL Setup Instructions](./WSL_SETUP_INSTRUCTIONS.md) first before proceeding with the steps below. ### Prep work for running tests