@@ -75,6 +75,43 @@ describe("Calendar general interaction", () => {
75
75
assert . ok ( new Date ( parseInt ( focusedItemTimestamp ) * 1000 ) . getUTCFullYear ( ) === 1997 , "The focused year is 1997" ) ;
76
76
} ) ;
77
77
78
+ it ( "Calendar focuses the selected month when monthpicker is opened with space" , ( ) => {
79
+ browser . url ( `http://localhost:${ PORT } /test-resources/pages/Calendar.html` ) ;
80
+ const calendar = browser . $ ( "#calendar1" ) ;
81
+ const dayPicker = calendar . shadow$ ( "ui5-daypicker" ) ;
82
+ const monthPicker = calendar . shadow$ ( "ui5-monthpicker" ) ;
83
+ const currentDayItem = dayPicker . shadow$ ( `div[data-sap-timestamp="974851200"]` ) ;
84
+ calendar . setAttribute ( "timestamp" , new Date ( Date . UTC ( 2000 , 10 , 22 , 0 , 0 , 0 ) ) . valueOf ( ) / 1000 ) ;
85
+
86
+ currentDayItem . click ( ) ;
87
+ browser . keys ( "Tab" ) ;
88
+ browser . keys ( "Space" ) ;
89
+
90
+ const focusedItemTimestamp = monthPicker . shadow$ ( `[tabindex="0"]` ) . getAttribute ( "data-sap-timestamp" ) ;
91
+ const isHidden = monthPicker . getAttribute ( "hidden" ) ;
92
+ assert . ok ( ! isHidden , "The monthpicker is present" ) ;
93
+ assert . ok ( new Date ( parseInt ( focusedItemTimestamp ) * 1000 ) . getUTCMonth ( ) === 10 , "The focused month is November" ) ;
94
+ } ) ;
95
+
96
+ it ( "Calendar focuses the selected year when yearpicker is opened with space" , ( ) => {
97
+ browser . url ( `http://localhost:${ PORT } /test-resources/pages/Calendar.html` ) ;
98
+ const calendar = browser . $ ( "#calendar1" ) ;
99
+ const dayPicker = calendar . shadow$ ( "ui5-daypicker" ) ;
100
+ const yearPicker = calendar . shadow$ ( "ui5-yearpicker" ) ;
101
+ const currentDayItem = dayPicker . shadow$ ( `div[data-sap-timestamp="974851200"]` ) ;
102
+ calendar . setAttribute ( "timestamp" , new Date ( Date . UTC ( 2000 , 10 , 22 , 0 , 0 , 0 ) ) . valueOf ( ) / 1000 ) ;
103
+
104
+ currentDayItem . click ( ) ;
105
+ browser . keys ( "Tab" ) ;
106
+ browser . keys ( "Tab" ) ;
107
+ browser . keys ( "Space" ) ;
108
+
109
+ const isHidden = yearPicker . getAttribute ( "hidden" ) ;
110
+ assert . ok ( ! isHidden , "The yearpicker is present" ) ;
111
+ const focusedItemTimestamp = yearPicker . shadow$ ( `[tabindex="0"]` ) . getAttribute ( "data-sap-timestamp" ) ;
112
+ assert . ok ( new Date ( parseInt ( focusedItemTimestamp ) * 1000 ) . getUTCFullYear ( ) === 2000 , "The focused year is 2000" ) ;
113
+ } ) ;
114
+
78
115
it ( "Calendar doesn't mark year as selected when there are no selected dates" , ( ) => {
79
116
browser . url ( `http://localhost:${ PORT } /test-resources/pages/Calendar.html` ) ;
80
117
const calendar = browser . $ ( "#calendar1" ) ;
0 commit comments