Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E Tests: Add basic coverage for the Gutenberg plugin #3679

Closed

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Nov 24, 2022

Try to activate and install the Gutenberg plugin. This will catch naming collisions between Core and GB (see Core ticket 57197 for an example).

To test:

  1. Check out this branch and run npm run env:start.
  2. Run npm run test:e2e -- tests/e2e/specs/gutenberg-plugin.test.js locally and verify that it passes.
  3. Add a function definition to Core that's also present in Gutenberg (without function_exists guards or the like). I use the following:
diff --git a/src/wp-settings.php b/src/wp-settings.php
index 3ed93b2f36..d2fdafc74b 100644
--- a/src/wp-settings.php
+++ b/src/wp-settings.php
@@ -8,6 +8,10 @@
  * @package WordPress
  */
 
+function gutenberg_style_engine_get_styles() {
+       die();
+}
+
 /**
  * Stores the location of the WordPress directory of functions, classes, and core content.
  *
  1. Run npm run test:e2e -- tests/e2e/specs/gutenberg-plugin.test.js again and watch it fail.

Trac ticket: https://core.trac.wordpress.org/ticket/57197


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@ockham ockham self-assigned this Nov 24, 2022
@ockham
Copy link
Contributor Author

ockham commented Nov 24, 2022

As an alternative, we could consider making a WP CLI based test.

Pro:

  • Probably runs faster than an e2e test.

Con:

  • Doesn't really seem to fit into any of our current test frameworks (neither PHP/JS unit tests nor e2e tests).

Copy link
Contributor

@costdev costdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ockham!

This review just contains a couple of minor suggestions for consistency with other tests and the Javascript documentation standards.

tests/e2e/specs/gutenberg-plugin.test.js Outdated Show resolved Hide resolved
tests/e2e/specs/gutenberg-plugin.test.js Outdated Show resolved Hide resolved
@fullofcaffeine
Copy link
Member

fullofcaffeine commented Nov 24, 2022

This is great! Do you think it's a better approach than running core tests in Gutenberg PRs (like I originally discussed here: https://wordpress.slack.com/archives/C03B0H5J0/p1650590706137509), or perhaps they're not mutually exclusive? I'd say they are complementary, so we could also try a similar approach in the GB repo.

EDIT: I now see this is not really for running core GB PHPUnit tests in core, but only for activating the plugin, which is also great but not the same thing I was talking about above when I mentioned core tests in GB. Still, this is a great step forward!

@ockham
Copy link
Contributor Author

ockham commented Nov 24, 2022

This is great! Do you think it's a better approach than running core tests in Gutenberg PRs (like I originally discussed here: https://wordpress.slack.com/archives/C03B0H5J0/p1650590706137509), or perhaps they're not mutually exclusive? I'd say they are complementary, so we could also try a similar approach in the GB repo.

EDIT: I now see this is not really for running core GB PHPUnit tests in core, but only for activating the plugin, which is also great but not the same thing I was talking about above when I mentioned core tests in GB. Still, this is a great step forward!

Thank you! Yeah, so this would be complementary to running Core's tests on Gutenberg PRs. (The latter sounds a bit familiar BTW: WordPress/gutenberg#26418 😬)

ockham and others added 2 commits November 24, 2022 20:29
Co-authored-by: Colin Stewart <[email protected]>
Co-authored-by: Colin Stewart <[email protected]>
@fullofcaffeine
Copy link
Member

(The latter sounds a bit familiar BTW: WordPress/gutenberg#26418 grimacing)

Oh gosh! I didn't recall this PR, thanks for pointing that out! We should definitely resume work there!

Copy link
Contributor

@costdev costdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @ockham, LGTM! 👍

@ockham
Copy link
Contributor Author

ockham commented Nov 30, 2022

Thank you for reviewing @costdev!

Committed to Core in https://core.trac.wordpress.org/changeset/54913/.

@ockham ockham closed this Nov 30, 2022
@ockham ockham deleted the add/gutenberg-plugin-e2e-coverage branch November 30, 2022 13:17
@ockham ockham restored the add/gutenberg-plugin-e2e-coverage branch November 30, 2022 13:59
@ockham ockham deleted the add/gutenberg-plugin-e2e-coverage branch November 30, 2022 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants