Skip to content

Commit

Permalink
Fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Sep 4, 2018
1 parent ae2ecac commit 72b2eab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -53,15 +53,19 @@ class BlockToolbar extends Component {
);
}

if ( ! isValid || 'visual' !== mode ) {
if ( ! isValid ) {
return null;
}

return (
<div className="editor-block-toolbar">
<BlockSwitcher clientIds={ blockClientIds } />
<BlockControls.Slot />
<BlockFormatControls.Slot />
{ mode === 'visual' && (
<Fragment>
<BlockSwitcher clientIds={ blockClientIds } />
<BlockControls.Slot />
<BlockFormatControls.Slot />
</Fragment>
) }
<BlockSettingsMenu clientIds={ blockClientIds } />
</div>
);
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/specs/block-deletion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
12 changes: 12 additions & 0 deletions test/e2e/specs/editor-modes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]' );
Expand All @@ -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"]' );
Expand All @@ -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"]' );
Expand All @@ -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"]' );
Expand Down

0 comments on commit 72b2eab

Please sign in to comment.