Skip to content

Commit

Permalink
Try fixing the typing quickly e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Oct 30, 2018
1 parent 4c1ecdb commit 4cc3a13
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 0 additions & 5 deletions packages/editor/src/components/rich-text/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ export default class TinyMCE extends Component {
} );

editor.dom.setHTML = setHTML;
tinymce.DOM.addClass( editor.getBody(), 'mce-initialised' );
} );

editor.on( 'remove', () => {
tinymce.DOM.removeClass( editor.getBody(), 'mce-initialised' );
} );
},
} );
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/specs/block-deletion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
newPost,
pressWithModifier,
ACCESS_MODIFIER_KEYS,
waitForRichTextInitialization,
} from '../support/utils';

const addThreeParagraphsToNewPost = async () => {
Expand All @@ -16,8 +17,10 @@ const addThreeParagraphsToNewPost = async () => {
await clickBlockAppender();
await page.keyboard.type( 'First paragraph' );
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();
await page.keyboard.type( 'Second paragraph' );
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();
};

const clickOnBlockSettingsMenuItem = async ( buttonLabel ) => {
Expand Down Expand Up @@ -96,6 +99,7 @@ describe( 'block deletion -', () => {
// Add a third paragraph for this test.
await page.keyboard.type( 'Third paragraph' );
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();

// Press the up arrow once to select the third and fourth blocks.
await pressWithModifier( 'Shift', 'ArrowUp' );
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/specs/splitting-merging.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
pressTimes,
pressWithModifier,
META_KEY,
waitForRichTextInitialization,
} from '../support/utils';

describe( 'splitting and merging blocks', () => {
Expand Down Expand Up @@ -132,7 +133,9 @@ describe( 'splitting and merging blocks', () => {
await pressWithModifier( META_KEY, 'b' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();

await page.keyboard.press( 'Backspace' );

Expand Down Expand Up @@ -172,8 +175,11 @@ describe( 'splitting and merging blocks', () => {
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'First' );
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();
await page.keyboard.press( 'Enter' );
await waitForRichTextInitialization();
await page.keyboard.type( 'Second' );
await page.keyboard.press( 'ArrowUp' );
await page.keyboard.press( 'ArrowUp' );
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ async function login() {
* @return {Promise} Promise resolving once RichText is initialized, or is
* determined to not be a container of the active element.
*/
async function waitForRichTextInitialization() {
export async function waitForRichTextInitialization() {
const isInRichText = await page.evaluate( () => {
return document.activeElement.contentEditable === 'true';
return !! document.activeElement.closest( '.editor-rich-text__tinymce' );
} );

if ( ! isInRichText ) {
return;
}

return page.waitForFunction( () => {
return !! document.activeElement.closest( '.mce-initialised' );
return !! document.activeElement.closest( '.mce-content-body' );
} );
}

Expand Down

0 comments on commit 4cc3a13

Please sign in to comment.