addFilterRetryFull()

in common-utils/common-UI/common-UI.js [45:81]


  addFilterRetryFull(field, operator, value = null, maxRetries = 3) {
    // Try and select the desire combo box option
    const selectComboBoxInput = (selector, keyword) => {
      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 })
    }

    // Attempt up to three times to select the desired field and operator options and input the value (if applicable)
    const tryToAddFilter = (field, operator, value = null, retry = 0) => {
      this.testRunner.get('[data-test-subj="addFilter"]').click({ scrollBehavior: 'center' }).then(() => {
        selectComboBoxInput('filterFieldSuggestionList', field)
        this.testRunner.get('[data-test-subj="filterFieldSuggestionList"]').then(($field) => {
          const cls = $field.attr('class')
          if (cls.includes('euiComboBox-isInvalid') && retry < maxRetries) {
            this.testRunner.get('[data-test-subj="cancelSaveFilter"]').click()
            tryToAddFilter(field, operator, value, retry + 1)
          } else {
            selectComboBoxInput('filterOperatorList', operator)
            this.testRunner.get('[data-test-subj="filterOperatorList"]').then(($operator) => {
              const cls = $operator.attr('class')
              if (cls.includes('euiComboBox-isInvalid') && retry < maxRetries) {
                this.testRunner.get('[data-test-subj="cancelSaveFilter"]').click()
                tryToAddFilter(field, operator, value, retry + 1)
              } else {
                if (value !== null) {
                  this.testRunner.get('[data-test-subj="filterParams"]').find('input').type(value)
                }
                this.testRunner.get('[data-test-subj="saveFilter"]').click()
                this.testRunner.get(this._generateFilterSearchString(field)).last().should('be.visible')
              }
            })
          }
        })
      })
    }
    tryToAddFilter(field, operator, value)
  }