-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that the invalid block warning appears and that buttons are clickable. Should cover the issue fixed in #11768
- Loading branch information
1 parent
38001c6
commit 0cb8177
Showing
1 changed file
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
newPost, | ||
clickBlockAppender, | ||
} from '../support/utils'; | ||
|
||
describe( 'invalid blocks', () => { | ||
beforeEach( async () => { | ||
await newPost(); | ||
} ); | ||
|
||
it( 'Should show an invalid block message with clickable options', async () => { | ||
// Create an empty paragraph with the focus in the block | ||
await clickBlockAppender(); | ||
await page.keyboard.type( 'hello' ); | ||
|
||
// Click the 'more options' | ||
await page.mouse.move( 200, 300, { steps: 10 } ); | ||
await page.click( 'button[aria-label="More options"]' ); | ||
|
||
// Change to HTML mode and close the options | ||
const changeModeButton = await page.waitForXPath( '//button[text()="Edit as HTML"]' ); | ||
await changeModeButton.click(); | ||
|
||
// Focus on the textarea and enter an invalid paragraph | ||
await page.click( '.editor-block-list__layout .editor-block-list__block .editor-block-list__block-html-textarea' ); | ||
await page.keyboard.type( '<p>invalid paragraph' ); | ||
|
||
// Takes the focus away from the block so the invalid warning is triggered | ||
await page.click( '.editor-post-save-draft' ); | ||
expect( console ).toHaveErrored(); | ||
expect( console ).toHaveWarned(); | ||
|
||
// Click on the 'resolve' button | ||
await page.click( '.editor-warning__actions button' ); | ||
|
||
// Check we get the resolve modal with the appropriate contents | ||
const htmlBlockContent = await page.$eval( '.editor-block-compare__html', ( node ) => node.textContent ); | ||
expect( htmlBlockContent ).toEqual( '<p>hello</p><p>invalid paragraph' ); | ||
} ); | ||
} ); |