From 774267cd82ad463df2f793990b36356d240e1402 Mon Sep 17 00:00:00 2001 From: Stacey Gammon Date: Fri, 3 Mar 2017 09:26:33 -0500 Subject: [PATCH] Fix edit controls bug, add more tests, make other tests more stable. --- .../kibana/public/dashboard/dashboard.js | 1 + test/functional/apps/dashboard/_view_edit.js | 37 +++++++++++++------ test/support/page_objects/dashboard_page.js | 8 ++-- test/support/page_objects/header_page.js | 9 +++-- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/core_plugins/kibana/public/dashboard/dashboard.js b/src/core_plugins/kibana/public/dashboard/dashboard.js index a644129c7692c..98c56824814de 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard.js @@ -178,6 +178,7 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter, function updateViewMode(newMode) { $scope.topNavMenu = getTopNavConfig(newMode, navActions); dashboardState.switchViewMode(newMode); + $scope.dashboardViewMode = newMode; } const onChangeViewMode = (newMode) => { diff --git a/test/functional/apps/dashboard/_view_edit.js b/test/functional/apps/dashboard/_view_edit.js index 4a8f634896c43..3c0327e40c68f 100644 --- a/test/functional/apps/dashboard/_view_edit.js +++ b/test/functional/apps/dashboard/_view_edit.js @@ -30,26 +30,41 @@ bdd.describe('dashboard view edit mode', function viewEditModeTests() { expect(inViewMode).to.equal(true); }); - bdd.it('view mode hides panel edit controls', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickDashboardByLinkText(dashboardName); + bdd.describe('panel edit controls', function () { + bdd.it('are hidden in view mode', async function () { + await PageObjects.dashboard.gotoDashboardLandingPage(); + await PageObjects.dashboard.clickDashboardByLinkText(dashboardName); + + const editLinkExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelEditLink'); + const moveExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelMoveIcon'); + const removeExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelRemoveIcon'); + + expect(editLinkExists).to.equal(false); + expect(moveExists).to.equal(false); + expect(removeExists).to.equal(false); + }); + + bdd.it('are shown in edit mode', async function () { + await PageObjects.dashboard.clickEdit(); - const editLinkExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelEditLink'); - const moveExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelMoveIcon'); - const removeExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelRemoveIcon'); + const editLinkExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelEditLink'); + const moveExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelMoveIcon'); + const removeExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelRemoveIcon'); - expect(editLinkExists).to.equal(false); - expect(moveExists).to.equal(false); - expect(removeExists).to.equal(false); + expect(editLinkExists).to.equal(true); + expect(moveExists).to.equal(true); + expect(removeExists).to.equal(true); + }); }); - bdd.it('view mode shows expand on a panel', async function () { + // Panel expand should also be shown in view mode, but only on mouse hover. + bdd.describe('panel expand control shown in edit mode', async function () { + await PageObjects.dashboard.clickEdit(); const expandExists = await PageObjects.common.doesTestSubjectExist('dashboardPanelExpandIcon'); expect(expandExists).to.equal(true); }); bdd.it('save auto exits out of edit mode', async function () { - await PageObjects.dashboard.clickEdit(); await PageObjects.dashboard.saveDashboard(dashboardName); const isViewMode = await PageObjects.dashboard.getIsInViewMode(); diff --git a/test/support/page_objects/dashboard_page.js b/test/support/page_objects/dashboard_page.js index 5fccf2410e250..3626d8363f486 100644 --- a/test/support/page_objects/dashboard_page.js +++ b/test/support/page_objects/dashboard_page.js @@ -387,9 +387,11 @@ export default class DashboardPage { async filterOnPieSlice() { PageObjects.common.debug('Filtering on a pie slice'); - const slices = await PageObjects.common.findAllByCssSelector('svg > g > path.slice'); - PageObjects.common.debug('Slices found:' + slices.length); - return slices[0].click(); + await PageObjects.common.try(async () => { + const slices = await PageObjects.common.findAllByCssSelector('svg > g > path.slice'); + PageObjects.common.debug('Slices found:' + slices.length); + return slices[0].click(); + }); } getSharedItemsCount() { diff --git a/test/support/page_objects/header_page.js b/test/support/page_objects/header_page.js index 111ae38c1daf8..524555cda08a5 100644 --- a/test/support/page_objects/header_page.js +++ b/test/support/page_objects/header_page.js @@ -60,9 +60,12 @@ export default class HeaderPage { .catch(() => false); } - clickAbsoluteButton() { - return this.remote.setFindTimeout(defaultFindTimeout) - .findByLinkText('Absolute').click(); + async clickAbsoluteButton() { + await PageObjects.common.try(async () => { + await this.remote.setFindTimeout(defaultFindTimeout); + const absoluteButton = await this.remote.findByLinkText('Absolute'); + await absoluteButton.click(); + }); } clickQuickButton() {