-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: End to end test to make sure when all blocks get removed the def…
…ault block appender gets inserter and selected
- Loading branch information
1 parent
5e4c2ae
commit 6e44d6b
Showing
5 changed files
with
83 additions
and
36 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
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
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,22 @@ | ||
/** | ||
* Checks if the block that is focused is the default block. | ||
* | ||
* @return {Promise} Promise resolving with a boolean indicating if the focused block is the default block. | ||
*/ | ||
export function isInDefaultBlock() { | ||
return page.evaluate( () => { | ||
const activeElement = document.activeElement; | ||
// activeElement may be null in that case we should return false | ||
if ( ! activeElement ) { | ||
return false; | ||
} | ||
const closestElementWithDataTpe = activeElement.closest( '[data-type]' ); | ||
if ( ! closestElementWithDataTpe ) { | ||
return false; | ||
} | ||
const activeBlockName = closestElementWithDataTpe.getAttribute( 'data-type' ); | ||
const defaultBlockName = window.wp.blocks.getDefaultBlockName(); | ||
|
||
return activeBlockName === defaultBlockName; | ||
} ); | ||
} |
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
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