From c2dc5b1ee96b9859b3a21bf28ebf8c10b1e49099 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 1 Nov 2023 12:49:04 -0300 Subject: [PATCH 1/3] Deactivate a feature that is only in draft --- includes/classes/Command.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/classes/Command.php b/includes/classes/Command.php index 8c937afecb..3705c98815 100644 --- a/includes/classes/Command.php +++ b/includes/classes/Command.php @@ -144,11 +144,16 @@ public function deactivate_feature( $args, $assoc_args ) { WP_CLI::error( esc_html__( 'No feature with that slug is registered', 'elasticpress' ) ); } - $active_features = Utils\get_option( 'ep_feature_settings', [] ); + $active_features = Features::factory()->get_feature_settings(); + $active_features_draft = Features::factory()->get_feature_settings_draft(); - $key = array_search( $feature->slug, array_keys( $active_features ), true ); + $key_current = array_search( $feature->slug, array_keys( $active_features ), true ); + $key_draft = array_search( $feature->slug, array_keys( $active_features_draft ), true ); - if ( false === $key || empty( $active_features[ $feature->slug ]['active'] ) ) { + $in_current = false !== $key_current && ! empty( $active_features[ $feature->slug ]['active'] ); + $in_draft = false !== $key_draft && ! empty( $active_features_draft[ $feature->slug ]['active'] ); + + if ( ! $in_current && ! $in_draft ) { WP_CLI::error( esc_html__( 'Feature is not active', 'elasticpress' ) ); } From a211b6e14027bf27f9e56cb0c79abca1230cccc3 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 1 Nov 2023 13:25:00 -0300 Subject: [PATCH 2/3] Cast settings to array --- includes/classes/Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/classes/Command.php b/includes/classes/Command.php index 3705c98815..8546c68f0b 100644 --- a/includes/classes/Command.php +++ b/includes/classes/Command.php @@ -144,8 +144,8 @@ public function deactivate_feature( $args, $assoc_args ) { WP_CLI::error( esc_html__( 'No feature with that slug is registered', 'elasticpress' ) ); } - $active_features = Features::factory()->get_feature_settings(); - $active_features_draft = Features::factory()->get_feature_settings_draft(); + $active_features = (array) Features::factory()->get_feature_settings(); + $active_features_draft = (array) Features::factory()->get_feature_settings_draft(); $key_current = array_search( $feature->slug, array_keys( $active_features ), true ); $key_draft = array_search( $feature->slug, array_keys( $active_features_draft ), true ); From 64a63c66db21267a60401fbf545a1d654b3f48dd Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 1 Nov 2023 13:25:15 -0300 Subject: [PATCH 3/3] Click on the WooCommerce feature tab --- tests/cypress/integration/features/woocommerce.cy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cypress/integration/features/woocommerce.cy.js b/tests/cypress/integration/features/woocommerce.cy.js index 59679dad87..2e6bddbeed 100644 --- a/tests/cypress/integration/features/woocommerce.cy.js +++ b/tests/cypress/integration/features/woocommerce.cy.js @@ -26,6 +26,7 @@ describe('WooCommerce Feature', { tags: '@slow' }, () => { cy.activatePlugin('woocommerce'); cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('#tab-panel-0-woocommerce').click(); cy.get('.components-form-toggle__input').should('be.checked'); });