From 7a499d0c8bac72818bf1386da182e5653a318450 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 6 Oct 2023 14:11:45 -0300 Subject: [PATCH 1/3] Hide Comments and Terms by default --- includes/classes/Feature/Comments/Comments.php | 7 +++++++ includes/classes/Feature/Terms/Terms.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/includes/classes/Feature/Comments/Comments.php b/includes/classes/Feature/Comments/Comments.php index fe3d7af8db..dd47d23fa1 100644 --- a/includes/classes/Feature/Comments/Comments.php +++ b/includes/classes/Feature/Comments/Comments.php @@ -20,6 +20,13 @@ * Comments feature class */ class Comments extends Feature { + /** + * Whether the feature should be always visible in the dashboard + * + * @since 5.0.0 + * @var boolean + */ + protected $is_visible = false; /** * Initialize feature, setting it's config diff --git a/includes/classes/Feature/Terms/Terms.php b/includes/classes/Feature/Terms/Terms.php index c0d406557d..ac9feb536e 100644 --- a/includes/classes/Feature/Terms/Terms.php +++ b/includes/classes/Feature/Terms/Terms.php @@ -17,6 +17,13 @@ * Terms feature class */ class Terms extends Feature { + /** + * Whether the feature should be always visible in the dashboard + * + * @since 5.0.0 + * @var boolean + */ + protected $is_visible = false; /** * Initialize feature, setting it's config From 02b9e7d8f58efbb3ea3c6dc36d370bcd31aed5c8 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 6 Oct 2023 14:16:34 -0300 Subject: [PATCH 2/3] Make features visible for e2e tests --- .wp-env.json | 1 + .../integration/features/comments.cy.js | 1 + tests/cypress/integration/features/terms.cy.js | 1 + .../test-plugins/show-comments-and-terms.php | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+) create mode 100644 tests/cypress/wordpress-files/test-plugins/show-comments-and-terms.php diff --git a/.wp-env.json b/.wp-env.json index 8b362a3ff4..a39610c6e0 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -34,6 +34,7 @@ "wp-content/plugins/filter-instant-results-per-page.php": "./tests/cypress/wordpress-files/test-plugins/filter-instant-results-per-page.php", "wp-content/plugins/filter-instant-results-args-schema.php": "./tests/cypress/wordpress-files/test-plugins/filter-instant-results-args-schema.php", "wp-content/plugins/filter-autosuggest-navigate-callback.php": "./tests/cypress/wordpress-files/test-plugins/filter-autosuggest-navigate-callback.php", + "wp-content/plugins/show-comments-and-terms.php": "./tests/cypress/wordpress-files/test-plugins/show-comments-and-terms.php", "wp-content/uploads/content-example.xml": "./tests/cypress/wordpress-files/test-docs/content-example.xml" } } diff --git a/tests/cypress/integration/features/comments.cy.js b/tests/cypress/integration/features/comments.cy.js index 3b05e9b5bb..d0208dbc65 100644 --- a/tests/cypress/integration/features/comments.cy.js +++ b/tests/cypress/integration/features/comments.cy.js @@ -13,6 +13,7 @@ describe('Comments Feature', { tags: '@slow' }, () => { cy.get('#comment_previously_approved').check(); cy.get('#submit').click(); cy.maybeEnableFeature('comments'); + cy.activatePlugin('show-comments-and-terms', 'wpCli'); }); /** diff --git a/tests/cypress/integration/features/terms.cy.js b/tests/cypress/integration/features/terms.cy.js index 2e6d3bf180..0622de8694 100644 --- a/tests/cypress/integration/features/terms.cy.js +++ b/tests/cypress/integration/features/terms.cy.js @@ -4,6 +4,7 @@ describe('Terms Feature', { tags: '@slow' }, () => { before(() => { cy.visitAdminPage('edit-tags.php?taxonomy=post_tag'); + cy.activatePlugin('show-comments-and-terms', 'wpCli'); /** * Delete all tags. diff --git a/tests/cypress/wordpress-files/test-plugins/show-comments-and-terms.php b/tests/cypress/wordpress-files/test-plugins/show-comments-and-terms.php new file mode 100644 index 0000000000..1d6d639023 --- /dev/null +++ b/tests/cypress/wordpress-files/test-plugins/show-comments-and-terms.php @@ -0,0 +1,18 @@ + Date: Fri, 6 Oct 2023 14:29:50 -0300 Subject: [PATCH 3/3] Adjust unit tests --- tests/php/features/TestComments.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/php/features/TestComments.php b/tests/php/features/TestComments.php index 76a2c2b9f5..0b3b7116df 100644 --- a/tests/php/features/TestComments.php +++ b/tests/php/features/TestComments.php @@ -168,17 +168,17 @@ public function testRequirementsStatus() { * @group comments */ public function testIsVisible() { - $this->assertTrue( $this->get_feature()->is_visible() ); + $this->assertFalse( $this->get_feature()->is_visible() ); $change_visibility = function ( $is_visible, $feature_slug, $feature ) { - $this->assertTrue( $is_visible ); + $this->assertFalse( $is_visible ); $this->assertSame( 'comments', $feature_slug ); $this->assertInstanceOf( '\ElasticPress\Feature\Comments\Comments', $feature ); - return false; + return true; }; add_filter( 'ep_feature_is_visible', $change_visibility, 10, 3 ); - $this->assertFalse( $this->get_feature()->is_visible() ); + $this->assertTrue( $this->get_feature()->is_visible() ); } /** @@ -188,16 +188,16 @@ public function testIsVisible() { * @group comments */ public function testIsAvailable() { - $this->assertTrue( $this->get_feature()->is_available() ); + $this->assertFalse( $this->get_feature()->is_available() ); $change_availability = function ( $is_available, $feature_slug, $feature ) { - $this->assertTrue( $is_available ); + $this->assertFalse( $is_available ); $this->assertSame( 'comments', $feature_slug ); $this->assertInstanceOf( '\ElasticPress\Feature\Comments\Comments', $feature ); - return false; + return true; }; add_filter( 'ep_feature_is_available', $change_availability, 10, 3 ); - $this->assertFalse( $this->get_feature()->is_available() ); + $this->assertTrue( $this->get_feature()->is_available() ); } }