From 60e22bf1fc581eb22885a247f82e78ef9850d235 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 25 Oct 2018 15:22:52 +0100 Subject: [PATCH] Add an e2e test for the autop issue --- .../compatibility-classic-editor.test.js.snap | 10 ++++++ .../compatibility-classic-editor.test.js | 33 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/e2e/specs/__snapshots__/compatibility-classic-editor.test.js.snap create mode 100644 test/e2e/specs/compatibility-classic-editor.test.js diff --git a/test/e2e/specs/__snapshots__/compatibility-classic-editor.test.js.snap b/test/e2e/specs/__snapshots__/compatibility-classic-editor.test.js.snap new file mode 100644 index 0000000000000..7eace840053e5 --- /dev/null +++ b/test/e2e/specs/__snapshots__/compatibility-classic-editor.test.js.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Compatibility with Classic Editor Should not apply autop when rendering blocks 1`] = ` +" + + +Random Link + + " +`; diff --git a/test/e2e/specs/compatibility-classic-editor.test.js b/test/e2e/specs/compatibility-classic-editor.test.js new file mode 100644 index 0000000000000..08192494b5e1b --- /dev/null +++ b/test/e2e/specs/compatibility-classic-editor.test.js @@ -0,0 +1,33 @@ +/** + * Internal dependencies + */ +import { newPost, insertBlock, publishPost } from '../support/utils'; + +describe( 'Compatibility with Classic Editor', () => { + beforeEach( async () => { + await newPost(); + } ); + + it( 'Should not apply autop when rendering blocks', async () => { + // Save should not be an option for new empty post. + expect( await page.$( '.editor-post-save-draft' ) ).toBe( null ); + + // Add title to enable valid non-empty post save. + await insertBlock( 'Custom HTML' ); + await page.keyboard.type( '' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( 'Random Link' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '' ); + await publishPost(); + + // View the post. + const viewPostLinks = await page.$x( "//a[contains(text(), 'View Post')]" ); + await viewPostLinks[ 0 ].click(); + await page.waitForNavigation(); + + // Check the the dynamic block appears. + const content = await page.$eval( '.entry-content', ( element ) => element.innerHTML ); + expect( content ).toMatchSnapshot(); + } ); +} );