[discover] fix shared links tests for cloud testing (#47572)
* Add method to open permalinks menu entry if available * Migrate to TypeScript
This commit is contained in:
parent
46fbbd6a2f
commit
08de89b588
|
@ -17,7 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export function SharePageProvider({ getService, getPageObjects }) {
|
||||
import { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
export function SharePageProvider({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const find = getService('find');
|
||||
const PageObjects = getPageObjects(['visualize', 'common']);
|
||||
|
@ -32,7 +34,7 @@ export function SharePageProvider({ getService, getPageObjects }) {
|
|||
return testSubjects.click('shareTopNavButton');
|
||||
}
|
||||
|
||||
async openShareMenuItem(itemTitle) {
|
||||
async openShareMenuItem(itemTitle: string) {
|
||||
log.debug(`openShareMenuItem title:${itemTitle}`);
|
||||
const isShareMenuOpen = await this.isShareMenuOpen();
|
||||
if (!isShareMenuOpen) {
|
||||
|
@ -45,11 +47,24 @@ export function SharePageProvider({ getService, getPageObjects }) {
|
|||
await this.clickShareTopNavButton();
|
||||
}
|
||||
const menuPanel = await find.byCssSelector('div.euiContextMenuPanel');
|
||||
testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
|
||||
await testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
|
||||
await testSubjects.waitForDeleted(menuPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
* if there are more entries in the share menu, the permalinks entry has to be clicked first
|
||||
* else the selection isn't displayed. this happens if you're testing against an instance
|
||||
* with xpack features enabled, where there's also a csv sharing option
|
||||
* in a pure OSS environment, the permalinks sharing panel is displayed initially
|
||||
*/
|
||||
async openPermaLinks() {
|
||||
if (await testSubjects.exists('sharePanel-Permalinks')) {
|
||||
await testSubjects.click(`sharePanel-Permalinks`);
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedUrl() {
|
||||
await this.openPermaLinks();
|
||||
return await testSubjects.getAttribute('copyShareUrlButton', 'data-share-url');
|
||||
}
|
||||
|
||||
|
@ -68,9 +83,9 @@ export function SharePageProvider({ getService, getPageObjects }) {
|
|||
}
|
||||
|
||||
async exportAsSavedObject() {
|
||||
await this.openPermaLinks();
|
||||
return await testSubjects.click('exportAsSavedObject');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new SharePage();
|
Loading…
Reference in a new issue