Skip to content

Commit

Permalink
Testing: Update splitting test to ensure caret merge positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jun 29, 2018
1 parent 29bcba5 commit dd0e347
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ exports[`splitting and merging blocks Should split and merge paragraph blocks us

exports[`splitting and merging blocks Should split and merge paragraph blocks using Enter and Backspace 2`] = `
"<!-- wp:paragraph -->
<p>FirstSecond</p>
<p>FirstBetweenSecond</p>
<!-- /wp:paragraph -->"
`;
37 changes: 17 additions & 20 deletions test/e2e/specs/splitting-merging.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
* Internal dependencies
*/
import '../support/bootstrap';
import { newPost, newDesktopBrowserPage, insertBlock } from '../support/utils';
import {
newPost,
newDesktopBrowserPage,
insertBlock,
getHTMLFromCodeEditor,
switchToEditor,
} from '../support/utils';

describe( 'splitting and merging blocks', () => {
beforeAll( async () => {
Expand All @@ -11,7 +17,7 @@ describe( 'splitting and merging blocks', () => {
} );

it( 'Should split and merge paragraph blocks using Enter and Backspace', async () => {
//Use regular inserter to add paragraph block and text
// Use regular inserter to add paragraph block and text
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'FirstSecond' );

Expand All @@ -21,32 +27,23 @@ describe( 'splitting and merging blocks', () => {
}
await page.keyboard.press( 'Enter' );

//Switch to Code Editor to check HTML output
await page.click( '.edit-post-more-menu [aria-label="More"]' );
let codeEditorButton = ( await page.$x( '//button[contains(text(), \'Code Editor\')]' ) )[ 0 ];
await codeEditorButton.click( 'button' );

//Assert that there are now two paragraph blocks with correct content
let textEditorContent = await page.$eval( '.editor-post-text-editor', ( element ) => element.value );
// Assert that there are now two paragraph blocks with correct content
let textEditorContent = await getHTMLFromCodeEditor();
expect( textEditorContent ).toMatchSnapshot();

//Switch to Visual Editor to continue testing
await page.click( '.edit-post-more-menu [aria-label="More"]' );
const visualEditorButton = ( await page.$x( '//button[contains(text(), \'Visual Editor\')]' ) )[ 0 ];
await visualEditorButton.click( 'button' );
// Switch to Visual Editor to continue testing
await switchToEditor( 'Visual' );

//Press Backspace to merge paragraph blocks
// Press Backspace to merge paragraph blocks
await page.click( '.is-selected' );
await page.keyboard.press( 'Home' );
await page.keyboard.press( 'Backspace' );

//Switch to Code Editor to check HTML output
await page.click( '.edit-post-more-menu [aria-label="More"]' );
codeEditorButton = ( await page.$x( '//button[contains(text(), \'Code Editor\')]' ) )[ 0 ];
await codeEditorButton.click( 'button' );
// Ensure that caret position is correctly placed at the between point.
await page.keyboard.type( 'Between' );

//Assert that there is now one paragraph with correct content
textEditorContent = await page.$eval( '.editor-post-text-editor', ( element ) => element.value );
// Assert that there is now one paragraph with correct content
textEditorContent = await getHTMLFromCodeEditor();
expect( textEditorContent ).toMatchSnapshot();
} );
} );

0 comments on commit dd0e347

Please sign in to comment.