From f2d5e89a5fe0afc36ad755a4ff83419cc0796d74 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Thu, 25 Oct 2018 10:41:03 +0200 Subject: [PATCH] Make all plugin API e2e test independent --- test/e2e/specs/plugins-api.test.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/e2e/specs/plugins-api.test.js b/test/e2e/specs/plugins-api.test.js index d1f218a948dc33..d149cf492a5a33 100644 --- a/test/e2e/specs/plugins-api.test.js +++ b/test/e2e/specs/plugins-api.test.js @@ -14,13 +14,16 @@ import { activatePlugin, deactivatePlugin } from '../support/plugins'; describe( 'Using Plugins API', () => { beforeAll( async () => { await activatePlugin( 'gutenberg-test-plugin-plugins-api' ); - await newPost(); } ); afterAll( async () => { await deactivatePlugin( 'gutenberg-test-plugin-plugins-api' ); } ); + beforeEach( async () => { + await newPost(); + } ); + describe( 'Post Status Info', () => { it( 'Should render post status info inside Document Setting sidebar', async () => { await openDocumentSettingsSidebar(); @@ -31,16 +34,13 @@ describe( 'Using Plugins API', () => { } ); describe( 'Publish Panel', () => { - afterEach( async () => { - // Close Publish panel. - await page.click( '.editor-post-publish-panel__header button[aria-label="Close panel"]' ); - } ); - - it( 'Should render publish panel inside Pre-publish sidebar', async () => { + beforeEach( async () => { // Type something first to activate Publish button. await clickBlockAppender(); await page.keyboard.type( 'First paragraph' ); + } ); + it( 'Should render publish panel inside Pre-publish sidebar', async () => { await openPublishPanel(); const pluginPublishPanelText = await page.$eval( '.editor-post-publish-panel .my-publish-panel-plugin__pre', ( el ) => el.innerText ); @@ -66,8 +66,13 @@ describe( 'Using Plugins API', () => { it( 'Should close plugins sidebar using More Menu item', async () => { await clickOnMoreMenuItem( 'Sidebar title plugin' ); - const pluginSidebar = await page.$( '.edit-post-sidebar' ); - expect( pluginSidebar ).toBeNull(); + const pluginSidebarOpened = await page.$( '.edit-post-sidebar' ); + expect( pluginSidebarOpened ).not.toBeNull(); + + await clickOnMoreMenuItem( 'Sidebar title plugin' ); + + const pluginSidebarClosed = await page.$( '.edit-post-sidebar' ); + expect( pluginSidebarClosed ).toBeNull(); } ); } ); } );