diff --git a/x-pack/test/functional/apps/lens/persistent_context.ts b/x-pack/test/functional/apps/lens/persistent_context.ts index 8d536aac3f795..a115b720f6f2c 100644 --- a/x-pack/test/functional/apps/lens/persistent_context.ts +++ b/x-pack/test/functional/apps/lens/persistent_context.ts @@ -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(); diff --git a/x-pack/test/functional/apps/lens/smokescreen.ts b/x-pack/test/functional/apps/lens/smokescreen.ts index 6c4fa94a259e9..0ddafe581c21d 100644 --- a/x-pack/test/functional/apps/lens/smokescreen.ts +++ b/x-pack/test/functional/apps/lens/smokescreen.ts @@ -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); + }); }); } diff --git a/x-pack/test/functional/es_archives/lens/basic/data.json.gz b/x-pack/test/functional/es_archives/lens/basic/data.json.gz index ddf4a27289dff..c9ae08fe6f628 100644 Binary files a/x-pack/test/functional/es_archives/lens/basic/data.json.gz and b/x-pack/test/functional/es_archives/lens/basic/data.json.gz differ diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index f8ecacbc1141d..05818ae3bbf66 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -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'); @@ -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 *