Warn if the title is a duplicate (#10321)

* Warn if the title is a duplicate

* warn when copyOnSave is checked.  add a test

* update message

* fix tests

* Fix issues with substring matching

add more tests.

* make case insensitive and return matching title

* Fix bug caused by subtle difference between this.type and type

Add a comment and rename one of the variables to make the distinction
clearer.

* add debug messages.

* fix tests again

* uncomment out tests

* more debug messages

* save more screenshots

* Need to wait till save finishes or the page may redirect the url after the page has navigated away

* address code review comments
This commit is contained in:
Stacey Gammon 2017-02-24 09:26:37 -05:00 committed by GitHub
parent 4c5044a302
commit c253583a3d
10 changed files with 318 additions and 67 deletions

View file

@ -0,0 +1,86 @@
import expect from 'expect.js';
import { bdd } from '../../../support';
import PageObjects from '../../../support/page_objects';
bdd.describe('dashboard save', function describeIndexTests() {
const dashboardName = 'Dashboard Save Test';
bdd.before(async function () {
return PageObjects.dashboard.initTests();
});
bdd.it('warns on duplicate name for new dashboard', async function() {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.saveDashboard(dashboardName);
let isConfirmOpen = await PageObjects.common.isConfirmModalOpen();
expect(isConfirmOpen).to.equal(false);
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName);
isConfirmOpen = await PageObjects.common.isConfirmModalOpen();
expect(isConfirmOpen).to.equal(true);
});
bdd.it('does not save on reject confirmation', async function() {
await PageObjects.common.clickCancelOnModal();
const countOfDashboards = await PageObjects.dashboard.getDashboardCountWithName(dashboardName);
expect(countOfDashboards).to.equal(1);
});
bdd.it('Saves on confirm duplicate title warning', async function() {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName);
await PageObjects.common.clickConfirmOnModal();
// This is important since saving a new dashboard will cause a refresh of the page. We have to
// wait till it finishes reloading or it might reload the url after simulating the
// dashboard landing page click.
await PageObjects.header.waitUntilLoadingHasFinished();
const countOfDashboards = await PageObjects.dashboard.getDashboardCountWithName(dashboardName);
expect(countOfDashboards).to.equal(2);
});
bdd.it('Does not warn when you save an existing dashboard with the title it already has, and that title is a duplicate',
async function() {
await PageObjects.dashboard.clickDashboardByLinkText(dashboardName);
await PageObjects.header.isGlobalLoadingIndicatorHidden();
await PageObjects.dashboard.saveDashboard(dashboardName);
const isConfirmOpen = await PageObjects.common.isConfirmModalOpen();
expect(isConfirmOpen).to.equal(false);
}
);
bdd.it('Warns you when you Save as New Dashboard, and the title is a duplicate', async function() {
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName, { saveAsNew: true });
const isConfirmOpen = await PageObjects.common.isConfirmModalOpen();
expect(isConfirmOpen).to.equal(true);
await PageObjects.common.clickCancelOnModal();
});
bdd.it('Does not warn when only the prefix matches', async function() {
await PageObjects.dashboard.saveDashboard(dashboardName.split(' ')[0]);
const isConfirmOpen = await PageObjects.common.isConfirmModalOpen();
expect(isConfirmOpen).to.equal(false);
});
bdd.it('Warns when case is different', async function() {
await PageObjects.dashboard.enterDashboardTitleAndClickSave(dashboardName.toUpperCase());
const isConfirmOpen = await PageObjects.common.isConfirmModalOpen();
expect(isConfirmOpen).to.equal(true);
await PageObjects.common.clickCancelOnModal();
});
});

View file

@ -17,7 +17,7 @@ bdd.describe('dashboard time', function dashboardSaveWithTime() {
bdd.it('is saved', async function () {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.addVisualizations([PageObjects.dashboard.getTestVisualizationNames()[0]]);
await PageObjects.dashboard.saveDashboard(dashboardName, false);
await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: false });
});
bdd.it('Does not set the time picker on open', async function () {
@ -35,7 +35,7 @@ bdd.describe('dashboard time', function dashboardSaveWithTime() {
bdd.describe('dashboard with stored timed', async function () {
bdd.it('is saved with quick time', async function () {
await PageObjects.header.setQuickTime('Today');
await PageObjects.dashboard.saveDashboard(dashboardName, true);
await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true });
});
bdd.it('sets quick time on open', async function () {
@ -49,7 +49,7 @@ bdd.describe('dashboard time', function dashboardSaveWithTime() {
bdd.it('is saved with absolute time', async function () {
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
await PageObjects.dashboard.saveDashboard(dashboardName, true);
await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true });
});
bdd.it('sets absolute time on open', async function () {

View file

@ -14,5 +14,6 @@ bdd.describe('dashboard app', function () {
});
require('./_dashboard');
require('./_dashboard_save');
require('./_dashboard_time');
});

View file

@ -60,7 +60,7 @@ bdd.describe('visualize app', function describeIndexTests() {
});
bdd.describe('area charts', function indexPatternCreation() {
const vizName1 = 'Visualization AreaChart';
const vizName1 = 'Visualization AreaChart Name Test';
bdd.it('should save and load with special characters', function () {
const vizNamewithSpecialChars = vizName1 + '/?&=%';