kibana/x-pack/test/functional/page_objects/watcher_page.js
Spencer 50be0d888e
[ftr] wrap remote in browser service (#26394)
* [pageObjects/common] remove unused runScript method

* [pageObjects/common] remove almost unused doesCssSelectorExist method

* [pageObjects/graph] convert to use find/testSubjects services

* [pageObjects/discover] refactor out remote service

* [pageObjects/pointSeries] refactor out remote service

* [pageObjects/monitoring] refactor out remote service

* [ftr] refactor uses of remote to use browser or find

* [ftr/services/remote] wrap remote with browser service

* [pageObjects/security] refactor out uses of remote

* [ftr/services/browser] isolate element calls to find

* [ftr] rename remote service to __leadfoot__

* [ftr/leadfoot] cleanup some renames in find, keep names in other tests
2018-11-29 14:30:47 -08:00

65 lines
2.3 KiB
JavaScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { map as mapAsync } from 'bluebird';
export function WatcherPageProvider({ getPageObjects, getService }) {
const PageObjects = getPageObjects(['common', 'header', 'settings']);
const find = getService('find');
const testSubjects = getService('testSubjects');
class WatcherPage {
async clearAllWatches() {
const checkBoxExists = await testSubjects.exists('selectAllWatchesCheckBox');
if (checkBoxExists) {
await testSubjects.click('selectAllWatchesCheckBox');
await testSubjects.click('btnDeleteWatches');
await testSubjects.click('confirmModalConfirmButton');
await PageObjects.header.waitUntilLoadingHasFinished();
}
}
async createWatch(watchName, name) {
await testSubjects.click('createAdvancedWatchButton');
await find.setValue('#id', watchName);
await find.setValue('#name', name);
await testSubjects.click('btnSaveWatch');
await PageObjects.header.waitUntilLoadingHasFinished();
}
async getWatch(watchID) {
const watchRow = await testSubjects.find(`watchRow-${watchID}`);
const text = await watchRow.getVisibleText();
const columns = text.split("\n");
return {
id: columns[0],
name: columns[1]
};
}
async deleteWatch() {
await testSubjects.click('selectAllWatchesCheckBox');
await testSubjects.click('btnDeleteWatches');
}
//get all the watches in the list
async getWatches() {
const watches = await find.allByCssSelector('.kuiTableRow');
return mapAsync(watches, async watch => {
const checkBox = await watch.findByCssSelector('td:nth-child(1)');
const id = await watch.findByCssSelector('td:nth-child(2)');
const name = await watch.findByCssSelector('td:nth-child(3)');
return {
checkBox: (await checkBox.getProperty('innerHTML')).includes('input'),
id: await id.getVisibleText(),
name: (await name.getVisibleText()).split(',').map(role => role.trim())
};
});
}
}
return new WatcherPage();
}