Skip to content

Commit

Permalink
David's fix #31121
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Apr 23, 2021
1 parent 46f147d commit 31b339a
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions packages/e2e-tests/experimental-features.js
Original file line number Diff line number Diff line change
@@ -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 '';
} );
},
};

0 comments on commit 31b339a

Please sign in to comment.