Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( 'creates the block and makes it available in the block editor', async () => {
const blockName = 'Testing Example';
const fieldName = 'Testing Text';
// Create the Block Lab block (a 'block_lab' post).
await visitAdminPage( 'post-new.php', '?post_type=block_lab' );
await page.click( '[name="post_title"]' );
await pressKeyWithModifier( 'primary', 'a' );
await page.keyboard.type( blockName );
// Add a Text field.
await page.click( '#block-add-field' );
await page.click( '.block-fields-edit-label input' );
await pressKeyWithModifier( 'primary', 'a' );
await page.keyboard.type( fieldName );
// Publish the block.
await page.click( '#publish' );
// There should be a success notice.
await page.waitForSelector( '.updated' );
// Create a new post and add the new block.
await createNewPost();
await insertBlockFromInserter( blockName );
await page.waitForSelector( '.wp-block' );
const fieldValue = 'this is some example text';
const fieldSelector = '.components-base-control__field';
export async function waitAndType( page, selector, value, options = { visible: true } ) {
const el = await waitForSelector( page, selector, options );
await page.focus( selector );
await pressKeyWithModifier( 'primary', 'a' );
// await el.click( { clickCount: 3 } );
await page.waitFor( 300 );
await el.type( value, options );
}
it( 'should open the context menu when pressing Shift+F10 on a page', async () => {
await insertBlock( 'Page' );
await pressKeyWithModifier( 'shift', 'F10' );
expect( page ).toMatchElement( POPOVER_SELECTOR );
expect( page ).toMatchElement( POPOVER_SELECTOR + ' .right-click-duplicate-page' );
expect( page ).toMatchElement( POPOVER_SELECTOR + ' .right-click-remove-page' );
} );
} );
export async function searchForBlock( searchTerm ) {
await openGlobalBlockInserter();
await page.focus( '.block-editor-inserter__search' );
await pressKeyWithModifier( 'primary', 'a' );
await page.keyboard.type( searchTerm );
}
export async function fillField( selector, text ) {
await page.focus( selector );
await pressKeyWithModifier( 'primary', 'a' );
await page.type( selector, text.toString() );
}