@@ -33,25 +33,32 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
3333 // wrapper around EuiComboBox interactions
3434 class ComboBox {
3535 /**
36- * set value inside combobox
36+ * Finds combobox element and sets specified value
3737 *
38- * @param comboBoxSelector test subject selector
39- * @param value
38+ * @param comboBoxSelector data- test-subj selector
39+ * @param value option text
4040 */
41+
4142 public async set ( comboBoxSelector : string , value : string ) : Promise < void > {
4243 log . debug ( `comboBox.set, comboBoxSelector: ${ comboBoxSelector } ` ) ;
4344 const comboBox = await testSubjects . find ( comboBoxSelector ) ;
4445 await this . setElement ( comboBox , value ) ;
4546 }
4647
47- private async clickOption ( isMouseClick : boolean , element : WebElementWrapper ) {
48+ /**
49+ * Clicks option in combobox dropdown
50+ *
51+ * @param isMouseClick if 'true', click will be done with mouse
52+ * @param element element that wraps up option
53+ */
54+ private async clickOption ( isMouseClick : boolean , element : WebElementWrapper ) : Promise < void > {
4855 return isMouseClick ? await element . clickMouseButton ( ) : await element . click ( ) ;
4956 }
5057
5158 /**
52- * set value inside combobox element
59+ * Sets value for specified combobox element
5360 *
54- * @param comboBoxElement
61+ * @param comboBoxElement element that wraps up EuiComboBox
5562 * @param value
5663 */
5764 public async setElement (
@@ -66,7 +73,8 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
6673 return ;
6774 }
6875
69- await this . _filterOptionsList ( comboBoxElement , value ) ;
76+ comboBoxElement . scrollIntoViewIfNecessary ( ) ;
77+ await this . setFilterValue ( comboBoxElement , value ) ;
7078 await this . openOptionsList ( comboBoxElement ) ;
7179
7280 if ( value !== undefined ) {
@@ -90,30 +98,42 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
9098 }
9199
92100 /**
93- * This method set custom value to comboBox.
101+ * Finds combobox element and sets custom value
94102 * It applies changes by pressing Enter key. Sometimes it may lead to auto-submitting a form.
95103 *
96- * @param comboBoxSelector test subject selector
97- * @param value
104+ * @param comboBoxSelector data- test-subj selector
105+ * @param value option text
98106 */
99- async setCustom ( comboBoxSelector : string , value : string ) {
107+ public async setCustom ( comboBoxSelector : string , value : string ) : Promise < void > {
100108 log . debug ( `comboBox.setCustom, comboBoxSelector: ${ comboBoxSelector } , value: ${ value } ` ) ;
101109 const comboBoxElement = await testSubjects . find ( comboBoxSelector ) ;
102- await this . _filterOptionsList ( comboBoxElement , value ) ;
110+ await this . setFilterValue ( comboBoxElement , value ) ;
103111 await PageObjects . common . pressEnterKey ( ) ;
104112 await this . closeOptionsList ( comboBoxElement ) ;
105113 }
106114
107- async filterOptionsList ( comboBoxSelector : string , filterValue : string ) {
115+ /**
116+ * Finds combobox element and sets filter value
117+ *
118+ * @param comboBoxSelector data-test-subj selector
119+ * @param filterValue text
120+ */
121+ public async filterOptionsList ( comboBoxSelector : string , filterValue : string ) : Promise < void > {
108122 log . debug (
109123 `comboBox.filterOptionsList, comboBoxSelector: ${ comboBoxSelector } , filter: ${ filterValue } `
110124 ) ;
111125 const comboBox = await testSubjects . find ( comboBoxSelector ) ;
112- await this . _filterOptionsList ( comboBox , filterValue ) ;
126+ await this . setFilterValue ( comboBox , filterValue ) ;
113127 await this . closeOptionsList ( comboBox ) ;
114128 }
115129
116- private async _filterOptionsList (
130+ /**
131+ * Sets new filter value in specified combobox element
132+ *
133+ * @param comboBoxElement element that wraps up EuiComboBox
134+ * @param filterValue text
135+ */
136+ private async setFilterValue (
117137 comboBoxElement : WebElementWrapper ,
118138 filterValue : string
119139 ) : Promise < void > {
@@ -124,10 +144,20 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
124144 await this . waitForOptionsListLoading ( comboBoxElement ) ;
125145 }
126146
147+ /**
148+ * Waits options list to be loaded
149+ *
150+ * @param comboBoxElement element that wraps up EuiComboBox
151+ */
127152 private async waitForOptionsListLoading ( comboBoxElement : WebElementWrapper ) : Promise < void > {
128153 await comboBoxElement . waitForDeletedByCssSelector ( '.euiLoadingSpinner' ) ;
129154 }
130155
156+ /**
157+ * Returns options list as a single string
158+ *
159+ * @param comboBoxSelector data-test-subj selector
160+ */
131161 public async getOptionsList ( comboBoxSelector : string ) : Promise < string > {
132162 log . debug ( `comboBox.getOptionsList, comboBoxSelector: ${ comboBoxSelector } ` ) ;
133163 const comboBox = await testSubjects . find ( comboBoxSelector ) ;
@@ -145,37 +175,33 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
145175 return optionsText ;
146176 }
147177
178+ /**
179+ * Finds combobox element and checks if it has selected options
180+ *
181+ * @param comboBoxSelector data-test-subj selector
182+ */
148183 public async doesComboBoxHaveSelectedOptions ( comboBoxSelector : string ) : Promise < boolean > {
149184 log . debug ( `comboBox.doesComboBoxHaveSelectedOptions, comboBoxSelector: ${ comboBoxSelector } ` ) ;
150185 const comboBox = await testSubjects . find ( comboBoxSelector ) ;
151- const selectedOptions = await comboBox . findAllByClassName (
152- 'euiComboBoxPill' ,
153- WAIT_FOR_EXISTS_TIME
154- ) ;
155- return selectedOptions . length > 0 ;
186+ const $ = await comboBox . parseDomContent ( ) ;
187+ return $ ( '.euiComboBoxPill' ) . toArray ( ) . length > 0 ;
156188 }
157189
190+ /**
191+ * Returns selected options
192+ * @param comboBoxSelector data-test-subj selector
193+ */
158194 public async getComboBoxSelectedOptions ( comboBoxSelector : string ) : Promise < string [ ] > {
159195 log . debug ( `comboBox.getComboBoxSelectedOptions, comboBoxSelector: ${ comboBoxSelector } ` ) ;
160- return await retry . try ( async ( ) => {
161- const comboBox = await testSubjects . find ( comboBoxSelector ) ;
162- const selectedOptions = await comboBox . findAllByClassName (
163- 'euiComboBoxPill' ,
164- WAIT_FOR_EXISTS_TIME
165- ) ;
166- if ( selectedOptions . length === 0 ) {
167- return [ ] ;
168- }
169- return Promise . all (
170- selectedOptions . map ( async optionElement => {
171- return await optionElement . getVisibleText ( ) ;
172- } )
173- ) ;
174- } ) ;
196+ const comboBox = await testSubjects . find ( comboBoxSelector ) ;
197+ const $ = await comboBox . parseDomContent ( ) ;
198+ return $ ( '.euiComboBoxPill' )
199+ . toArray ( )
200+ . map ( option => $ ( option ) . text ( ) ) ;
175201 }
176202
177203 /**
178- * clearing value from combobox
204+ * Finds combobox element and clears value in the input field by clicking clear button
179205 *
180206 * @param comboBoxSelector data-test-subj selector
181207 */
@@ -209,9 +235,9 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
209235 }
210236
211237 /**
212- * closing option list for combobox
238+ * Closes options list
213239 *
214- * @param comboBoxElement
240+ * @param comboBoxElement element that wraps up EuiComboBox
215241 */
216242 public async closeOptionsList ( comboBoxElement : WebElementWrapper ) : Promise < void > {
217243 const isOptionsListOpen = await testSubjects . exists ( 'comboBoxOptionsList' ) ;
@@ -222,9 +248,9 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
222248 }
223249
224250 /**
225- * opened list of options for combobox
251+ * Opens options list
226252 *
227- * @param comboBoxElement
253+ * @param comboBoxElement element that wraps up EuiComboBox
228254 */
229255 public async openOptionsList ( comboBoxElement : WebElementWrapper ) : Promise < void > {
230256 const isOptionsListOpen = await testSubjects . exists ( 'comboBoxOptionsList' ) ;
@@ -237,10 +263,10 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
237263 }
238264
239265 /**
240- * check if option is already selected
266+ * Checks if specified option is already selected
241267 *
242- * @param comboBoxElement
243- * @param value
268+ * @param comboBoxElement element that wraps up EuiComboBox
269+ * @param value option text
244270 */
245271 public async isOptionSelected (
246272 comboBoxElement : WebElementWrapper ,
0 commit comments