Skip to content

Commit

Permalink
Testing: Click at rightish of between inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Apr 2, 2018
1 parent cee70e6 commit f67884c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion test/e2e/specs/adding-blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ describe( 'adding blocks', () => {
await newPost();
} );

/**
* Given a Puppeteer ElementHandle, clicks around the center-right point.
*
* TEMPORARY: This is a mild hack to work around a bug in the application
* which prevents clicking at center of the inserter, due to conflicting
* overlap of focused block contextual toolbar.
*
* @see Puppeteer.ElementHandle#click
*
* @link https://github.com/WordPress/gutenberg/pull/5658#issuecomment-376943568
*
* @param {Puppeteer.ElementHandle} elementHandle Element handle.
*
* @return {Promise} Promise resolving when element clicked.
*/
async function clickAtRightish( elementHandle ) {
await elementHandle._scrollIntoViewIfNeeded();
const box = await elementHandle._assertBoundingBox();
const x = box.x + ( box.width * 0.75 );
const y = box.y + ( box.height / 2 );
return page.mouse.click( x, y );
}

it( 'Should insert content using the placeholder and the regular inserter', async () => {
// Default block appender is provisional
await page.click( '.editor-default-block-appender' );
Expand Down Expand Up @@ -39,7 +62,8 @@ describe( 'adding blocks', () => {
// Using the between inserter
await page.mouse.move( 200, 300 );
await page.mouse.move( 250, 350 );
await page.click( '[data-type="core/quote"] .editor-block-list__insertion-point-inserter' );
const inserter = await page.$( '[data-type="core/quote"] .editor-block-list__insertion-point-inserter' );
await clickAtRightish( inserter );
await page.keyboard.type( 'Second paragraph' );

// Switch to Text Mode to check HTML Output
Expand Down

0 comments on commit f67884c

Please sign in to comment.