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/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 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 @@ +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() ); } }