3c8c23c9ef
* Expand coverage of dashboard tests and decrease time * Fix timing error when sub urls fail to save from too fast app link clicking * discover doesn't have breadcrumbs * Check top nav text so it works on both listing and saved object edit/view pages * need to do the add panel operations one at a time * Need both types of input in filter * Give test data a title * Remove incorrect and unnecessary comment * Move data around and get rid of 6_3 specific naming as we will end up migrating the data as we progress * Remove code accidentally checked in
263 lines
8.6 KiB
JavaScript
263 lines
8.6 KiB
JavaScript
export function HeaderPageProvider({ getService, getPageObjects }) {
|
|
const config = getService('config');
|
|
const remote = getService('remote');
|
|
const log = getService('log');
|
|
const retry = getService('retry');
|
|
const find = getService('find');
|
|
const testSubjects = getService('testSubjects');
|
|
const PageObjects = getPageObjects(['common']);
|
|
|
|
const defaultFindTimeout = config.get('timeouts.find');
|
|
|
|
class HeaderPage {
|
|
|
|
async clickSelector(selector) {
|
|
log.debug(`clickSelector(${selector})`);
|
|
await retry.try(async () => await remote.findByCssSelector(selector).click());
|
|
}
|
|
|
|
async confirmTopNavTextContains(text) {
|
|
await retry.try(async () => {
|
|
const topNavText = await PageObjects.common.getTopNavText();
|
|
if (topNavText.toLowerCase().indexOf(text.toLowerCase()) < 0) {
|
|
throw new Error(`Top nav text ${topNavText} does not contain ${text} (case insensitive)`);
|
|
}
|
|
});
|
|
}
|
|
|
|
async clickDiscover() {
|
|
log.debug('click Discover tab');
|
|
await this.clickSelector('a[href*=\'discover\']');
|
|
await PageObjects.common.waitForTopNavToBeVisible();
|
|
await this.isGlobalLoadingIndicatorHidden();
|
|
}
|
|
|
|
async clickVisualize() {
|
|
log.debug('click Visualize tab');
|
|
await this.clickSelector('a[href*=\'visualize\']');
|
|
await PageObjects.common.waitForTopNavToBeVisible();
|
|
await this.confirmTopNavTextContains('visualize');
|
|
await this.isGlobalLoadingIndicatorHidden();
|
|
}
|
|
|
|
async clickDashboard() {
|
|
log.debug('click Dashboard tab');
|
|
await this.clickSelector('a[href*=\'dashboard\']');
|
|
await PageObjects.common.waitForTopNavToBeVisible();
|
|
await this.confirmTopNavTextContains('dashboard');
|
|
await this.isGlobalLoadingIndicatorHidden();
|
|
}
|
|
|
|
async clickManagement() {
|
|
log.debug('click Management tab');
|
|
await this.clickSelector('a[href*=\'management\']');
|
|
await this.isGlobalLoadingIndicatorHidden();
|
|
}
|
|
|
|
async clickSettings() {
|
|
log.debug('click Settings tab');
|
|
await this.clickSelector('a[href*=\'settings\']');
|
|
}
|
|
|
|
async clickTimepicker() {
|
|
await testSubjects.click('globalTimepickerButton');
|
|
}
|
|
|
|
async clickQuickButton() {
|
|
await retry.try(async () => {
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
await testSubjects.click('timepicker-quick-button');
|
|
});
|
|
}
|
|
|
|
async isTimepickerOpen() {
|
|
return await testSubjects.exists('timePicker');
|
|
}
|
|
|
|
async isAbsoluteSectionShowing() {
|
|
log.debug('isAbsoluteSectionShowing');
|
|
return await PageObjects.common.doesCssSelectorExist('input[ng-model=\'absolute.from\']');
|
|
}
|
|
|
|
async showAbsoluteSection() {
|
|
log.debug('showAbsoluteSection');
|
|
const isAbsoluteSectionShowing = await this.isAbsoluteSectionShowing();
|
|
if (!isAbsoluteSectionShowing) {
|
|
await retry.try(async () => {
|
|
await remote.setFindTimeout(defaultFindTimeout);
|
|
await testSubjects.click('timepicker-absolute-button');
|
|
// Check to make sure one of the elements on the absolute section is showing.
|
|
await this.getFromTime();
|
|
});
|
|
}
|
|
}
|
|
|
|
async getFromTime() {
|
|
log.debug('getFromTime');
|
|
return await retry.try(async () => {
|
|
await this.ensureTimePickerIsOpen();
|
|
await this.showAbsoluteSection();
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
return await remote.findByCssSelector('input[ng-model=\'absolute.from\']')
|
|
.getProperty('value');
|
|
});
|
|
}
|
|
|
|
async getToTime() {
|
|
log.debug('getToTime');
|
|
return await retry.try(async () => {
|
|
await this.ensureTimePickerIsOpen();
|
|
await this.showAbsoluteSection();
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
return await remote.findByCssSelector('input[ng-model=\'absolute.to\']')
|
|
.getProperty('value');
|
|
});
|
|
}
|
|
|
|
async setFromTime(timeString) {
|
|
log.debug(`setFromTime: ${timeString}`);
|
|
await retry.try(async () => {
|
|
await this.ensureTimePickerIsOpen();
|
|
await this.showAbsoluteSection();
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
await remote.findByCssSelector('input[ng-model=\'absolute.from\']')
|
|
.clearValue()
|
|
.type(timeString);
|
|
});
|
|
}
|
|
|
|
async setToTime(timeString) {
|
|
log.debug(`setToTime: ${timeString}`);
|
|
await retry.try(async () => {
|
|
await this.ensureTimePickerIsOpen();
|
|
await this.showAbsoluteSection();
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
await remote.findByCssSelector('input[ng-model=\'absolute.to\']')
|
|
.clearValue()
|
|
.type(timeString);
|
|
});
|
|
}
|
|
|
|
async clickGoButton() {
|
|
log.debug('clickGoButton');
|
|
await retry.try(async () => {
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
await testSubjects.click('timepickerGoButton');
|
|
await this.waitUntilLoadingHasFinished();
|
|
});
|
|
}
|
|
|
|
async ensureTimePickerIsOpen() {
|
|
log.debug('ensureTimePickerIsOpen');
|
|
const isOpen = await this.isTimepickerOpen();
|
|
if (!isOpen) {
|
|
await retry.try(async () => {
|
|
await this.clickTimepicker();
|
|
const isOpen = await this.isTimepickerOpen();
|
|
if (!isOpen) throw new Error('Time picker still not open, try again.');
|
|
});
|
|
}
|
|
}
|
|
|
|
async setAbsoluteRange(fromTime, toTime) {
|
|
log.debug(`Setting absolute range to ${fromTime} to ${toTime}`);
|
|
await this.ensureTimePickerIsOpen();
|
|
log.debug('--Clicking Absolute button');
|
|
await this.showAbsoluteSection();
|
|
log.debug('--Setting From Time : ' + fromTime);
|
|
await this.setFromTime(fromTime);
|
|
log.debug('--Setting To Time : ' + toTime);
|
|
await this.setToTime(toTime);
|
|
await this.clickGoButton();
|
|
await this.isGlobalLoadingIndicatorHidden();
|
|
}
|
|
|
|
async setQuickTime(quickTime) {
|
|
await this.ensureTimePickerIsOpen();
|
|
log.debug('--Clicking Quick button');
|
|
await this.clickQuickButton();
|
|
await remote.setFindTimeout(defaultFindTimeout)
|
|
.findByLinkText(quickTime).click();
|
|
}
|
|
|
|
async getAutoRefreshState() {
|
|
return testSubjects.getAttribute('globalTimepickerAutoRefreshButton', 'data-test-subj-state');
|
|
}
|
|
|
|
// check if the auto refresh state is active and to pause it
|
|
async pauseAutoRefresh() {
|
|
let result = false;
|
|
if (await this.getAutoRefreshState() === 'active') {
|
|
await testSubjects.click('globalTimepickerAutoRefreshButton');
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// check if the auto refresh state is inactive and to resume it
|
|
async resumeAutoRefresh() {
|
|
let result = false;
|
|
if (await this.getAutoRefreshState() === 'inactive') {
|
|
await testSubjects.click('globalTimepickerAutoRefreshButton');
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
async getToastMessage(findTimeout = defaultFindTimeout) {
|
|
const toastMessage =
|
|
await find.displayedByCssSelector('kbn-truncated.toast-message.ng-isolate-scope', findTimeout);
|
|
const messageText = await toastMessage.getVisibleText();
|
|
log.debug(`getToastMessage: ${messageText}`);
|
|
return messageText;
|
|
}
|
|
|
|
async waitForToastMessageGone() {
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
await remote.waitForDeletedByCssSelector('kbn-truncated.toast-message');
|
|
}
|
|
|
|
async clickToastOK() {
|
|
log.debug('clickToastOK');
|
|
await retry.try(async () => {
|
|
remote.setFindTimeout(defaultFindTimeout);
|
|
await remote.findByCssSelector('button[ng-if="notif.accept"]')
|
|
.click();
|
|
});
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
await this.isGlobalLoadingIndicatorHidden();
|
|
}
|
|
|
|
async isGlobalLoadingIndicatorVisible() {
|
|
log.debug('isGlobalLoadingIndicatorVisible');
|
|
return await testSubjects.exists('globalLoadingIndicator');
|
|
}
|
|
|
|
async isGlobalLoadingIndicatorHidden() {
|
|
log.debug('isGlobalLoadingIndicatorHidden');
|
|
return await find.byCssSelector('[data-test-subj="globalLoadingIndicator"].ng-hide', defaultFindTimeout * 10);
|
|
}
|
|
|
|
async getPrettyDuration() {
|
|
return await testSubjects.getVisibleText('globalTimepickerRange');
|
|
}
|
|
|
|
async isSharedTimefilterEnabled() {
|
|
return await find.existsByCssSelector('[shared-timefilter=true]');
|
|
}
|
|
}
|
|
|
|
return new HeaderPage();
|
|
}
|