Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter range retry selection #34

Merged
merged 1 commit into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions common-utils/common-UI/common-UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,42 @@ export class CommonUI {
this.testRunner.get(this._generateFilterSearchString(field)).last().should('be.visible')
}

/**
* Attempts to add a specified filter, retrying by reselecting the failed option
* @param {String} field Field value to select
* @param {String} operator Operator value to select
* @param {String} value1 Value field input
* @param {String} value2 Value field input
*/
addFilterRangeRetrySelection(field, operator, value1, value2, maxRetries = 3) {
const selectComboBoxInput = (selector, keyword, retry = 0) => {
this.testRunner.get(`[data-test-subj="${selector}"]`).find('[data-test-subj="comboBoxInput"]').trigger('focus').type(`{selectall}{backspace}${keyword}`)
this.testRunner.get(`[data-test-subj="comboBoxOptionsList ${selector}-optionsList"]`).find(`[title="${keyword}"]`).trigger('click', { force: true })
this.testRunner.get(`[data-test-subj="${selector}"]`).then(($box) => {
const cls = $box.attr('class')
if (cls.includes('euiComboBox-isInvalid') && retry < maxRetries) {
this.testRunner.wrap($box).find('[data-test-subj="comboBoxInput"]').type('{selectall}{backspace}')
this.testRunner.wrap($box).find('[data-test-subj="comboBoxToggleListButton"]').click()
selectComboBoxInput(selector, keyword, retry + 1)
}
})
}

this.testRunner.get('[data-test-subj="addFilter"]').click().then(() => {
selectComboBoxInput('filterFieldSuggestionList', field)
selectComboBoxInput('filterOperatorList', operator)
})

this.testRunner.get('[data-test-subj="filterParams"]')
.find('input')
.first()
.type(value1);
this.testRunner.get('[data-test-subj="filterParams"]').find('input').last().type(value2);

this.testRunner.get('[data-test-subj="saveFilter"]').click()
this.testRunner.get(this._generateFilterSearchString(field)).last().should('be.visible')
}

/**
* Pins a filter with a specified field attribute and an optional
* index number representing which position the desired filter is located at
Expand Down