@@ -74,6 +74,48 @@ describe("Select general interaction", () => {
74
74
assert . strictEqual ( inputResult . getProperty ( "value" ) , "5" , "Change event should have fired twice" ) ;
75
75
} ) ;
76
76
77
+ it ( "changes selection on Tab" , ( ) => {
78
+ const select = browser . $ ( "#keyboardHandling" ) ;
79
+ const EXPECTED_SELECTION_TEXT = "Banana" ;
80
+
81
+ select . click ( ) ; // Open select
82
+ select . click ( ) ; // Close select. Focus is on the select now
83
+ select . keys ( "Space" ) ;
84
+
85
+ select . keys ( "ArrowUp" ) ;
86
+ select . keys ( "Tab" ) ;
87
+ const selectText = select . shadow$ ( "ui5-label" ) ;
88
+
89
+ assert . ok ( selectText . getHTML ( false ) . indexOf ( EXPECTED_SELECTION_TEXT ) > - 1 , "Arrow Up should change selected item" ) ;
90
+
91
+ const focusedElementId = browser . execute ( ( ) => {
92
+ return document . activeElement . id ;
93
+ } ) ;
94
+
95
+ assert . strictEqual ( focusedElementId , browser . $ ( "#inputResult" ) . getAttribute ( "id" ) , "Next focusable element is focused" ) ;
96
+ } ) ;
97
+
98
+ it ( "changes selection on Shift + Tab" , ( ) => {
99
+ const select = browser . $ ( "#keyboardHandling" ) ;
100
+ const EXPECTED_SELECTION_TEXT = "Orange" ;
101
+
102
+ select . click ( ) ; // Open select
103
+ select . click ( ) ; // Close select. Focus is on the select now
104
+ select . keys ( "Space" ) ;
105
+
106
+ select . keys ( "ArrowDown" ) ;
107
+ browser . keys ( [ "Shift" , "Tab" ] ) ;
108
+ const selectText = select . shadow$ ( "ui5-label" ) ;
109
+
110
+ assert . ok ( selectText . getHTML ( false ) . indexOf ( EXPECTED_SELECTION_TEXT ) > - 1 , "Arrow Down should change selected item" ) ;
111
+
112
+ const focusedElementId = browser . execute ( ( ) => {
113
+ return document . activeElement . id ;
114
+ } ) ;
115
+
116
+ assert . strictEqual ( focusedElementId , browser . $ ( "#mySelectEsc" ) . getAttribute ( "id" ) , "Previous focusable element is focused" ) ;
117
+ } ) ;
118
+
77
119
it ( "tests selection does not cycle with ArrowDown" , ( ) => {
78
120
const select = $ ( "#selectionNotCycling" ) ;
79
121
const EXPECTED_SELECTION_TEXT = "Opt3" ;
@@ -83,7 +125,7 @@ describe("Select general interaction", () => {
83
125
assert . ok ( selectOptionText . getHTML ( false ) . indexOf ( EXPECTED_SELECTION_TEXT ) > - 1 , "Selected option text is " + EXPECTED_SELECTION_TEXT ) ;
84
126
85
127
// The last item is already selected - pressing ArrowDown should not change the focus or the selection
86
- select . keys ( "ArrowDown" ) ;
128
+ select . keys ( "ArrowDown" ) ;
87
129
assert . ok ( selectOptionText . getHTML ( false ) . indexOf ( EXPECTED_SELECTION_TEXT ) > - 1 , "Selected option text remains " + EXPECTED_SELECTION_TEXT ) ;
88
130
89
131
// Close the select not to cover other components that tests would try to click
@@ -99,7 +141,7 @@ describe("Select general interaction", () => {
99
141
assert . ok ( selectOptionText . getHTML ( false ) . indexOf ( EXPECTED_SELECTION_TEXT ) > - 1 , "Selected option text is " + EXPECTED_SELECTION_TEXT ) ;
100
142
101
143
// The last item is already selected - pressing ArrowUp should not change the focus or the selection
102
- select . keys ( "ArrowUp" ) ;
144
+ select . keys ( "ArrowUp" ) ;
103
145
assert . ok ( selectOptionText . getHTML ( false ) . indexOf ( EXPECTED_SELECTION_TEXT ) > - 1 , "Selected option text remains " + EXPECTED_SELECTION_TEXT ) ;
104
146
105
147
// Close the select not to cover other components that tests would try to click
@@ -221,7 +263,7 @@ describe("Select general interaction", () => {
221
263
select . keys ( "Escape" ) ;
222
264
223
265
select . click ( ) ;
224
- const staticAreaItemClassName = browser . getStaticAreaItemClassName ( "#mySelect" ) ;
266
+ const staticAreaItemClassName = browser . getStaticAreaItemClassName ( "#mySelect" ) ;
225
267
const firstItem = browser . $ ( `.${ staticAreaItemClassName } ` ) . shadow$ ( "ui5-li:first-child" ) ;
226
268
227
269
firstItem . click ( ) ;
@@ -245,7 +287,7 @@ describe("Select general interaction", () => {
245
287
assert . ok ( selectText . getHTML ( false ) . indexOf ( EXPECTED_SELECTION_TEXT ) !== - 1 , "Select label is correct." ) ;
246
288
247
289
// verify that ESC does not interfere when the picker is closed
248
- select . keys ( "Escape" ) ;
290
+ select . keys ( "Escape" ) ;
249
291
select . click ( ) ;
250
292
thirdItem . click ( ) ;
251
293
0 commit comments