From dd0e34796c3eaf8c7862e606654e57d2eaa57ffa Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 29 Jun 2018 09:22:39 -0400 Subject: [PATCH] Testing: Update splitting test to ensure caret merge positioning --- .../splitting-merging.test.js.snap | 2 +- test/e2e/specs/splitting-merging.test.js | 37 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/test/e2e/specs/__snapshots__/splitting-merging.test.js.snap b/test/e2e/specs/__snapshots__/splitting-merging.test.js.snap index 98d163a480fbd..1008845e2d6ab 100644 --- a/test/e2e/specs/__snapshots__/splitting-merging.test.js.snap +++ b/test/e2e/specs/__snapshots__/splitting-merging.test.js.snap @@ -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`] = ` " -

FirstSecond

+

FirstBetweenSecond

" `; diff --git a/test/e2e/specs/splitting-merging.test.js b/test/e2e/specs/splitting-merging.test.js index 5c727cbf406d9..0f5ac760ac5fd 100644 --- a/test/e2e/specs/splitting-merging.test.js +++ b/test/e2e/specs/splitting-merging.test.js @@ -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 () => { @@ -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' ); @@ -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(); } ); } );