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

Test/dashboard func by value #2

Draft
wants to merge 1 commit into
base: feature/timeToVisualizeRibbonCut
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ export function SavedObjectSaveModalDashboard(props: DashboardSaveModalProps) {
}
hasChildLabel={false}
>
<EuiPanel color="subdued" hasShadow={false}>
<EuiPanel color="subdued" hasShadow={false} data-test-subj="addToDashboard-options">
<div>
<EuiRadio
checked={dashboardOption === 'existing'}
id="existing"
id="existing-dashboard-option"
name="dashboard-option"
label={i18n.translate(
'presentationUtil.saveModalDashboard.existingDashboardOptionLabel',
Expand All @@ -129,7 +129,7 @@ export function SavedObjectSaveModalDashboard(props: DashboardSaveModalProps) {

<EuiRadio
checked={dashboardOption === 'new'}
id="new"
id="new-dashboard-option"
name="dashboard-option"
label={i18n.translate(
'presentationUtil.saveModalDashboard.newDashboardOptionLabel',
Expand All @@ -145,7 +145,7 @@ export function SavedObjectSaveModalDashboard(props: DashboardSaveModalProps) {

<EuiRadio
checked={dashboardOption === null}
id="library"
id="add-to-library-option"
name="dashboard-option"
label={i18n.translate('presentationUtil.saveModalDashboard.libraryOptionLabel', {
defaultMessage: 'No dashboard, but add to library',
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/apps/dashboard/sync_colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
field: 'geo.src',
});

await PageObjects.lens.save('vis1', true, true);
await PageObjects.lens.saveAndReturn();
await PageObjects.header.waitUntilLoadingHasFinished();
await dashboardAddPanel.clickCreateNewLink();
await dashboardAddPanel.clickVisType('lens');
Expand All @@ -84,7 +84,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await filterBar.addFilter('geo.src', 'is not', 'CN');

await PageObjects.lens.save('vis2', true, true);
await PageObjects.lens.saveAndReturn();
await PageObjects.header.waitUntilLoadingHasFinished();
const colorMapping1 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(0));
const colorMapping2 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(1));
Expand Down
109 changes: 55 additions & 54 deletions x-pack/test/functional/apps/dashboard_mode/dashboard_empty_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
// import expect from '@kbn/expect';

export default function ({ getPageObjects, getService }) {
const log = getService('log');
Expand All @@ -27,7 +27,9 @@ export default function ({ getPageObjects, getService }) {
await PageObjects.dashboard.gotoDashboardLandingPage();
});

async function createAndAddLens(title, saveAsNew = false, redirectToOrigin = true) {
// TODO: Title no longer added by default so maybe we want to manually add one after
// returning from Lens?
async function createAndAddLens(title) {
log.debug(`createAndAddLens(${title})`);
const inViewMode = await PageObjects.dashboard.getIsInViewMode();
if (inViewMode) {
Expand All @@ -52,17 +54,16 @@ export default function ({ getPageObjects, getService }) {
operation: 'terms',
field: 'ip',
});
await PageObjects.lens.save(title, saveAsNew, redirectToOrigin);
await PageObjects.lens.saveAndReturn();
}

it('adds Lens visualization to empty dashboard', async () => {
const title = 'Dashboard Test Lens';
await testSubjects.exists('addVisualizationButton');
await testSubjects.click('addVisualizationButton');
await dashboardVisualizations.ensureNewVisualizationDialogIsShowing();
await createAndAddLens(title);
await createAndAddLens();
await PageObjects.dashboard.waitForRenderComplete();
await testSubjects.exists(`embeddablePanelHeading-${title}`);
await testSubjects.exists(`embeddablePanelHeading-`); // TODO: panels now have no title by default in by-value flow
});

it('redirects via save and return button after edit', async () => {
Expand All @@ -71,56 +72,56 @@ export default function ({ getPageObjects, getService }) {
await PageObjects.lens.saveAndReturn();
});

it('redirects via save as button after edit, renaming itself', async () => {
const newTitle = 'wowee, looks like I have a new title';
const originalPanelCount = await PageObjects.dashboard.getPanelCount();
await PageObjects.dashboard.waitForRenderComplete();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.lens.save(newTitle, false, true);
await PageObjects.dashboard.waitForRenderComplete();
const newPanelCount = await PageObjects.dashboard.getPanelCount();
expect(newPanelCount).to.eql(originalPanelCount);
const titles = await PageObjects.dashboard.getPanelTitles();
expect(titles.indexOf(newTitle)).to.not.be(-1);
});
// it('redirects via save as button after edit, renaming itself', async () => {
// const newTitle = 'wowee, looks like I have a new title';
// const originalPanelCount = await PageObjects.dashboard.getPanelCount();
// await PageObjects.dashboard.waitForRenderComplete();
// await dashboardPanelActions.openContextMenu();
// await dashboardPanelActions.clickEdit();
// await PageObjects.lens.saveAndReturn();
// await PageObjects.dashboard.waitForRenderComplete();
// const newPanelCount = await PageObjects.dashboard.getPanelCount();
// expect(newPanelCount).to.eql(originalPanelCount);
// const titles = await PageObjects.dashboard.getPanelTitles();
// expect(titles.indexOf(newTitle)).to.not.be(-1);
// });

it('redirects via save as button after edit, adding a new panel', async () => {
const newTitle = 'wowee, my title just got cooler';
const originalPanelCount = await PageObjects.dashboard.getPanelCount();
await PageObjects.dashboard.waitForRenderComplete();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.lens.save(newTitle, true, true);
await PageObjects.dashboard.waitForRenderComplete();
const newPanelCount = await PageObjects.dashboard.getPanelCount();
expect(newPanelCount).to.eql(originalPanelCount + 1);
const titles = await PageObjects.dashboard.getPanelTitles();
expect(titles.indexOf(newTitle)).to.not.be(-1);
});
// it('redirects via save as button after edit, adding a new panel', async () => {
// const newTitle = 'wowee, my title just got cooler';
// const originalPanelCount = await PageObjects.dashboard.getPanelCount();
// await PageObjects.dashboard.waitForRenderComplete();
// await dashboardPanelActions.openContextMenu();
// await dashboardPanelActions.clickEdit();
// await PageObjects.lens.saveToLibrary(newTitle, true, true);
// await PageObjects.dashboard.waitForRenderComplete();
// const newPanelCount = await PageObjects.dashboard.getPanelCount();
// expect(newPanelCount).to.eql(originalPanelCount + 1);
// const titles = await PageObjects.dashboard.getPanelTitles();
// expect(titles.indexOf(newTitle)).to.not.be(-1);
// });

it('loses originatingApp connection after save as when redirectToOrigin is false', async () => {
await PageObjects.dashboard.saveDashboard('empty dashboard test');
await PageObjects.dashboard.switchToEditMode();
const newTitle = 'wowee, my title just got cooler again';
await PageObjects.dashboard.waitForRenderComplete();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.lens.save(newTitle, true, false);
await PageObjects.lens.notLinkedToOriginatingApp();
await PageObjects.common.navigateToApp('dashboard');
});
// it('loses originatingApp connection after save as when redirectToOrigin is false', async () => {
// await PageObjects.dashboard.saveDashboard('empty dashboard test');
// await PageObjects.dashboard.switchToEditMode();
// const newTitle = 'wowee, my title just got cooler again';
// await PageObjects.dashboard.waitForRenderComplete();
// await dashboardPanelActions.openContextMenu();
// await dashboardPanelActions.clickEdit();
// await PageObjects.lens.saveToLibrary(newTitle, true, false);
// await PageObjects.lens.notLinkedToOriginatingApp();
// await PageObjects.common.navigateToApp('dashboard');
// });

it('loses originatingApp connection after first save when redirectToOrigin is false', async () => {
const title = 'non-dashboard Test Lens';
await PageObjects.dashboard.loadSavedDashboard('empty dashboard test');
await PageObjects.dashboard.switchToEditMode();
await testSubjects.exists('dashboardAddNewPanelButton');
await testSubjects.click('dashboardAddNewPanelButton');
await dashboardVisualizations.ensureNewVisualizationDialogIsShowing();
await createAndAddLens(title, false, false);
await PageObjects.lens.notLinkedToOriginatingApp();
await PageObjects.common.navigateToApp('dashboard');
});
// it('loses originatingApp connection after first save when redirectToOrigin is false', async () => {
// const title = 'non-dashboard Test Lens';
// await PageObjects.dashboard.loadSavedDashboard('empty dashboard test');
// await PageObjects.dashboard.switchToEditMode();
// await testSubjects.exists('dashboardAddNewPanelButton');
// await testSubjects.click('dashboardAddNewPanelButton');
// await dashboardVisualizations.ensureNewVisualizationDialogIsShowing();
// await createAndAddLens(title, false, false);
// await PageObjects.lens.notLinkedToOriginatingApp();
// await PageObjects.common.navigateToApp('dashboard');
// });
});
}
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/lens/persistent_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
operation: 'avg',
field: 'bytes',
});
await PageObjects.lens.save('persistentcontext');
await PageObjects.lens.saveToLibrary('persistentcontext');
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();
const timeRange = await PageObjects.timePicker.getTimeConfig();
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/lens/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2);

await PageObjects.lens.save('Afancilenstest');
await PageObjects.lens.saveToLibrary('Afancilenstest');

// Ensure the visualization shows up in the visualize list, and takes
// us back to the visualization as we configured it.
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/apps/lens/smokescreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
field: 'ip',
});

await PageObjects.lens.save('Afancilenstest');
await PageObjects.lens.saveToLibrary('Afancilenstest');

// Ensure the visualization shows up in the visualize list, and takes
// us back to the visualization as we configured it.
Expand Down Expand Up @@ -304,7 +304,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1
);

await PageObjects.lens.save('twolayerchart');
await PageObjects.lens.saveToLibrary('twolayerchart');
await testSubjects.click('lnsSuggestion-asDonut > lnsSuggestion');

expect(await PageObjects.lens.getLayerCount()).to.eql(1);
Expand Down
28 changes: 22 additions & 6 deletions x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,38 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
/**
* Save the current Lens visualization.
*/
async save(title: string, saveAsNew?: boolean, redirectToOrigin?: boolean) {
async saveToLibrary(title: string, saveAsNew?: boolean) {
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.click('lnsApp_saveButton');
await testSubjects.setValue('savedObjectTitle', title);

const radioGroup = await testSubjects.find('addToDashboard-options');
const label = await radioGroup.findByCssSelector(`label[for="add-to-library-option"]`);
await label.click();

const saveAsNewCheckboxExists = await testSubjects.exists('saveAsNewCheckbox');
if (saveAsNewCheckboxExists) {
const state = saveAsNew ? 'check' : 'uncheck';
await testSubjects.setEuiSwitch('saveAsNewCheckbox', state);
}

const redirectToOriginCheckboxExists = await testSubjects.exists('returnToOriginModeSwitch');
if (redirectToOriginCheckboxExists) {
const state = redirectToOrigin ? 'check' : 'uncheck';
await testSubjects.setEuiSwitch('returnToOriginModeSwitch', state);
}
await testSubjects.click('confirmSaveSavedObjectButton');
await retry.waitForWithTimeout('Save modal to disappear', 1000, () =>
testSubjects
.missingOrFail('confirmSaveSavedObjectButton')
.then(() => true)
.catch(() => false)
);
},

async saveToNewDashboard(title: string) {
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.click('lnsApp_saveButton');
await testSubjects.setValue('savedObjectTitle', title);

const radioGroup = await testSubjects.find('addToDashboard-options');
const label = await radioGroup.findByCssSelector(`label[for="new-dashboard-option"]`);
await label.click();

await testSubjects.click('confirmSaveSavedObjectButton');
await retry.waitForWithTimeout('Save modal to disappear', 1000, () =>
Expand Down