From f333b373f67888d153ff417db683141d563ac781 Mon Sep 17 00:00:00 2001 From: hsing Date: Fri, 12 Feb 2021 14:38:33 -0500 Subject: [PATCH 1/7] Remove extra content wrapper --- .../class-wc-twenty-twenty-one.php | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/includes/theme-support/class-wc-twenty-twenty-one.php b/includes/theme-support/class-wc-twenty-twenty-one.php index b7d36f646b7..6b568ae0e2d 100644 --- a/includes/theme-support/class-wc-twenty-twenty-one.php +++ b/includes/theme-support/class-wc-twenty-twenty-one.php @@ -24,9 +24,6 @@ class WC_Twenty_Twenty_One { remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); - add_action( 'woocommerce_before_main_content', array( __CLASS__, 'output_content_wrapper' ), 10 ); - add_action( 'woocommerce_after_main_content', array( __CLASS__, 'output_content_wrapper_end' ), 10 ); - // This theme doesn't have a traditional sidebar. remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); @@ -34,7 +31,7 @@ class WC_Twenty_Twenty_One { add_filter( 'woocommerce_enqueue_styles', array( __CLASS__, 'enqueue_styles' ) ); // Enqueue wp-admin compatibility styles. - add_action( 'admin_enqueue_scripts', array( __CLASS__ , 'enqueue_admin_styles' ) ); + add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_admin_styles' ) ); // Register theme features. add_theme_support( 'wc-product-gallery-zoom' ); @@ -50,22 +47,6 @@ class WC_Twenty_Twenty_One { } - /** - * Open the Twenty Twenty One wrapper. - */ - public static function output_content_wrapper() { - echo '
'; - echo '
'; - } - - /** - * Close the Twenty Twenty One wrapper. - */ - public static function output_content_wrapper_end() { - echo '
'; - echo '
'; - } - /** * Enqueue CSS for this theme. * From 47a3d1bfb3a723255d29940e79b2d1eef114a767 Mon Sep 17 00:00:00 2001 From: Timmy Crawford Date: Wed, 9 Dec 2020 12:05:14 -0800 Subject: [PATCH 2/7] Tracker: Add tracking of woocommerce_admin_disabled usage. --- includes/class-wc-tracker.php | 5 ++- tests/php/includes/class-wc-tracker-test.php | 39 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/php/includes/class-wc-tracker-test.php diff --git a/includes/class-wc-tracker.php b/includes/class-wc-tracker.php index 4fb3719602e..4c595f6db70 100644 --- a/includes/class-wc-tracker.php +++ b/includes/class-wc-tracker.php @@ -113,7 +113,7 @@ class WC_Tracker { * * @return array */ - private static function get_tracking_data() { + public static function get_tracking_data() { $data = array(); // General site info. @@ -166,6 +166,9 @@ class WC_Tracker { // Cart & checkout tech (blocks or shortcodes). $data['cart_checkout'] = self::get_cart_checkout_info(); + // WooCommerce Admin info. + $data['wc_admin_disabled'] = apply_filters( 'woocommerce_admin_disabled', false ) ? 'yes' : 'no'; + return apply_filters( 'woocommerce_tracker_data', $data ); } diff --git a/tests/php/includes/class-wc-tracker-test.php b/tests/php/includes/class-wc-tracker-test.php new file mode 100644 index 00000000000..39f5a8eaa4b --- /dev/null +++ b/tests/php/includes/class-wc-tracker-test.php @@ -0,0 +1,39 @@ +assertArrayHasKey( 'wc_admin_disabled', $tracking_data ); + $this->assertEquals( 'no', $tracking_data['wc_admin_disabled'] ); + + // Test the case for woocommerce_admin_disabled filter returning true. + add_filter( 'wc_admin_disabled', $this->disable_woocommerce_admin() ); + + $tracking_data_disabled_wc_admin = WC_Tracker::get_tracking_data(); + $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data_disabled_wc_admin ); + $this->assertEquals( 'yes', $tracking_data['wc_admin_disabled'] ); + remove_filter( 'wc_admin_disabled', $this->disable_woocommerce_admin() ); + } + +} From c7a19b538ac2f27d7725543861342159edc23509 Mon Sep 17 00:00:00 2001 From: Timmy Crawford Date: Fri, 22 Jan 2021 17:22:38 -0800 Subject: [PATCH 3/7] Updates per feedback. --- includes/class-wc-tracker.php | 2 +- tests/php/includes/class-wc-tracker-test.php | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/includes/class-wc-tracker.php b/includes/class-wc-tracker.php index 4c595f6db70..9b009e035ea 100644 --- a/includes/class-wc-tracker.php +++ b/includes/class-wc-tracker.php @@ -113,7 +113,7 @@ class WC_Tracker { * * @return array */ - public static function get_tracking_data() { + private static function get_tracking_data() { $data = array(); // General site info. diff --git a/tests/php/includes/class-wc-tracker-test.php b/tests/php/includes/class-wc-tracker-test.php index 39f5a8eaa4b..2bf44d7e7df 100644 --- a/tests/php/includes/class-wc-tracker-test.php +++ b/tests/php/includes/class-wc-tracker-test.php @@ -21,7 +21,16 @@ class WC_Tracker_Test extends \WC_Unit_Test_Case { * Test the tracking of wc_admin being disabled via filter. */ public function test_wc_admin_disabled_get_tracking_data() { - $tracking_data = WC_Tracker::get_tracking_data(); + $posted_data = null; + add_filter( + 'pre_http_request', + function( $pre, $args, $url ) use ( &$posted_data ) { + $posted_data = $args; + return true; + }, 3, 10 + ); + WC_Tracker::send_tracking_data( true ); + $tracking_data = json_decode( $posted_data['body'], true ); // Test the default case of no filter for set for woocommerce_admin_disabled. $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data ); @@ -30,7 +39,13 @@ class WC_Tracker_Test extends \WC_Unit_Test_Case { // Test the case for woocommerce_admin_disabled filter returning true. add_filter( 'wc_admin_disabled', $this->disable_woocommerce_admin() ); - $tracking_data_disabled_wc_admin = WC_Tracker::get_tracking_data(); + // Bypass the 1h cooldown period so we can invoke send_tracking_data again. + add_filter( + 'woocommerce_tracker_last_send_time', + function( $time ) { return $time - 10000; } + ); + WC_Tracker::send_tracking_data( true ); + $tracking_data_disabled_wc_admin = json_decode( $posted_data['body'], true ); $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data_disabled_wc_admin ); $this->assertEquals( 'yes', $tracking_data['wc_admin_disabled'] ); remove_filter( 'wc_admin_disabled', $this->disable_woocommerce_admin() ); From 5cf3c6be8c4c6259f7511995b6ea0033f8806d4a Mon Sep 17 00:00:00 2001 From: Timmy Crawford Date: Thu, 25 Feb 2021 12:48:56 -0800 Subject: [PATCH 4/7] Fix tests. --- tests/php/includes/class-wc-tracker-test.php | 73 +++++++++++++------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/tests/php/includes/class-wc-tracker-test.php b/tests/php/includes/class-wc-tracker-test.php index 2bf44d7e7df..c589c498076 100644 --- a/tests/php/includes/class-wc-tracker-test.php +++ b/tests/php/includes/class-wc-tracker-test.php @@ -9,46 +9,69 @@ * Class WC_Tracker_Test */ class WC_Tracker_Test extends \WC_Unit_Test_Case { - - /** - * Utility method to add filter on woocommerce_admin_disabled - */ - public function disable_woocommerce_admin() { - return true; - } - /** * Test the tracking of wc_admin being disabled via filter. */ public function test_wc_admin_disabled_get_tracking_data() { $posted_data = null; + + // Test the case for woocommerce_admin_disabled filter returning true. + add_filter( + 'woocommerce_admin_disabled', + function( $default ) { + return true; + } + ); + add_filter( 'pre_http_request', function( $pre, $args, $url ) use ( &$posted_data ) { + if ( $posted_data ) { + $posted_data = null; + } $posted_data = $args; return true; - }, 3, 10 + }, + 3, + 10 ); WC_Tracker::send_tracking_data( true ); $tracking_data = json_decode( $posted_data['body'], true ); - // Test the default case of no filter for set for woocommerce_admin_disabled. - $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data ); - $this->assertEquals( 'no', $tracking_data['wc_admin_disabled'] ); - - // Test the case for woocommerce_admin_disabled filter returning true. - add_filter( 'wc_admin_disabled', $this->disable_woocommerce_admin() ); - - // Bypass the 1h cooldown period so we can invoke send_tracking_data again. - add_filter( - 'woocommerce_tracker_last_send_time', - function( $time ) { return $time - 10000; } - ); - WC_Tracker::send_tracking_data( true ); - $tracking_data_disabled_wc_admin = json_decode( $posted_data['body'], true ); - $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data_disabled_wc_admin ); + // Test the default case of no filter for set for woocommerce_admin_disabled. + $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data ); $this->assertEquals( 'yes', $tracking_data['wc_admin_disabled'] ); - remove_filter( 'wc_admin_disabled', $this->disable_woocommerce_admin() ); + $posted_data = null; + + // Bypass time delay so we can invoke send_tracking_data again. + update_option( 'woocommerce_tracker_last_send', strtotime( '-2 weeks' ) ); } + /** + * Test the tracking of wc_admin being not disabled via filter. + */ + public function test_wc_admin_not_disabled_get_tracking_data() { + $posted_data = null; + // Bypass time delay so we can invoke send_tracking_data again. + update_option( 'woocommerce_tracker_last_send', strtotime( '-2 weeks' ) ); + + add_filter( + 'pre_http_request', + function( $pre, $args, $url ) use ( &$posted_data ) { + if ( $posted_data ) { + $posted_data = null; + } + $posted_data = $args; + return true; + }, + 3, + 10 + ); + WC_Tracker::send_tracking_data( true ); + $tracking_data = json_decode( $posted_data['body'], true ); + + // Test the default case of no filter for set for woocommerce_admin_disabled. + $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data ); + $this->assertEquals( 'no', $tracking_data['wc_admin_disabled'] ); + } } From 64e934e79b65ea7e8bdc643643b6805aa4c4364d Mon Sep 17 00:00:00 2001 From: Timmy Crawford Date: Thu, 25 Feb 2021 14:22:29 -0800 Subject: [PATCH 5/7] Remove debug code in tests. --- tests/php/includes/class-wc-tracker-test.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/php/includes/class-wc-tracker-test.php b/tests/php/includes/class-wc-tracker-test.php index c589c498076..901d85958c7 100644 --- a/tests/php/includes/class-wc-tracker-test.php +++ b/tests/php/includes/class-wc-tracker-test.php @@ -26,9 +26,6 @@ class WC_Tracker_Test extends \WC_Unit_Test_Case { add_filter( 'pre_http_request', function( $pre, $args, $url ) use ( &$posted_data ) { - if ( $posted_data ) { - $posted_data = null; - } $posted_data = $args; return true; }, @@ -41,10 +38,6 @@ class WC_Tracker_Test extends \WC_Unit_Test_Case { // Test the default case of no filter for set for woocommerce_admin_disabled. $this->assertArrayHasKey( 'wc_admin_disabled', $tracking_data ); $this->assertEquals( 'yes', $tracking_data['wc_admin_disabled'] ); - $posted_data = null; - - // Bypass time delay so we can invoke send_tracking_data again. - update_option( 'woocommerce_tracker_last_send', strtotime( '-2 weeks' ) ); } /** @@ -58,9 +51,6 @@ class WC_Tracker_Test extends \WC_Unit_Test_Case { add_filter( 'pre_http_request', function( $pre, $args, $url ) use ( &$posted_data ) { - if ( $posted_data ) { - $posted_data = null; - } $posted_data = $args; return true; }, From d03f4fef790c36b519584d7a81df9dad3e2df3f4 Mon Sep 17 00:00:00 2001 From: Rebecca Scott Date: Fri, 26 Feb 2021 10:06:59 +1000 Subject: [PATCH 6/7] Bump woocommerce-admin version to 2.0.2 --- composer.json | 2 +- composer.lock | 52 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index c3e455b5154..33cecfc6758 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "pelago/emogrifier": "3.1.0", "psr/container": "1.0.0", "woocommerce/action-scheduler": "3.1.6", - "woocommerce/woocommerce-admin": "2.0.1", + "woocommerce/woocommerce-admin": "2.0.2", "woocommerce/woocommerce-blocks": "4.4.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 75060660288..24b5bc27a02 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "95f29b23c1baa50f079597378d1673f1", + "content-hash": "f24a600ea103061d766dd7b06c13e8f2", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -44,6 +44,9 @@ "GPL-2.0-or-later" ], "description": "Creates a custom autoloader for a plugin or theme.", + "support": { + "source": "https://github.com/Automattic/jetpack-autoloader/tree/v2.9.1" + }, "time": "2021-02-05T19:07:06+00:00" }, { @@ -75,6 +78,9 @@ "GPL-2.0-or-later" ], "description": "A wrapper for defining constants in a more testable way.", + "support": { + "source": "https://github.com/Automattic/jetpack-constants/tree/v1.5.1" + }, "time": "2020-10-28T19:00:31+00:00" }, { @@ -205,6 +211,10 @@ "zend", "zikula" ], + "support": { + "issues": "https://github.com/composer/installers/issues", + "source": "https://github.com/composer/installers/tree/v1.10.0" + }, "funding": [ { "url": "https://packagist.com", @@ -279,6 +289,10 @@ "geolocation", "maxmind" ], + "support": { + "issues": "https://github.com/maxmind/MaxMind-DB-Reader-php/issues", + "source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.6.0" + }, "time": "2019-12-19T22:59:03+00:00" }, { @@ -353,6 +367,10 @@ "email", "pre-processing" ], + "support": { + "issues": "https://github.com/MyIntervals/emogrifier/issues", + "source": "https://github.com/MyIntervals/emogrifier" + }, "time": "2019-12-26T19:37:31+00:00" }, { @@ -402,6 +420,10 @@ "container-interop", "psr" ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/master" + }, "time": "2017-02-14T16:28:37+00:00" }, { @@ -493,20 +515,24 @@ ], "description": "Action Scheduler for WordPress and WooCommerce", "homepage": "https://actionscheduler.org/", + "support": { + "issues": "https://github.com/woocommerce/action-scheduler/issues", + "source": "https://github.com/woocommerce/action-scheduler/tree/master" + }, "time": "2020-05-12T16:22:33+00:00" }, { "name": "woocommerce/woocommerce-admin", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-admin.git", - "reference": "b7e89c48479348847fc97ae8be8c27d068106d04" + "reference": "c4ffd90ebc72652f9d1bc8943a56d7723acc5bf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/b7e89c48479348847fc97ae8be8c27d068106d04", - "reference": "b7e89c48479348847fc97ae8be8c27d068106d04", + "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/c4ffd90ebc72652f9d1bc8943a56d7723acc5bf4", + "reference": "c4ffd90ebc72652f9d1bc8943a56d7723acc5bf4", "shasum": "" }, "require": { @@ -538,7 +564,11 @@ ], "description": "A modern, javascript-driven WooCommerce Admin experience.", "homepage": "https://github.com/woocommerce/woocommerce-admin", - "time": "2021-02-12T01:19:48+00:00" + "support": { + "issues": "https://github.com/woocommerce/woocommerce-admin/issues", + "source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.0.2" + }, + "time": "2021-02-25T07:29:24+00:00" }, { "name": "woocommerce/woocommerce-blocks", @@ -585,6 +615,10 @@ "gutenberg", "woocommerce" ], + "support": { + "issues": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues", + "source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v4.4.3" + }, "time": "2021-02-11T18:07:48+00:00" } ], @@ -633,6 +667,10 @@ "isolation", "tool" ], + "support": { + "issues": "https://github.com/bamarni/composer-bin-plugin/issues", + "source": "https://github.com/bamarni/composer-bin-plugin/tree/master" + }, "time": "2020-05-03T08:27:20+00:00" } ], @@ -648,5 +686,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } From a53bb20a625b64ca2d5ce66f7ead03f6bf2659ce Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Mon, 1 Mar 2021 17:35:49 +0530 Subject: [PATCH 7/7] Disable comment workflow since it fails on fork. --- .github/workflows/pr-build-and-e2e-tests.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/pr-build-and-e2e-tests.yml b/.github/workflows/pr-build-and-e2e-tests.yml index 5eb717628a6..bb66e43bc44 100644 --- a/.github/workflows/pr-build-and-e2e-tests.yml +++ b/.github/workflows/pr-build-and-e2e-tests.yml @@ -21,19 +21,6 @@ jobs: name: woocommerce path: ${{ steps.build.outputs.zip_path }} retention-days: 7 - - - name: Add comment - uses: actions/github-script@v3 - if: github.repository_owner == 'woocommerce' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: ':package: Artifacts ready for [download](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})!' - }) e2e-tests-cache: name: Set e2e caches for running tests