Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: add e2e test for invalid blocks #11814

Merged
merged 1 commit into from
Nov 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions test/e2e/specs/invalid-block.test.js
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' );
} );
} );