Fix Failing test: X-Pack CCS Tests.x-pack/test/functional/apps/lens/roup1/smokescreen·ts - lens app - group 1 lens smokescreen tests should allow to change index pattern (#133015) (#135398)

* Fix Failing test: X-Pack CCS Tests.x-pack/test/functional/apps/lens/group1/smokescreen·ts - lens app - group 1 lens smokescreen tests should allow to change index pattern

* fix CI

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 0ac9a7c802)

Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
This commit is contained in:
Joe Reuter 2022-06-29 11:46:37 +02:00 committed by GitHub
parent 98609f54af
commit a4f8dc60ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View file

@ -56,6 +56,7 @@ export function DataViewsList({
placeholder: i18n.translate('unifiedSearch.query.queryBar.indexPattern.findDataView', {
defaultMessage: 'Find a data view',
}),
'data-test-subj': 'indexPattern-switcher--input',
...(selectableProps ? selectableProps.searchProps : undefined),
}}
>

View file

@ -10,6 +10,7 @@ import { FtrService } from '../ftr_provider_context';
export class UnifiedSearchPageObject extends FtrService {
private readonly browser = this.ctx.getService('browser');
private readonly retry = this.ctx.getService('retry');
private readonly testSubjects = this.ctx.getService('testSubjects');
public async closeTour() {
@ -23,4 +24,17 @@ export class UnifiedSearchPageObject extends FtrService {
await this.browser.setLocalStorageItem('data.newDataViewMenu', 'true');
await this.browser.refresh();
}
public async switchDataView(switchButtonSelector: string, dataViewTitle: string) {
await this.testSubjects.click(switchButtonSelector);
const indexPatternSwitcher = await this.testSubjects.find('indexPattern-switcher', 500);
await this.testSubjects.setValue('indexPattern-switcher--input', dataViewTitle);
await (await indexPatternSwitcher.findByCssSelector(`[title="${dataViewTitle}"]`)).click();
await this.retry.waitFor(
'wait for updating switcher',
async () => (await this.testSubjects.getVisibleText(switchButtonSelector)) === dataViewTitle
);
}
}

View file

@ -841,18 +841,16 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
/**
* Changes the index pattern in the data panel
*/
async switchDataPanelIndexPattern(name: string) {
await testSubjects.click('lns-dataView-switch-link');
await find.clickByCssSelector(`[title="${name}"]`);
async switchDataPanelIndexPattern(dataViewTitle: string) {
await PageObjects.unifiedSearch.switchDataView('lns-dataView-switch-link', dataViewTitle);
await PageObjects.header.waitUntilLoadingHasFinished();
},
/**
* Changes the index pattern for the first layer
*/
async switchFirstLayerIndexPattern(name: string) {
await testSubjects.click('lns_layerIndexPatternLabel');
await find.clickByCssSelector(`.lnsChangeIndexPatternPopover [title="${name}"]`);
async switchFirstLayerIndexPattern(dataViewTitle: string) {
await PageObjects.unifiedSearch.switchDataView('lns_layerIndexPatternLabel', dataViewTitle);
await PageObjects.header.waitUntilLoadingHasFinished();
},