Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: End 2 end tests to allowedBlocks restrictions
- Loading branch information
1 parent
1386ab4
commit 50e9ef4
Showing
12 changed files
with
316 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/e2e-test-utils/src/get-all-block-inserter-item-titles.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { sortBy, uniq } from 'lodash'; | ||
|
||
/** | ||
* Returns an array of strings with all inserter item titles. | ||
* | ||
* @return {Promise} Promise resolving with an array containing all inserter item titles. | ||
*/ | ||
export async function getAllBlockInserterItemTitles() { | ||
const inserterItemTitles = await page.evaluate( () => { | ||
return Array.from( | ||
document.querySelectorAll( | ||
'.editor-inserter__results .editor-block-types-list__item-title' | ||
) | ||
).map( | ||
( inserterItem ) => { | ||
return inserterItem.innerText; | ||
} | ||
); | ||
} ); | ||
return sortBy( uniq( inserterItemTitles ) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/e2e-test-utils/src/open-all-block-inserter-categories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Opens all block inserter categories. | ||
*/ | ||
export async function openAllBlockInserterCategories() { | ||
const notOpenCategoryPanels = await page.$$( | ||
'.editor-inserter__results .components-panel__body:not(.is-opened)' | ||
); | ||
for ( const categoryPanel of notOpenCategoryPanels ) { | ||
await categoryPanel.click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Opens the global block inserter. | ||
*/ | ||
export async function openGlobalBlockInserter() { | ||
await page.click( '.edit-post-header [aria-label="Add block"]' ); | ||
// Waiting here is necessary because sometimes the inserter takes more time to | ||
// render than Puppeteer takes to complete the 'click' action | ||
await page.waitForSelector( '.editor-inserter__menu' ); | ||
} |
Oops, something went wrong.