Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function addReusableBlock() {
await createNewPost();
const isTopToolbarEnabled = await page.$eval( '.edit-post-layout', ( layout ) => {
return layout.classList.contains( 'has-fixed-toolbar' );
} );
if ( ! isTopToolbarEnabled ) {
await clickOnMoreMenuItem( 'Top Toolbar' );
}
await removeAllBlocks();
// Insert a paragraph block
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Reusable block!' );
await clickButtonByLabel( 'More options' );
export async function createCourse( title = 'Test Course' ) {
page.on( 'dialog', dialog => dialog.accept() );
await createNewPost( {
title,
postType: 'course',
} );
await publishPost();
return await page.evaluate( () => wp.data.select( 'core/editor' ).getCurrentPostId() );
}
export async function createPost( postType, title = 'Test Course' ) {
page.on( 'dialog', dialog => dialog.accept() );
await createNewPost( {
title,
postType,
} );
await publishPost();
return await page.evaluate( () => wp.data.select( 'core/editor' ).getCurrentPostId() );
}