From 47a69e15cda227db959e87a9424ddf4ed275ca57 Mon Sep 17 00:00:00 2001 From: Matthew Riley MacPherson Date: Wed, 8 Aug 2018 00:48:26 +0100 Subject: [PATCH] chore: Add test for block mover (#8011) (#8392) * chore: Add test for block mover (#8011) --- test/e2e/specs/block-mover.test.js | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/e2e/specs/block-mover.test.js diff --git a/test/e2e/specs/block-mover.test.js b/test/e2e/specs/block-mover.test.js new file mode 100644 index 00000000000000..5d1b77707c244b --- /dev/null +++ b/test/e2e/specs/block-mover.test.js @@ -0,0 +1,40 @@ +/** + * Internal dependencies + */ +import '../support/bootstrap'; +import { newPost, newDesktopBrowserPage } from '../support/utils'; + +describe( 'block mover', () => { + beforeEach( async () => { + await newDesktopBrowserPage(); + await newPost(); + } ); + + it( 'should show block mover when more than one block exists', async () => { + // Create a two blocks on the page. + await page.click( '.editor-default-block-appender' ); + await page.keyboard.type( 'First Paragraph' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( 'Second Paragraph' ); + + // Select a block so the block mover is rendered. + await page.focus( '.editor-block-list__block' ); + + const blockMover = await page.$$( '.editor-block-mover' ); + // There should be a block mover. + expect( blockMover ).toHaveLength( 1 ); + } ); + + it( 'should hide block mover when only one block exists', async () => { + // Create a single block on the page. + await page.click( '.editor-default-block-appender' ); + await page.keyboard.type( 'First Paragraph' ); + + // Select a block so the block mover has the possibility of being rendered. + await page.focus( '.editor-block-list__block' ); + + // Ensure no block mover exists when only one block exists on the page. + const blockMover = await page.$$( '.editor-block-mover' ); + expect( blockMover ).toHaveLength( 0 ); + } ); +} );