From 31b339a30215135f198013f1be98acfecf638f2d Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 23 Apr 2021 14:07:57 +0300 Subject: [PATCH] David's fix #31121 --- packages/e2e-tests/experimental-features.js | 52 +++++++++------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/packages/e2e-tests/experimental-features.js b/packages/e2e-tests/experimental-features.js index 115b69d9e45e2..c58f08e018d4f 100644 --- a/packages/e2e-tests/experimental-features.js +++ b/packages/e2e-tests/experimental-features.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { addQueryArgs } from '@wordpress/url'; -import { visitAdminPage, wpDataSelect } from '@wordpress/e2e-test-utils'; +import { visitAdminPage } from '@wordpress/e2e-test-utils'; async function setExperimentalFeaturesState( features, enable ) { const query = addQueryArgs( '', { @@ -131,34 +131,28 @@ export const siteEditor = { }, async getEditedPostContent() { - const postId = await wpDataSelect( - 'core/edit-site', - 'getEditedPostId' - ); - const postType = await wpDataSelect( - 'core/edit-site', - 'getEditedPostType' - ); - const record = await wpDataSelect( - 'core', - 'getEditedEntityRecord', - 'postType', - postType, - postId - ); - if ( record ) { - if ( typeof record.content === 'function' ) { - return record.content( record ); - } else if ( record.blocks ) { - return await page.evaluate( - ( blocks ) => - window.wp.blocks.__unstableSerializeAndClean( blocks ), - record.blocks - ); - } else if ( record.content ) { - return record.content; + return await page.evaluate( async () => { + const postId = window.wp.data + .select( 'core/edit-site' ) + .getEditedPostId(); + const postType = window.wp.data + .select( 'core/edit-site' ) + .getEditedPostType(); + const record = window.wp.data + .select( 'core' ) + .getEditedEntityRecord( 'postType', postType, postId ); + if ( record ) { + if ( typeof record.content === 'function' ) { + return record.content( record ); + } else if ( record.blocks ) { + return window.wp.blocks.__unstableSerializeAndClean( + record.blocks + ); + } else if ( record.content ) { + return record.content; + } } - } - return ''; + return ''; + } ); }, };