From 72b2eabafa693f987571240caf71e55cea251739 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 4 Sep 2018 12:21:40 +0100 Subject: [PATCH] Fix e2e tests --- .../editor/src/components/block-toolbar/index.js | 14 +++++++++----- test/e2e/specs/block-deletion.test.js | 6 ++++++ test/e2e/specs/editor-modes.test.js | 12 ++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/components/block-toolbar/index.js b/packages/editor/src/components/block-toolbar/index.js index c2e8f7016ae614..a288e6026f29b4 100644 --- a/packages/editor/src/components/block-toolbar/index.js +++ b/packages/editor/src/components/block-toolbar/index.js @@ -2,7 +2,7 @@ * WordPress Dependencies */ import { withSelect } from '@wordpress/data'; -import { Component, createRef } from '@wordpress/element'; +import { Component, createRef, Fragment } from '@wordpress/element'; import { focus } from '@wordpress/dom'; /** @@ -53,15 +53,19 @@ class BlockToolbar extends Component { ); } - if ( ! isValid || 'visual' !== mode ) { + if ( ! isValid ) { return null; } return (
- - - + { mode === 'visual' && ( + + + + + + ) }
); diff --git a/test/e2e/specs/block-deletion.test.js b/test/e2e/specs/block-deletion.test.js index 9851cd7526eb8d..bb530f9478b69e 100644 --- a/test/e2e/specs/block-deletion.test.js +++ b/test/e2e/specs/block-deletion.test.js @@ -31,6 +31,12 @@ describe( 'block deletion -', () => { describe( 'deleting the third block using the Remove Block menu item', () => { it( 'results in two remaining blocks and positions the caret at the end of the second block', async () => { + // The blocks can't be empty to trigger the toolbar + await page.keyboard.type( 'Paragraph to remove' ); + + // Move the mouse to show the block toolbar + await page.mouse.move( 200, 300, { steps: 10 } ); + await clickOnBlockSettingsMenuItem( 'Remove Block' ); expect( await getEditedPostContent() ).toMatchSnapshot(); diff --git a/test/e2e/specs/editor-modes.test.js b/test/e2e/specs/editor-modes.test.js index 9a7aa4ca0bc07d..6c451607aedb27 100644 --- a/test/e2e/specs/editor-modes.test.js +++ b/test/e2e/specs/editor-modes.test.js @@ -15,6 +15,9 @@ describe( 'Editing modes (visual/HTML)', () => { let visualBlock = await page.$$( '.editor-block-list__layout .editor-block-list__block .editor-rich-text' ); expect( visualBlock ).toHaveLength( 1 ); + // Move the mouse to show the block toolbar + await page.mouse.move( 200, 300, { steps: 10 } ); + // Change editing mode from "Visual" to "HTML". await page.waitForSelector( 'button[aria-label="More options"]' ); await page.click( 'button[aria-label="More options"]' ); @@ -25,6 +28,9 @@ describe( 'Editing modes (visual/HTML)', () => { const htmlBlock = await page.$$( '.editor-block-list__layout .editor-block-list__block .editor-block-list__block-html-textarea' ); expect( htmlBlock ).toHaveLength( 1 ); + // Move the mouse to show the block toolbar + await page.mouse.move( 200, 300, { steps: 10 } ); + // Change editing mode from "HTML" back to "Visual". await page.waitForSelector( 'button[aria-label="More options"]' ); await page.click( 'button[aria-label="More options"]' ); @@ -37,6 +43,9 @@ describe( 'Editing modes (visual/HTML)', () => { } ); it( 'should display sidebar in HTML mode', async () => { + // Move the mouse to show the block toolbar + await page.mouse.move( 200, 300, { steps: 10 } ); + // Change editing mode from "Visual" to "HTML". await page.waitForSelector( 'button[aria-label="More options"]' ); await page.click( 'button[aria-label="More options"]' ); @@ -50,6 +59,9 @@ describe( 'Editing modes (visual/HTML)', () => { } ); it( 'should update HTML in HTML mode when sidebar is used', async () => { + // Move the mouse to show the block toolbar + await page.mouse.move( 200, 300, { steps: 10 } ); + // Change editing mode from "Visual" to "HTML". await page.waitForSelector( 'button[aria-label="More options"]' ); await page.click( 'button[aria-label="More options"]' );