mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* remove inline awaits * testSubjects.find now always returns a promise, so we need to make sure there is no more inlining * more find conversions * need to pass property name * Make sure async functions are awaited on.
This commit is contained in:
parent
f3551a145c
commit
9f62ee555e
15 changed files with 190 additions and 203 deletions
|
@ -152,7 +152,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
|
||||
it('when the query is edited and applied', async function () {
|
||||
const originalQuery = await PageObjects.dashboard.getQuery();
|
||||
await PageObjects.dashboard.appendQuery('extra stuff');
|
||||
await PageObjects.dashboard.setQuery(`${originalQuery} and extra stuff`);
|
||||
await PageObjects.dashboard.clickFilterButton();
|
||||
|
||||
await PageObjects.dashboard.clickCancelOutOfEditMode();
|
||||
|
@ -184,8 +184,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
await originalFilters[0].click();
|
||||
await originalFilters[0].click();
|
||||
|
||||
const removeFilterButton = await testSubjects.find('removeFilter-memory');
|
||||
await removeFilterButton.click();
|
||||
await testSubjects.click('removeFilter-memory');
|
||||
|
||||
const noFilters = await PageObjects.dashboard.getFilters(1000);
|
||||
expect(noFilters.length).to.equal(0);
|
||||
|
@ -288,7 +287,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
|
||||
|
||||
const originalQuery = await PageObjects.dashboard.getQuery();
|
||||
await PageObjects.dashboard.appendQuery('extra stuff');
|
||||
await PageObjects.dashboard.setQuery(`${originalQuery} extra stuff`);
|
||||
|
||||
await PageObjects.dashboard.clickCancelOutOfEditMode();
|
||||
|
||||
|
|
|
@ -17,16 +17,13 @@ export default function ({ getService, getPageObjects }) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should enable creation after selecting time field', function () {
|
||||
it('should enable creation after selecting time field', async function () {
|
||||
// select a time field and check that Create button is enabled
|
||||
return PageObjects.settings.selectTimeFieldOption('@timestamp')
|
||||
.then(function () {
|
||||
return PageObjects.settings.getCreateButton().isEnabled()
|
||||
.then(function (enabled) {
|
||||
screenshots.take('Settings-indices-enable-creation');
|
||||
expect(enabled).to.be.ok();
|
||||
});
|
||||
});
|
||||
await PageObjects.settings.selectTimeFieldOption('@timestamp');
|
||||
const createButton = await PageObjects.settings.getCreateButton();
|
||||
const enabled = await createButton.isEnabled();
|
||||
screenshots.take('Settings-indices-enable-creation');
|
||||
expect(enabled).to.be.ok();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,12 +28,11 @@ export default function ({ getService, getPageObjects }) {
|
|||
.then(id => indexPatternId = id);
|
||||
});
|
||||
|
||||
it('should have index pattern in page header', function () {
|
||||
return PageObjects.settings.getIndexPageHeading().getVisibleText()
|
||||
.then(function (patternName) {
|
||||
screenshots.take('Settings-indices-new-index-pattern');
|
||||
expect(patternName).to.be('logstash-*');
|
||||
});
|
||||
it('should have index pattern in page header', async function () {
|
||||
const indexPageHeading = await PageObjects.settings.getIndexPageHeading();
|
||||
const patternName = await indexPageHeading.getVisibleText();
|
||||
screenshots.take('Settings-indices-new-index-pattern');
|
||||
expect(patternName).to.be('logstash-*');
|
||||
});
|
||||
|
||||
it('should have index pattern in url', function url() {
|
||||
|
|
|
@ -17,28 +17,25 @@ export default function ({ getService, getPageObjects }) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should contain default index pattern', function () {
|
||||
it('should contain default index pattern', async function () {
|
||||
const defaultPattern = 'logstash-*';
|
||||
|
||||
return PageObjects.settings.getIndexPatternField().getProperty('value')
|
||||
.then(function (pattern) {
|
||||
expect(pattern).to.be(defaultPattern);
|
||||
});
|
||||
const indexPatternField = await PageObjects.settings.getIndexPatternField();
|
||||
const pattern = await indexPatternField.getProperty('value');
|
||||
expect(pattern).to.be(defaultPattern);
|
||||
});
|
||||
|
||||
it('should not select the time field', function () {
|
||||
return PageObjects.settings.getTimeFieldNameField().isSelected()
|
||||
.then(function (timeFieldIsSelected) {
|
||||
log.debug('timeField isSelected = ' + timeFieldIsSelected);
|
||||
expect(timeFieldIsSelected).to.not.be.ok();
|
||||
});
|
||||
it('should not select the time field', async function () {
|
||||
const timeFieldNameField = await PageObjects.settings.getTimeFieldNameField();
|
||||
const timeFieldIsSelected = await timeFieldNameField.isSelected();
|
||||
log.debug('timeField isSelected = ' + timeFieldIsSelected);
|
||||
expect(timeFieldIsSelected).to.not.be.ok();
|
||||
});
|
||||
|
||||
it('should not enable creation', function () {
|
||||
return PageObjects.settings.getCreateIndexPatternButton().isEnabled()
|
||||
.then(function (enabled) {
|
||||
expect(enabled).to.not.be.ok();
|
||||
});
|
||||
it('should not enable creation', async function () {
|
||||
const createIndexPatternButton = await PageObjects.settings.getCreateIndexPatternButton();
|
||||
const enabled = await createIndexPatternButton.isEnabled();
|
||||
expect(enabled).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,14 +11,11 @@ export default function ({ getService, getPageObjects }) {
|
|||
await PageObjects.common.navigateToApp('status_page');
|
||||
});
|
||||
|
||||
it('should show the kibana plugin as ready', function () {
|
||||
return retry.tryForTime(6000, function () {
|
||||
return testSubjects.find('statusBreakdown')
|
||||
.getVisibleText()
|
||||
.then(function (text) {
|
||||
screenshots.take('Status');
|
||||
expect(text.indexOf('plugin:kibana')).to.be.above(-1);
|
||||
});
|
||||
it('should show the kibana plugin as ready', async function () {
|
||||
await retry.tryForTime(6000, async () => {
|
||||
const text = await testSubjects.getVisibleText('statusBreakdown');
|
||||
screenshots.take('Status');
|
||||
expect(text.indexOf('plugin:kibana')).to.be.above(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -28,28 +28,27 @@ export function ContextPageProvider({ getService }) {
|
|||
await this.waitUntilContextLoadingHasFinished();
|
||||
}
|
||||
|
||||
getPredecessorCountPicker() {
|
||||
return testSubjects.find('predecessorCountPicker');
|
||||
async getPredecessorCountPicker() {
|
||||
return await testSubjects.find('predecessorCountPicker');
|
||||
}
|
||||
|
||||
getSuccessorCountPicker() {
|
||||
return testSubjects.find('successorCountPicker');
|
||||
async getSuccessorCountPicker() {
|
||||
return await testSubjects.find('successorCountPicker');
|
||||
}
|
||||
|
||||
getPredecessorLoadMoreButton() {
|
||||
return testSubjects.find('predecessorLoadMoreButton');
|
||||
async getPredecessorLoadMoreButton() {
|
||||
return await testSubjects.find('predecessorLoadMoreButton');
|
||||
}
|
||||
|
||||
getSuccessorLoadMoreButton() {
|
||||
return testSubjects.find('predecessorLoadMoreButton');
|
||||
async getSuccessorLoadMoreButton() {
|
||||
return await testSubjects.find('predecessorLoadMoreButton');
|
||||
}
|
||||
|
||||
waitUntilContextLoadingHasFinished() {
|
||||
return retry.try(async () => {
|
||||
if (
|
||||
!(await this.getSuccessorLoadMoreButton().isEnabled())
|
||||
|| !(await this.getPredecessorLoadMoreButton().isEnabled())
|
||||
) {
|
||||
const successorLoadMoreButton = await this.getSuccessorLoadMoreButton();
|
||||
const predecessorLoadMoreButton = await this.getPredecessorLoadMoreButton();
|
||||
if (!successorLoadMoreButton.isEnabled() || !predecessorLoadMoreButton.isEnabled()) {
|
||||
throw new Error('loading context rows');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -64,14 +64,14 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
|
|||
return await queryObject.getProperty('value');
|
||||
}
|
||||
|
||||
appendQuery(query) {
|
||||
log.debug('Appending query');
|
||||
return retry.try(() => testSubjects.find('queryInput').type(query));
|
||||
async setQuery(query) {
|
||||
log.debug(`setQuery(${query})`);
|
||||
return await testSubjects.setValue('queryInput', query);
|
||||
}
|
||||
|
||||
clickFilterButton() {
|
||||
async clickFilterButton() {
|
||||
log.debug('Clicking filter button');
|
||||
return testSubjects.click('querySubmitButton');
|
||||
return await testSubjects.click('querySubmitButton');
|
||||
}
|
||||
|
||||
async clickClone() {
|
||||
|
@ -327,18 +327,15 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
|
|||
});
|
||||
}
|
||||
|
||||
getPanelTitles() {
|
||||
async getPanelTitles() {
|
||||
log.debug('in getPanelTitles');
|
||||
return testSubjects.findAll('dashboardPanelTitle')
|
||||
.then(function (titleObjects) {
|
||||
const titleObjects = await testSubjects.findAll('dashboardPanelTitle');
|
||||
|
||||
function getTitles(chart) {
|
||||
return chart.getVisibleText();
|
||||
}
|
||||
|
||||
const getTitlePromises = titleObjects.map(getTitles);
|
||||
return Promise.all(getTitlePromises);
|
||||
});
|
||||
function getTitles(chart) {
|
||||
return chart.getVisibleText();
|
||||
}
|
||||
const getTitlePromises = titleObjects.map(getTitles);
|
||||
return Promise.all(getTitlePromises);
|
||||
}
|
||||
|
||||
async getDashboardPanels() {
|
||||
|
|
|
@ -3,6 +3,7 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
|
|||
const log = getService('log');
|
||||
const retry = getService('retry');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const find = getService('find');
|
||||
const PageObjects = getPageObjects(['header', 'common']);
|
||||
|
||||
const getRemote = () => (
|
||||
|
@ -21,9 +22,8 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
|
|||
.findByCssSelector('button[aria-label=\'Search\']');
|
||||
}
|
||||
|
||||
getTimespanText() {
|
||||
return testSubjects.find('globalTimepickerRange')
|
||||
.getVisibleText();
|
||||
async getTimespanText() {
|
||||
return await testSubjects.getVisibleText('globalTimepickerRange');
|
||||
}
|
||||
|
||||
getChartTimespan() {
|
||||
|
@ -67,9 +67,8 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
|
|||
return testSubjects.click('discoverOpenButton');
|
||||
}
|
||||
|
||||
getCurrentQueryName() {
|
||||
return testSubjects.find('discoverCurrentQuery')
|
||||
.getVisibleText();
|
||||
async getCurrentQueryName() {
|
||||
return await testSubjects.getVisibleText('discoverCurrentQuery');
|
||||
}
|
||||
|
||||
getBarChartData() {
|
||||
|
@ -126,32 +125,21 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
|
|||
});
|
||||
}
|
||||
|
||||
getChartInterval() {
|
||||
return testSubjects.find('discoverIntervalSelect')
|
||||
.getProperty('value')
|
||||
.then(selectedValue => {
|
||||
return getRemote()
|
||||
.findByCssSelector('option[value="' + selectedValue + '"]')
|
||||
.getVisibleText();
|
||||
});
|
||||
async getChartInterval() {
|
||||
const selectedValue = await testSubjects.getProperty('discoverIntervalSelect', 'value');
|
||||
const selectedOption = await find.byCssSelector('option[value="' + selectedValue + '"]');
|
||||
return selectedOption.getVisibleText();
|
||||
}
|
||||
|
||||
setChartInterval(interval) {
|
||||
return getRemote()
|
||||
.setFindTimeout(5000)
|
||||
.findByCssSelector('option[label="' + interval + '"]')
|
||||
.click()
|
||||
.then(() => {
|
||||
return PageObjects.header.waitUntilLoadingHasFinished();
|
||||
});
|
||||
async setChartInterval(interval) {
|
||||
const optionElement = await find.byCssSelector('option[label="' + interval + '"]', 5000);
|
||||
await optionElement.click();
|
||||
return await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
}
|
||||
|
||||
getHitCount() {
|
||||
return PageObjects.header.waitUntilLoadingHasFinished()
|
||||
.then(() => {
|
||||
return testSubjects.find('discoverQueryHits')
|
||||
.getVisibleText();
|
||||
});
|
||||
async getHitCount() {
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
return await testSubjects.getVisibleText('discoverQueryHits');
|
||||
}
|
||||
|
||||
query(queryString) {
|
||||
|
@ -211,18 +199,16 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
|
|||
return testSubjects.click('sharedSnapshotCopyButton');
|
||||
}
|
||||
|
||||
getShareCaption() {
|
||||
return testSubjects.find('shareUiTitle')
|
||||
.getVisibleText();
|
||||
async getShareCaption() {
|
||||
return await testSubjects.getVisibleText('shareUiTitle');
|
||||
}
|
||||
|
||||
getSharedUrl() {
|
||||
return testSubjects.find('sharedSnapshotUrl')
|
||||
.getProperty('value');
|
||||
async getSharedUrl() {
|
||||
return await testSubjects.getProperty('sharedSnapshotUrl', 'value');
|
||||
}
|
||||
|
||||
toggleSidebarCollapse() {
|
||||
return testSubjects.find('collapseSideBarButton').click();
|
||||
async toggleSidebarCollapse() {
|
||||
return await testSubjects.click('collapseSideBarButton');
|
||||
}
|
||||
|
||||
getAllFieldNames() {
|
||||
|
@ -239,14 +225,12 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
|
|||
.getProperty('clientWidth');
|
||||
}
|
||||
|
||||
hasNoResults() {
|
||||
return testSubjects.find('discoverNoResults')
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
async hasNoResults() {
|
||||
return await testSubjects.exists('discoverNoResults');
|
||||
}
|
||||
|
||||
getNoResultsTimepicker() {
|
||||
return testSubjects.find('discoverNoResultsTimefilter');
|
||||
async getNoResultsTimepicker() {
|
||||
return await testSubjects.find('discoverNoResultsTimefilter');
|
||||
}
|
||||
|
||||
hasNoResultsTimepicker() {
|
||||
|
@ -256,8 +240,8 @@ export function DiscoverPageProvider({ getService, getPageObjects }) {
|
|||
.catch(() => false);
|
||||
}
|
||||
|
||||
clickFieldListItem(field) {
|
||||
return testSubjects.click(`field-${field}`);
|
||||
async clickFieldListItem(field) {
|
||||
return await testSubjects.click(`field-${field}`);
|
||||
}
|
||||
|
||||
async clickFieldListItemAdd(field) {
|
||||
|
|
|
@ -210,15 +210,11 @@ export function HeaderPageProvider({ getService, getPageObjects }) {
|
|||
}
|
||||
|
||||
async getPrettyDuration() {
|
||||
return await testSubjects.find('globalTimepickerRange').getVisibleText();
|
||||
return await testSubjects.getVisibleText('globalTimepickerRange');
|
||||
}
|
||||
|
||||
async isSharedTimefilterEnabled() {
|
||||
const element = await remote
|
||||
.setFindTimeout(defaultFindTimeout)
|
||||
.findByCssSelector(`[shared-timefilter=true]`);
|
||||
|
||||
return !!element;
|
||||
return await find.existsByCssSelector('[shared-timefilter=true]');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,8 @@ export function PointSeriesPageProvider({ getService }) {
|
|||
.click();
|
||||
}
|
||||
|
||||
clickAddAxis() {
|
||||
return testSubjects.find('visualizeAddYAxisButton')
|
||||
.click();
|
||||
async clickAddAxis() {
|
||||
return await testSubjects.click('visualizeAddYAxisButton');
|
||||
}
|
||||
|
||||
getValueAxesCount() {
|
||||
|
|
|
@ -5,6 +5,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
const retry = getService('retry');
|
||||
const config = getService('config');
|
||||
const remote = getService('remote');
|
||||
const find = getService('find');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const PageObjects = getPageObjects(['header', 'common']);
|
||||
|
||||
|
@ -31,10 +32,9 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
await this.clickLinkText('Index Patterns');
|
||||
}
|
||||
|
||||
getAdvancedSettings(propertyName) {
|
||||
async getAdvancedSettings(propertyName) {
|
||||
log.debug('in setAdvancedSettings');
|
||||
return testSubjects.find(`advancedSetting-${propertyName}-currentValue`)
|
||||
.getVisibleText();
|
||||
return await testSubjects.getVisibleText(`advancedSetting-${propertyName}-currentValue`);
|
||||
}
|
||||
|
||||
async setAdvancedSettings(propertyName, propertyValue) {
|
||||
|
@ -62,53 +62,56 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
await PageObjects.common.navigateToApp('settings');
|
||||
}
|
||||
|
||||
getIndexPatternField() {
|
||||
return testSubjects.find('createIndexPatternNameInput');
|
||||
async getIndexPatternField() {
|
||||
return await testSubjects.find('createIndexPatternNameInput');
|
||||
}
|
||||
|
||||
getTimeFieldNameField() {
|
||||
return testSubjects.find('createIndexPatternTimeFieldSelect');
|
||||
async clickTimeFieldNameField() {
|
||||
return await testSubjects.click('createIndexPatternTimeFieldSelect');
|
||||
}
|
||||
|
||||
async getTimeFieldNameField() {
|
||||
return await testSubjects.find('createIndexPatternTimeFieldSelect');
|
||||
}
|
||||
|
||||
async selectTimeFieldOption(selection) {
|
||||
// open dropdown
|
||||
(await this.getTimeFieldNameField()).click();
|
||||
await this.clickTimeFieldNameField();
|
||||
// close dropdown, keep focus
|
||||
(await this.getTimeFieldNameField()).click();
|
||||
await this.clickTimeFieldNameField();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await retry.try(async () => {
|
||||
return await retry.try(async () => {
|
||||
log.debug(`selectTimeFieldOption(${selection})`);
|
||||
(await this.getTimeFieldOption(selection)).click();
|
||||
const selected = (await this.getTimeFieldOption(selection)).isSelected();
|
||||
const timeFieldOption = await this.getTimeFieldOption(selection);
|
||||
await timeFieldOption.click();
|
||||
const selected = await timeFieldOption.isSelected();
|
||||
if (!selected) throw new Error('option not selected: ' + selected);
|
||||
});
|
||||
}
|
||||
|
||||
getTimeFieldOption(selection) {
|
||||
return remote.setFindTimeout(defaultFindTimeout)
|
||||
.findDisplayedByCssSelector('option[label="' + selection + '"]');
|
||||
async getTimeFieldOption(selection) {
|
||||
return await find.displayedByCssSelector('option[label="' + selection + '"]');
|
||||
}
|
||||
|
||||
getCreateIndexPatternButton() {
|
||||
return testSubjects.find('createIndexPatternCreateButton');
|
||||
async getCreateIndexPatternButton() {
|
||||
return await testSubjects.find('createIndexPatternCreateButton');
|
||||
}
|
||||
|
||||
getCreateButton() {
|
||||
return remote.setFindTimeout(defaultFindTimeout)
|
||||
.findDisplayedByCssSelector('[type="submit"]');
|
||||
async getCreateButton() {
|
||||
return await find.displayedByCssSelector('[type="submit"]');
|
||||
}
|
||||
|
||||
async clickDefaultIndexButton() {
|
||||
await testSubjects.find('setDefaultIndexPatternButton').click();
|
||||
await testSubjects.click('setDefaultIndexPatternButton');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
}
|
||||
|
||||
async clickDeletePattern() {
|
||||
await testSubjects.find('deleteIndexPatternButton').click();
|
||||
await testSubjects.click('deleteIndexPatternButton');
|
||||
}
|
||||
|
||||
getIndexPageHeading() {
|
||||
return testSubjects.find('indexPatternTitle');
|
||||
async getIndexPageHeading() {
|
||||
return await testSubjects.find('indexPatternTitle');
|
||||
}
|
||||
|
||||
getConfigureHeader() {
|
||||
|
@ -151,14 +154,11 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
);
|
||||
}
|
||||
|
||||
getFieldsTabCount() {
|
||||
return retry.try(() => {
|
||||
return testSubjects.find('tab-count-indexedFields')
|
||||
.getVisibleText()
|
||||
.then((theText) => {
|
||||
// the value has () around it, remove them
|
||||
return theText.replace(/\((.*)\)/, '$1');
|
||||
});
|
||||
async getFieldsTabCount() {
|
||||
return await retry.try(async () => {
|
||||
const text = await testSubjects.getVisibleText('tab-count-indexedFields');
|
||||
// the value has () around it, remove them
|
||||
return text.replace(/\((.*)\)/, '$1');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,8 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
await this.clickKibanaIndices();
|
||||
await this.setIndexPatternField(indexPatternName);
|
||||
await this.selectTimeFieldOption(timefield);
|
||||
await this.getCreateButton().click();
|
||||
const createButton = await this.getCreateButton();
|
||||
await createButton.click();
|
||||
});
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await retry.try(async () => {
|
||||
|
@ -305,8 +306,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
|
||||
async setIndexPatternField(pattern) {
|
||||
log.debug(`setIndexPatternField(${pattern})`);
|
||||
return testSubjects.find('createIndexPatternNameInput')
|
||||
.clearValue().type(pattern);
|
||||
return await testSubjects.setValue('createIndexPatternNameInput', pattern);
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,7 +318,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
});
|
||||
await retry.try(async () => {
|
||||
log.debug('getAlertText');
|
||||
alertText = await testSubjects.find('confirmModalBodyText').getVisibleText();
|
||||
alertText = await testSubjects.getVisibleText('confirmModalBodyText');
|
||||
});
|
||||
await retry.try(async () => {
|
||||
log.debug('acceptConfirmation');
|
||||
|
@ -392,7 +392,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
|
||||
async setScriptedFieldName(name) {
|
||||
log.debug('set scripted field name = ' + name);
|
||||
await testSubjects.find('editorFieldName').type(name);
|
||||
await testSubjects.setValue('editorFieldName', name);
|
||||
}
|
||||
|
||||
async setScriptedFieldLanguage(language) {
|
||||
|
@ -453,12 +453,12 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
|
|||
|
||||
async setScriptedFieldPopularity(popularity) {
|
||||
log.debug('set scripted field popularity = ' + popularity);
|
||||
await testSubjects.find('editorFieldCount').type(popularity);
|
||||
await testSubjects.setValue('editorFieldCount', popularity);
|
||||
}
|
||||
|
||||
async setScriptedFieldScript(script) {
|
||||
log.debug('set scripted field script = ' + script);
|
||||
await testSubjects.find('editorFieldScript').type(script);
|
||||
await testSubjects.setValue('editorFieldScript', script);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ export function DocTableProvider({ getService }) {
|
|||
const testSubjects = getService('testSubjects');
|
||||
|
||||
class DocTable {
|
||||
getTable() {
|
||||
return testSubjects.find('docTable');
|
||||
async getTable() {
|
||||
return await testSubjects.find('docTable');
|
||||
}
|
||||
|
||||
async getBodyRows(table) {
|
||||
|
|
|
@ -13,7 +13,7 @@ export function FilterBarProvider({ getService }) {
|
|||
async toggleFilterEnabled(key) {
|
||||
const filterElement = await testSubjects.find(`filter & filter-key-${key}`);
|
||||
await remote.moveMouseTo(filterElement);
|
||||
await testSubjects.find(`filter & filter-key-${key} disableFilter-${key}`).click();
|
||||
await testSubjects.click(`filter & filter-key-${key} disableFilter-${key}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@ export function FindProvider({ getService }) {
|
|||
const defaultFindTimeout = config.get('timeouts.find');
|
||||
|
||||
class Find {
|
||||
byCssSelector(selector) {
|
||||
async byCssSelector(selector, timeout = defaultFindTimeout) {
|
||||
log.debug(`findByCssSelector ${selector}`);
|
||||
return remote
|
||||
.setFindTimeout(defaultFindTimeout)
|
||||
.findByCssSelector(selector);
|
||||
const remoteWithTimeout = remote.setFindTimeout(timeout);
|
||||
const element = await remoteWithTimeout.findByCssSelector(selector);
|
||||
remoteWithTimeout.setFindTimeout(defaultFindTimeout);
|
||||
return element;
|
||||
}
|
||||
|
||||
async allByCssSelector(selector, timeout = defaultFindTimeout) {
|
||||
|
@ -33,14 +34,31 @@ export function FindProvider({ getService }) {
|
|||
|
||||
async existsByLinkText(linkText) {
|
||||
log.debug(`existsByLinkText ${linkText}`);
|
||||
|
||||
const exists = await remote
|
||||
.setFindTimeout(1000)
|
||||
.findDisplayedByLinkText(linkText)
|
||||
const remoteWithTimeout = remote.setFindTimeout(1000);
|
||||
const exists = await remoteWithTimeout.findDisplayedByLinkText(linkText)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
remoteWithTimeout.setFindTimeout(defaultFindTimeout);
|
||||
return exists;
|
||||
}
|
||||
|
||||
remote.setFindTimeout(defaultFindTimeout);
|
||||
async existsByDisplayedByCssSelector(selector) {
|
||||
log.debug(`existsByDisplayedByCssSelector ${selector}`);
|
||||
const remoteWithTimeout = remote.setFindTimeout(1000);
|
||||
const exists = await remoteWithTimeout.findDisplayedByCssSelector(selector)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
remoteWithTimeout.setFindTimeout(defaultFindTimeout);
|
||||
return exists;
|
||||
}
|
||||
|
||||
async existsByCssSelector(selector) {
|
||||
log.debug(`existsByCssSelector ${selector}`);
|
||||
const remoteWithTimeout = remote.setFindTimeout(1000);
|
||||
const exists = await remoteWithTimeout.findByCssSelector(selector)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
remoteWithTimeout.setFindTimeout(defaultFindTimeout);
|
||||
return exists;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@ export function TestSubjectsProvider({ getService }) {
|
|||
|
||||
class TestSubjects {
|
||||
async exists(selector) {
|
||||
log.debug(`doesTestSubjectExist ${selector}`);
|
||||
log.debug(`TestSubjects.exists(${selector})`);
|
||||
return await find.existsByDisplayedByCssSelector(testSubjSelector(selector));
|
||||
}
|
||||
|
||||
const exists = await remote
|
||||
.setFindTimeout(1000)
|
||||
.findDisplayedByCssSelector(testSubjSelector(selector))
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
remote.setFindTimeout(defaultFindTimeout);
|
||||
return exists;
|
||||
async append(selector, text) {
|
||||
return await retry.try(async () => {
|
||||
const input = await this.find(selector);
|
||||
await input.click();
|
||||
await input.type(text);
|
||||
});
|
||||
}
|
||||
|
||||
async click(selector) {
|
||||
|
@ -31,33 +31,38 @@ export function TestSubjectsProvider({ getService }) {
|
|||
});
|
||||
}
|
||||
|
||||
find(selector, timeout = defaultFindTimeout) {
|
||||
log.debug('in findTestSubject: ' + testSubjSelector(selector));
|
||||
let originalFindTimeout = null;
|
||||
return remote
|
||||
.getFindTimeout()
|
||||
.then((findTimeout) => originalFindTimeout = findTimeout)
|
||||
.setFindTimeout(timeout)
|
||||
.findDisplayedByCssSelector(testSubjSelector(selector))
|
||||
.then(
|
||||
(result) => remote.setFindTimeout(originalFindTimeout)
|
||||
.finally(() => result),
|
||||
(error) => remote.setFindTimeout(originalFindTimeout)
|
||||
.finally(() => { throw error; }),
|
||||
);
|
||||
async find(selector, timeout = defaultFindTimeout) {
|
||||
log.debug(`TestSubjects.find(${selector})`);
|
||||
return await find.displayedByCssSelector(testSubjSelector(selector), timeout);
|
||||
}
|
||||
|
||||
async findAll(selector) {
|
||||
log.debug('in findAllTestSubjects: ' + testSubjSelector(selector));
|
||||
log.debug(`TestSubjects.findAll(${selector})`);
|
||||
const all = await find.allByCssSelector(testSubjSelector(selector));
|
||||
return await filterAsync(all, el => el.isDisplayed());
|
||||
}
|
||||
|
||||
async setValue(selector, value) {
|
||||
const input = await retry.try(() => this.find(selector));
|
||||
await retry.try(() => input.click());
|
||||
await input.clearValue();
|
||||
await input.type(value);
|
||||
async getProperty(selector, property) {
|
||||
return await retry.try(async () => {
|
||||
const element = await this.find(selector);
|
||||
return await element.getProperty(property);
|
||||
});
|
||||
}
|
||||
|
||||
async setValue(selector, text) {
|
||||
return await retry.try(async () => {
|
||||
const input = await this.find(selector);
|
||||
await input.click();
|
||||
await input.clearValue();
|
||||
await input.type(text);
|
||||
});
|
||||
}
|
||||
|
||||
async getVisibleText(selector) {
|
||||
return await retry.try(async () => {
|
||||
const element = await this.find(selector);
|
||||
return await element.getVisibleText();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue