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

[Lens] Add tests for index pattern switching #81987

Merged
merged 1 commit into from
Oct 30, 2020
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
7 changes: 7 additions & 0 deletions x-pack/test/functional/apps/lens/persistent_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await filterBar.hasFilter('ip', '97.220.3.248', false, true);
});

it('keeps selected index pattern after refresh', async () => {
await PageObjects.lens.switchDataPanelIndexPattern('otherpattern');
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.lens.getDataPanelIndexPattern()).to.equal('otherpattern');
});

it('keeps time range and pinned filters after refreshing directly after saving', async () => {
// restore defaults so visualization becomes saveable
await security.testUser.restoreDefaults();
Expand Down
6 changes: 6 additions & 0 deletions x-pack/test/functional/apps/lens/smokescreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,5 +308,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(await PageObjects.lens.getDatatableHeaderText(1)).to.eql('Average of bytes');
expect(await PageObjects.lens.getDatatableCellText(0, 1)).to.eql('6,011.351');
});

it('should allow to change index pattern', async () => {
await PageObjects.lens.switchFirstLayerIndexPattern('otherpattern');
expect(await PageObjects.lens.getFirstLayerIndexPattern()).to.equal('otherpattern');
expect(await PageObjects.lens.isShowingNoResults()).to.equal(true);
});
});
}
Binary file modified x-pack/test/functional/es_archives/lens/basic/data.json.gz
Binary file not shown.
38 changes: 38 additions & 0 deletions x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,38 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
await testSubjects.click('lnsLayerAddButton');
},

/**
* Changes the index pattern in the data panel
*/
async switchDataPanelIndexPattern(name: string) {
await testSubjects.click('indexPattern-switch-link');
await find.clickByCssSelector(`[title="${name}"]`);
await PageObjects.header.waitUntilLoadingHasFinished();
},

/**
* Changes the index pattern for the first layer
*/
async switchFirstLayerIndexPattern(name: string) {
await testSubjects.click('lns_layerIndexPatternLabel');
await find.clickByCssSelector(`[title="${name}"]`);
await PageObjects.header.waitUntilLoadingHasFinished();
},

/**
* Returns the current index pattern of the data panel
*/
async getDataPanelIndexPattern() {
return await (await testSubjects.find('indexPattern-switch-link')).getAttribute('title');
},

/**
* Returns the current index pattern of the first layer
*/
async getFirstLayerIndexPattern() {
return await (await testSubjects.find('lns_layerIndexPatternLabel')).getAttribute('title');
},

async linkedToOriginatingApp() {
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.existOrFail('lnsApp_saveAndReturnButton');
Expand All @@ -316,6 +348,12 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
return await trigger.getVisibleText();
},

async isShowingNoResults() {
return (
(await (await testSubjects.find('lnsWorkspace')).getVisibleText()) === 'No results found'
);
},

/**
* Gets text of the specified datatable header cell
*
Expand Down