diff --git a/.github/workflows/pr-build-and-e2e-tests.yml b/.github/workflows/pr-build-and-e2e-tests.yml index 3d749dbd926..b907eed2928 100644 --- a/.github/workflows/pr-build-and-e2e-tests.yml +++ b/.github/workflows/pr-build-and-e2e-tests.yml @@ -7,9 +7,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - E2E_PLAYWRIGHT: true - jobs: e2e-tests-run: name: Runs E2E tests. @@ -31,50 +28,24 @@ jobs: - name: Load docker images and start containers. working-directory: plugins/woocommerce - run: pnpm exec wc-e2e docker:up - - - name: Run Puppeteer E2E tests. - if: fromJSON(env.E2E_PLAYWRIGHT) != true - id: run-puppeteer-e2e-tests - working-directory: plugins/woocommerce - env: - WC_E2E_SCREENSHOTS: 1 - E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} - E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} - run: pnpm exec wc-e2e test:e2e - - - name: Archive Puppeteer E2E test results - if: | - always() && - fromJSON(env.E2E_PLAYWRIGHT) != true && - ( - steps.run-puppeteer-e2e-tests.conclusion != 'cancelled' || - steps.run-puppeteer-e2e-tests.conclusion != 'skipped' - ) - uses: actions/upload-artifact@v3 - with: - name: pptr-e2e-test-results - path: plugins/woocommerce/tests/e2e/test-results.json - if-no-files-found: ignore - retention-days: 5 + run: pnpm env:test --filter=woocommerce - name: Download and install Chromium browser. - if: fromJSON(env.E2E_PLAYWRIGHT) working-directory: plugins/woocommerce run: pnpx playwright install chromium - name: Run Playwright E2E tests. timeout-minutes: 60 id: run_playwright_e2e_tests - if: fromJSON(env.E2E_PLAYWRIGHT) + env: + USE_WP_ENV: 1 working-directory: plugins/woocommerce - run: pnpx playwright test --config=e2e/playwright.config.js + run: pnpx playwright test --config=tests/e2e-pw/playwright.config.js - name: Generate Playwright E2E Test report. id: generate_e2e_report if: | always() && - fromJSON(env.E2E_PLAYWRIGHT) && ( steps.run_playwright_e2e_tests.conclusion != 'cancelled' || steps.run_playwright_e2e_tests.conclusion != 'skipped' @@ -85,7 +56,6 @@ jobs: - name: Archive Playwright E2E test report if: | always() && - fromJSON(env.E2E_PLAYWRIGHT) && steps.generate_e2e_report.conclusion == 'success' uses: actions/upload-artifact@v3 with: @@ -96,19 +66,6 @@ jobs: if-no-files-found: ignore retention-days: 5 - - name: Archive Puppeteer E2E test screenshots - uses: actions/upload-artifact@v3 - if: | - always() && - ( - fromJSON(env.E2E_PLAYWRIGHT) != true - ) - with: - name: E2E Screenshots - path: plugins/woocommerce/tests/e2e/screenshots - if-no-files-found: ignore - retention-days: 5 - api-tests-run: name: Runs API tests. runs-on: ubuntu-20.04 @@ -131,7 +88,7 @@ jobs: - name: Load docker images and start containers. working-directory: plugins/woocommerce - run: pnpm exec wc-e2e docker:up + run: pnpm env:test --filter=woocommerce - name: Run tests command. working-directory: plugins/woocommerce @@ -169,14 +126,11 @@ jobs: - name: Install and Build uses: ./.github/actions/install-build - - name: Workaround to use initialization file with prepopulated data. - working-directory: plugins/woocommerce/tests/e2e/docker - run: | - cp init-sample-products.sh initialize.sh - - name: Load docker images and start containers. working-directory: plugins/woocommerce - run: pnpm exec wc-e2e docker:up + run: | + pnpm env:dev --filter=woocommerce + pnpm env:performance-init --filter=woocommerce - name: Install k6 run: | @@ -217,19 +171,11 @@ jobs: path: artifacts/api - name: Download Playwright E2E test report artifact - if: fromJSON(env.E2E_PLAYWRIGHT) uses: actions/download-artifact@v3 with: name: e2e-test-report---pr-${{ github.event.number }} path: artifacts/e2e - - name: Download Puppeteer E2E test report artifact - if: fromJSON(env.E2E_PLAYWRIGHT) != true - uses: actions/download-artifact@v3 - with: - name: pptr-e2e-test-results - path: artifacts/e2e - - name: Prepare test summary id: prepare-test-summary uses: actions/github-script@v6 @@ -278,22 +224,7 @@ jobs: RUN_ID: ${{ github.run_id }} COMMIT_SHA: ${{ github.event.pull_request.head.sha }} steps: - - name: Publish API test report - if: fromJSON(env.E2E_PLAYWRIGHT) != true - env: - ARTIFACT_NAME: api-test-report---pr-${{ github.event.number }} - run: | - gh workflow run publish-report.yml \ - -f test_workflow=pr \ - -f test_type=api \ - -f run_id=$RUN_ID \ - -f artifact_name=$ARTIFACT_NAME \ - -f pr_number=$PR_NUMBER \ - -f commit_sha=$COMMIT_SHA \ - --repo woocommerce/woocommerce-test-reports - - name: Publish test reports - if: fromJSON(env.E2E_PLAYWRIGHT) env: API_ARTIFACT: api-test-report---pr-${{ github.event.number }} E2E_ARTIFACT: e2e-test-report---pr-${{ github.event.number }} diff --git a/.gitignore b/.gitignore index 7eeab6a70ad..2cca1c88ec9 100644 --- a/.gitignore +++ b/.gitignore @@ -89,10 +89,10 @@ allure-results changes.json # Playwright output & working files -/plugins/woocommerce/e2e/output -/plugins/woocommerce/e2e/report -/plugins/woocommerce/e2e/storage -/plugins/woocommerce/e2e/test-results.json +/plugins/woocommerce/tests/e2e-pw/output +/plugins/woocommerce/tests/e2e-pw/report +/plugins/woocommerce/tests/e2e-pw/storage +/plugins/woocommerce/tests/e2e-pw/test-results.json # Turborepo .turbo diff --git a/plugins/woocommerce/.eslintrc.js b/plugins/woocommerce/.eslintrc.js index 9167959de3f..dc29e0ad21c 100644 --- a/plugins/woocommerce/.eslintrc.js +++ b/plugins/woocommerce/.eslintrc.js @@ -28,13 +28,13 @@ module.exports = { }, overrides: [ { - files: ["e2e/tests/**/*.spec.js", "e2e/*.js"], + files: ["tests/e2e-pw/**/*.spec.js", "tests/e2e/**/*.spec.js"], rules: { "jest/no-test-callback": "off", "@wordpress/no-unsafe-wp-apis": "off", "import/no-extraneous-dependencies": "off", "import/no-unresolved": "off" } - } + }, ] }; diff --git a/plugins/woocommerce/.gitignore b/plugins/woocommerce/.gitignore index 7b2a4823cdb..8ffcd94e1f1 100644 --- a/plugins/woocommerce/.gitignore +++ b/plugins/woocommerce/.gitignore @@ -18,8 +18,6 @@ tests/cli/vendor /tests/bin/tmp /tests/e2e/config/local-*.json /tests/e2e/config/local.json -/tests/e2e/config/default.json -/tests/e2e/docker /tests/e2e/screenshots /tests/e2e/plugins .phpunit.result.cache diff --git a/plugins/woocommerce/.wp-env.json b/plugins/woocommerce/.wp-env.json index d8e416c1c8c..7625faf3b4f 100644 --- a/plugins/woocommerce/.wp-env.json +++ b/plugins/woocommerce/.wp-env.json @@ -11,7 +11,10 @@ "env": { "development": {}, "tests": { - "port": 8086 + "port": 8086, + "config": { + "ALTERNATE_WP_CRON": false + } } } } diff --git a/plugins/woocommerce/changelog/add-ci-wp-env-switch b/plugins/woocommerce/changelog/add-ci-wp-env-switch new file mode 100644 index 00000000000..1c704c3dc88 --- /dev/null +++ b/plugins/woocommerce/changelog/add-ci-wp-env-switch @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Updating e2e, api and performance tests against a wp-env environment diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json index 466bfc32571..dc4ddb8ea48 100644 --- a/plugins/woocommerce/package.json +++ b/plugins/woocommerce/package.json @@ -33,8 +33,8 @@ "docker:ssh": "pnpm exec wc-e2e docker:ssh", "docker:up": "pnpm exec wc-e2e docker:up", "env:dev": "pnpm wp-env start", - "env:init-test": "./e2e/bin/env-setup.sh", - "env:test": "pnpm run env:dev && ./e2e/bin/test-env-setup.sh", + "env:test": "pnpm run env:dev && ./tests/e2e-pw/bin/test-env-setup.sh", + "env:performance-init": "./tests/performance/bin/init-sample-products.sh", "env:down": "pnpm wp-env stop", "env:destroy": "pnpm wp-env destroy", "test:api": "API_TEST_REPORT_DIR=\"$PWD/tests/api\" pnpm exec wc-api-tests test api", diff --git a/plugins/woocommerce/e2e/README.md b/plugins/woocommerce/tests/e2e-pw/README.md similarity index 92% rename from plugins/woocommerce/e2e/README.md rename to plugins/woocommerce/tests/e2e-pw/README.md index 67c422de037..0a882a630a6 100644 --- a/plugins/woocommerce/e2e/README.md +++ b/plugins/woocommerce/tests/e2e-pw/README.md @@ -44,9 +44,9 @@ To run the test again, re-create the environment to start with a fresh state: Other ways of running tests: - `pnpm env:test --filter=woocommerce` (headless) -- `cd plugin/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=e2e/playwright.config.js --headed` (headed) -- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=e2e/playwright.config.js --debug` (debug) -- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=e2e/playwright.config.js ./e2e/tests/activate-and-setup/basic-setup.spec.js` (running a single test) +- `cd plugin/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js --headed` (headed) +- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js --debug` (debug) +- `cd plugins/woocommerce && USE_WP_ENV=1 pnpm playwright test --config=tests/e2e-pw/playwright.config.js ./tests/e2e-pw/tests/activate-and-setup/basic-setup.spec.js` (running a single test) To see all options, run `cd plugins/woocommerce && pnpm playwright test --help` @@ -85,11 +85,11 @@ The test environment uses the following test variables: } ``` -If you need to modify the port for your local test environment (eg. port is already in use) or use, edit [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/e2e/playwright.config.js). Depending on what environment tool you are using, you will need to also edit the respective `.json` file. +If you need to modify the port for your local test environment (eg. port is already in use) or use, edit [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js). Depending on what environment tool you are using, you will need to also edit the respective `.json` file. **Modiify the port wp-env** -Edit [.wp-env.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/.wp-env.json) and [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/e2e/playwright.config.js). +Edit [.wp-env.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/.wp-env.json) and [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js). **Modiify port for e2e-environment** diff --git a/plugins/woocommerce/e2e/bin/test-env-setup.sh b/plugins/woocommerce/tests/e2e-pw/bin/test-env-setup.sh similarity index 100% rename from plugins/woocommerce/e2e/bin/test-env-setup.sh rename to plugins/woocommerce/tests/e2e-pw/bin/test-env-setup.sh diff --git a/plugins/woocommerce/e2e/global-setup.js b/plugins/woocommerce/tests/e2e-pw/global-setup.js similarity index 100% rename from plugins/woocommerce/e2e/global-setup.js rename to plugins/woocommerce/tests/e2e-pw/global-setup.js diff --git a/plugins/woocommerce/e2e/global-teardown.js b/plugins/woocommerce/tests/e2e-pw/global-teardown.js similarity index 100% rename from plugins/woocommerce/e2e/global-teardown.js rename to plugins/woocommerce/tests/e2e-pw/global-teardown.js diff --git a/plugins/woocommerce/e2e/playwright.config.js b/plugins/woocommerce/tests/e2e-pw/playwright.config.js similarity index 100% rename from plugins/woocommerce/e2e/playwright.config.js rename to plugins/woocommerce/tests/e2e-pw/playwright.config.js diff --git a/plugins/woocommerce/tests/e2e-pw/storage/adminState.json b/plugins/woocommerce/tests/e2e-pw/storage/adminState.json new file mode 100644 index 00000000000..8098ee78c77 --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/storage/adminState.json @@ -0,0 +1,65 @@ +{ + "cookies": [ + { + "sameSite": "Lax", + "name": "wordpress_dc5025de8b60c0a511df7c07d81ead97", + "value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C8ac4ff905331544a3cbcf0c58840ebfc3f492d4511dd17f48dbed18f5662a2c6", + "domain": "localhost", + "path": "/wp-content/plugins", + "expires": -1, + "httpOnly": true, + "secure": false + }, + { + "sameSite": "Lax", + "name": "wordpress_dc5025de8b60c0a511df7c07d81ead97", + "value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C8ac4ff905331544a3cbcf0c58840ebfc3f492d4511dd17f48dbed18f5662a2c6", + "domain": "localhost", + "path": "/wp-admin", + "expires": -1, + "httpOnly": true, + "secure": false + }, + { + "sameSite": "Lax", + "name": "wordpress_test_cookie", + "value": "WP%20Cookie%20check", + "domain": "localhost", + "path": "/", + "expires": -1, + "httpOnly": false, + "secure": false + }, + { + "sameSite": "Lax", + "name": "wordpress_logged_in_dc5025de8b60c0a511df7c07d81ead97", + "value": "admin%7C1660405922%7CjsNIRwmbjFh7KIGlSHy50rSs6X0L0zISppmBqgh0u0u%7C6de27e0d8393de7715c07e144424d90733d53e65b8665c8a7db1ad94798c369c", + "domain": "localhost", + "path": "/", + "expires": -1, + "httpOnly": true, + "secure": false + }, + { + "sameSite": "Lax", + "name": "tk_ai", + "value": "woo%3AT9QFbJmpuSGWcjApaONaBtSB", + "domain": "localhost", + "path": "/", + "expires": -1, + "httpOnly": false, + "secure": false + }, + { + "sameSite": "Lax", + "name": "wp-settings-time-1", + "value": "1660233126", + "domain": "localhost", + "path": "/", + "expires": 1691769126.937059, + "httpOnly": false, + "secure": false + } + ], + "origins": [] +} \ No newline at end of file diff --git a/plugins/woocommerce/tests/e2e-pw/storage/customerState.json b/plugins/woocommerce/tests/e2e-pw/storage/customerState.json new file mode 100644 index 00000000000..6fa41f487e0 --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/storage/customerState.json @@ -0,0 +1,45 @@ +{ + "cookies": [ + { + "sameSite": "Lax", + "name": "wordpress_dc5025de8b60c0a511df7c07d81ead97", + "value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7Cccb6b6b9e1190e94ef751360fded6ec026c89350f9f4695e9bf900ca09d72a84", + "domain": "localhost", + "path": "/wp-content/plugins", + "expires": -1, + "httpOnly": true, + "secure": false + }, + { + "sameSite": "Lax", + "name": "wordpress_dc5025de8b60c0a511df7c07d81ead97", + "value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7Cccb6b6b9e1190e94ef751360fded6ec026c89350f9f4695e9bf900ca09d72a84", + "domain": "localhost", + "path": "/wp-admin", + "expires": -1, + "httpOnly": true, + "secure": false + }, + { + "sameSite": "Lax", + "name": "wordpress_test_cookie", + "value": "WP%20Cookie%20check", + "domain": "localhost", + "path": "/", + "expires": -1, + "httpOnly": false, + "secure": false + }, + { + "sameSite": "Lax", + "name": "wordpress_logged_in_dc5025de8b60c0a511df7c07d81ead97", + "value": "customer%7C1660405929%7CL0OCLRBBMubq8iKqOeQU1NqOzTWFd7ppECd1n100GKG%7C869a28fa8ef17799b6d097d84c8155c7d0dd18cd9967f7a18e3f49f41dd71226", + "domain": "localhost", + "path": "/", + "expires": -1, + "httpOnly": true, + "secure": false + } + ], + "origins": [] +} \ No newline at end of file diff --git a/plugins/woocommerce/e2e/test-data/sample_products.csv b/plugins/woocommerce/tests/e2e-pw/test-data/sample_products.csv similarity index 100% rename from plugins/woocommerce/e2e/test-data/sample_products.csv rename to plugins/woocommerce/tests/e2e-pw/test-data/sample_products.csv diff --git a/plugins/woocommerce/e2e/test-data/sample_products_override.csv b/plugins/woocommerce/tests/e2e-pw/test-data/sample_products_override.csv similarity index 100% rename from plugins/woocommerce/e2e/test-data/sample_products_override.csv rename to plugins/woocommerce/tests/e2e-pw/test-data/sample_products_override.csv diff --git a/plugins/woocommerce/e2e/tests/activate-and-setup/basic-setup.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/basic-setup.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/activate-and-setup/basic-setup.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/basic-setup.spec.js diff --git a/plugins/woocommerce/e2e/tests/activate-and-setup/complete-onboarding-wizard.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/complete-onboarding-wizard.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/activate-and-setup/complete-onboarding-wizard.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/complete-onboarding-wizard.spec.js diff --git a/plugins/woocommerce/e2e/tests/activate-and-setup/setup-onboarding.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/setup-onboarding.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/activate-and-setup/setup-onboarding.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/setup-onboarding.spec.js diff --git a/plugins/woocommerce/e2e/tests/admin-analytics/analytics-overview.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/admin-analytics/analytics-overview.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/admin-analytics/analytics-overview.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/admin-analytics/analytics-overview.spec.js diff --git a/plugins/woocommerce/e2e/tests/admin-analytics/analytics.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/admin-analytics/analytics.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/admin-analytics/analytics.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/admin-analytics/analytics.spec.js diff --git a/plugins/woocommerce/e2e/tests/admin-marketing/coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/admin-marketing/coupons.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/admin-marketing/coupons.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/admin-marketing/coupons.spec.js diff --git a/plugins/woocommerce/e2e/tests/admin-tasks/payment.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/admin-tasks/payment.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/admin-tasks/payment.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/admin-tasks/payment.spec.js diff --git a/plugins/woocommerce/e2e/tests/basic.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/basic.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/basic.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/basic.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/create-coupon.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/create-coupon.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/create-order.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/create-order.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/create-shipping-classes.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-shipping-classes.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/create-shipping-classes.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/create-shipping-classes.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/create-shipping-zones.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-shipping-zones.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/create-shipping-zones.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/create-shipping-zones.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/create-simple-product.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-simple-product.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/create-simple-product.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/create-simple-product.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/create-variable-product.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-variable-product.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/create-variable-product.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/create-variable-product.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/customer-payment-page.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-payment-page.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/customer-payment-page.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-payment-page.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/order-coupon.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-coupon.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/order-coupon.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/order-coupon.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/order-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/order-edit.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/order-emails.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/order-emails.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/order-refund.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-refund.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/order-refund.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/order-refund.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/order-search.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-search.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/order-search.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/order-search.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/order-status-filter.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-status-filter.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/order-status-filter.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/order-status-filter.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/page-loads.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/page-loads.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/page-loads.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/page-loads.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/product-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/product-edit.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/product-edit.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/product-edit.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/product-import-csv.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/product-import-csv.spec.js similarity index 98% rename from plugins/woocommerce/e2e/tests/merchant/product-import-csv.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/product-import-csv.spec.js index 27498717e5f..6f94b624045 100644 --- a/plugins/woocommerce/e2e/tests/merchant/product-import-csv.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/product-import-csv.spec.js @@ -1,9 +1,9 @@ const { test, expect } = require( '@playwright/test' ); const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default; const path = require( 'path' ); -const filePath = path.resolve( 'e2e/test-data/sample_products.csv' ); +const filePath = path.resolve( 'tests/e2e-pw/test-data/sample_products.csv' ); const filePathOverride = path.resolve( - 'e2e/test-data/sample_products_override.csv' + 'tests/e2e-pw/test-data/sample_products_override.csv' ); const productIds = []; diff --git a/plugins/woocommerce/e2e/tests/merchant/product-search.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/product-search.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/product-search.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/product-search.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/product-settings.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/product-settings.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/product-settings.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/product-settings.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/settings-general.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/settings-general.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/settings-general.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/settings-general.spec.js diff --git a/plugins/woocommerce/e2e/tests/merchant/settings-tax.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/settings-tax.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/merchant/settings-tax.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/merchant/settings-tax.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/calculate-shipping.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/calculate-shipping.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/calculate-shipping.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/calculate-shipping.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/cart-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-coupons.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/cart-coupons.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-coupons.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/cart-redirection.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-redirection.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/cart-redirection.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-redirection.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/cart.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/cart.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/cart.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/checkout-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-coupons.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/checkout-coupons.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-coupons.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/checkout-create-account.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-create-account.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/checkout-create-account.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-create-account.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/checkout-login.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-login.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/checkout-login.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-login.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/checkout.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/checkout.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/my-account-create-account.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-create-account.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/my-account-create-account.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-create-account.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/my-account-pay-order.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-pay-order.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/my-account-pay-order.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-pay-order.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/my-account.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/my-account.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/order-email-receiving.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/order-email-receiving.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/order-email-receiving.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/order-email-receiving.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/product-browse-search-sort.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/product-browse-search-sort.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/product-browse-search-sort.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/product-browse-search-sort.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/single-product.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/single-product.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/single-product.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/single-product.spec.js diff --git a/plugins/woocommerce/e2e/tests/shopper/variable-product-updates.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/variable-product-updates.spec.js similarity index 100% rename from plugins/woocommerce/e2e/tests/shopper/variable-product-updates.spec.js rename to plugins/woocommerce/tests/e2e-pw/tests/shopper/variable-product-updates.spec.js diff --git a/plugins/woocommerce/tests/e2e/config/jest.config.js b/plugins/woocommerce/tests/e2e/config/jest.config.js index 4e3b87bcce7..2468bd59e82 100644 --- a/plugins/woocommerce/tests/e2e/config/jest.config.js +++ b/plugins/woocommerce/tests/e2e/config/jest.config.js @@ -1,6 +1,7 @@ const path = require( 'path' ); -const { useE2EJestConfig, getAppRoot } = require( '@woocommerce/e2e-environment' ); +const { useE2EJestConfig } = require( '@woocommerce/e2e-environment' ); +// eslint-disable-next-line const jestConfig = useE2EJestConfig( { roots: [ path.resolve( __dirname, '../specs' ) ], } ); diff --git a/plugins/woocommerce/tests/e2e/config/jest.setup.js b/plugins/woocommerce/tests/e2e/config/jest.setup.js index f413c18ce85..dca14a43a63 100644 --- a/plugins/woocommerce/tests/e2e/config/jest.setup.js +++ b/plugins/woocommerce/tests/e2e/config/jest.setup.js @@ -1,47 +1,58 @@ +/* global page */ + +/** + * External dependencies + */ import { clearLocalStorage, setBrowserViewport, withRestApi, - WP_ADMIN_LOGIN + WP_ADMIN_LOGIN, } from '@woocommerce/e2e-utils'; +/** + * Internal dependencies + */ const config = require( 'config' ); const { HTTPClientFactory } = require( '@woocommerce/api' ); -const { addConsoleSuppression, updateReadyPageStatus, setupJestRetries } = require( '@woocommerce/e2e-environment' ); +const { + addConsoleSuppression, + updateReadyPageStatus, + setupJestRetries, +} = require( '@woocommerce/e2e-environment' ); const { DEFAULT_TIMEOUT_OVERRIDE } = process.env; // @todo: remove this once https://github.com/woocommerce/woocommerce-admin/issues/6992 has been addressed -addConsoleSuppression('woocommerce_shared_settings', false); +addConsoleSuppression( 'woocommerce_shared_settings', false ); // @todo: remove this once https://github.com/woocommerce/woocommerce/issues/31867 has been addressed -addConsoleSuppression('wp.compose.withState', false); +addConsoleSuppression( 'wp.compose.withState', false ); /** * Uses the WordPress API to delete all existing posts */ async function trashExistingPosts() { - const apiUrl = config.get('url'); + const apiUrl = config.get( 'url' ); const wpPostsEndpoint = '/wp/v2/posts'; - const adminUsername = config.get('users.admin.username'); - const adminPassword = config.get('users.admin.password'); - const client = HTTPClientFactory.build(apiUrl) - .withBasicAuth(adminUsername, adminPassword) + const adminUsername = config.get( 'users.admin.username' ); + const adminPassword = config.get( 'users.admin.password' ); + const client = HTTPClientFactory.build( apiUrl ) + .withBasicAuth( adminUsername, adminPassword ) .create(); // List all existing posts - const response = await client.get(wpPostsEndpoint); + const response = await client.get( wpPostsEndpoint ); const posts = response.data; // Delete each post - for (const post of posts) { - await client.delete(`${wpPostsEndpoint}/${post.id}`); + for ( const post of posts ) { + await client.delete( `${ wpPostsEndpoint }/${ post.id }` ); } } // Before every test suite run, delete all content created by the test. This ensures // other posts/comments/etc. aren't dirtying tests and tests don't depend on // each other's side-effects. -beforeAll(async () => { - +beforeAll( async () => { setupJestRetries( 2 ); if ( DEFAULT_TIMEOUT_OVERRIDE ) { @@ -51,7 +62,7 @@ beforeAll(async () => { try { // Update the ready page to prevent concurrent test runs - await updateReadyPageStatus('draft'); + await updateReadyPageStatus( 'draft' ); await trashExistingPosts(); await withRestApi.deleteAllProducts(); await withRestApi.deleteAllCoupons(); @@ -60,25 +71,25 @@ beforeAll(async () => { // Prevent an error here causing tests to fail. } - await page.goto(WP_ADMIN_LOGIN); + await page.goto( WP_ADMIN_LOGIN ); await clearLocalStorage(); await setBrowserViewport( { width: 1280, height: 800, - }); -}); + } ); +} ); // Clear browser cookies and cache using DevTools. // This is to ensure that each test ends with no user logged in. -afterAll(async () => { +afterAll( async () => { // Reset the ready page to published to allow future test runs try { - await updateReadyPageStatus('publish'); + await updateReadyPageStatus( 'publish' ); } catch ( error ) { // Prevent an error here causing tests to fail. } const client = await page.target().createCDPSession(); - await client.send('Network.clearBrowserCookies'); - await client.send('Network.clearBrowserCache'); -}); + await client.send( 'Network.clearBrowserCookies' ); + await client.send( 'Network.clearBrowserCache' ); +} ); diff --git a/plugins/woocommerce/tests/e2e/specs/activate-and-setup/setup-onboarding.js b/plugins/woocommerce/tests/e2e/specs/activate-and-setup/setup-onboarding.js index f3de8c5841b..1d97833b414 100644 --- a/plugins/woocommerce/tests/e2e/specs/activate-and-setup/setup-onboarding.js +++ b/plugins/woocommerce/tests/e2e/specs/activate-and-setup/setup-onboarding.js @@ -1,7 +1,11 @@ /* * Internal dependencies */ -const { runActivationTest, runInitialStoreSettingsTest, runSetupOnboardingTests } = require( '@woocommerce/e2e-core-tests' ); +const { + runActivationTest, + runInitialStoreSettingsTest, + runSetupOnboardingTests, +} = require( '@woocommerce/e2e-core-tests' ); runActivationTest(); runInitialStoreSettingsTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/admin-analytics/analytics-overview.test.js b/plugins/woocommerce/tests/e2e/specs/admin-analytics/analytics-overview.test.js index 9bc1b4e7467..5d196295c23 100644 --- a/plugins/woocommerce/tests/e2e/specs/admin-analytics/analytics-overview.test.js +++ b/plugins/woocommerce/tests/e2e/specs/admin-analytics/analytics-overview.test.js @@ -1,3 +1,5 @@ -const { testAdminAnalyticsOverview } = require( '@woocommerce/admin-e2e-tests' ); +const { + testAdminAnalyticsOverview, +} = require( '@woocommerce/admin-e2e-tests' ); testAdminAnalyticsOverview(); diff --git a/plugins/woocommerce/tests/e2e/specs/admin-homescreen/activity-panel.test.js b/plugins/woocommerce/tests/e2e/specs/admin-homescreen/activity-panel.test.js index b8865709e32..6ff843ab77c 100644 --- a/plugins/woocommerce/tests/e2e/specs/admin-homescreen/activity-panel.test.js +++ b/plugins/woocommerce/tests/e2e/specs/admin-homescreen/activity-panel.test.js @@ -1,3 +1,5 @@ -const { testAdminHomescreenActivityPanel } = require( '@woocommerce/admin-e2e-tests' ); +const { + testAdminHomescreenActivityPanel, +} = require( '@woocommerce/admin-e2e-tests' ); testAdminHomescreenActivityPanel(); diff --git a/plugins/woocommerce/tests/e2e/specs/admin-homescreen/task-list.test.js b/plugins/woocommerce/tests/e2e/specs/admin-homescreen/task-list.test.js index ae76561b357..9bbfdabdc49 100644 --- a/plugins/woocommerce/tests/e2e/specs/admin-homescreen/task-list.test.js +++ b/plugins/woocommerce/tests/e2e/specs/admin-homescreen/task-list.test.js @@ -1,3 +1,5 @@ -const { testAdminHomescreenTasklist } = require( '@woocommerce/admin-e2e-tests' ); +const { + testAdminHomescreenTasklist, +} = require( '@woocommerce/admin-e2e-tests' ); testAdminHomescreenTasklist(); diff --git a/plugins/woocommerce/tests/e2e/specs/admin-tasks/purchase.test.js b/plugins/woocommerce/tests/e2e/specs/admin-tasks/purchase.test.js index 8a7c6572c72..f9998efb94a 100644 --- a/plugins/woocommerce/tests/e2e/specs/admin-tasks/purchase.test.js +++ b/plugins/woocommerce/tests/e2e/specs/admin-tasks/purchase.test.js @@ -1,3 +1,5 @@ -const { testAdminPurchaseSetupTask } = require( '@woocommerce/admin-e2e-tests' ); +const { + testAdminPurchaseSetupTask, +} = require( '@woocommerce/admin-e2e-tests' ); testAdminPurchaseSetupTask(); diff --git a/plugins/woocommerce/tests/e2e/specs/front-end/cart-calculate-shipping.test.js b/plugins/woocommerce/tests/e2e/specs/front-end/cart-calculate-shipping.test.js index 6ee84f7b8f2..aebd14abb16 100644 --- a/plugins/woocommerce/tests/e2e/specs/front-end/cart-calculate-shipping.test.js +++ b/plugins/woocommerce/tests/e2e/specs/front-end/cart-calculate-shipping.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runCartCalculateShippingTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runCartCalculateShippingTest, +} = require( '@woocommerce/e2e-core-tests' ); runCartCalculateShippingTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/front-end/checkout-coupons.test.js b/plugins/woocommerce/tests/e2e/specs/front-end/checkout-coupons.test.js index 6bc6e858302..c3449e328dc 100644 --- a/plugins/woocommerce/tests/e2e/specs/front-end/checkout-coupons.test.js +++ b/plugins/woocommerce/tests/e2e/specs/front-end/checkout-coupons.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runCheckoutApplyCouponsTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runCheckoutApplyCouponsTest, +} = require( '@woocommerce/e2e-core-tests' ); runCheckoutApplyCouponsTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/front-end/checkout-create-account.test.js b/plugins/woocommerce/tests/e2e/specs/front-end/checkout-create-account.test.js index 58cdf32b230..b9f855bfa64 100644 --- a/plugins/woocommerce/tests/e2e/specs/front-end/checkout-create-account.test.js +++ b/plugins/woocommerce/tests/e2e/specs/front-end/checkout-create-account.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runCheckoutCreateAccountTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runCheckoutCreateAccountTest, +} = require( '@woocommerce/e2e-core-tests' ); runCheckoutCreateAccountTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/front-end/checkout-login-account.test.js b/plugins/woocommerce/tests/e2e/specs/front-end/checkout-login-account.test.js index 1bf304e04ad..66587a3941c 100644 --- a/plugins/woocommerce/tests/e2e/specs/front-end/checkout-login-account.test.js +++ b/plugins/woocommerce/tests/e2e/specs/front-end/checkout-login-account.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runCheckoutLoginAccountTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runCheckoutLoginAccountTest, +} = require( '@woocommerce/e2e-core-tests' ); runCheckoutLoginAccountTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/front-end/my-account-create-account.test.js b/plugins/woocommerce/tests/e2e/specs/front-end/my-account-create-account.test.js index cfcbfdc780b..0135715b778 100644 --- a/plugins/woocommerce/tests/e2e/specs/front-end/my-account-create-account.test.js +++ b/plugins/woocommerce/tests/e2e/specs/front-end/my-account-create-account.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runMyAccountCreateAccountTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runMyAccountCreateAccountTest, +} = require( '@woocommerce/e2e-core-tests' ); runMyAccountCreateAccountTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/front-end/product-browse-search-sort.test.js b/plugins/woocommerce/tests/e2e/specs/front-end/product-browse-search-sort.test.js index ed12d1cb341..8a41e63ea62 100644 --- a/plugins/woocommerce/tests/e2e/specs/front-end/product-browse-search-sort.test.js +++ b/plugins/woocommerce/tests/e2e/specs/front-end/product-browse-search-sort.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runProductBrowseSearchSortTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runProductBrowseSearchSortTest, +} = require( '@woocommerce/e2e-core-tests' ); runProductBrowseSearchSortTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/front-end/variable-product-updates.test.js b/plugins/woocommerce/tests/e2e/specs/front-end/variable-product-updates.test.js index fefa5414482..0320297558a 100644 --- a/plugins/woocommerce/tests/e2e/specs/front-end/variable-product-updates.test.js +++ b/plugins/woocommerce/tests/e2e/specs/front-end/variable-product-updates.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runVariableProductUpdateTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runVariableProductUpdateTest, +} = require( '@woocommerce/e2e-core-tests' ); runVariableProductUpdateTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/smoke-tests/update-woocommerce.js b/plugins/woocommerce/tests/e2e/specs/smoke-tests/update-woocommerce.js index 446a80cea38..b95391ae836 100644 --- a/plugins/woocommerce/tests/e2e/specs/smoke-tests/update-woocommerce.js +++ b/plugins/woocommerce/tests/e2e/specs/smoke-tests/update-woocommerce.js @@ -3,15 +3,16 @@ */ const { merchant, utils } = require( '@woocommerce/e2e-utils' ); -const { getRemotePluginZip, getLatestReleaseZipUrl, deleteDownloadedPluginFiles } = require( '@woocommerce/e2e-environment' ); +const { + getRemotePluginZip, + getLatestReleaseZipUrl, + deleteDownloadedPluginFiles, +} = require( '@woocommerce/e2e-environment' ); /** * External dependencies */ -const { - it, - beforeAll, -} = require( '@jest/globals' ); +const { it, beforeAll } = require( '@jest/globals' ); const { UPDATE_WC, TEST_RELEASE } = process.env; @@ -20,35 +21,39 @@ const pluginName = 'WooCommerce'; let pluginPath; -utils.describeIf( UPDATE_WC )( 'WooCommerce plugin can be uploaded and activated', () => { - beforeAll( async () => { +utils.describeIf( UPDATE_WC )( + 'WooCommerce plugin can be uploaded and activated', + () => { + beforeAll( async () => { + if ( TEST_RELEASE ) { + zipUrl = await getLatestReleaseZipUrl( + 'woocommerce/woocommerce' + ); + } else { + zipUrl = + 'https://github.com/woocommerce/woocommerce/releases/download/nightly/woocommerce-trunk-nightly.zip'; + } - if ( TEST_RELEASE ) { - zipUrl = await getLatestReleaseZipUrl( 'woocommerce/woocommerce' ); - } else { - zipUrl = 'https://github.com/woocommerce/woocommerce/releases/download/nightly/woocommerce-trunk-nightly.zip'; - } + pluginPath = await getRemotePluginZip( zipUrl ); + await merchant.login(); + } ); - pluginPath = await getRemotePluginZip( zipUrl ); - await merchant.login(); - }); + afterAll( async () => { + await merchant.logout(); + await deleteDownloadedPluginFiles(); + } ); - afterAll( async () => { - await merchant.logout(); - await deleteDownloadedPluginFiles(); - }); + it( 'can upload and activate the WooCommerce plugin', async () => { + await merchant.uploadAndActivatePlugin( pluginPath, pluginName ); + } ); - it( 'can upload and activate the WooCommerce plugin', async () => { - await merchant.uploadAndActivatePlugin( pluginPath, pluginName ); - }); + it( 'can run the database update', async () => { + // Check for, and run, the database upgrade if needed + await merchant.runDatabaseUpdate(); + } ); - it( 'can run the database update', async () => { - // Check for, and run, the database upgrade if needed - await merchant.runDatabaseUpdate(); - }); - - it( 'can remove downloaded plugin zip', async () => { - await deleteDownloadedPluginFiles(); - } ); - -}); + it( 'can remove downloaded plugin zip', async () => { + await deleteDownloadedPluginFiles(); + } ); + } +); diff --git a/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js b/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js index 7526b336f00..e12ee05cce2 100644 --- a/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js +++ b/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js @@ -3,17 +3,19 @@ */ const { merchant, utils } = require( '@woocommerce/e2e-utils' ); -const { getRemotePluginZip, getLatestReleaseZipUrl, deleteDownloadedPluginFiles } = require( '@woocommerce/e2e-environment' ); +const { + getRemotePluginZip, + getLatestReleaseZipUrl, + deleteDownloadedPluginFiles, +} = require( '@woocommerce/e2e-environment' ); /** * External dependencies */ -const { - it, - beforeAll, -} = require( '@jest/globals' ); +const { it, beforeAll } = require( '@jest/globals' ); -const { GITHUB_REPOSITORY, PLUGIN_NAME, GITHUB_TOKEN, PLUGIN_REPOSITORY } = process.env; +const { GITHUB_REPOSITORY, PLUGIN_NAME, GITHUB_TOKEN, PLUGIN_REPOSITORY } = + process.env; // allows us to upload plugins from different repositories. const pluginName = PLUGIN_NAME ? PLUGIN_NAME : 'WooCommerce'; @@ -37,10 +39,12 @@ utils.describeIf( repository )( await merchant.logout(); } ); + /* eslint-disable jest/expect-expect */ it( 'can upload and activate the provided plugin', async () => { await merchant.uploadAndActivatePlugin( pluginPath, PLUGIN_NAME ); } ); + /* eslint-disable jest/expect-expect */ it( 'can remove downloaded plugin zip', async () => { await deleteDownloadedPluginFiles(); } ); diff --git a/plugins/woocommerce/tests/e2e/specs/wp-admin/order-customer-payment-page.test.js b/plugins/woocommerce/tests/e2e/specs/wp-admin/order-customer-payment-page.test.js index 808d5a8ede9..3aad6c4f770 100644 --- a/plugins/woocommerce/tests/e2e/specs/wp-admin/order-customer-payment-page.test.js +++ b/plugins/woocommerce/tests/e2e/specs/wp-admin/order-customer-payment-page.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runMerchantOrdersCustomerPaymentPage } = require( '@woocommerce/e2e-core-tests' ); +const { + runMerchantOrdersCustomerPaymentPage, +} = require( '@woocommerce/e2e-core-tests' ); runMerchantOrdersCustomerPaymentPage(); diff --git a/plugins/woocommerce/tests/e2e/specs/wp-admin/update-general-settings.test.js b/plugins/woocommerce/tests/e2e/specs/wp-admin/update-general-settings.test.js index 91bdbebeaaf..ee056a44499 100644 --- a/plugins/woocommerce/tests/e2e/specs/wp-admin/update-general-settings.test.js +++ b/plugins/woocommerce/tests/e2e/specs/wp-admin/update-general-settings.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runUpdateGeneralSettingsTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runUpdateGeneralSettingsTest, +} = require( '@woocommerce/e2e-core-tests' ); runUpdateGeneralSettingsTest(); diff --git a/plugins/woocommerce/tests/e2e/specs/wp-admin/wccom-connect.test.js b/plugins/woocommerce/tests/e2e/specs/wp-admin/wccom-connect.test.js index a7b4cd8deed..a943447d87c 100644 --- a/plugins/woocommerce/tests/e2e/specs/wp-admin/wccom-connect.test.js +++ b/plugins/woocommerce/tests/e2e/specs/wp-admin/wccom-connect.test.js @@ -1,6 +1,8 @@ /* * Internal dependencies */ -const { runInitiateWccomConnectionTest } = require( '@woocommerce/e2e-core-tests' ); +const { + runInitiateWccomConnectionTest, +} = require( '@woocommerce/e2e-core-tests' ); runInitiateWccomConnectionTest(); diff --git a/plugins/woocommerce/tests/performance/README.md b/plugins/woocommerce/tests/performance/README.md index f69e7b53f9b..e8dedf66ae7 100644 --- a/plugins/woocommerce/tests/performance/README.md +++ b/plugins/woocommerce/tests/performance/README.md @@ -54,9 +54,12 @@ Alternatively the k6 docker image can be used to execute tests. Before using the tests a test environment is needed to run against. -In the WooCommerce e2e tests there is a Docker Initialization Script [`init-sample-products.sh`](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/e2e/docker/init-sample-products.sh) that will set up a shop with sample products imported and the shop settings (payment method, permalinks, address etc) needed for the tests already set. It is recommended using this to just see the tests in action. +We first spin up an environment using `wp-env` and configure that environment with the necessary plugins and data using the Initialization Script [`init-sample-products.sh`](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/performance/bin/init-sample-products.sh) that will set up a shop with sample products imported and the shop settings (payment method, permalinks, address etc) needed for the tests already set. It is recommended using this to just see the tests in action. -`npx wc-e2e docker:up ./tests/e2e/docker/init-sample-products.sh` +```sh +pnpm run env:dev --filter=woocommerce +pnpm run env:performance-init --filter=woocommerce +``` If using a different environment the details can be changed in `config.js`. diff --git a/plugins/woocommerce/tests/performance/bin/init-sample-products.sh b/plugins/woocommerce/tests/performance/bin/init-sample-products.sh new file mode 100755 index 00000000000..8ff1244b972 --- /dev/null +++ b/plugins/woocommerce/tests/performance/bin/init-sample-products.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +echo "Initializing WooCommerce E2E" + +wp-env run tests-cli "wp plugin activate woocommerce" + +wp-env run tests-cli "wp user create customer customer@woocommercecoree2etestsuite.com --user_pass=password --role=subscriber --path=/var/www/html" + +# we cannot create API keys for the API, so we using basic auth, this plugin allows that. +wp-env run tests-cli "wp plugin install https://github.com/WP-API/Basic-Auth/archive/master.zip --activate" + +# update permalinks to `pretty` to make it easier for testing APIs with k6 +wp-env run tests-cli "wp option update permalink_structure /%postname%/" + +# install the WP Mail Logging plugin to test emails +wp-env run tests-cli "wp plugin install wp-mail-logging --activate" + +# Installing and activating the WordPress Importer plugin to import sample products" +wp-env run tests-cli "wp plugin install wordpress-importer --activate" + +# Adding basic WooCommerce settings" +wp-env run tests-cli "wp option set woocommerce_store_address 'Example Address Line 1'" +wp-env run tests-cli "wp option set woocommerce_store_address_2 'Example Address Line 2'" +wp-env run tests-cli "wp option set woocommerce_store_city 'Example City'" +wp-env run tests-cli "wp option set woocommerce_default_country 'US:CA'" +wp-env run tests-cli "wp option set woocommerce_store_postcode '94110'" +wp-env run tests-cli "wp option set woocommerce_currency 'USD'" +wp-env run tests-cli "wp option set woocommerce_product_type 'both'" +wp-env run tests-cli "wp option set woocommerce_allow_tracking 'no'" +wp-env run tests-cli "wp option set woocommerce_enable_checkout_login_reminder 'yes'" +wp-env run tests-cli "wp option set --format=json woocommerce_cod_settings '{\"enabled\":\"yes\"}'" + +# WooCommerce shop pages +wp-env run tests-cli "wp wc --user=admin tool run install_pages" + +# Importing WooCommerce sample products" +wp-env run tests-cli "wp import wp-content/plugins/woocommerce/sample-data/sample_products.xml --authors=skip" + +# install Storefront +wp-env run tests-cli "wp theme install storefront --activate" + +echo "Success! Your E2E Test Environment is now ready."