From 1a637ee0da59d2ec53d23135840f4bf925f04832 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Mon, 16 Jul 2018 13:16:27 -0400 Subject: [PATCH] Testing: Add E2E case to ensure cleaned TinyMCE content --- .../__snapshots__/writing-flow.test.js.snap | 12 ++++++++++++ test/e2e/specs/writing-flow.test.js | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/test/e2e/specs/__snapshots__/writing-flow.test.js.snap b/test/e2e/specs/__snapshots__/writing-flow.test.js.snap index 578cc425e4874..5dc0ca5385785 100644 --- a/test/e2e/specs/__snapshots__/writing-flow.test.js.snap +++ b/test/e2e/specs/__snapshots__/writing-flow.test.js.snap @@ -24,6 +24,18 @@ exports[`adding blocks Should navigate inner blocks with arrow keys 1`] = ` " `; +exports[`adding blocks should clean TinyMCE content 1`] = ` +" +

+" +`; + +exports[`adding blocks should clean TinyMCE content 2`] = ` +" +

Inside

+" +`; + exports[`adding blocks should navigate around inline boundaries 1`] = ` "

FirstAfter

diff --git a/test/e2e/specs/writing-flow.test.js b/test/e2e/specs/writing-flow.test.js index 854a209c9dca5..6753e7aba078d 100644 --- a/test/e2e/specs/writing-flow.test.js +++ b/test/e2e/specs/writing-flow.test.js @@ -142,4 +142,22 @@ describe( 'adding blocks', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); + + it( 'should clean TinyMCE content', async () => { + // Ensure no zero-width space character. Notably, this can occur when + // save occurs while at an inline boundary edge. + await page.click( '.editor-default-block-appender__content' ); + await pressWithModifier( 'mod', 'b' ); + expect( await getEditedPostContent() ).toMatchSnapshot(); + + // When returning to Visual mode, backspace in selected block should + // reset to the provisional block. + await page.keyboard.press( 'Backspace' ); + + // Ensure no data-mce-selected. Notably, this can occur when content + // is saved while typing within an inline boundary. + await pressWithModifier( 'mod', 'b' ); + await page.keyboard.type( 'Inside' ); + expect( await getEditedPostContent() ).toMatchSnapshot(); + } ); } );