Skip to content

Commit

Permalink
Merge branch 'fix/discreteLibraryOption' of github.com:poffdeluxe/kib…
Browse files Browse the repository at this point in the history
…ana into fix/discreteLibraryOption
  • Loading branch information
ThomThomson committed Mar 15, 2021
2 parents 08e90c7 + 4ffb9ee commit 9469c13
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 13 deletions.
176 changes: 171 additions & 5 deletions test/functional/apps/visualize/_add_to_dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
]);

describe('Add to Dashboard', function describeIndexTests() {
it('adding a new metric to a new dashboard', async function () {
it('adding a new metric to a new dashboard by value', async function () {
await PageObjects.visualize.navigateToNewAggBasedVisualization();
await PageObjects.visualize.clickMetric();
await PageObjects.visualize.clickNewSearch();
Expand All @@ -36,17 +36,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await PageObjects.timeToVisualize.saveFromModal('My New Vis 1', {
addToDashboard: 'new',
saveToLibrary: false,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(1);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists('My New Vis 1');
expect(isLinked).to.be(false);

await PageObjects.timeToVisualize.resetNewDashboard();
});

it('adding a new metric to a new dashboard by reference', async function () {
await PageObjects.visualize.navigateToNewAggBasedVisualization();
await PageObjects.visualize.clickMetric();
await PageObjects.visualize.clickNewSearch();
await PageObjects.timePicker.setDefaultAbsoluteRange();

await testSubjects.click('visualizeSaveButton');

await PageObjects.timeToVisualize.saveFromModal('My Saved New Vis 1', {
addToDashboard: 'new',
saveToLibrary: true,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(1);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists(
'My Saved New Vis 1'
);
expect(isLinked).to.be(true);

await PageObjects.timeToVisualize.resetNewDashboard();
});

it('adding a existing metric to a new dashboard', async function () {
it('adding a existing metric to a new dashboard by value', async function () {
await PageObjects.visualize.navigateToNewAggBasedVisualization();
await PageObjects.visualize.clickMetric();
await PageObjects.visualize.clickNewSearch();
Expand All @@ -57,6 +87,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
// Save this new viz to library
await PageObjects.timeToVisualize.saveFromModal('My New Vis 1', {
addToDashboard: null,
saveToLibrary: true,
});

await testSubjects.click('visualizeSaveButton');
Expand All @@ -68,17 +99,93 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.timeToVisualize.saveFromModal('My New Vis 1 Copy', {
addToDashboard: 'new',
saveAsNew: true,
saveToLibrary: false,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(1);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists(
'My New Vis 1 Copy'
);
expect(isLinked).to.be(false);

await PageObjects.timeToVisualize.resetNewDashboard();
});

it('adding a existing metric to a new dashboard by reference', async function () {
await PageObjects.visualize.navigateToNewAggBasedVisualization();
await PageObjects.visualize.clickMetric();
await PageObjects.visualize.clickNewSearch();
await PageObjects.timePicker.setDefaultAbsoluteRange();

await testSubjects.click('visualizeSaveButton');

// Save this new viz to library
await PageObjects.timeToVisualize.saveFromModal('Another New Vis 1', {
addToDashboard: null,
saveToLibrary: true,
});

await testSubjects.click('visualizeSaveButton');

// All the options should be disabled
await PageObjects.timeToVisualize.ensureDashboardOptionsAreDisabled();

// Save a new copy of this viz to a new dashboard
await PageObjects.timeToVisualize.saveFromModal('Another New Vis 1 Copy', {
addToDashboard: 'new',
saveAsNew: true,
saveToLibrary: true,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(1);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists(
'Another New Vis 1 Copy'
);
expect(isLinked).to.be(true);

await PageObjects.timeToVisualize.resetNewDashboard();
});

it('adding a new metric to an existing dashboard', async function () {
it('adding a new metric to an existing dashboard by value', async function () {
await PageObjects.common.navigateToApp('dashboard');

await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.addVisualizations(['Visualization AreaChart']);
await PageObjects.dashboard.saveDashboard('My Excellent Dashboard');
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.searchAndExpectItemsCount('dashboard', 'My Excellent Dashboard', 1);

await PageObjects.visualize.navigateToNewAggBasedVisualization();
await PageObjects.visualize.clickMetric();
await PageObjects.visualize.clickNewSearch();
await PageObjects.timePicker.setDefaultAbsoluteRange();

await testSubjects.click('visualizeSaveButton');

await PageObjects.timeToVisualize.saveFromModal('My New Vis 2', {
addToDashboard: 'existing',
dashboardId: 'My Excellent Dashboard',
saveToLibrary: false,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(2);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists('My New Vis 2');
expect(isLinked).to.be(false);
});

it('adding a new metric to an existing dashboard by reference', async function () {
await PageObjects.common.navigateToApp('dashboard');

await PageObjects.dashboard.clickNewDashboard();
Expand All @@ -94,18 +201,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await testSubjects.click('visualizeSaveButton');

await PageObjects.timeToVisualize.saveFromModal('My New Vis 2', {
await PageObjects.timeToVisualize.saveFromModal('My Saved New Vis 2', {
addToDashboard: 'existing',
dashboardId: 'My Wonderful Dashboard',
saveToLibrary: true,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(2);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists(
'My Saved New Vis 2'
);
expect(isLinked).to.be(true);
});

it('adding a existing metric to an existing dashboard', async function () {
it('adding a existing metric to an existing dashboard by value', async function () {
await PageObjects.common.navigateToApp('dashboard');

await PageObjects.dashboard.clickNewDashboard();
Expand All @@ -124,6 +237,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
// Save this new viz to library
await PageObjects.timeToVisualize.saveFromModal('My New Vis 2', {
addToDashboard: null,
saveToLibrary: true,
});

await testSubjects.click('visualizeSaveButton');
Expand All @@ -136,12 +250,64 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
addToDashboard: 'existing',
dashboardId: 'My Very Cool Dashboard',
saveAsNew: true,
saveToLibrary: false,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(2);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists(
'My New Vis 2 Copy'
);
expect(isLinked).to.be(false);
});

it('adding a existing metric to an existing dashboard by reference', async function () {
await PageObjects.common.navigateToApp('dashboard');

await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.addVisualizations(['Visualization AreaChart']);
await PageObjects.dashboard.saveDashboard('My Very Neat Dashboard');
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.searchAndExpectItemsCount('dashboard', 'My Very Neat Dashboard', 1);

await PageObjects.visualize.navigateToNewAggBasedVisualization();
await PageObjects.visualize.clickMetric();
await PageObjects.visualize.clickNewSearch();
await PageObjects.timePicker.setDefaultAbsoluteRange();

await testSubjects.click('visualizeSaveButton');

// Save this new viz to library
await PageObjects.timeToVisualize.saveFromModal('Neat Saved Vis 2', {
addToDashboard: null,
saveToLibrary: true,
});

await testSubjects.click('visualizeSaveButton');

// All the options should be disabled
await PageObjects.timeToVisualize.ensureDashboardOptionsAreDisabled();

// Save a new copy of this viz to an existing dashboard
await PageObjects.timeToVisualize.saveFromModal('Neat Saved Vis 2 Copy', {
addToDashboard: 'existing',
dashboardId: 'My Very Neat Dashboard',
saveAsNew: true,
saveToLibrary: true,
});

await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.metricValuesExist(['14,004']);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(2);

const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists(
'Neat Saved Vis 2 Copy'
);
expect(isLinked).to.be(true);
});
});
}
18 changes: 10 additions & 8 deletions test/functional/page_objects/time_to_visualize_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export function TimeToVisualizePageProvider({ getService, getPageObjects }: FtrP
const dashboardSelector = await testSubjects.find('add-to-dashboard-options');
await dashboardSelector.findByCssSelector(`input[id="new-dashboard-option"]:disabled`);
await dashboardSelector.findByCssSelector(`input[id="existing-dashboard-option"]:disabled`);
await dashboardSelector.findByCssSelector(`input[id="add-to-library-option"]:disabled`);

const librarySelector = await testSubjects.find('add-to-library-checkbox');
await librarySelector.findByCssSelector(`input[id="add-to-library-option"]:disabled`);
}

public async resetNewDashboard() {
Expand Down Expand Up @@ -64,13 +66,6 @@ export function TimeToVisualizePageProvider({ getService, getPageObjects }: FtrP
await testSubjects.setEuiSwitch('saveAsNewCheckbox', state);
}

const hasRedirectToOrigin = await testSubjects.exists('returnToOriginModeSwitch');
if (hasRedirectToOrigin && redirectToOrigin !== undefined) {
const state = redirectToOrigin ? 'check' : 'uncheck';
log.debug('redirect to origin checkbox exists. Setting its state to', state);
await testSubjects.setEuiSwitch('returnToOriginModeSwitch', state);
}

const hasDashboardSelector = await testSubjects.exists('add-to-dashboard-options');
if (hasDashboardSelector && addToDashboard !== undefined) {
let option: DashboardPickerOption = 'no-dashboard-option';
Expand Down Expand Up @@ -101,6 +96,13 @@ export function TimeToVisualizePageProvider({ getService, getPageObjects }: FtrP
await label.click();
}
}

const hasRedirectToOrigin = await testSubjects.exists('returnToOriginModeSwitch');
if (hasRedirectToOrigin && redirectToOrigin !== undefined) {
const state = redirectToOrigin ? 'check' : 'uncheck';
log.debug('redirect to origin checkbox exists. Setting its state to', state);
await testSubjects.setEuiSwitch('returnToOriginModeSwitch', state);
}
}

public async libraryNotificationExists(panelTitle: string) {
Expand Down

0 comments on commit 9469c13

Please sign in to comment.