2018-05-29 05:06:30 +02:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
2017-04-12 00:01:06 +02:00
|
|
|
export function HeaderPageProvider({ getService, getPageObjects }) {
|
|
|
|
const config = getService('config');
|
|
|
|
const log = getService('log');
|
|
|
|
const retry = getService('retry');
|
|
|
|
const testSubjects = getService('testSubjects');
|
2019-01-18 21:39:01 +01:00
|
|
|
const appsMenu = getService('appsMenu');
|
|
|
|
const globalNav = getService('globalNav');
|
2017-04-12 00:01:06 +02:00
|
|
|
const PageObjects = getPageObjects(['common']);
|
|
|
|
|
|
|
|
const defaultFindTimeout = config.get('timeouts.find');
|
|
|
|
|
|
|
|
class HeaderPage {
|
|
|
|
async clickDiscover() {
|
2019-01-18 21:39:01 +01:00
|
|
|
await appsMenu.clickLink('Discover');
|
2017-05-31 18:29:08 +02:00
|
|
|
await PageObjects.common.waitForTopNavToBeVisible();
|
2018-05-03 01:37:23 +02:00
|
|
|
await this.awaitGlobalLoadingIndicatorHidden();
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async clickVisualize() {
|
2019-01-18 21:39:01 +01:00
|
|
|
await appsMenu.clickLink('Visualize');
|
2018-05-03 01:37:23 +02:00
|
|
|
await this.awaitGlobalLoadingIndicatorHidden();
|
2019-01-18 21:39:01 +01:00
|
|
|
await retry.waitFor('first breadcrumb to be "Visualize"', async () => {
|
|
|
|
const firstBreadcrumb = await globalNav.getFirstBreadcrumb();
|
|
|
|
if (firstBreadcrumb !== 'Visualize') {
|
|
|
|
log.debug('-- first breadcrumb =', firstBreadcrumb);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async clickDashboard() {
|
2019-01-18 21:39:01 +01:00
|
|
|
await appsMenu.clickLink('Dashboard');
|
|
|
|
await retry.waitFor('dashboard app to be loaded', async () => {
|
2018-06-13 02:43:20 +02:00
|
|
|
const isNavVisible = await testSubjects.exists('top-nav');
|
|
|
|
const isLandingPageVisible = await testSubjects.exists('dashboardLandingPage');
|
2019-01-18 21:39:01 +01:00
|
|
|
return isNavVisible || isLandingPageVisible;
|
2018-06-13 02:43:20 +02:00
|
|
|
});
|
2018-05-03 01:37:23 +02:00
|
|
|
await this.awaitGlobalLoadingIndicatorHidden();
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|
|
|
|
|
2018-01-30 09:56:37 +01:00
|
|
|
async clickManagement() {
|
2019-01-18 21:39:01 +01:00
|
|
|
await appsMenu.clickLink('Management');
|
2018-05-03 01:37:23 +02:00
|
|
|
await this.awaitGlobalLoadingIndicatorHidden();
|
2018-01-30 09:56:37 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 00:01:06 +02:00
|
|
|
async waitUntilLoadingHasFinished() {
|
|
|
|
try {
|
|
|
|
await this.isGlobalLoadingIndicatorVisible();
|
|
|
|
} catch (exception) {
|
|
|
|
if (exception.name === 'ElementNotVisible') {
|
|
|
|
// selenium might just have been too slow to catch it
|
|
|
|
} else {
|
|
|
|
throw exception;
|
|
|
|
}
|
|
|
|
}
|
2018-05-03 01:37:23 +02:00
|
|
|
await this.awaitGlobalLoadingIndicatorHidden();
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async isGlobalLoadingIndicatorVisible() {
|
2017-07-27 21:26:09 +02:00
|
|
|
log.debug('isGlobalLoadingIndicatorVisible');
|
2019-09-27 20:49:51 +02:00
|
|
|
return await testSubjects.exists('globalLoadingIndicator', { timeout: 1500 });
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|
|
|
|
|
2018-05-03 01:37:23 +02:00
|
|
|
async awaitGlobalLoadingIndicatorHidden() {
|
2019-01-14 21:19:40 +01:00
|
|
|
await testSubjects.existOrFail('globalLoadingIndicator-hidden', {
|
|
|
|
allowHidden: true,
|
|
|
|
timeout: defaultFindTimeout * 10
|
|
|
|
});
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|
|
|
|
|
2018-11-06 23:25:44 +01:00
|
|
|
async awaitKibanaChrome() {
|
|
|
|
log.debug('awaitKibanaChrome');
|
|
|
|
await testSubjects.find('kibanaChrome', defaultFindTimeout * 10);
|
|
|
|
}
|
|
|
|
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return new HeaderPage();
|
|
|
|
}
|