@@ -72,8 +72,11 @@ declare global {
72
72
* __Note:__ The select popover must be visible, otherwise it can lead to unwanted side effects.
73
73
*
74
74
* @param text text of the ui5-option that should be clicked
75
- * @example cy.get('[ui5-select]').clickUi5SelectOptionByText('Option2');
75
+ * @param options ClickOptions
76
76
*
77
+ * @deprecated : This command is deprecated. Please use `clickDropdownMenuItemByText` instead.
78
+ *
79
+ * @example cy.get('[ui5-select]').clickUi5SelectOptionByText('Option2');*
77
80
*/
78
81
clickUi5SelectOptionByText ( text : string , options ?: Partial < ClickOptions > ) : Chainable < Element > ;
79
82
@@ -82,9 +85,39 @@ declare global {
82
85
*
83
86
* __Note:__ The select popover must be visible, otherwise it can lead to unwanted side effects.
84
87
*
88
+ * @deprecated : This command is deprecated. Please use `clickDropdownMenuItem` instead.
89
+ *
85
90
* @example cy.get('[ui5-option]').clickUi5SelectOption();
86
91
*/
87
92
clickUi5SelectOption ( options ?: Partial < ClickOptions > ) : Chainable < Element > ;
93
+
94
+ /**
95
+ * Click on an option of "select-like" components by text. Currently supported components are `ui5-select`, `ui5-combobox` and `ui5-multi-combobox`.
96
+ *
97
+ * __Note:__ The popover must be visible, otherwise it can lead to unwanted side effects.
98
+ *
99
+ * @param text text of the item inside the popover that should be clicked
100
+ * @param options Cypress.ClickOptions
101
+ * @example cy.get('[ui5-select]').clickDropdownMenuItemByText('Option2');
102
+ *
103
+ */
104
+ clickDropdownMenuItemByText ( text : string , options ?: Partial < ClickOptions > ) : Chainable < Element > ;
105
+
106
+ /**
107
+ * Click on a chained option of "select-like" components. Currently supported components are `ui5-option`, `ui5-mcb-item` and `ui5-cb-item` (since v1.24.3 of `@ui5/webcomponents`).
108
+ *
109
+ * __Note:__ The popover must be visible, otherwise it can lead to unwanted side effects.
110
+ *
111
+ * @example cy.get('[ui5-option]').clickDropdownMenuItem();
112
+ */
113
+ clickDropdownMenuItem ( options ?: Partial < ClickOptions > ) : Chainable < Element > ;
114
+
115
+ /**
116
+ * Click on the open button in "select-like" components to open the popover. Currently supported components are `ui5-select`, `ui5-combobox` and `ui5-multi-combobox`.
117
+ *
118
+ * @example cy.get('[ui5-select]').openDropDownByClick();
119
+ */
120
+ openDropDownByClick ( options ?: Partial < ClickOptions > ) : Chainable < Element > ;
88
121
}
89
122
}
90
123
}
@@ -155,4 +188,40 @@ Cypress.Commands.add('clickUi5SelectOption', { prevSubject: 'element' }, (subjec
155
188
} ) ;
156
189
} ) ;
157
190
191
+ Cypress . Commands . add ( 'clickDropdownMenuItemByText' , { prevSubject : 'element' } , ( subject , text , options = { } ) => {
192
+ cy . wrap ( subject ) . then ( async ( $dropdown ) => {
193
+ // @ts -expect-error: ui5-webcomponent types are not bundled in
194
+ const staticArea = await $dropdown . get ( 0 ) . getStaticAreaItemDomRef ( ) ;
195
+ cy . wrap ( staticArea ) . find ( '[ui5-responsive-popover][open]' ) . should ( 'be.visible' ) ;
196
+ // necessary as otherwise focusing the ui5-li is flaky
197
+ cy . wait ( 300 ) ;
198
+ cy . wrap ( staticArea )
199
+ . contains ( text )
200
+ . then ( async ( $li ) => {
201
+ await $li . get ( 0 ) . focus ( ) ;
202
+ cy . wrap ( $li )
203
+ . find ( 'li' )
204
+ . click ( { force : true , ...options } ) ;
205
+ } ) ;
206
+ } ) ;
207
+ } ) ;
208
+
209
+ Cypress . Commands . add ( 'clickDropdownMenuItem' , { prevSubject : 'element' } , ( subject , options = { } ) => {
210
+ cy . wrap ( subject ) . then ( ( $option ) => {
211
+ // @ts -expect-error: ui5-webcomponent types are not bundled in
212
+ const domRef = $option . get ( 0 ) . getDomRef ( ) ;
213
+ cy . wrap ( domRef )
214
+ . find ( 'li' )
215
+ . click ( { force : true , ...options } ) ;
216
+ } ) ;
217
+ } ) ;
218
+
219
+ Cypress . Commands . add ( 'openDropDownByClick' , { prevSubject : 'element' } , ( subject , options = { } ) => {
220
+ if ( subject . get ( 0 ) . hasAttribute ( 'ui5-multi-combobox' ) ) {
221
+ // mcb needs a lot of calculation time to make the popover available
222
+ cy . wait ( 500 ) ;
223
+ }
224
+ cy . wrap ( subject ) . shadow ( ) . find ( '[input-icon]' ) . click ( options ) ;
225
+ } ) ;
226
+
158
227
export { } ;
0 commit comments