Skip to content

Commit

Permalink
E2E: Update Heading block's aria-label (#45986)
Browse files Browse the repository at this point in the history
...and make it backwards-compatible. This label was updated in WordPress/gutenberg#23034.

Co-authored-by: Bart <bartlomiej.kalisz@gmail.com>
  • Loading branch information
sirreal and WunderBart authored Oct 1, 2020
1 parent 6e9e6d4 commit 1815f46
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions test/e2e/lib/gutenberg/gutenberg-editor-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ export default class GutenbergEditorComponent extends AsyncBaseContainer {
blockClass = 'dynamic-separator';
break;
case 'Heading':
ariaLabel = 'Write heading…';
break;
case 'Layout Grid':
prefix = 'jetpack-';
Expand Down Expand Up @@ -355,12 +354,22 @@ export default class GutenbergEditorComponent extends AsyncBaseContainer {
const inserterBlockItemSelector = By.css(
`.edit-post-layout__inserter-panel .block-editor-inserter__block-list button.editor-block-list-item-${ prefix }${ blockClass }`
);
const insertedBlockSelector = By.css(

let insertedBlockSelector = By.css(
`.block-editor-block-list__block.${
hasChildBlocks ? 'has-child-selected' : 'is-selected'
}[aria-label*='${ selectorAriaLabel }']`
);

// @TODO: Remove this condition when Gutenberg v9.1 is deployed for all sites.
if ( title === 'Heading' ) {
const deprecatedSelector = insertedBlockSelector.value.replace(
selectorAriaLabel,
'Write heading…'
);
insertedBlockSelector = By.css( `${ insertedBlockSelector.value }, ${ deprecatedSelector }` );
}

await this.openBlockInserterAndSearch( title );

if ( await driverHelper.elementIsNotPresent( this.driver, inserterBlockItemSelector ) ) {
Expand Down Expand Up @@ -416,15 +425,28 @@ export default class GutenbergEditorComponent extends AsyncBaseContainer {
}

async removeBlock( blockID ) {
const blockSelector = By.css( `.wp-block[id="${blockID}"]`);
await driverHelper.isEventuallyPresentAndDisplayed( this.driver, blockSelector, this.explicitWaitMS / 5 );
const blockSelector = By.css( `.wp-block[id="${ blockID }"]` );
await driverHelper.isEventuallyPresentAndDisplayed(
this.driver,
blockSelector,
this.explicitWaitMS / 5
);
await this.driver.findElement( blockSelector ).click();
await driverHelper.clickWhenClickable( this.driver, By.css( '.block-editor-block-settings-menu' ) );
await driverHelper.isEventuallyPresentAndDisplayed( this.driver, By.css( '.components-menu-group' ), this.explicitWaitMS / 5 );
await driverHelper.clickWhenClickable(
this.driver,
By.css( '.block-editor-block-settings-menu' )
);
await driverHelper.isEventuallyPresentAndDisplayed(
this.driver,
By.css( '.components-menu-group' ),
this.explicitWaitMS / 5
);
await this.driver.sleep( 1000 );
return await driverHelper.clickWhenClickable(
this.driver,
By.css( '.components-menu-group:last-of-type button.components-menu-item__button:last-of-type' )
By.css(
'.components-menu-group:last-of-type button.components-menu-item__button:last-of-type'
)
);
}

Expand Down

0 comments on commit 1815f46

Please sign in to comment.