@@ -21,6 +21,55 @@ describe("Toolbar general interaction", () => {
21
21
. should ( "have.attr" , "value-state" , "Critical" ) ;
22
22
} ) ;
23
23
24
+ it ( "Should render the select with the correct attributes inside the popover" , ( ) => {
25
+ cy . mount (
26
+ < div style = "width: 250px;" >
27
+ < Toolbar id = "otb_e" >
28
+ < ToolbarSelect value-state = "Critical" accessible-name = "Add" accessible-name-ref = "title" id = "toolbar-select" >
29
+ < ToolbarSelectOption > 1</ ToolbarSelectOption >
30
+ < ToolbarSelectOption selected > 2</ ToolbarSelectOption >
31
+ < ToolbarSelectOption > 3</ ToolbarSelectOption >
32
+ </ ToolbarSelect >
33
+
34
+
35
+ < ToolbarSelect disabled class = "custom-class" >
36
+ < ToolbarSelectOption > 1</ ToolbarSelectOption >
37
+ < ToolbarSelectOption selected > 2</ ToolbarSelectOption >
38
+ < ToolbarSelectOption > 3</ ToolbarSelectOption >
39
+ </ ToolbarSelect >
40
+ </ Toolbar >
41
+ </ div >
42
+ ) ;
43
+
44
+ const otb = cy . get ( "#otb_e" ) . as ( "otb" ) ;
45
+
46
+ cy . get ( "@otb" )
47
+ . shadow ( )
48
+ . find ( ".ui5-tb-overflow-btn" )
49
+ . click ( ) ;
50
+ const overflowButton = otb . shadow ( ) . find ( ".ui5-tb-overflow-btn" ) ;
51
+
52
+ cy . get ( "@otb" )
53
+ . shadow ( )
54
+ . find ( ".ui5-overflow-popover" ) . as ( "popover" )
55
+ . should ( "have.attr" , "open" , "open" ) ;
56
+ overflowButton . click ( ) ;
57
+ cy . wait ( 500 ) ;
58
+
59
+ cy . get ( "@otb" )
60
+ . find ( "#toolbar-select" )
61
+ . should ( "have.attr" , "value-state" , "Critical" )
62
+
63
+ . should ( "have.attr" , "accessible-name" , "Add" )
64
+
65
+ . should ( "have.attr" , "accessible-name-ref" , "title" )
66
+
67
+ cy . get ( "@otb" )
68
+ . find ( ".custom-class" )
69
+ . should ( "have.attr" , "disabled" , "disabled" ) ;
70
+
71
+ } ) ;
72
+
24
73
it ( "Should render the select with disabled property correctly" , ( ) => {
25
74
cy . mount (
26
75
< Toolbar >
@@ -42,7 +91,7 @@ describe("Toolbar general interaction", () => {
42
91
it ( "Should render accessible name correctly" , ( ) => {
43
92
cy . mount (
44
93
< Toolbar >
45
- < ToolbarSelect
94
+ < ToolbarSelect
46
95
accessibleName = "Add"
47
96
accessibleNameRef = "title"
48
97
>
@@ -110,4 +159,104 @@ describe("Toolbar general interaction", () => {
110
159
111
160
cy . get ( "@changeStub" ) . should ( "have.been.called" ) ;
112
161
} ) ;
162
+
163
+ describe ( "value and label properties" , ( ) => {
164
+ it ( "Should verify the initial value of the ToolbarSelect" , ( ) => {
165
+ // Mount the Toolbar with a ToolbarSelect component
166
+ cy . mount (
167
+ < Toolbar >
168
+ < ToolbarSelect value = "Option 2" >
169
+ < span slot = "label" > Select an Option:</ span >
170
+ < ToolbarSelectOption > Option 1</ ToolbarSelectOption >
171
+ < ToolbarSelectOption > Option 2</ ToolbarSelectOption >
172
+ < ToolbarSelectOption > Option 3</ ToolbarSelectOption >
173
+ </ ToolbarSelect >
174
+ </ Toolbar >
175
+ ) ;
176
+
177
+ // Verify the initial value of the ToolbarSelect
178
+ cy . get ( "ui5-select" , { includeShadowDom : true } )
179
+ . should ( "have.attr" , "value" , "Option 2" ) ;
180
+ } ) ;
181
+
182
+ it ( "Should verify the label slot content" , ( ) => {
183
+ // Mount the Toolbar with a ToolbarSelect component
184
+ cy . mount (
185
+ < Toolbar >
186
+ < ToolbarSelect value = "Option 2" >
187
+ < span slot = "label" > Select an Option:</ span >
188
+ < ToolbarSelectOption > Option 1</ ToolbarSelectOption >
189
+ < ToolbarSelectOption > Option 2</ ToolbarSelectOption >
190
+ < ToolbarSelectOption > Option 3</ ToolbarSelectOption >
191
+ </ ToolbarSelect >
192
+ </ Toolbar >
193
+ ) ;
194
+
195
+ // Verify the label slot content
196
+ cy . get ( "ui5-toolbar-select" )
197
+ . find ( "span[slot='label']" )
198
+ . should ( "contain.text" , "Select an Option:" ) ;
199
+ } ) ;
200
+
201
+ it ( "Should change the value and update the selection" , ( ) => {
202
+ // Mount the Toolbar with a ToolbarSelect component
203
+ cy . mount (
204
+ < Toolbar >
205
+ < ToolbarSelect value = "Option 2" >
206
+ < ToolbarSelectOption > Option 1</ ToolbarSelectOption >
207
+ < ToolbarSelectOption > Option 2</ ToolbarSelectOption >
208
+ < ToolbarSelectOption > Option 3</ ToolbarSelectOption >
209
+ </ ToolbarSelect >
210
+ </ Toolbar >
211
+ ) ;
212
+
213
+ // Change the value of the ToolbarSelect
214
+ cy . get ( "ui5-select" , { includeShadowDom : true } )
215
+ . realClick ( )
216
+ . find ( "ui5-option" )
217
+ . contains ( "Option 3" )
218
+ . realClick ( ) ;
219
+
220
+ // Verify the updated value of the ToolbarSelect
221
+ cy . get ( "ui5-select" , { includeShadowDom : true } )
222
+ . should ( "have.attr" , "value" , "Option 3" ) ;
223
+ } ) ;
224
+
225
+ it ( "Should handle a value with no corresponding option" , ( ) => {
226
+ // Mount the Toolbar with a ToolbarSelect component
227
+ cy . mount (
228
+ < Toolbar >
229
+ < ToolbarSelect value = "NonExistentOption" >
230
+ < ToolbarSelectOption > Option 1</ ToolbarSelectOption >
231
+ < ToolbarSelectOption > Option 2</ ToolbarSelectOption >
232
+ < ToolbarSelectOption > Option 3</ ToolbarSelectOption >
233
+ </ ToolbarSelect >
234
+ </ Toolbar >
235
+ ) ;
236
+
237
+ // Verify that no option is selected when the value does not match any option
238
+ cy . get ( "ui5-select" , { includeShadowDom : true } )
239
+ . should ( "have.attr" , "value" , "NonExistentOption" ) ;
240
+ } ) ;
241
+
242
+ it ( "Should update the value programmatically and reflect the selection" , ( ) => {
243
+ // Mount the Toolbar with a ToolbarSelect component
244
+ cy . mount (
245
+ < Toolbar >
246
+ < ToolbarSelect value = "Option 1" >
247
+ < ToolbarSelectOption > Option 1</ ToolbarSelectOption >
248
+ < ToolbarSelectOption > Option 2</ ToolbarSelectOption >
249
+ < ToolbarSelectOption > Option 3</ ToolbarSelectOption >
250
+ </ ToolbarSelect >
251
+ </ Toolbar >
252
+ ) ;
253
+
254
+ // Update the value programmatically
255
+ cy . get ( "ui5-toolbar-select" ) . invoke ( "attr" , "value" , "Option 3" ) ;
256
+
257
+ // Verify the updated value and selection
258
+ cy . get ( "ui5-select" , { includeShadowDom : true } )
259
+ . should ( "have.attr" , "value" , "Option 3" ) ;
260
+ } ) ;
261
+ } ) ;
113
262
} ) ;
0 commit comments