Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable save button if visualization is dirty #11576

Merged
merged 3 commits into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ function VisEditor($rootScope, $scope, $route, timefilter, AppState, $window, kb
description: 'Save Visualization',
template: require('plugins/kibana/visualize/editor/panels/save.html'),
testId: 'visualizeSaveButton',
disableButton() {
return Boolean(editableVis.dirty);
},
tooltip() {
if (editableVis.dirty) {
return 'Apply or Discard your changes before saving';
}
}
}, {
key: 'share',
description: 'Share Visualization',
Expand Down
59 changes: 59 additions & 0 deletions test/functional/apps/visualize/_editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import expect from 'expect.js';

export default function ({ getService, getPageObjects }) {
const log = getService('log');
const PageObjects = getPageObjects(['common', 'visualize', 'header']);

describe('visualize app', function describeIndexTests() {
beforeEach(async function () {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';

log.debug('navigateToApp visualize');
await PageObjects.common.navigateToUrl('visualize', 'new');

log.debug('clickLineChart');
await PageObjects.visualize.clickLineChart();
await PageObjects.visualize.clickNewSearch();

log.debug(`Set absolute time range from "${fromTime}" to "${toTime}"`);
await PageObjects.header.setAbsoluteRange(fromTime, toTime);

// make sure that changes in the test are what will make the visualization dirty
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();

const isEnabled = await PageObjects.visualize.isSaveButtonEnabled();
expect(isEnabled).to.be(true);
});

describe('editor', function indexPatternCreation() {
it('should disable the save button if visualization is dirty', async function () {
log.debug('Bucket = Split Chart');
await PageObjects.visualize.clickBucket('Split Chart');
log.debug('Aggregation = Terms');
await PageObjects.visualize.selectAggregation('Terms');
log.debug('Field = extension');
await PageObjects.visualize.selectField('extension.raw');

const isEnabled = await PageObjects.visualize.isSaveButtonEnabled();
expect(isEnabled).to.be(false);
});

it('should enable the save button if changes are applied', async function () {
log.debug('Bucket = Split Chart');
await PageObjects.visualize.clickBucket('Split Chart');
log.debug('Aggregation = Terms');
await PageObjects.visualize.selectAggregation('Terms');
log.debug('Field = extension');
await PageObjects.visualize.selectField('extension.raw');

await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();

const isEnabled = await PageObjects.visualize.isSaveButtonEnabled();
expect(isEnabled).to.be(true);
});
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/visualize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function ({ getService, loadTestFile }) {
});
});

loadTestFile(require.resolve('./_editor'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is why you're awesome @scampi. Community PRs rarely include UI-tests!!!

loadTestFile(require.resolve('./_chart_types'));
loadTestFile(require.resolve('./_area_chart'));
loadTestFile(require.resolve('./_line_chart'));
Expand Down
6 changes: 6 additions & 0 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
}


async isSaveButtonEnabled() {
const saveButton = await testSubjects.find('visualizeSaveButton');
const clazz = await saveButton.getProperty('className');
return clazz.indexOf('kuiLocalMenuItem-isDisabled') === -1;
}

saveVisualization(vizName) {
return testSubjects.click('visualizeSaveButton')
.then(() => {
Expand Down