Skip to content

Commit

Permalink
add tests for index pattern switching (#81987) (#82133)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Oct 30, 2020
1 parent aab4657 commit 697262a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
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

0 comments on commit 697262a

Please sign in to comment.