From 81882ddcc043e1ff82e44e89e33878dcd4470a18 Mon Sep 17 00:00:00 2001 From: bernhard-reiter Date: Fri, 26 Apr 2024 10:29:26 +0000 Subject: [PATCH] Tests: Skip Gutenberg plugin activation test on older WP versions. The purpose of `tests/e2e/specs/gutenberg-plugin.test.js` is to ensure that running the Gutenberg plugin (stable version) on a WordPress `trunk` install doesn't produce any fatals. The test was introduced in [54913], i.e. it has been around since WP 6.2. It makes sense to have it present on older branches, as the Gutenberg plugin not only supports `trunk`, but also the current stable version of WordPress (i.e. currently 6.5), and one version below (6.4). However, it is not expected to work on any earlier versions beyond that; in practice, it has produced errors on some of those. This changeset checks the REST API response from the plugin activation request. If it returns an error with error code `plugin_wp_incompatible`, it skips the test. Props jorbin, johnbillion, swissspidy. Fixes #60971. git-svn-id: https://develop.svn.wordpress.org/trunk@58046 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/e2e/specs/gutenberg-plugin.test.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/e2e/specs/gutenberg-plugin.test.js b/tests/e2e/specs/gutenberg-plugin.test.js index 8f3ff20acc1c1..11a91a712c1e7 100644 --- a/tests/e2e/specs/gutenberg-plugin.test.js +++ b/tests/e2e/specs/gutenberg-plugin.test.js @@ -29,7 +29,20 @@ test.describe( 'Gutenberg plugin', () => { expect( plugin.status ).toBe( 'inactive' ); - await requestUtils.activatePlugin( 'gutenberg' ); + try { + await requestUtils.activatePlugin( 'gutenberg' ); + } catch ( error ) { + if ( + typeof error === 'object' && + error !== null && + Object.prototype.hasOwnProperty.call( error, 'code' ) && + error.code === 'plugin_wp_incompatible' + ) { + test.skip(); + } else { + throw error; + } + } plugin = await requestUtils.rest( { path: 'wp/v2/plugins/gutenberg/gutenberg',