CYS: Fix E2E tests on WordPress 6.6 (#49632)

* CYS: Fix E2E tests on WordPress 6.6

* try now

* fix test

* try now

* fix tests

* run e2e tes against WordPress 6.5

* Add changefile(s) from automation for the following project(s): woocommerce

* restore changes

* fix test

* run against WordPress 6.6

* restore changes

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Luigi Teschio 2024-07-17 16:36:34 +02:00 committed by GitHub
parent 7dd0c1a055
commit e16a866cc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 10 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Comment: Fixes `plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js`E2E tests when run on WordPress 6.6.

View File

@ -4,6 +4,7 @@ const { CustomizeStorePage } = require( '../customize-store.page' );
const { encodeCredentials } = require( '../../../utils/plugin-utils' );
const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
const { setOption } = require( '../../../utils/options' );
const test = base.extend( {
@ -434,17 +435,22 @@ test.describe( 'Assembler -> Color Pickers', { tag: '@gutenberg' }, () => {
response.status() === 200
);
const waitResponseTemplate = page.waitForResponse(
( response ) =>
response.url().includes(
// When CYS will support all block themes, this URL will change.
'wp-json/wp/v2/templates/twentytwentyfour//home'
) && response.status() === 200
);
const wordPressVersion = await getInstalledWordPressVersion();
await saveButton.click();
await Promise.all( [ waitResponseGlobalStyles, waitResponseTemplate ] );
await Promise.all( [
waitResponseGlobalStyles,
wordPressVersion < 6.6
? page.waitForResponse(
( response ) =>
response.url().includes(
// When CYS will support all block themes, this URL will change.
'wp-json/wp/v2/templates/twentytwentyfour//home'
) && response.status() === 200
)
: Promise.resolve(),
] );
await page.goto( baseURL );
@ -510,6 +516,8 @@ test.describe( 'Assembler -> Color Pickers', { tag: '@gutenberg' }, () => {
baseURL,
}, testInfo ) => {
testInfo.snapshotSuffix = '';
const wordPressVersion = await getInstalledWordPressVersion();
const assembler = await assemblerPageObject.getAssembler();
const colorPicker = assembler.getByText( 'Create your own' );
@ -585,7 +593,7 @@ test.describe( 'Assembler -> Color Pickers', { tag: '@gutenberg' }, () => {
.click();
// eslint-disable-next-line playwright/no-conditional-in-test
if ( gutenbergPlugin ) {
if ( gutenbergPlugin || wordPressVersion >= 6.6 ) {
for ( const feature of mapTypeFeaturesGutenberg[ type ] ) {
const container = assembler.locator(
'.block-editor-panel-color-gradient-settings__dropdown-content'

View File

@ -1,3 +1,6 @@
const { promisify } = require( 'util' );
const execAsync = promisify( require( 'child_process' ).exec );
const getVersionWPLatestMinusOne = async ( { core, github } ) => {
const URL_WP_STABLE_VERSION_CHECK =
'https://api.wordpress.org/core/stable-check/1.0/';
@ -21,4 +24,18 @@ const getVersionWPLatestMinusOne = async ( { core, github } ) => {
core.setOutput( 'version', latestMinus1 );
};
module.exports = { getVersionWPLatestMinusOne };
const getInstalledWordPressVersion = async () => {
try {
const { stdout } = await execAsync(
`pnpm exec wp-env run tests-cli -- wp core version`
);
return Number.parseFloat( stdout.trim() );
} catch ( error ) {
throw new Error(
`Error getting WordPress version: ${ error.message }`
);
}
};
module.exports = { getVersionWPLatestMinusOne, getInstalledWordPressVersion };