2020-10-27 12:24:53 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { searchForBlock } from '@wordpress/e2e-test-utils';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the inserter, searches for the given term, then selects the first
|
|
|
|
* result that appears.
|
|
|
|
*
|
|
|
|
* @param {string} searchTerm The text to search the inserter for.
|
|
|
|
*/
|
|
|
|
export async function insertBlockDontWaitForInsertClose( searchTerm ) {
|
|
|
|
await searchForBlock( searchTerm );
|
|
|
|
const insertButton = (
|
|
|
|
await page.$x( `//button//span[contains(text(), '${ searchTerm }')]` )
|
|
|
|
)[ 0 ];
|
|
|
|
await insertButton.click();
|
|
|
|
}
|
|
|
|
|
|
|
|
export const closeInserter = async () => {
|
2021-04-16 10:48:27 +00:00
|
|
|
if (
|
|
|
|
await page.evaluate( () => {
|
|
|
|
return !! document.querySelector(
|
|
|
|
'.edit-post-header [aria-label="Add block"]'
|
|
|
|
);
|
|
|
|
} )
|
|
|
|
) {
|
|
|
|
await page.click( '.edit-post-header [aria-label="Add block"]' );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await page.click(
|
|
|
|
'.edit-post-header [aria-label="Toggle block inserter"]'
|
|
|
|
);
|
2020-10-27 12:24:53 +00:00
|
|
|
};
|