mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
## Summary This PR makes few changes: - extend [kbn-test-subj-selector](https://github.com/elastic/kibana/compare/main...dmlemeshko:kibana:ftr/add-dataViews-service?expand=1#diff-43f2401dd3f9c11b6cbd75c8801a6ccbbe1d4db5a19e907f263c4932f810c73c) with wildcard (*) support: ``` testSubjSelector('*dataView-switch-link') => [data-test-subj*="dataView-switch-link"] ``` It allows us to search for DOM elements with the common text part in `data-test-subj` attribute, e.g. `lns-dataView-switch-link` & `discover-dataView-switch-link` - add new FTR service [dataViews](test/functional/apps/discover/group4/_adhoc_data_views.ts) to unify mostly identical code related to data views across multiple page objects (lens, discover, unified_search, dashboard) It is not a big win in terms of code cleanup, but should save some time whenever we will need to make logic updates.
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
import { FtrService } from '../ftr_provider_context';
|
|
|
|
export class UnifiedSearchPageObject extends FtrService {
|
|
private readonly retry = this.ctx.getService('retry');
|
|
private readonly testSubjects = this.ctx.getService('testSubjects');
|
|
private readonly find = this.ctx.getService('find');
|
|
|
|
public async switchDataView(
|
|
switchButtonSelector: string,
|
|
dataViewTitle: string,
|
|
transitionFromTextBasedLanguages?: boolean
|
|
) {
|
|
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();
|
|
|
|
if (Boolean(transitionFromTextBasedLanguages)) {
|
|
await this.testSubjects.click('unifiedSearch_switch_noSave');
|
|
}
|
|
|
|
await this.retry.waitFor(
|
|
'wait for updating switcher',
|
|
async () => (await this.getSelectedDataView(switchButtonSelector)) === dataViewTitle
|
|
);
|
|
}
|
|
|
|
public async getSelectedDataView(switchButtonSelector: string) {
|
|
let visibleText = '';
|
|
|
|
await this.retry.waitFor('wait for updating switcher', async () => {
|
|
visibleText = await this.testSubjects.getVisibleText(switchButtonSelector);
|
|
return Boolean(visibleText);
|
|
});
|
|
|
|
return visibleText;
|
|
}
|
|
|
|
public async selectTextBasedLanguage(language: string) {
|
|
await this.find.clickByCssSelector(
|
|
`[data-test-subj="text-based-languages-switcher"] [title="${language}"]`
|
|
);
|
|
}
|
|
}
|