Skip to content

Commit

Permalink
Fix edit controls bug, add more tests, make other tests more stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
stacey-gammon committed Mar 23, 2017
1 parent 7875547 commit 774267c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/core_plugins/kibana/public/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
37 changes: 26 additions & 11 deletions test/functional/apps/dashboard/_view_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 5 additions & 3 deletions test/support/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 6 additions & 3 deletions test/support/page_objects/header_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 774267c

Please sign in to comment.