From 55e1fadd3d5cdea3bb56df4c8b7a27c56a7ee394 Mon Sep 17 00:00:00 2001 From: Carl Alexander Date: Sun, 21 Nov 2021 14:35:58 -0500 Subject: [PATCH 01/54] Add `file` to check import file path hooks --- .../importers/class-wc-product-csv-importer-controller.php | 2 +- plugins/woocommerce/includes/wc-conditional-functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php b/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php index b14ad20f453..d22dd430441 100644 --- a/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -92,7 +92,7 @@ class WC_Product_CSV_Importer_Controller { * @return bool */ public static function is_file_valid_csv( $file, $check_path = true ) { - if ( $check_path && apply_filters( 'woocommerce_product_csv_importer_check_import_file_path', true ) && false !== stripos( $file, '://' ) ) { + if ( $check_path && apply_filters( 'woocommerce_product_csv_importer_check_import_file_path', true, $file ) && false !== stripos( $file, '://' ) ) { return false; } diff --git a/plugins/woocommerce/includes/wc-conditional-functions.php b/plugins/woocommerce/includes/wc-conditional-functions.php index bdebe59dc48..f44ee86eac9 100644 --- a/plugins/woocommerce/includes/wc-conditional-functions.php +++ b/plugins/woocommerce/includes/wc-conditional-functions.php @@ -466,7 +466,7 @@ function wc_is_file_valid_csv( $file, $check_path = true ) { * @since 3.6.4 * @param bool $check_import_file_path If requires file path check. Defaults to true. */ - $check_import_file_path = apply_filters( 'woocommerce_csv_importer_check_import_file_path', true ); + $check_import_file_path = apply_filters( 'woocommerce_csv_importer_check_import_file_path', true, $file ); if ( $check_path && $check_import_file_path && false !== stripos( $file, '://' ) ) { return false; From 9a6ba5cac98d9ec4118843e08e5eb078e6960499 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 8 Jan 2022 01:05:43 +0100 Subject: [PATCH 02/54] fix #31586 fix #31586 - Special characters in email subject --- plugins/woocommerce/includes/emails/class-wc-email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/emails/class-wc-email.php b/plugins/woocommerce/includes/emails/class-wc-email.php index 1b4d9a61eee..9f05fd39f28 100644 --- a/plugins/woocommerce/includes/emails/class-wc-email.php +++ b/plugins/woocommerce/includes/emails/class-wc-email.php @@ -651,7 +651,7 @@ class WC_Email extends WC_Settings_API { $message = apply_filters( 'woocommerce_mail_content', $this->style_inline( $message ) ); $mail_callback = apply_filters( 'woocommerce_mail_callback', 'wp_mail', $this ); - $mail_callback_params = apply_filters( 'woocommerce_mail_callback_params', array( $to, $subject, $message, $headers, $attachments ), $this ); + $mail_callback_params = apply_filters( 'woocommerce_mail_callback_params', array( $to, wp_specialchars_decode( $subject ), $message, $headers, $attachments ), $this ); $return = $mail_callback( ...$mail_callback_params ); remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); From 5dbf994d8e432c571a3fafb2c4019047dc9f789a Mon Sep 17 00:00:00 2001 From: jamelreid Date: Sat, 15 Jan 2022 13:58:25 -0500 Subject: [PATCH 03/54] Added steps to tests condition evaluation --- .github/workflows/pr-smoke-test.yml | 33 +++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-smoke-test.yml b/.github/workflows/pr-smoke-test.yml index a875d04c4d6..406307c0489 100644 --- a/.github/workflows/pr-smoke-test.yml +++ b/.github/workflows/pr-smoke-test.yml @@ -50,7 +50,7 @@ jobs: UPDATE_WC: 1 DEFAULT_TIMEOUT_OVERRIDE: 120000 run: | - pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.js + pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.j - name: Post Smoke tests results comment on PR if: always() @@ -81,7 +81,7 @@ jobs: UPDATE_WC: 1 DEFAULT_TIMEOUT_OVERRIDE: 120000 run: | - pnpx wc-e2e test:e2e + pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.j - name: Post E2E tests results comment on PR if: always() @@ -101,3 +101,32 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} labels: 'run: smoke tests' + + - name: Remove label from pull request 2. + if: | + always() && + ${{ contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) }} + uses: actions-ecosystem/action-remove-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'run: smoke tests' + + - name: Remove label from pull request 3. + if: | + ${{ always() + && contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) + }} + uses: actions-ecosystem/action-remove-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'run: smoke tests' + + - name: Remove label from pull request 4. + if: | + always() + && contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) + + uses: actions-ecosystem/action-remove-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'run: smoke tests' From bb2810abf9cb63983e0a234d4ea1430db083e745 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Sat, 15 Jan 2022 14:07:16 -0500 Subject: [PATCH 04/54] Fixed commands and removed test steps --- .github/workflows/pr-smoke-test.yml | 31 ++--------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pr-smoke-test.yml b/.github/workflows/pr-smoke-test.yml index 406307c0489..01344186e80 100644 --- a/.github/workflows/pr-smoke-test.yml +++ b/.github/workflows/pr-smoke-test.yml @@ -50,7 +50,7 @@ jobs: UPDATE_WC: 1 DEFAULT_TIMEOUT_OVERRIDE: 120000 run: | - pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.j + pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.js - name: Post Smoke tests results comment on PR if: always() @@ -81,7 +81,7 @@ jobs: UPDATE_WC: 1 DEFAULT_TIMEOUT_OVERRIDE: 120000 run: | - pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.j + pnpx wc-e2e test:e2e - name: Post E2E tests results comment on PR if: always() @@ -96,36 +96,9 @@ jobs: await script({github, context}) - name: Remove label from pull request. - if: always() && ${{ contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) }} - uses: actions-ecosystem/action-remove-labels@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: 'run: smoke tests' - - - name: Remove label from pull request 2. - if: | - always() && - ${{ contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) }} - uses: actions-ecosystem/action-remove-labels@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: 'run: smoke tests' - - - name: Remove label from pull request 3. - if: | - ${{ always() - && contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) - }} - uses: actions-ecosystem/action-remove-labels@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: 'run: smoke tests' - - - name: Remove label from pull request 4. if: | always() && contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) - uses: actions-ecosystem/action-remove-labels@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} From 80bf1cfb76d3cb27c86cd3ac17435fe20c859c28 Mon Sep 17 00:00:00 2001 From: Menaka S Date: Tue, 18 Jan 2022 14:22:42 +0400 Subject: [PATCH 05/54] Add WcPay settings info to WC Tracker --- plugins/woocommerce/includes/class-wc-tracker.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/woocommerce/includes/class-wc-tracker.php b/plugins/woocommerce/includes/class-wc-tracker.php index 9346ce8c987..a7e9c6fc082 100644 --- a/plugins/woocommerce/includes/class-wc-tracker.php +++ b/plugins/woocommerce/includes/class-wc-tracker.php @@ -151,6 +151,9 @@ class WC_Tracker { // Payment gateway info. $data['gateways'] = self::get_active_payment_gateways(); + // WcPay settings info. + $data['wcpay_settings'] = self::get_wcpay_settings(); + // Shipping method info. $data['shipping_methods'] = self::get_active_shipping_methods(); @@ -303,6 +306,15 @@ class WC_Tracker { ); } + /** + * Get the settings of WooCommerce Payments plugin + * + * @return array + */ + private static function get_wcpay_settings() { + return get_option( 'woocommerce_woocommerce_payments_settings' ); + } + /** * Check to see if the helper is connected to woocommerce.com * @@ -589,6 +601,7 @@ class WC_Tracker { return $active_gateways; } + /** * Get a list of all active shipping methods. * From af8fedf6f6f7c6b6f4383766d1367b9bd1d98e89 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Tue, 18 Jan 2022 11:46:09 -0500 Subject: [PATCH 06/54] Removed whitespace --- .github/workflows/pr-smoke-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-smoke-test.yml b/.github/workflows/pr-smoke-test.yml index 01344186e80..97cf35a0676 100644 --- a/.github/workflows/pr-smoke-test.yml +++ b/.github/workflows/pr-smoke-test.yml @@ -102,4 +102,4 @@ jobs: uses: actions-ecosystem/action-remove-labels@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - labels: 'run: smoke tests' + labels: 'run: smoke tests' From f5411284a5153e5bc956857e6697b75da8ce4b8d Mon Sep 17 00:00:00 2001 From: mrleemon Date: Tue, 18 Jan 2022 20:00:33 +0100 Subject: [PATCH 07/54] Wrap terms and conditions required asterisk symbol with tag --- plugins/woocommerce/templates/checkout/terms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/templates/checkout/terms.php b/plugins/woocommerce/templates/checkout/terms.php index 21ade908400..188a9f1784a 100644 --- a/plugins/woocommerce/templates/checkout/terms.php +++ b/plugins/woocommerce/templates/checkout/terms.php @@ -28,7 +28,7 @@ if ( apply_filters( 'woocommerce_checkout_show_terms', true ) && function_exists

From 9cd3c6976d6326b5b8f61be84181f1793fa425f9 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Fri, 21 Jan 2022 17:51:46 -0500 Subject: [PATCH 08/54] Used resolveLocalE2ePath for path to test results --- packages/js/e2e-environment/bin/post-results-to-github-pr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/js/e2e-environment/bin/post-results-to-github-pr.js b/packages/js/e2e-environment/bin/post-results-to-github-pr.js index 319c10510dc..daa39d48d68 100644 --- a/packages/js/e2e-environment/bin/post-results-to-github-pr.js +++ b/packages/js/e2e-environment/bin/post-results-to-github-pr.js @@ -1,7 +1,8 @@ const fs = require( 'fs' ); const path = require( 'path' ); +const { resolveLocalE2ePath } = require( '../utils' ); -const resultsFile = path.resolve( __dirname, '../test-results.json' ); +const resultsFile = resolveLocalE2ePath( 'test-results.json' ); const buildOutput = ( results ) => { const { TITLE, SMOKE_TEST_URL } = process.env; From cd8559381b1473850d0c123140e9d1bb74cc5289 Mon Sep 17 00:00:00 2001 From: dhjw Date: Sat, 22 Jan 2022 16:07:04 -0800 Subject: [PATCH 09/54] Enable browser-suggested passwords on checkout signup --- .../woocommerce/includes/class-wc-checkout.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/woocommerce/includes/class-wc-checkout.php b/plugins/woocommerce/includes/class-wc-checkout.php index 5bc4fb42e2d..076b8a48e32 100644 --- a/plugins/woocommerce/includes/class-wc-checkout.php +++ b/plugins/woocommerce/includes/class-wc-checkout.php @@ -247,19 +247,21 @@ class WC_Checkout { if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) { $this->fields['account']['account_username'] = array( - 'type' => 'text', - 'label' => __( 'Account username', 'woocommerce' ), - 'required' => true, - 'placeholder' => esc_attr__( 'Username', 'woocommerce' ), + 'type' => 'text', + 'label' => __( 'Account username', 'woocommerce' ), + 'required' => true, + 'placeholder' => esc_attr__( 'Username', 'woocommerce' ), + 'autocomplete' => 'username', ); } if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) { $this->fields['account']['account_password'] = array( - 'type' => 'password', - 'label' => __( 'Create account password', 'woocommerce' ), - 'required' => true, - 'placeholder' => esc_attr__( 'Password', 'woocommerce' ), + 'type' => 'password', + 'label' => __( 'Create account password', 'woocommerce' ), + 'required' => true, + 'placeholder' => esc_attr__( 'Password', 'woocommerce' ), + 'autocomplete' => 'new-password', ); } $this->fields = apply_filters( 'woocommerce_checkout_fields', $this->fields ); From b46e6815975ad58dfdc7fbcff55803fc9dc72415 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Mon, 24 Jan 2022 10:22:29 -0500 Subject: [PATCH 10/54] Updated path to test-results.json --- .../js/e2e-environment/bin/post-results-to-github-pr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/js/e2e-environment/bin/post-results-to-github-pr.js b/packages/js/e2e-environment/bin/post-results-to-github-pr.js index daa39d48d68..1e45140484e 100644 --- a/packages/js/e2e-environment/bin/post-results-to-github-pr.js +++ b/packages/js/e2e-environment/bin/post-results-to-github-pr.js @@ -1,8 +1,7 @@ const fs = require( 'fs' ); const path = require( 'path' ); -const { resolveLocalE2ePath } = require( '../utils' ); -const resultsFile = resolveLocalE2ePath( 'test-results.json' ); +const resultsFile = path.resolve( __dirname, '../../../../plugins/woocommerce/tests/e2e/test-results.json' ); const buildOutput = ( results ) => { const { TITLE, SMOKE_TEST_URL } = process.env; @@ -27,7 +26,8 @@ module.exports = async ( { github, context } ) => { output = buildOutput( results ); } else { - output = `## Test Results Not Found!`; + output = `## Test Results Not Found! \n\n`; + output += 'The path to the `test-results.json` file may need to be updated in the `post-results-to-github-pr.js` script'; } await github.rest.issues.createComment( { From 4001340603243311387fa93e76b2a27a43d5db2c Mon Sep 17 00:00:00 2001 From: Jason Kytros Date: Mon, 24 Jan 2022 17:29:19 +0200 Subject: [PATCH 11/54] Hook `set_session` at `woocommerce_after_calculate_totals` @ `1000` --- plugins/woocommerce/includes/class-wc-cart-session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/class-wc-cart-session.php b/plugins/woocommerce/includes/class-wc-cart-session.php index 079b628a546..4985fcd2bee 100644 --- a/plugins/woocommerce/includes/class-wc-cart-session.php +++ b/plugins/woocommerce/includes/class-wc-cart-session.php @@ -47,7 +47,7 @@ final class WC_Cart_Session { public function init() { add_action( 'wp_loaded', array( $this, 'get_cart_from_session' ) ); add_action( 'woocommerce_cart_emptied', array( $this, 'destroy_cart_session' ) ); - add_action( 'woocommerce_after_calculate_totals', array( $this, 'set_session' ) ); + add_action( 'woocommerce_after_calculate_totals', array( $this, 'set_session' ), 1000 ); add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'set_session' ) ); add_action( 'woocommerce_removed_coupon', array( $this, 'set_session' ) ); From 48bfc2c3b20bf55af47d4225bd1e3ad825016cbf Mon Sep 17 00:00:00 2001 From: jamelreid Date: Tue, 25 Jan 2022 11:41:28 -0500 Subject: [PATCH 12/54] Made summary output more dynamic --- .../bin/post-results-to-github-pr.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/js/e2e-environment/bin/post-results-to-github-pr.js b/packages/js/e2e-environment/bin/post-results-to-github-pr.js index 1e45140484e..8327e0030ed 100644 --- a/packages/js/e2e-environment/bin/post-results-to-github-pr.js +++ b/packages/js/e2e-environment/bin/post-results-to-github-pr.js @@ -5,14 +5,22 @@ const resultsFile = path.resolve( __dirname, '../../../../plugins/woocommerce/te const buildOutput = ( results ) => { const { TITLE, SMOKE_TEST_URL } = process.env; + const resultKeys = Object.keys( results ); let output = `## ${ TITLE }:\n\n`; output += `**Test URL:** ${ SMOKE_TEST_URL }\n`; - output += `**Total Number of Passed Tests:** ${ results.numTotalTests }\n`; - output += `**Total Number of Failed Tests:** ${ results.numFailedTests }\n`; - output += `**Total Number of Test Suites:** ${ results.numTotalTestSuites }\n`; - output += `**Total Number of Passed Test Suites:** ${ results.numPassedTestSuites }\n`; - output += `**Total Number of Failed Test Suites:** ${ results.numFailedTestSuites }\n`; + + resultKeys.forEach( ( key ) => { + // The keys that we care about all start with 'num' + if ( key.includes( 'num' ) ) { + // match only capitalized words + const words = key.match( /[A-Z][a-z]+/g ); + + output += `**Total Number of ${ words.join( ' ' ) }:** ${ + results[ key ] + }\n`; + } + } ); return output; }; From bba4a3a1a4ef79cc1c4829fb06c93bf228b68db1 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Tue, 25 Jan 2022 15:13:18 -0500 Subject: [PATCH 13/54] Updated file path --- packages/js/e2e-environment/bin/post-results-to-github-pr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/e2e-environment/bin/post-results-to-github-pr.js b/packages/js/e2e-environment/bin/post-results-to-github-pr.js index 8327e0030ed..203e637a812 100644 --- a/packages/js/e2e-environment/bin/post-results-to-github-pr.js +++ b/packages/js/e2e-environment/bin/post-results-to-github-pr.js @@ -1,7 +1,7 @@ const fs = require( 'fs' ); const path = require( 'path' ); -const resultsFile = path.resolve( __dirname, '../../../../plugins/woocommerce/tests/e2e/test-results.json' ); +const resultsFile = path.resolve( __dirname, '../test-results.json' ); const buildOutput = ( results ) => { const { TITLE, SMOKE_TEST_URL } = process.env; From f07decf956c71b0f1a75455d6276fb7d29aac1bd Mon Sep 17 00:00:00 2001 From: jamelreid Date: Tue, 25 Jan 2022 16:48:28 -0500 Subject: [PATCH 14/54] Updated extraction path --- .github/workflows/smoke-test-daily.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test-daily.yml b/.github/workflows/smoke-test-daily.yml index d642f012abe..37c8a702a10 100644 --- a/.github/workflows/smoke-test-daily.yml +++ b/.github/workflows/smoke-test-daily.yml @@ -132,7 +132,7 @@ jobs: working-directory: tmp run: | unzip woocommerce.zip -d woocommerce - mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ + mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/tests/e2e/plugins/ - name: Install dependencies again working-directory: package/woocommerce From e2eea8140f6078eb76c2bf8920e90ab8d78433f3 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 09:49:41 -0500 Subject: [PATCH 15/54] Added a workflow to test daily smoke tests at will --- .github/workflows/smoke-test-daily-test.yml | 147 ++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 .github/workflows/smoke-test-daily-test.yml diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml new file mode 100644 index 00000000000..a50c6648f2d --- /dev/null +++ b/.github/workflows/smoke-test-daily-test.yml @@ -0,0 +1,147 @@ +name: Smoke test daily Test +on: + pull_request: + branches: + - trunk + types: + - labeled +jobs: + login-run: + name: Daily smoke test on trunk. + if: "${{ contains(github.event.label.name, 'run: daily tests') }}" + runs-on: ubuntu-18.04 + steps: + + - name: Create dirs. + run: | + mkdir -p code/woocommerce + mkdir -p package/woocommerce + mkdir -p tmp/woocommerce + mkdir -p node_modules + + - name: Checkout code. + uses: actions/checkout@v2 + with: + path: package/woocommerce + ref: trunk + + - name: Install prerequisites. + working-directory: package/woocommerce/plugins/woocommerce + run: | + npm install -g pnpm + pnpm install + pnpm nx composer-install-no-dev woocommerce + pnpm nx build-assets woocommerce + pnpm install jest + + - name: Run smoke test. + working-directory: package/woocommerce/plugins/woocommerce + env: + SMOKE_TEST_URL: ${{ secrets.SMOKE_TEST_URL }} + SMOKE_TEST_ADMIN_USER: ${{ secrets.SMOKE_TEST_ADMIN_USER }} + SMOKE_TEST_ADMIN_PASSWORD: ${{ secrets.SMOKE_TEST_ADMIN_PASSWORD }} + SMOKE_TEST_ADMIN_USER_EMAIL: ${{ secrets.SMOKE_TEST_ADMIN_USER_EMAIL }} + SMOKE_TEST_CUSTOMER_USER: ${{ secrets.SMOKE_TEST_CUSTOMER_USER }} + SMOKE_TEST_CUSTOMER_PASSWORD: ${{ secrets.SMOKE_TEST_CUSTOMER_PASSWORD }} + WC_E2E_SCREENSHOTS: 1 + E2E_RETEST: 1 + E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} + E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }} + UPDATE_WC: 1 + DEFAULT_TIMEOUT_OVERRIDE: 120000 + BASE_URL: ${{ secrets.SMOKE_TEST_URL }} + USER_KEY: ${{ secrets.SMOKE_TEST_ADMIN_USER }} + USER_SECRET: ${{ secrets.SMOKE_TEST_ADMIN_PASSWORD }} + run: | + pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.js + pnpx wc-e2e test:e2e + pnpx wc-api-tests test api + + build: + name: Build zip for PR + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + id: build + uses: woocommerce/action-build@trunk + env: + BUILD_ENV: e2e + + - name: Upload PR zip + uses: actions/upload-artifact@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: woocommerce + path: ${{ steps.build.outputs.zip_path }} + retention-days: 7 + + test-plugins: + name: Smoke tests with ${{ matrix.plugin }} plugin installed + runs-on: ubuntu-18.04 + needs: [build] + strategy: + fail-fast: false + matrix: + include: + - plugin: 'WooCommerce Payments' + repo: 'automattic/woocommerce-payments' + steps: + - name: Create dirs. + run: | + mkdir -p code/woocommerce + mkdir -p package/woocommerce + mkdir -p tmp/woocommerce + mkdir -p node_modules + + - name: Checkout code. + uses: actions/checkout@v2 + with: + path: package/woocommerce + + - name: Install PNPM and install dependencies + working-directory: package/woocommerce + run: | + npm install -g pnpm + pnpm install + + - name: Load docker images and start containers. + working-directory: package/woocommerce/plugins/woocommerce + run: pnpx wc-e2e docker:up + + - name: Move current directory to code. We will install zip file in this dir later. + run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce + + - name: Download WooCommerce ZIP. + uses: actions/download-artifact@v2 + with: + name: woocommerce + path: tmp + + - name: Extract and replace WooCommerce zip. + working-directory: tmp + run: | + unzip woocommerce.zip -d woocommerce + mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/tests/e2e/plugins/ + + - name: Install dependencies again + working-directory: package/woocommerce + run: | + npm install -g pnpm + pnpm install + + - name: Run tests command. + working-directory: package/woocommerce/plugins/woocommerce + env: + WC_E2E_SCREENSHOTS: 1 + E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} + E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} + GITHUB_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} + PLUGIN_NAME: ${{ matrix.plugin }} + GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} + run: | + pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js + pnpm nx test-e2e woocommerce From 457f4b0160a4e446632d6ab69b9747428fd3a60a Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 10:11:12 -0500 Subject: [PATCH 16/54] Ensure that the directory is created --- .github/workflows/smoke-test-daily-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index a50c6648f2d..2eac5d060cb 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -124,6 +124,7 @@ jobs: - name: Extract and replace WooCommerce zip. working-directory: tmp run: | + mkdir -p ../package/woocommerce/plugins/woocommerce/tests/e2e/plugins unzip woocommerce.zip -d woocommerce mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/tests/e2e/plugins/ From 28e87eeb3d38b9cb81fe282a3b7011a4b9977c60 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 10:23:57 -0500 Subject: [PATCH 17/54] Removed step reduce execution time --- .github/workflows/smoke-test-daily-test.yml | 51 --------------------- 1 file changed, 51 deletions(-) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index 2eac5d060cb..a005bb96843 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -6,57 +6,6 @@ on: types: - labeled jobs: - login-run: - name: Daily smoke test on trunk. - if: "${{ contains(github.event.label.name, 'run: daily tests') }}" - runs-on: ubuntu-18.04 - steps: - - - name: Create dirs. - run: | - mkdir -p code/woocommerce - mkdir -p package/woocommerce - mkdir -p tmp/woocommerce - mkdir -p node_modules - - - name: Checkout code. - uses: actions/checkout@v2 - with: - path: package/woocommerce - ref: trunk - - - name: Install prerequisites. - working-directory: package/woocommerce/plugins/woocommerce - run: | - npm install -g pnpm - pnpm install - pnpm nx composer-install-no-dev woocommerce - pnpm nx build-assets woocommerce - pnpm install jest - - - name: Run smoke test. - working-directory: package/woocommerce/plugins/woocommerce - env: - SMOKE_TEST_URL: ${{ secrets.SMOKE_TEST_URL }} - SMOKE_TEST_ADMIN_USER: ${{ secrets.SMOKE_TEST_ADMIN_USER }} - SMOKE_TEST_ADMIN_PASSWORD: ${{ secrets.SMOKE_TEST_ADMIN_PASSWORD }} - SMOKE_TEST_ADMIN_USER_EMAIL: ${{ secrets.SMOKE_TEST_ADMIN_USER_EMAIL }} - SMOKE_TEST_CUSTOMER_USER: ${{ secrets.SMOKE_TEST_CUSTOMER_USER }} - SMOKE_TEST_CUSTOMER_PASSWORD: ${{ secrets.SMOKE_TEST_CUSTOMER_PASSWORD }} - WC_E2E_SCREENSHOTS: 1 - E2E_RETEST: 1 - E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} - E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }} - UPDATE_WC: 1 - DEFAULT_TIMEOUT_OVERRIDE: 120000 - BASE_URL: ${{ secrets.SMOKE_TEST_URL }} - USER_KEY: ${{ secrets.SMOKE_TEST_ADMIN_USER }} - USER_SECRET: ${{ secrets.SMOKE_TEST_ADMIN_PASSWORD }} - run: | - pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.js - pnpx wc-e2e test:e2e - pnpx wc-api-tests test api - build: name: Build zip for PR runs-on: ubuntu-latest From cd8af3e2c412d33d6767bc395ee80605aee36c21 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 11:32:15 -0500 Subject: [PATCH 18/54] Updated GITHUB_REPOSITORY in test workflow --- .github/workflows/smoke-test-daily-test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index a005bb96843..13aec34ea67 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -73,9 +73,8 @@ jobs: - name: Extract and replace WooCommerce zip. working-directory: tmp run: | - mkdir -p ../package/woocommerce/plugins/woocommerce/tests/e2e/plugins unzip woocommerce.zip -d woocommerce - mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/tests/e2e/plugins/ + mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ - name: Install dependencies again working-directory: package/woocommerce @@ -89,7 +88,7 @@ jobs: WC_E2E_SCREENSHOTS: 1 E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} - GITHUB_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} + GITHUB_REPOSITORY: ${{ matrix.repo }} PLUGIN_NAME: ${{ matrix.plugin }} GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | From a631454b91606eff34ab80fd762e13993bec3ae8 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 11:53:43 -0500 Subject: [PATCH 19/54] Updated describe block for better logging --- .../e2e/specs/smoke-tests/upload-plugin.js | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) 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 1bdb3a950a4..7dfe7304b2d 100644 --- a/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js +++ b/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js @@ -18,25 +18,30 @@ const { GITHUB_REPOSITORY, PLUGIN_NAME, GITHUB_TOKEN } = process.env; let zipUrl; let pluginPath; -utils.describeIf( GITHUB_REPOSITORY )( 'Upload and activate plugin', () => { - beforeAll( async () => { - zipUrl = await getLatestReleaseZipUrl( GITHUB_REPOSITORY, GITHUB_TOKEN ); +utils.describeIf( GITHUB_REPOSITORY )( + `Upload and activate ${ PLUGIN_NAME } from ${ GITHUB_REPOSITORY }`, + () => { + beforeAll( async () => { + zipUrl = await getLatestReleaseZipUrl( + GITHUB_REPOSITORY, + GITHUB_TOKEN + ); - pluginPath = await getRemotePluginZip( zipUrl, GITHUB_TOKEN ); + pluginPath = await getRemotePluginZip( zipUrl, GITHUB_TOKEN ); - await merchant.login(); - }); + await merchant.login(); + } ); - afterAll( async () => { - await merchant.logout(); - }); + afterAll( async () => { + await merchant.logout(); + } ); - it( 'can upload and activate the provided plugin', async () => { - await merchant.uploadAndActivatePlugin( pluginPath, PLUGIN_NAME ); - }); + it( 'can upload and activate the provided plugin', async () => { + await merchant.uploadAndActivatePlugin( pluginPath, PLUGIN_NAME ); + } ); - it( 'can remove downloaded plugin zip', async () => { - await deleteDownloadedPluginFiles(); - } ); - -}); + it( 'can remove downloaded plugin zip', async () => { + await deleteDownloadedPluginFiles(); + } ); + } +); From fcf3d0fb5d757ba12d19f4ab71c712fb43a7f803 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 12:24:43 -0500 Subject: [PATCH 20/54] Set GITHUB_REPOSITORY test --- .github/workflows/smoke-test-daily-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index 13aec34ea67..225ce94b708 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -92,5 +92,7 @@ jobs: PLUGIN_NAME: ${{ matrix.plugin }} GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | + echo "GITHUB_REPOSITORY=${{ matrix.repo }}}" + echo $GITHUB_REPOSITORY pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js pnpm nx test-e2e woocommerce From e771145aa0b53e1a60095abf3909d084a28d8dbd Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 12:49:05 -0500 Subject: [PATCH 21/54] Added a PLUGIN_REPOSITORY variable --- .github/workflows/smoke-test-daily-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index 225ce94b708..d78e908b054 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -88,11 +88,9 @@ jobs: WC_E2E_SCREENSHOTS: 1 E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} - GITHUB_REPOSITORY: ${{ matrix.repo }} + PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} PLUGIN_NAME: ${{ matrix.plugin }} GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | - echo "GITHUB_REPOSITORY=${{ matrix.repo }}}" - echo $GITHUB_REPOSITORY pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js pnpm nx test-e2e woocommerce From 8158343c741de223472228fb3a0fe4399a9e3be6 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 12:49:32 -0500 Subject: [PATCH 22/54] Added support for PLUGIN_REPOSITORY & PLUGIN_NAME --- .../tests/e2e/specs/smoke-tests/upload-plugin.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 7dfe7304b2d..cbfa48d1186 100644 --- a/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js +++ b/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js @@ -13,19 +13,20 @@ const { beforeAll, } = require( '@jest/globals' ); -const { GITHUB_REPOSITORY, PLUGIN_NAME, GITHUB_TOKEN } = 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'; +const repository = PLUGIN_REPOSITORY ? PLUGIN_REPOSITORY : GITHUB_REPOSITORY; let zipUrl; let pluginPath; -utils.describeIf( GITHUB_REPOSITORY )( - `Upload and activate ${ PLUGIN_NAME } from ${ GITHUB_REPOSITORY }`, +utils.describeIf( GITHUB_REPOSITORY || PLUGIN_REPOSITORY )( + `Upload and activate ${ pluginName } from ${ repository }`, () => { beforeAll( async () => { - zipUrl = await getLatestReleaseZipUrl( - GITHUB_REPOSITORY, - GITHUB_TOKEN - ); + zipUrl = await getLatestReleaseZipUrl( repository, GITHUB_TOKEN ); pluginPath = await getRemotePluginZip( zipUrl, GITHUB_TOKEN ); From f5bbebb95bf74442daa7a568808ec31b9bd4a638 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 13:08:46 -0500 Subject: [PATCH 23/54] Updated test command --- .github/workflows/smoke-test-daily-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index d78e908b054..992e0a784f5 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -93,4 +93,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpm nx test-e2e woocommerce + pnpm wc-e2e test-e2e From c0b3712398d998b3f02d6bfddc80fb932c51187d Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 13:20:34 -0500 Subject: [PATCH 24/54] Updated test command --- .github/workflows/smoke-test-daily-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index 992e0a784f5..a6bad09e22a 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -93,4 +93,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpm wc-e2e test-e2e + pnpx wc-e2e test-e2e From df7e0c72ff81465d4a325e3793eacd8282b4c1c0 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 13:32:58 -0500 Subject: [PATCH 25/54] Fixed test command --- .github/workflows/smoke-test-daily-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index a6bad09e22a..9853d03cac0 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -93,4 +93,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpx wc-e2e test-e2e + pnpx wc-e2e test:e2e From 464839bfe240cb0194e33d05e37e1f865fdc1541 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 13:56:43 -0500 Subject: [PATCH 26/54] Changed GITHUB_REPOSITORY to PLUGIN_REPOSITORY Also updated the test command and reverted previous changes done in this PR. --- .github/workflows/smoke-test-daily.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/smoke-test-daily.yml b/.github/workflows/smoke-test-daily.yml index 37c8a702a10..c130a9b1738 100644 --- a/.github/workflows/smoke-test-daily.yml +++ b/.github/workflows/smoke-test-daily.yml @@ -132,7 +132,7 @@ jobs: working-directory: tmp run: | unzip woocommerce.zip -d woocommerce - mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/tests/e2e/plugins/ + mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ - name: Install dependencies again working-directory: package/woocommerce @@ -146,9 +146,9 @@ jobs: WC_E2E_SCREENSHOTS: 1 E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} - GITHUB_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} + PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} PLUGIN_NAME: ${{ matrix.plugin }} GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpm nx test-e2e woocommerce + pnpx wc-e2e test-e2e From b690b16247d164c312c4d63809802cd9e029e452 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 14:03:36 -0500 Subject: [PATCH 27/54] Removed test workflow file --- .github/workflows/smoke-test-daily-test.yml | 96 --------------------- 1 file changed, 96 deletions(-) delete mode 100644 .github/workflows/smoke-test-daily-test.yml diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml deleted file mode 100644 index 9853d03cac0..00000000000 --- a/.github/workflows/smoke-test-daily-test.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Smoke test daily Test -on: - pull_request: - branches: - - trunk - types: - - labeled -jobs: - build: - name: Build zip for PR - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Build - id: build - uses: woocommerce/action-build@trunk - env: - BUILD_ENV: e2e - - - name: Upload PR zip - uses: actions/upload-artifact@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - name: woocommerce - path: ${{ steps.build.outputs.zip_path }} - retention-days: 7 - - test-plugins: - name: Smoke tests with ${{ matrix.plugin }} plugin installed - runs-on: ubuntu-18.04 - needs: [build] - strategy: - fail-fast: false - matrix: - include: - - plugin: 'WooCommerce Payments' - repo: 'automattic/woocommerce-payments' - steps: - - name: Create dirs. - run: | - mkdir -p code/woocommerce - mkdir -p package/woocommerce - mkdir -p tmp/woocommerce - mkdir -p node_modules - - - name: Checkout code. - uses: actions/checkout@v2 - with: - path: package/woocommerce - - - name: Install PNPM and install dependencies - working-directory: package/woocommerce - run: | - npm install -g pnpm - pnpm install - - - name: Load docker images and start containers. - working-directory: package/woocommerce/plugins/woocommerce - run: pnpx wc-e2e docker:up - - - name: Move current directory to code. We will install zip file in this dir later. - run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce - - - name: Download WooCommerce ZIP. - uses: actions/download-artifact@v2 - with: - name: woocommerce - path: tmp - - - name: Extract and replace WooCommerce zip. - working-directory: tmp - run: | - unzip woocommerce.zip -d woocommerce - mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ - - - name: Install dependencies again - working-directory: package/woocommerce - run: | - npm install -g pnpm - pnpm install - - - name: Run tests command. - working-directory: package/woocommerce/plugins/woocommerce - env: - WC_E2E_SCREENSHOTS: 1 - E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} - E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} - PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} - PLUGIN_NAME: ${{ matrix.plugin }} - GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} - run: | - pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpx wc-e2e test:e2e From b66b7542440894ef9836b2c3b896261c8b8d4676 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 14:21:51 -0500 Subject: [PATCH 28/54] Fixed test command --- .github/workflows/smoke-test-daily.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test-daily.yml b/.github/workflows/smoke-test-daily.yml index c130a9b1738..2bb316e7363 100644 --- a/.github/workflows/smoke-test-daily.yml +++ b/.github/workflows/smoke-test-daily.yml @@ -151,4 +151,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpx wc-e2e test-e2e + pnpx wc-e2e test:e2e From 122ea458aecb14214d20fb9826c638ceb1d8ddc2 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 14:22:25 -0500 Subject: [PATCH 29/54] Updated to match changes in smoke-test-daily.yml --- .github/workflows/smoke-test-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/smoke-test-release.yml b/.github/workflows/smoke-test-release.yml index f6a6acee5a3..fda4e18c327 100644 --- a/.github/workflows/smoke-test-release.yml +++ b/.github/workflows/smoke-test-release.yml @@ -170,9 +170,9 @@ jobs: WC_E2E_SCREENSHOTS: 1 E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} - GITHUB_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} + PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} PLUGIN_NAME: ${{ matrix.plugin }} GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpm nx test-e2e woocommerce + pnpx wc-e2e test:e2e From 70091b2a35059ffc533564d6206fd4a76a40294f Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 17:07:10 -0500 Subject: [PATCH 30/54] Updated describeIf to use repository variable --- .../woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cbfa48d1186..7526b336f00 100644 --- a/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js +++ b/plugins/woocommerce/tests/e2e/specs/smoke-tests/upload-plugin.js @@ -22,7 +22,7 @@ const repository = PLUGIN_REPOSITORY ? PLUGIN_REPOSITORY : GITHUB_REPOSITORY; let zipUrl; let pluginPath; -utils.describeIf( GITHUB_REPOSITORY || PLUGIN_REPOSITORY )( +utils.describeIf( repository )( `Upload and activate ${ pluginName } from ${ repository }`, () => { beforeAll( async () => { From 3ff19df36fbc876875790b25ad12416e8c72c449 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 17:07:25 -0500 Subject: [PATCH 31/54] Added .yml file to test workflow --- .github/workflows/smoke-test-daily-test.yml | 96 +++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/smoke-test-daily-test.yml diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml new file mode 100644 index 00000000000..9853d03cac0 --- /dev/null +++ b/.github/workflows/smoke-test-daily-test.yml @@ -0,0 +1,96 @@ +name: Smoke test daily Test +on: + pull_request: + branches: + - trunk + types: + - labeled +jobs: + build: + name: Build zip for PR + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + id: build + uses: woocommerce/action-build@trunk + env: + BUILD_ENV: e2e + + - name: Upload PR zip + uses: actions/upload-artifact@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: woocommerce + path: ${{ steps.build.outputs.zip_path }} + retention-days: 7 + + test-plugins: + name: Smoke tests with ${{ matrix.plugin }} plugin installed + runs-on: ubuntu-18.04 + needs: [build] + strategy: + fail-fast: false + matrix: + include: + - plugin: 'WooCommerce Payments' + repo: 'automattic/woocommerce-payments' + steps: + - name: Create dirs. + run: | + mkdir -p code/woocommerce + mkdir -p package/woocommerce + mkdir -p tmp/woocommerce + mkdir -p node_modules + + - name: Checkout code. + uses: actions/checkout@v2 + with: + path: package/woocommerce + + - name: Install PNPM and install dependencies + working-directory: package/woocommerce + run: | + npm install -g pnpm + pnpm install + + - name: Load docker images and start containers. + working-directory: package/woocommerce/plugins/woocommerce + run: pnpx wc-e2e docker:up + + - name: Move current directory to code. We will install zip file in this dir later. + run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce + + - name: Download WooCommerce ZIP. + uses: actions/download-artifact@v2 + with: + name: woocommerce + path: tmp + + - name: Extract and replace WooCommerce zip. + working-directory: tmp + run: | + unzip woocommerce.zip -d woocommerce + mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ + + - name: Install dependencies again + working-directory: package/woocommerce + run: | + npm install -g pnpm + pnpm install + + - name: Run tests command. + working-directory: package/woocommerce/plugins/woocommerce + env: + WC_E2E_SCREENSHOTS: 1 + E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} + E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} + PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} + PLUGIN_NAME: ${{ matrix.plugin }} + GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} + run: | + pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js + pnpx wc-e2e test:e2e From 7da9e3c32e17d6115dd41c0904ce58118b311f7c Mon Sep 17 00:00:00 2001 From: jamelreid Date: Wed, 26 Jan 2022 17:29:29 -0500 Subject: [PATCH 32/54] Removed test .yml file --- .github/workflows/smoke-test-daily-test.yml | 96 --------------------- 1 file changed, 96 deletions(-) delete mode 100644 .github/workflows/smoke-test-daily-test.yml diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml deleted file mode 100644 index 9853d03cac0..00000000000 --- a/.github/workflows/smoke-test-daily-test.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Smoke test daily Test -on: - pull_request: - branches: - - trunk - types: - - labeled -jobs: - build: - name: Build zip for PR - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Build - id: build - uses: woocommerce/action-build@trunk - env: - BUILD_ENV: e2e - - - name: Upload PR zip - uses: actions/upload-artifact@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - name: woocommerce - path: ${{ steps.build.outputs.zip_path }} - retention-days: 7 - - test-plugins: - name: Smoke tests with ${{ matrix.plugin }} plugin installed - runs-on: ubuntu-18.04 - needs: [build] - strategy: - fail-fast: false - matrix: - include: - - plugin: 'WooCommerce Payments' - repo: 'automattic/woocommerce-payments' - steps: - - name: Create dirs. - run: | - mkdir -p code/woocommerce - mkdir -p package/woocommerce - mkdir -p tmp/woocommerce - mkdir -p node_modules - - - name: Checkout code. - uses: actions/checkout@v2 - with: - path: package/woocommerce - - - name: Install PNPM and install dependencies - working-directory: package/woocommerce - run: | - npm install -g pnpm - pnpm install - - - name: Load docker images and start containers. - working-directory: package/woocommerce/plugins/woocommerce - run: pnpx wc-e2e docker:up - - - name: Move current directory to code. We will install zip file in this dir later. - run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce - - - name: Download WooCommerce ZIP. - uses: actions/download-artifact@v2 - with: - name: woocommerce - path: tmp - - - name: Extract and replace WooCommerce zip. - working-directory: tmp - run: | - unzip woocommerce.zip -d woocommerce - mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ - - - name: Install dependencies again - working-directory: package/woocommerce - run: | - npm install -g pnpm - pnpm install - - - name: Run tests command. - working-directory: package/woocommerce/plugins/woocommerce - env: - WC_E2E_SCREENSHOTS: 1 - E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} - E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} - PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} - PLUGIN_NAME: ${{ matrix.plugin }} - GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} - run: | - pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - pnpx wc-e2e test:e2e From d7a76a5e89f07f3a66de536a6b1b826d12d813ee Mon Sep 17 00:00:00 2001 From: helgatheviking <507025+helgatheviking@users.noreply.github.com> Date: Wed, 26 Jan 2022 18:17:39 -0700 Subject: [PATCH 33/54] Limit input widths to number inputs in Twenty Twenty One theme. Follow up to #31698. --- plugins/woocommerce/legacy/css/twenty-twenty-one.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/legacy/css/twenty-twenty-one.scss b/plugins/woocommerce/legacy/css/twenty-twenty-one.scss index a168e9d37b2..a59a9de2d01 100644 --- a/plugins/woocommerce/legacy/css/twenty-twenty-one.scss +++ b/plugins/woocommerce/legacy/css/twenty-twenty-one.scss @@ -601,7 +601,7 @@ dl.variation, margin-right: 0.5rem; } - input { + input[type="number"] { width: 5em; } } From 2baa3bca3094b12b21ca88eb5e39d002004d0177 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 08:43:16 -0500 Subject: [PATCH 34/54] Added workflow script for testing --- .github/workflows/smoke-test-daily-test.yml | 108 ++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/smoke-test-daily-test.yml diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml new file mode 100644 index 00000000000..cdba458cfb6 --- /dev/null +++ b/.github/workflows/smoke-test-daily-test.yml @@ -0,0 +1,108 @@ +name: Smoke test daily Test +on: + pull_request: + branches: + - trunk + types: + - labeled +jobs: + build: + name: Build zip for PR + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + id: build + uses: woocommerce/action-build@trunk + env: + BUILD_ENV: e2e + + - name: Upload PR zip + uses: actions/upload-artifact@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: woocommerce + path: ${{ steps.build.outputs.zip_path }} + retention-days: 7 + + test-plugins: + name: Smoke tests with ${{ matrix.plugin }} plugin installed + runs-on: ubuntu-18.04 + needs: [build] + strategy: + fail-fast: false + matrix: + include: + - plugin: 'WooCommerce Payments' + repo: 'automattic/woocommerce-payments' + - plugin: 'WooCommerce PayPal Payments' + repo: 'woocommerce/woocommerce-paypal-payments' + - plugin: 'WooCommerce Shipping & Tax' + repo: 'automattic/woocommerce-services' + - plugin: 'WooCommerce Subscriptions' + repo: WC_SUBSCRIPTIONS_REPO + private: true + - plugin: 'WordPress SEO' # Yoast SEO in the UI, but the slug is wordpress-seo + repo: 'Yoast/wordpress-seo' + - plugin: 'Contact Form 7' + repo: 'takayukister/contact-form-7' + steps: + - name: Create dirs. + run: | + mkdir -p code/woocommerce + mkdir -p package/woocommerce + mkdir -p tmp/woocommerce + mkdir -p node_modules + + - name: Checkout code. + uses: actions/checkout@v2 + with: + path: package/woocommerce + + - name: Install PNPM and install dependencies + working-directory: package/woocommerce + run: | + npm install -g pnpm + pnpm install + + - name: Load docker images and start containers. + working-directory: package/woocommerce/plugins/woocommerce + run: pnpx wc-e2e docker:up + + - name: Move current directory to code. We will install zip file in this dir later. + run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce + + - name: Download WooCommerce ZIP. + uses: actions/download-artifact@v2 + with: + name: woocommerce + path: tmp + + - name: Extract and replace WooCommerce zip. + working-directory: tmp + run: | + unzip woocommerce.zip -d woocommerce + mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ + + - name: Install dependencies again + working-directory: package/woocommerce + run: | + npm install -g pnpm + pnpm install + + - name: Run tests command. + working-directory: package/woocommerce/plugins/woocommerce + env: + WC_E2E_SCREENSHOTS: 1 + E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} + E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} + PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} + PLUGIN_NAME: ${{ matrix.plugin }} + GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} + run: | + ls tests/e2e/plugins + pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js + pnpx wc-e2e test:e2e From bc73cf2a63ebb5f3616f814228622d479a71c40e Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 09:09:27 -0500 Subject: [PATCH 35/54] Updated test workflow --- .github/workflows/smoke-test-daily-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml index cdba458cfb6..64ae45d2d0c 100644 --- a/.github/workflows/smoke-test-daily-test.yml +++ b/.github/workflows/smoke-test-daily-test.yml @@ -103,6 +103,6 @@ jobs: PLUGIN_NAME: ${{ matrix.plugin }} GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} run: | - ls tests/e2e/plugins pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js + ls tests/e2e/plugins pnpx wc-e2e test:e2e From 68af14a26ba4aad6040644c04b101c5a764715ad Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 10:11:13 -0500 Subject: [PATCH 36/54] Updated to handle removing directories --- .../js/e2e-environment/utils/get-plugin-zip.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/js/e2e-environment/utils/get-plugin-zip.js b/packages/js/e2e-environment/utils/get-plugin-zip.js index e1077bae98c..56350b24f4f 100644 --- a/packages/js/e2e-environment/utils/get-plugin-zip.js +++ b/packages/js/e2e-environment/utils/get-plugin-zip.js @@ -152,13 +152,20 @@ const downloadZip = async ( fileUrl, downloadPath, authorizationToken ) => { const deleteDownloadedPluginFiles = async () => { const pluginSavePath = resolveLocalE2ePath( 'plugins' ); - fs.readdir( pluginSavePath, ( err, files ) => { + fs.readdir( pluginSavePath, ( err, contents ) => { if ( err ) throw err; - for ( const file of files ) { - fs.unlink( path.join( pluginSavePath, file ), ( error ) => { - if ( error ) throw error; - } ); + for ( const content of contents ) { + const contentPath = path.join( pluginSavePath, content ); + const stats = fs.lstatSync( contentPath ); + + if ( stats.isDirectory() ) { + fs.rmSync( contentPath, { recursive: true, force: true } ); + } else { + fs.unlink( contentPath, ( error ) => { + if ( error ) throw error; + } ); + } } } ); }; From d93d0abd778af26228a9436c90733d436eda1414 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Thu, 27 Jan 2022 16:52:26 +0100 Subject: [PATCH 37/54] Fix: double "PHP version upgrade required" double notice Recently a new admin notice has been added to warn users about the upcoming PHP 7.2 requirement starting in Woo 6.5. For new installs this was appearing together with the "recommended PHP 7.2" notice. This commit removes the "recommended" notice if the new "required" notice is already being displayed (unless the site is also using an outdated WordPress version, which is also covered by the "recommended" notice). --- .../includes/admin/class-wc-admin-notices.php | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-notices.php b/plugins/woocommerce/includes/admin/class-wc-admin-notices.php index 44319a301a4..8aeb50c495d 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-notices.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-notices.php @@ -138,6 +138,11 @@ class WC_Admin_Notices { 'php72_required_in_woo_65', __( '

PHP version requirements will change soon

WooCommerce 6.5, scheduled for May 2022, will require PHP 7.2 or newer to work. Your server is currently running an older version of PHP, so this change will impact your store. Upgrading to at least PHP 7.4 is recommended. Learn more about this change.

', 'woocommerce' ) ); + + $wp_version_is_ok = version_compare( get_bloginfo( 'version' ), WC_NOTICE_MIN_WP_VERSION, '>=' ); + if ( $wp_version_is_ok ) { + self::hide_notice( WC_PHP_MIN_REQUIREMENTS_NOTICE ); + } } /** @@ -209,14 +214,23 @@ class WC_Admin_Notices { $hide_notice = sanitize_text_field( wp_unslash( $_GET['wc-hide-notice'] ) ); // WPCS: input var ok, CSRF ok. - self::remove_notice( $hide_notice ); - - update_user_meta( get_current_user_id(), 'dismissed_' . $hide_notice . '_notice', true ); - - do_action( 'woocommerce_hide_' . $hide_notice . '_notice' ); + self::hide_notice( $hide_notice ); } } + /** + * Hide a single notice. + * + * @param $name Notice name. + */ + private static function hide_notice( $name ) { + self::remove_notice( $name ); + + update_user_meta( get_current_user_id(), 'dismissed_' . $name . '_notice', true ); + + do_action( 'woocommerce_hide_' . $name . '_notice' ); + } + /** * Add notices + styles if needed. */ From 19fa73acfd125ed0a0a5e6b4ff4fdfab667b340a Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 12:38:20 -0500 Subject: [PATCH 38/54] Updated top level menu css selectors This is done to ensure that page load tests work regardless of the order of the top level menu list. --- .../js/e2e-core-tests/src/specs/data/elements.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/js/e2e-core-tests/src/specs/data/elements.js b/packages/js/e2e-core-tests/src/specs/data/elements.js index fc3d268a0aa..917ae8ec762 100644 --- a/packages/js/e2e-core-tests/src/specs/data/elements.js +++ b/packages/js/e2e-core-tests/src/specs/data/elements.js @@ -5,13 +5,9 @@ export const MENUS = [ [ 'WooCommerce', - '#adminmenu > li:nth-child(8) > a', + '.menu-top > a[href*=wc-admin].menu-top-first', [ - [ - 'Home', - '', - 'Home', - ], + [ 'Home', '', 'Home' ], [ 'Orders', '#toplevel_page_woocommerce > ul > li:nth-child(3) > a', @@ -37,7 +33,7 @@ export const MENUS = [ ], [ 'Products', - '#adminmenu > li:nth-child(9) > a', + '.menu-top > a[href*=product].menu-top', [ [ 'All Products', @@ -68,7 +64,7 @@ export const MENUS = [ ], [ 'Marketing', - '#adminmenu > li:nth-child(11) > a', + '.menu-top > a[href*=marketing].menu-top', [ [ 'Overview', From cef0dd877b3a933e10bf3a33a129a0fd9a2a746e Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 12:39:50 -0500 Subject: [PATCH 39/54] Updated CHANGELOG.md --- packages/js/e2e-core-tests/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/js/e2e-core-tests/CHANGELOG.md b/packages/js/e2e-core-tests/CHANGELOG.md index e3c5f866a57..56c0e589bbb 100644 --- a/packages/js/e2e-core-tests/CHANGELOG.md +++ b/packages/js/e2e-core-tests/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +## Changed + +- Updated top level menu css selectors + ## Fixed - Moved `merchant.login()` out of `beforeAll()` block and into test body for retried runs. From 6a1b849d01d563cf5eb4b32bd4463a47afa5fbaf Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 12:46:16 -0500 Subject: [PATCH 40/54] Updated repo for WooCommerce Shipping & Tax --- .github/workflows/smoke-test-daily.yml | 2 +- .github/workflows/smoke-test-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/smoke-test-daily.yml b/.github/workflows/smoke-test-daily.yml index 2bb316e7363..e9126b249b2 100644 --- a/.github/workflows/smoke-test-daily.yml +++ b/.github/workflows/smoke-test-daily.yml @@ -88,7 +88,7 @@ jobs: - plugin: 'WooCommerce PayPal Payments' repo: 'woocommerce/woocommerce-paypal-payments' - plugin: 'WooCommerce Shipping & Tax' - repo: 'woocommerce/woocommerce-services' + repo: 'automattic/woocommerce-services' - plugin: 'WooCommerce Subscriptions' repo: WC_SUBSCRIPTIONS_REPO private: true diff --git a/.github/workflows/smoke-test-release.yml b/.github/workflows/smoke-test-release.yml index fda4e18c327..4ea577ad353 100644 --- a/.github/workflows/smoke-test-release.yml +++ b/.github/workflows/smoke-test-release.yml @@ -118,7 +118,7 @@ jobs: - plugin: 'WooCommerce PayPal Payments' repo: 'woocommerce/woocommerce-paypal-payments' - plugin: 'WooCommerce Shipping & Tax' - repo: 'woocommerce/woocommerce-services' + repo: 'automattic/woocommerce-services' - plugin: 'WooCommerce Subscriptions' repo: WC_SUBSCRIPTIONS_REPO private: true From c9cbcf744d4944bcc0548db2f8ec24b9bccf5df5 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 13:25:50 -0500 Subject: [PATCH 41/54] Removed test workflow file --- .github/workflows/smoke-test-daily-test.yml | 108 -------------------- 1 file changed, 108 deletions(-) delete mode 100644 .github/workflows/smoke-test-daily-test.yml diff --git a/.github/workflows/smoke-test-daily-test.yml b/.github/workflows/smoke-test-daily-test.yml deleted file mode 100644 index 64ae45d2d0c..00000000000 --- a/.github/workflows/smoke-test-daily-test.yml +++ /dev/null @@ -1,108 +0,0 @@ -name: Smoke test daily Test -on: - pull_request: - branches: - - trunk - types: - - labeled -jobs: - build: - name: Build zip for PR - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Build - id: build - uses: woocommerce/action-build@trunk - env: - BUILD_ENV: e2e - - - name: Upload PR zip - uses: actions/upload-artifact@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - name: woocommerce - path: ${{ steps.build.outputs.zip_path }} - retention-days: 7 - - test-plugins: - name: Smoke tests with ${{ matrix.plugin }} plugin installed - runs-on: ubuntu-18.04 - needs: [build] - strategy: - fail-fast: false - matrix: - include: - - plugin: 'WooCommerce Payments' - repo: 'automattic/woocommerce-payments' - - plugin: 'WooCommerce PayPal Payments' - repo: 'woocommerce/woocommerce-paypal-payments' - - plugin: 'WooCommerce Shipping & Tax' - repo: 'automattic/woocommerce-services' - - plugin: 'WooCommerce Subscriptions' - repo: WC_SUBSCRIPTIONS_REPO - private: true - - plugin: 'WordPress SEO' # Yoast SEO in the UI, but the slug is wordpress-seo - repo: 'Yoast/wordpress-seo' - - plugin: 'Contact Form 7' - repo: 'takayukister/contact-form-7' - steps: - - name: Create dirs. - run: | - mkdir -p code/woocommerce - mkdir -p package/woocommerce - mkdir -p tmp/woocommerce - mkdir -p node_modules - - - name: Checkout code. - uses: actions/checkout@v2 - with: - path: package/woocommerce - - - name: Install PNPM and install dependencies - working-directory: package/woocommerce - run: | - npm install -g pnpm - pnpm install - - - name: Load docker images and start containers. - working-directory: package/woocommerce/plugins/woocommerce - run: pnpx wc-e2e docker:up - - - name: Move current directory to code. We will install zip file in this dir later. - run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce - - - name: Download WooCommerce ZIP. - uses: actions/download-artifact@v2 - with: - name: woocommerce - path: tmp - - - name: Extract and replace WooCommerce zip. - working-directory: tmp - run: | - unzip woocommerce.zip -d woocommerce - mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/ - - - name: Install dependencies again - working-directory: package/woocommerce - run: | - npm install -g pnpm - pnpm install - - - name: Run tests command. - working-directory: package/woocommerce/plugins/woocommerce - env: - WC_E2E_SCREENSHOTS: 1 - E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} - E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }} - PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }} - PLUGIN_NAME: ${{ matrix.plugin }} - GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} - run: | - pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/upload-plugin.js - ls tests/e2e/plugins - pnpx wc-e2e test:e2e From 7d7b9996f59808965eaf4deb7615ae3655e7ff02 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 27 Jan 2022 13:29:32 -0500 Subject: [PATCH 42/54] Updated CHANGELOG.md --- packages/js/e2e-environment/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/js/e2e-environment/CHANGELOG.md b/packages/js/e2e-environment/CHANGELOG.md index c527a65a96f..322eb524f22 100644 --- a/packages/js/e2e-environment/CHANGELOG.md +++ b/packages/js/e2e-environment/CHANGELOG.md @@ -1,5 +1,8 @@ # Unreleased +## Changes +- Updated `deleteDownloadedPluginFiles()` to also be able to delete directories. + ## Added - Added `post-results-to-github-pr.js` to post smoke test results to a GitHub PR. From 6c2778c109b77f1944ca49b27b6bc20803b3937d Mon Sep 17 00:00:00 2001 From: Barry Hughes <3594411+barryhughes@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:33:08 -0800 Subject: [PATCH 43/54] Add docblock for revised filter. --- .../importers/class-wc-product-csv-importer-controller.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php b/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php index d22dd430441..b467d8f9f6d 100644 --- a/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -92,6 +92,12 @@ class WC_Product_CSV_Importer_Controller { * @return bool */ public static function is_file_valid_csv( $file, $check_path = true ) { + /** + * Can be used to override the decision to check the import file path. + * + * @param bool $check_import_file_path If the import file path should be checked. + * @param string $file Path of the file to be checked. + */ if ( $check_path && apply_filters( 'woocommerce_product_csv_importer_check_import_file_path', true, $file ) && false !== stripos( $file, '://' ) ) { return false; } From 3e740461dca16c75babd2ea347bfe17be46dabe9 Mon Sep 17 00:00:00 2001 From: Barry Hughes <3594411+barryhughes@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:33:56 -0800 Subject: [PATCH 44/54] Revise docblock. --- plugins/woocommerce/includes/wc-conditional-functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/wc-conditional-functions.php b/plugins/woocommerce/includes/wc-conditional-functions.php index f44ee86eac9..4729a92f673 100644 --- a/plugins/woocommerce/includes/wc-conditional-functions.php +++ b/plugins/woocommerce/includes/wc-conditional-functions.php @@ -464,7 +464,8 @@ function wc_is_file_valid_csv( $file, $check_path = true ) { * Filter check for CSV file path. * * @since 3.6.4 - * @param bool $check_import_file_path If requires file path check. Defaults to true. + * @param bool $check_import_file_path If requires file path check. Defaults to true. + * @param string $file Path of the file to be checked. */ $check_import_file_path = apply_filters( 'woocommerce_csv_importer_check_import_file_path', true, $file ); From 806a25633cdb57ddb15fc125e00254a367f51614 Mon Sep 17 00:00:00 2001 From: Oscar Sanchez S Date: Wed, 24 Nov 2021 23:53:18 -0600 Subject: [PATCH 45/54] Check if search param could be considered empty --- .../Version1/class-wc-rest-customers-v1-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-customers-v1-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-customers-v1-controller.php index 8a07bb36705..e1e3d8ab0b3 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-customers-v1-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-customers-v1-controller.php @@ -244,7 +244,7 @@ class WC_REST_Customers_V1_Controller extends WC_REST_Controller { $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; $prepared_args['search'] = $request['search']; - if ( '' !== $prepared_args['search'] ) { + if ( ! empty( $prepared_args['search'] ) ) { $prepared_args['search'] = '*' . $prepared_args['search'] . '*'; } From 0052af05d608416c0af43687f82003b18c429c8b Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:56:48 -0800 Subject: [PATCH 46/54] Ensure PHP is parsed --- plugins/woocommerce/templates/checkout/terms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/templates/checkout/terms.php b/plugins/woocommerce/templates/checkout/terms.php index 188a9f1784a..c048882c4a6 100644 --- a/plugins/woocommerce/templates/checkout/terms.php +++ b/plugins/woocommerce/templates/checkout/terms.php @@ -28,7 +28,7 @@ if ( apply_filters( 'woocommerce_checkout_show_terms', true ) && function_exists

From 80fbb5f74dd73c7db745c6fca549acc3c10c583d Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Fri, 28 Jan 2022 06:18:17 -0800 Subject: [PATCH 47/54] Echo the escaped text (required field asterix) --- plugins/woocommerce/templates/checkout/terms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/templates/checkout/terms.php b/plugins/woocommerce/templates/checkout/terms.php index c048882c4a6..e2c385c6333 100644 --- a/plugins/woocommerce/templates/checkout/terms.php +++ b/plugins/woocommerce/templates/checkout/terms.php @@ -28,7 +28,7 @@ if ( apply_filters( 'woocommerce_checkout_show_terms', true ) && function_exists

From 933de44557a419964aec7e11ad5d4c8f7101f995 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 28 Jan 2022 12:34:49 -0400 Subject: [PATCH 48/54] remove pnpm rule, fix utils build --- packages/js/api-core-tests/package.json | 1 - packages/js/api/package.json | 1 - packages/js/e2e-core-tests/package.json | 1 - packages/js/e2e-utils/package.json | 1 - packages/js/e2e-utils/src/factories/simple-product.js | 4 ++-- 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/js/api-core-tests/package.json b/packages/js/api-core-tests/package.json index c9ee60af086..2fc58990a3a 100644 --- a/packages/js/api-core-tests/package.json +++ b/packages/js/api-core-tests/package.json @@ -4,7 +4,6 @@ "description": "API tests for WooCommerce", "main": "index.js", "scripts": { - "preinstall": "npx only-allow pnpm", "test": "jest", "test:api": "jest --group=api", "test:hello": "jest --group=hello", diff --git a/packages/js/api/package.json b/packages/js/api/package.json index eded9fafdd6..56388920230 100644 --- a/packages/js/api/package.json +++ b/packages/js/api/package.json @@ -26,7 +26,6 @@ ], "sideEffects": false, "scripts": { - "preinstall": "npx only-allow pnpm", "clean": "rm -rf ./dist ./tsconfig.tsbuildinfo", "compile": "tsc -b", "build": "pnpm run clean && npm run compile", diff --git a/packages/js/e2e-core-tests/package.json b/packages/js/e2e-core-tests/package.json index 64d805aedcc..72e6da077d4 100644 --- a/packages/js/e2e-core-tests/package.json +++ b/packages/js/e2e-core-tests/package.json @@ -45,7 +45,6 @@ "access": "public" }, "scripts": { - "preinstall": "npx only-allow pnpm", "prepare": "pnpm run build", "clean": "rm -rf ./build ./build-module", "compile": "node ./../bin/build.js", diff --git a/packages/js/e2e-utils/package.json b/packages/js/e2e-utils/package.json index 9ab299798d2..e277882b16f 100644 --- a/packages/js/e2e-utils/package.json +++ b/packages/js/e2e-utils/package.json @@ -41,7 +41,6 @@ "access": "public" }, "scripts": { - "preinstall": "npx only-allow pnpm", "clean": "rm -rf ./build ./build-module", "compile": "node ./../bin/build.js", "build": "pnpm run clean && pnpm run compile", diff --git a/packages/js/e2e-utils/src/factories/simple-product.js b/packages/js/e2e-utils/src/factories/simple-product.js index c9dd0315409..e6a8a545991 100644 --- a/packages/js/e2e-utils/src/factories/simple-product.js +++ b/packages/js/e2e-utils/src/factories/simple-product.js @@ -17,8 +17,8 @@ export function simpleProductFactory( httpClient ) { } ); return { - name: params.name ?? faker.commerce.productName(), - regularPrice: params.regularPrice ?? faker.commerce.price(), + name: params.name ? params.name : faker.commerce.productName(), + regularPrice: params.regularPrice ? params.regularPrice : faker.commerce.price(), }; } ); } From 57ad5e388a483f2dcf2f9a3e09fccd9f7d016249 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 28 Jan 2022 13:15:45 -0400 Subject: [PATCH 49/54] add puppeteer dependency --- packages/js/e2e-environment/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/js/e2e-environment/package.json b/packages/js/e2e-environment/package.json index cc73b00b4dd..94d87eefc44 100644 --- a/packages/js/e2e-environment/package.json +++ b/packages/js/e2e-environment/package.json @@ -35,7 +35,8 @@ "jest-each": "25.5.0", "jest-puppeteer": "^4.4.0", "node-stream-zip": "^1.13.6", - "readline-sync": "^1.4.10", + "puppeteer": "2.1.1", + "readline-sync": "^1.4.10", "request": "^2.88.2", "sprintf-js": "^1.1.2" }, From 75bc438973e506c2cb5b18f7c7dede2a303a7e3e Mon Sep 17 00:00:00 2001 From: Joshua T Flowers Date: Sun, 30 Jan 2022 10:28:40 -0500 Subject: [PATCH 50/54] Update store setup widget to use task list API (#31755) * Hide store setup widget if user cannot manage woocommerce * Use task list API to retrieve tasks * Fix up URL and URL fragments from tasks * Remove URL assertion on external API response * Simplify task count and completed count test * Update tests around widget visibility * Update step number to be completed count +1 --- .../admin/class-wc-admin-dashboard-setup.php | 156 +++++++----------- .../views/html-admin-dashboard-setup.php | 2 +- .../class-wc-admin-dashboard-setup-test.php | 137 ++++++++------- 3 files changed, 139 insertions(+), 156 deletions(-) diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-dashboard-setup.php b/plugins/woocommerce/includes/admin/class-wc-admin-dashboard-setup.php index 4360241b37f..197bf7c5182 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-dashboard-setup.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-dashboard-setup.php @@ -7,6 +7,7 @@ */ use Automattic\Jetpack\Constants; +use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. @@ -20,40 +21,14 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : class WC_Admin_Dashboard_Setup { /** - * List of tasks. - * - * @var array + * The task list. */ - private $tasks = array( - 'store_details' => array( - 'completed' => false, - 'button_link' => 'admin.php?page=wc-admin&path=%2Fsetup-wizard', - ), - 'products' => array( - 'completed' => false, - 'button_link' => 'admin.php?page=wc-admin&task=products', - ), - 'woocommerce-payments' => array( - 'completed' => false, - 'button_link' => 'admin.php?page=wc-admin&path=%2Fpayments%2Fconnect', - ), - 'payments' => array( - 'completed' => false, - 'button_link' => 'admin.php?page=wc-admin&task=payments', - ), - 'tax' => array( - 'completed' => false, - 'button_link' => 'admin.php?page=wc-admin&task=tax', - ), - 'shipping' => array( - 'completed' => false, - 'button_link' => 'admin.php?page=wc-admin&task=shipping', - ), - 'appearance' => array( - 'completed' => false, - 'button_link' => 'admin.php?page=wc-admin&task=appearance', - ), - ); + private $task_list = null; + + /** + * The tasks. + */ + private $tasks = null; /** * # of completed tasks. @@ -67,9 +42,6 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : */ public function __construct() { if ( $this->should_display_widget() ) { - $this->populate_general_tasks(); - $this->populate_payment_tasks(); - $this->completed_tasks_count = $this->get_completed_tasks_count(); add_meta_box( 'wc_admin_dashboard_setup', __( 'WooCommerce Setup', 'woocommerce' ), @@ -93,9 +65,10 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : return; } - $button_link = $task['button_link']; - $completed_tasks_count = $this->completed_tasks_count; - $tasks_count = count( $this->tasks ); + $button_link = $this->get_button_link( $task ); + $completed_tasks_count = $this->get_completed_tasks_count(); + $step_number = $this->get_completed_tasks_count() + 1; + $tasks_count = count( $this->get_tasks() ); // Given 'r' (circle element's r attr), dashoffset = ((100-$desired_percentage)/100) * PI * (r*2). $progress_percentage = ( $completed_tasks_count / $tasks_count ) * 100; @@ -106,35 +79,68 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : } /** - * Populate tasks from the database. + * Get the button link for a given task. + * + * @param Task $task Task. + * @return string */ - private function populate_general_tasks() { - $tasks = get_option( 'woocommerce_task_list_tracked_completed_tasks', array() ); - foreach ( $tasks as $task ) { - if ( isset( $this->tasks[ $task ] ) ) { - $this->tasks[ $task ]['completed'] = true; - $this->tasks[ $task ]['button_link'] = wc_admin_url( $this->tasks[ $task ]['button_link'] ); - } + public function get_button_link( $task ) { + $url = $task->get_json()['actionUrl']; + + if ( substr( $url, 0, 4 ) === 'http' ) { + return $url; + } elseif ( $url ) { + return wc_admin_url( '&path=' . $url ); } + + return admin_url( 'admin.php?page=wc-admin&task=' . $task->get_id() ); } /** - * Getter for $tasks + * Get the task list. + * + * @return array + */ + public function get_task_list() { + if ( $this->task_list ) { + return $this->task_list; + } + + $this->set_task_list( TaskLists::get_list( 'setup' ) ); + return $this->task_list; + } + + /** + * Set the task list. + */ + public function set_task_list( $task_list ) { + return $this->task_list = $task_list; + } + + /** + * Get the tasks. * * @return array */ public function get_tasks() { + if ( $this->tasks ) { + return $this->tasks; + } + + $this->tasks = $this->get_task_list()->get_viewable_tasks(); return $this->tasks; } /** * Return # of completed tasks + * + * @return integer */ public function get_completed_tasks_count() { $completed_tasks = array_filter( - $this->tasks, + $this->get_tasks(), function( $task ) { - return $task['completed']; + return $task->is_complete(); } ); @@ -148,7 +154,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : */ private function get_next_task() { foreach ( $this->get_tasks() as $task ) { - if ( false === $task['completed'] ) { + if ( false === $task->is_complete() ) { return $task; } } @@ -161,51 +167,13 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : * * @return bool */ - private function should_display_widget() { - return WC()->is_wc_admin_active() && - 'yes' !== get_option( 'woocommerce_task_list_complete' ) && - 'yes' !== get_option( 'woocommerce_task_list_hidden' ); + public function should_display_widget() { + return current_user_can( 'manage_woocommerce' ) && + WC()->is_wc_admin_active() && + ! $this->get_task_list()->is_complete() && + ! $this->get_task_list()->is_hidden(); } - /** - * Populate payment tasks's visibility and completion - */ - private function populate_payment_tasks() { - $is_woo_payment_installed = is_plugin_active( 'woocommerce-payments/woocommerce-payments.php' ); - $country = explode( ':', get_option( 'woocommerce_default_country', 'US:CA' ) )[0]; - - // woocommerce-payments requires its plugin activated and country must be US. - if ( ! $is_woo_payment_installed || 'US' !== $country ) { - unset( $this->tasks['woocommerce-payments'] ); - } - - // payments can't be used when woocommerce-payments exists and country is US. - if ( $is_woo_payment_installed && 'US' === $country ) { - unset( $this->tasks['payments'] ); - } - - if ( isset( $this->tasks['payments'] ) ) { - $gateways = WC()->payment_gateways->get_available_payment_gateways(); - $enabled_gateways = array_filter( - $gateways, - function ( $gateway ) { - return 'yes' === $gateway->enabled; - } - ); - $this->tasks['payments']['completed'] = ! empty( $enabled_gateways ); - } - - if ( isset( $this->tasks['woocommerce-payments'] ) ) { - $wc_pay_is_connected = false; - if ( class_exists( '\WC_Payments' ) ) { - $wc_payments_gateway = \WC_Payments::get_gateway(); - $wc_pay_is_connected = method_exists( $wc_payments_gateway, 'is_connected' ) - ? $wc_payments_gateway->is_connected() - : false; - } - $this->tasks['woocommerce-payments']['completed'] = $wc_pay_is_connected; - } - } } endif; diff --git a/plugins/woocommerce/includes/admin/views/html-admin-dashboard-setup.php b/plugins/woocommerce/includes/admin/views/html-admin-dashboard-setup.php index ddc7b6b85f9..54e14a2bb6c 100644 --- a/plugins/woocommerce/includes/admin/views/html-admin-dashboard-setup.php +++ b/plugins/woocommerce/includes/admin/views/html-admin-dashboard-setup.php @@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) { - +
diff --git a/plugins/woocommerce/tests/php/includes/admin/class-wc-admin-dashboard-setup-test.php b/plugins/woocommerce/tests/php/includes/admin/class-wc-admin-dashboard-setup-test.php index 83b678a86b9..09dfebe05a0 100644 --- a/plugins/woocommerce/tests/php/includes/admin/class-wc-admin-dashboard-setup-test.php +++ b/plugins/woocommerce/tests/php/includes/admin/class-wc-admin-dashboard-setup-test.php @@ -5,6 +5,8 @@ * @package WooCommerce\Tests\Admin */ +use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskList; + /** * Class WC_Admin_Dashboard_Setup_Test */ @@ -17,6 +19,16 @@ class WC_Admin_Dashboard_Setup_Test extends WC_Unit_Test_Case { // Set default country to non-US so that 'payments' task gets added but 'woocommerce-payments' doesn't, // by default it won't be considered completed but we can manually change that as needed. update_option( 'woocommerce_default_country', 'JP' ); + $password = wp_generate_password( 8, false, false ); + $this->admin = wp_insert_user( + array( + 'user_login' => "test_admin$password", + 'user_pass' => $password, + 'user_email' => "admin$password@example.com", + 'role' => 'administrator', + ) + ); + wp_set_current_user( $this->admin ); parent::setUp(); } @@ -52,38 +64,71 @@ class WC_Admin_Dashboard_Setup_Test extends WC_Unit_Test_Case { return ob_get_clean(); } - /** - * Tests widget does not get rendered when woocommerce_task_list_hidden or woocommerce_task_list_hidden - * is true. - * - * @dataProvider should_display_widget_data_provider - * - * @param array $options a set of options. - */ - public function test_widget_does_not_get_rendered( array $options ) { - global $wp_meta_boxes; - - foreach ( $options as $name => $value ) { - update_option( $name, $value ); - } - - $this->get_widget(); - $this->assertNull( $wp_meta_boxes ); - } /** - * Given both woocommerce_task_list_hidden and woocommerce_task_list_complete are false - * Then the widget should be added to the $wp_meta_boxes + * Given the task list is not hidden and is not complete, make sure the widget is rendered. */ - public function test_widget_gets_rendered_when_both_options_are_false() { + public function test_widget_render() { + // Force the "payments" task to be considered incomplete. + add_filter( + 'woocommerce_available_payment_gateways', + function() { + return array(); + } + ); global $wp_meta_boxes; - update_option( 'woocommerce_task_list_complete', false ); - update_option( 'woocommerce_task_list_hidden', false ); + $task_list = $this->get_widget()->get_task_list(); + $task_list->unhide(); $this->get_widget(); $this->assertArrayHasKey( 'wc_admin_dashboard_setup', $wp_meta_boxes['dashboard']['normal']['high'] ); } + /** + * Tests widget does not display when task list is complete. + */ + public function test_widget_does_not_display_when_task_list_complete() { + $task_list = new class { + public function is_complete() { + return true; + } + }; + $widget = $this->get_widget(); + $widget->set_task_list( $task_list ); + + $this->assertFalse( $widget->should_display_widget() ); + } + + /** + * Tests widget does not display when task list is hidden. + */ + public function test_widget_does_not_display_when_task_list_hidden() { + $widget = $this->get_widget(); + $widget->get_task_list()->hide(); + + $this->assertFalse( $widget->should_display_widget() ); + } + + /** + * Tests widget does not display when user cannot manage woocommerce. + */ + public function test_widget_does_not_display_when_missing_capabilities() { + $password = wp_generate_password( 8, false, false ); + $author = wp_insert_user( + array( + 'user_login' => "test_author$password", + 'user_pass' => $password, + 'user_email' => "author$password@example.com", + 'role' => 'author', + ) + ); + wp_set_current_user( $author ); + + $widget = $this->get_widget(); + + $this->assertFalse( $widget->should_display_widget() ); + } + /** * Tests the widget output when 1 task has been completed. */ @@ -99,10 +144,9 @@ class WC_Admin_Dashboard_Setup_Test extends WC_Unit_Test_Case { $html = $this->get_widget_output(); $required_strings = array( - 'Step 0 of 6', + 'Step \d+ of \d+', 'You're almost there! Once you complete store setup you can start receiving orders.', 'Start selling', - 'admin.php\?page=wc-admin&path=%2Fsetup-wizard', ); foreach ( $required_strings as $required_string ) { @@ -126,42 +170,13 @@ class WC_Admin_Dashboard_Setup_Test extends WC_Unit_Test_Case { } ); - $completed_tasks = array( 'payments' ); - $tasks = $this->get_widget()->get_tasks(); - $tasks_count = count( $tasks ); - unset( $tasks['payments'] ); // That one is completed already. - foreach ( $tasks as $key => $task ) { - array_push( $completed_tasks, $key ); - update_option( 'woocommerce_task_list_tracked_completed_tasks', $completed_tasks ); - $completed_tasks_count = count( $completed_tasks ); - // When all tasks are completed, assert that the widget output is empty. - // As widget won't be rendered when tasks are completed. - if ( $completed_tasks_count === $tasks_count ) { - $this->assertEmpty( $this->get_widget_output() ); - } else { - $this->assertRegexp( "/Step ${completed_tasks_count} of 6/", $this->get_widget_output() ); - } + $completed_tasks_count = $this->get_widget()->get_completed_tasks_count(); + $tasks_count = count( $this->get_widget()->get_tasks() ); + $step_number = $completed_tasks_count + 1; + if ( $completed_tasks_count === $tasks_count ) { + $this->assertEmpty( $this->get_widget_output() ); + } else { + $this->assertRegexp( "/Step ${step_number} of 6/", $this->get_widget_output() ); } } - - - /** - * Provides dataset that controls output of `should_display_widget` - */ - public function should_display_widget_data_provider() { - return array( - array( - array( - 'woocommerce_task_list_complete' => 'yes', - 'woocommerce_task_list_hidden' => 'no', - ), - ), - array( - array( - 'woocommerce_task_list_complete' => 'no', - 'woocommerce_task_list_hidden' => 'yes', - ), - ), - ); - } } From 40f2575b6c1b8999f9bc0faa4e5f7731c4543f23 Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Tue, 18 Jan 2022 17:14:15 -0700 Subject: [PATCH 51/54] Style the 2022 theme store notice. --- .../legacy/css/twenty-twenty-two.scss | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce/legacy/css/twenty-twenty-two.scss b/plugins/woocommerce/legacy/css/twenty-twenty-two.scss index c26f49d1420..834f6be6529 100644 --- a/plugins/woocommerce/legacy/css/twenty-twenty-two.scss +++ b/plugins/woocommerce/legacy/css/twenty-twenty-two.scss @@ -1224,6 +1224,7 @@ $tt2-gray: #f7f7f7; } } + .wp-block-search { .wp-block-search__label { font-weight: normal; @@ -1263,4 +1264,23 @@ $tt2-gray: #f7f7f7; } } } -} \ No newline at end of file +} + +.woocommerce-store-notice { + color: var(--wp--preset--color--black); + border-top: 2px solid var( --wp--preset--color--primary ); + background: $tt2-gray; + padding: 2rem; + position: fixed; + bottom: 0; + left: 0; + width: 100%; + z-index: 999; + margin: 0; + + .woocommerce-store-notice__dismiss-link { + float: right; + margin-right: 4rem; + } +} + From 598f5f329d45ed447f6103025f35e98085931535 Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Thu, 20 Jan 2022 10:04:46 -0700 Subject: [PATCH 52/54] Fix typo. --- plugins/woocommerce/legacy/css/twenty-twenty-two.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/woocommerce/legacy/css/twenty-twenty-two.scss b/plugins/woocommerce/legacy/css/twenty-twenty-two.scss index 834f6be6529..3fae3d41ffd 100644 --- a/plugins/woocommerce/legacy/css/twenty-twenty-two.scss +++ b/plugins/woocommerce/legacy/css/twenty-twenty-two.scss @@ -1224,7 +1224,6 @@ $tt2-gray: #f7f7f7; } } - .wp-block-search { .wp-block-search__label { font-weight: normal; From 7d42347537498c6bd0166b47daca3ebde547ae4e Mon Sep 17 00:00:00 2001 From: jamelreid Date: Tue, 1 Feb 2022 13:27:25 -0500 Subject: [PATCH 53/54] Updated test not found output --- packages/js/e2e-environment/bin/post-results-to-github-pr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/e2e-environment/bin/post-results-to-github-pr.js b/packages/js/e2e-environment/bin/post-results-to-github-pr.js index 203e637a812..aea203077a8 100644 --- a/packages/js/e2e-environment/bin/post-results-to-github-pr.js +++ b/packages/js/e2e-environment/bin/post-results-to-github-pr.js @@ -35,7 +35,7 @@ module.exports = async ( { github, context } ) => { output = buildOutput( results ); } else { output = `## Test Results Not Found! \n\n`; - output += 'The path to the `test-results.json` file may need to be updated in the `post-results-to-github-pr.js` script'; + output += 'The path to the `test-results.json` file may need to be updated.'; } await github.rest.issues.createComment( { From 5ba1ceefcc403c1a6df007f3158ee265b876c69d Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 2 Feb 2022 15:43:58 -0400 Subject: [PATCH 54/54] refresh pnpm lock --- pnpm-lock.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1159a4a69a..b1adb802284 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -163,6 +163,7 @@ importers: jest-puppeteer: ^4.4.0 ndb: ^1.1.5 node-stream-zip: ^1.13.6 + puppeteer: 2.1.1 readline-sync: ^1.4.10 request: ^2.88.2 semver: ^7.3.2 @@ -172,7 +173,7 @@ importers: '@jest/test-sequencer': 25.5.4 '@slack/web-api': 6.5.1 '@woocommerce/api': link:../api - '@wordpress/e2e-test-utils': 4.16.1_jest@25.5.4 + '@wordpress/e2e-test-utils': 4.16.1_jest@25.5.4+puppeteer@2.1.1 '@wordpress/jest-preset-default': 7.1.3_@babel+core@7.12.9+jest@25.5.4 app-root-path: 3.0.0 commander: 4.1.1 @@ -180,8 +181,9 @@ importers: jest: 25.5.4 jest-circus: 25.1.0 jest-each: 25.5.0 - jest-puppeteer: 4.4.0 + jest-puppeteer: 4.4.0_puppeteer@2.1.1 node-stream-zip: 1.15.0 + puppeteer: 2.1.1 readline-sync: 1.4.10 request: 2.88.2 sprintf-js: 1.1.2 @@ -5346,7 +5348,7 @@ packages: - react-native dev: false - /@wordpress/e2e-test-utils/4.16.1_jest@25.5.4: + /@wordpress/e2e-test-utils/4.16.1_jest@25.5.4+puppeteer@2.1.1: resolution: {integrity: sha512-Dpsq5m0VSvjIhro2MjACSzkOkOf1jGEryzgEMW1ikbT6YI+motspHfGtisKXgYhZJOnjV4PwuEg+9lPVnd971g==} engines: {node: '>=8'} peerDependencies: @@ -5359,6 +5361,7 @@ packages: jest: 25.5.4 lodash: 4.17.21 node-fetch: 2.6.5 + puppeteer: 2.1.1 transitivePeerDependencies: - react-native dev: false @@ -13271,13 +13274,14 @@ packages: jest-resolve: 27.3.1 dev: true - /jest-puppeteer/4.4.0: + /jest-puppeteer/4.4.0_puppeteer@2.1.1: resolution: {integrity: sha512-ZaiCTlPZ07B9HW0erAWNX6cyzBqbXMM7d2ugai4epBDKpKvRDpItlRQC6XjERoJELKZsPziFGS0OhhUvTvQAXA==} peerDependencies: puppeteer: '>= 1.5.0 < 3' dependencies: expect-puppeteer: 4.4.0 jest-environment-puppeteer: 4.4.0 + puppeteer: 2.1.1 transitivePeerDependencies: - supports-color dev: false