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

Conditionally run E2E tests #3723

Merged
merged 1 commit into from
Nov 13, 2019
Merged

Conversation

pierlon
Copy link
Contributor

@pierlon pierlon commented Nov 13, 2019

Summary

Fixes currently failing E2E tests.

The test AMP Settings Screen › should not allow AMP Stories to be enabled when Gutenberg is not active failed because the condition that determines the status of the Stories experience checkbox now returns true on WP >= 5.3. Specifically, the test fails due to the checkbox no longer being disabled.

My proposed solution is to conditionally run tests based on the given environment. In this PR, I've made a wrapper for the test-e2e script (provided through wp-scripts) that checks if the current WordPress version is greater than or equal to 5.3, and if so, ignores the failing test. The wrapper is written with extensibility in mind for future cases where ignoring a test within a given constraint may be necessary.

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@googlebot googlebot added the cla: yes Signed the Google CLA label Nov 13, 2019

// Run E2E tests.
spawnScript( 'test-e2e', cmdArgs );
} );
Copy link
Member

Choose a reason for hiding this comment

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

I'm very inexperienced with E2E testing, but instead of creating this wrapper is not something like this possible:

diff --git a/tests/e2e/specs/amp-options.js b/tests/e2e/specs/amp-options.js
index 237fea8f..b874a08a 100644
--- a/tests/e2e/specs/amp-options.js
+++ b/tests/e2e/specs/amp-options.js
@@ -1,3 +1,8 @@
+/**
+ * External dependencies
+ */
+const semver = require( 'semver' );
+
 /**
  * WordPress dependencies
  */
@@ -54,6 +59,10 @@ describe( 'AMP Settings Screen', () => {
 	} );
 
 	it( 'should not allow AMP Stories to be enabled when Gutenberg is not active', async () => {
+		if ( semver.gte( '5.3.0', semver.coerce( process.env.WP_VERSION ) ) ) {
+			return;
+		}
+
 		await deactivatePlugin( 'gutenberg' );
 
 		await visitAdminPage( 'admin.php', 'page=amp-options' );

Copy link
Member

Choose a reason for hiding this comment

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

Or rather:

diff --git a/tests/e2e/specs/amp-options.js b/tests/e2e/specs/amp-options.js
index 237fea8f..eeb1ad2a 100644
--- a/tests/e2e/specs/amp-options.js
+++ b/tests/e2e/specs/amp-options.js
@@ -1,3 +1,8 @@
+/**
+ * External dependencies
+ */
+const semver = require( 'semver' );
+
 /**
  * WordPress dependencies
  */
@@ -53,7 +58,9 @@ describe( 'AMP Settings Screen', () => {
 		expect( await page.$eval( '#amp-settings', ( el ) => el.matches( ':invalid' ) ) ).toBe( true );
 	} );
 
+	if ( semver.lt( '5.3.0', semver.coerce( process.env.WP_VERSION ) ) ) {
 		it( 'should not allow AMP Stories to be enabled when Gutenberg is not active', async () => {
+
 			await deactivatePlugin( 'gutenberg' );
 
 			await visitAdminPage( 'admin.php', 'page=amp-options' );
@@ -64,6 +71,7 @@ describe( 'AMP Settings Screen', () => {
 
 			await activatePlugin( 'gutenberg' );
 		} );
+	}
 
 	it( 'should allow AMP Stories to be enabled when Gutenberg is active', async () => {
 		await visitAdminPage( 'admin.php', 'page=amp-options' );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I'm concerned the WP version isn't provided in the environment.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

This works. I'd like to get Pascal's thoughts when he's available.

@westonruter westonruter added this to the v1.4.1 milestone Nov 13, 2019
@westonruter westonruter merged commit c4d0f4f into develop Nov 13, 2019
@westonruter westonruter deleted the fix/failing_e2e_tests_on_WP_5.3 branch November 13, 2019 06:06
westonruter pushed a commit that referenced this pull request Nov 13, 2019
westonruter added a commit that referenced this pull request Nov 13, 2019
…ve-duplicate-amp-scripts

* 'develop' of github.com:ampproject/amp-wp: (66 commits)
  Improve display of validation errors for scripts (#3722)
  Conditionally run E2E tests (#3723)
  Tidy up validation error details (#3721)
  Add missing space after sentence (#3720)
  Default to the homepage instead of fetching the first AMP compatible post to customize (#3715)
  Include text content of style element in validation error (#3717)
  Fix summarizing error sources both parent theme and child theme (#3709)
  Exclude WordPress.PHP.DisallowShortTernary phpcs sniff
  Fix phpcs issues with date() and current_time()
  Exclude Generic.Arrays.DisallowShortArraySyntax from WordPress-Core
  Update dependency wp-coding-standards/wpcs to v2.2.0
  Improve specificity of JS doc
  Fix identifying sources for validation errors coming child themes (#3708)
  Fix failing E2E tests (#3707)
  Remove amp_validate query var from Validated URL 'View' row action
  Re-factor get_html_attribute_pattern as match_element_attributes
  Quote variables added to regex pattern
  Replace incorrect usage of esc_url() with esc_url_raw()
  Remove empty alt attributes
  Add object-fit=contain to amp-youtube placeholder image
  ...
westonruter added a commit that referenced this pull request Nov 14, 2019
* tag '1.4.1': (26 commits)
  Bump 1.4.1
  Update screenshots for 1.4.1
  Fix expected image name after upstream change (#3749)
  Use length property instead of count() method on DOMNodeList (#3727)
  Improve display of validation errors for scripts (#3722)
  Conditionally run E2E tests (#3723)
  Tidy up validation error details (#3721)
  Bump 1.4.1-RC1
  Default to the homepage instead of fetching the first AMP compatible post to customize (#3715)
  Add missing space after sentence (#3720)
  Include text content of style element in validation error (#3717)
  Use bitwise operator.
  Check if element is not in top toolbar.
  Fix user select for meta date and author
  Allow right click for meta blocks
  Fix summarizing error sources both parent theme and child theme (#3709)
  Fix identifying sources for validation errors coming child themes (#3708)
  Fix failing E2E tests (#3707)
  Remove amp_validate query var from Validated URL 'View' row action (#3706)
  Escape instances of unescapeed output in AMP settings screen code (#3703)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants