diff --git a/plugins/woocommerce/changelog/49632-fix-cys-6.6-test b/plugins/woocommerce/changelog/49632-fix-cys-6.6-test new file mode 100644 index 00000000000..421b9fd198a --- /dev/null +++ b/plugins/woocommerce/changelog/49632-fix-cys-6.6-test @@ -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. + diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js index 06e5f941e39..6a5a91e646b 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js @@ -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' diff --git a/plugins/woocommerce/tests/e2e-pw/utils/wordpress.js b/plugins/woocommerce/tests/e2e-pw/utils/wordpress.js index 9bc27a5078b..c36a21cd258 100644 --- a/plugins/woocommerce/tests/e2e-pw/utils/wordpress.js +++ b/plugins/woocommerce/tests/e2e-pw/utils/wordpress.js @@ -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 };