Skip to content

Commit

Permalink
Added maps and lens tests for link/unlink from embed library
Browse files Browse the repository at this point in the history
  • Loading branch information
cqliu1 committed Feb 1, 2021
1 parent fdff875 commit f3a6dc6
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { NotificationsStart } from '../../services/core';
import { dashboardAddToLibraryAction } from '../../dashboard_strings';
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';

export const ACTION_ADD_TO_LIBRARY = 'addToFromLibrary';
export const ACTION_ADD_TO_LIBRARY = 'saveToLibrary';

export interface AddToLibraryActionContext {
embeddable: IEmbeddable;
Expand Down
75 changes: 51 additions & 24 deletions test/functional/apps/dashboard/embeddable_library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'settings', 'common']);
const esArchiver = getService('esArchiver');
const find = getService('find');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const dashboardAddPanel = getService('dashboardAddPanel');
const panelActions = getService('dashboardPanelActions');

describe('embeddable library', () => {
before(async () => {
Expand All @@ -24,41 +27,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.preserveCrossAppState();
await PageObjects.dashboard.loadSavedDashboard('few panels');
await PageObjects.dashboard.clickNewDashboard();
});

it('unlink panel from embeddable library', async () => {
await PageObjects.dashboard.switchToEditMode();
let firstPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap');
const libraryAction = await testSubjects.findDescendant(
'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION',
firstPanel
);
await libraryAction.click();
await testSubjects.click('libraryNotificationUnlinkButton');
it('unlink visualize panel from embeddable library', async () => {
// add heatmap panel from library
await dashboardAddPanel.clickOpenAddPanel();
await dashboardAddPanel.filterEmbeddableNames('Rendering Test: heatmap');
await find.clickByButtonText('Rendering Test: heatmap');
await dashboardAddPanel.closeAddPanel();

const originalPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap');
await panelActions.unlinkFromLibary(originalPanel);
await testSubjects.existOrFail('unlinkPanelSuccess');

firstPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap');
const updatedPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap');
const libraryActionExists = await testSubjects.descendantExists(
'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION',
firstPanel
updatedPanel
);
expect(libraryActionExists).to.be(false);
});

it('save panel to embeddable library', async () => {
it('save visualize panel to embeddable library', async () => {
const originalPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap');
const menuIcon = await testSubjects.findDescendant(
'embeddablePanelToggleMenuIcon',
originalPanel
);
await menuIcon.click();
await testSubjects.click('embeddablePanelMore-mainMenu');
await testSubjects.click('embeddablePanelAction-addToFromLibrary');
await testSubjects.setValue('savedObjectTitle', 'Rendering Test: heatmap - copy', {
clearWithKeyboard: true,
});
await testSubjects.click('confirmSaveSavedObjectButton');
await panelActions.saveToLibrary('Rendering Test: heatmap - copy', originalPanel);
await testSubjects.existOrFail('addPanelToLibrarySuccess');

const updatedPanel = await testSubjects.find(
Expand All @@ -70,5 +63,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
expect(libraryActionExists).to.be(true);
});

it('unlink map panel from embeddable library', async () => {
// add map panel from library
await dashboardAddPanel.clickOpenAddPanel();
await dashboardAddPanel.filterEmbeddableNames('Rendering Test: geo map');
await find.clickByButtonText('Rendering Test: geo map');
await dashboardAddPanel.closeAddPanel();

const originalPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:geomap');
await panelActions.unlinkFromLibary(originalPanel);
await testSubjects.existOrFail('unlinkPanelSuccess');

const updatedPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:geomap');
const libraryActionExists = await testSubjects.descendantExists(
'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION',
updatedPanel
);
expect(libraryActionExists).to.be(false);
});

it('save map panel to embeddable library', async () => {
const originalPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:geomap');
await panelActions.saveToLibrary('Rendering Test: geo map - copy', originalPanel);
await testSubjects.existOrFail('addPanelToLibrarySuccess');

const updatedPanel = await testSubjects.find(
'embeddablePanelHeading-RenderingTest:geomap-copy'
);
const libraryActionExists = await testSubjects.descendantExists(
'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION',
updatedPanel
);
expect(libraryActionExists).to.be(true);
});
});
}
25 changes: 25 additions & 0 deletions test/functional/services/dashboard/panel_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-togglePanel';
const CUSTOMIZE_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-ACTION_CUSTOMIZE_PANEL';
const OPEN_CONTEXT_MENU_ICON_DATA_TEST_SUBJ = 'embeddablePanelToggleMenuIcon';
const OPEN_INSPECTOR_TEST_SUBJ = 'embeddablePanelAction-openInspector';
const LIBRARY_NOTIFICATION_TEST_SUBJ = 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION';
const SAVE_TO_LIBRARY_TEST_SUBJ = 'embeddablePanelAction-saveToLibrary';

export function DashboardPanelActionsProvider({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
Expand Down Expand Up @@ -172,6 +174,29 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }: Ft
await testSubjects.click(OPEN_INSPECTOR_TEST_SUBJ);
}

async unlinkFromLibary(parent?: WebElementWrapper) {
log.debug('unlinkFromLibrary');
const libraryNotification = parent
? await testSubjects.findDescendant(LIBRARY_NOTIFICATION_TEST_SUBJ, parent)
: await testSubjects.find(LIBRARY_NOTIFICATION_TEST_SUBJ);
await libraryNotification.click();
await testSubjects.click('libraryNotificationUnlinkButton');
}

async saveToLibrary(newTitle: string, parent?: WebElementWrapper) {
log.debug('saveToLibrary');
await this.openContextMenu(parent);
const exists = await testSubjects.exists(SAVE_TO_LIBRARY_TEST_SUBJ);
if (!exists) {
await this.clickContextMenuMoreItem();
}
await testSubjects.click(SAVE_TO_LIBRARY_TEST_SUBJ);
await testSubjects.setValue('savedObjectTitle', newTitle, {
clearWithKeyboard: true,
});
await testSubjects.click('confirmSaveSavedObjectButton');
}

async expectExistsRemovePanelAction() {
log.debug('expectExistsRemovePanelAction');
await this.expectExistsPanelAction(REMOVE_PANEL_DATA_TEST_SUBJ);
Expand Down
34 changes: 34 additions & 0 deletions x-pack/test/functional/apps/lens/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await panelActions.clickContextMenuMoreItem();
await testSubjects.existOrFail(ACTION_TEST_SUBJ);
});

it('unlink lens panel from embeddable library', async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.clickNewDashboard();
await dashboardAddPanel.clickOpenAddPanel();
await dashboardAddPanel.filterEmbeddableNames('lnsPieVis');
await find.clickByButtonText('lnsPieVis');
await dashboardAddPanel.closeAddPanel();

const originalPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis');
await panelActions.unlinkFromLibary(originalPanel);
await testSubjects.existOrFail('unlinkPanelSuccess');

const updatedPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis');
const libraryActionExists = await testSubjects.descendantExists(
'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION',
updatedPanel
);
expect(libraryActionExists).to.be(false);
});

it('save lens panel to embeddable library', async () => {
const originalPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis');
await panelActions.saveToLibrary('lnsPieVis - copy', originalPanel);
await testSubjects.click('confirmSaveSavedObjectButton');
await testSubjects.existOrFail('addPanelToLibrarySuccess');

const updatedPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis-copy');
const libraryActionExists = await testSubjects.descendantExists(
'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION',
updatedPanel
);
expect(libraryActionExists).to.be(true);
});
});
}

0 comments on commit f3a6dc6

Please sign in to comment.