Skip to content

Commit

Permalink
temp fix for selectInserterTab check
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Oct 31, 2022
1 parent 738ba9f commit c688472
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/e2e-test-utils/src/inserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,20 @@ async function waitForInserterCloseAndContentFocus() {
}

async function selectInserterTab( tabName ) {
const tab = await page.waitForXPath(
`//div[contains(@class, "block-editor-inserter__tabs")]//button[.="${ tabName }"]`
);
if ( ! tab.ariaSelected ) {
return tab.click();
}
try {
// There are cases that the inserter has no tabs, but we always show the block types tab.
// In these cases, we can skip the tab selection.
const tab = await page.waitForXPath(
`//div[contains(@class, "block-editor-inserter__tabs")]//button[.="${ tabName }"]`,
{ timeout: 3000 }
);
const ariaSelected = await (
await tab.getProperty( 'ariaSelected' )
).jsonValue();
if ( ariaSelected !== 'true' ) {
return tab.click();
}
} catch ( e ) {}
}

/**
Expand Down

0 comments on commit c688472

Please sign in to comment.