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:
parent
7dd0c1a055
commit
e16a866cc5
|
@ -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.
|
||||
|
|
@ -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'
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue