@@ -4,38 +4,63 @@ describe("TimePicker general interaction", () => {
4
4
browser . url ( "http://localhost:8080/test-resources/pages/TimePicker.html" ) ;
5
5
6
6
it ( "tests sliders value" , ( ) => {
7
- browser . $ ( "#timepicker" ) . setProperty ( "value" , "11:12:13" ) ;
8
- browser . $ ( "#timepicker" ) . shadow$ ( "ui5-input" ) . $ ( ".ui5-timepicker-input-icon-button" ) . click ( ) ;
7
+ const timepicker = browser . $ ( "#timepicker" ) ;
8
+ const staticAreaItemClassName = browser . getStaticAreaItemClassName ( "#timepicker" ) ;
9
+ const timepickerPopover = browser . $ ( `.${ staticAreaItemClassName } ` ) . shadow$ ( "ui5-responsive-popover" ) ;
10
+
11
+ // act
12
+ timepicker . setProperty ( "value" , "11:12:13" ) ;
13
+ timepicker . shadow$ ( "ui5-input" ) . $ ( ".ui5-timepicker-input-icon-button" ) . click ( ) ;
9
14
10
- const timepickerPopover = browser . $$ ( ".ui5wc_5" ) [ 0 ] . shadow$$ ( ".ui5-timepicker-popover" ) [ 0 ] ;
11
15
const hoursSliderValue = timepickerPopover . $ ( ".ui5-timepicker-hours-wheelslider" ) . getValue ( ) ;
12
16
const minutesSliderValue = timepickerPopover . $ ( ".ui5-timepicker-minutes-wheelslider" ) . getValue ( ) ;
13
17
const secondsSliderValue = timepickerPopover . $ ( ".ui5-timepicker-seconds-wheelslider" ) . getValue ( ) ;
14
18
19
+ // assert
15
20
assert . strictEqual ( hoursSliderValue , "11" , "Hours are equal" ) ;
16
21
assert . strictEqual ( minutesSliderValue , "12" , "Minutes are equal" ) ;
17
22
assert . strictEqual ( secondsSliderValue , "13" , "Minutes are equal" ) ;
18
23
} ) ;
19
24
20
25
it ( "tests sliders submit value" , ( ) => {
21
- const timepickerPopover = browser . $$ ( ".ui5wc_5" ) [ 0 ] . shadow$$ ( ".ui5-timepicker-popover" ) [ 0 ] ;
26
+ const timepicker = browser . $ ( "#timepicker" ) ;
27
+ const staticAreaItemClassName = browser . getStaticAreaItemClassName ( "#timepicker" ) ;
28
+ const timepickerPopover = browser . $ ( `.${ staticAreaItemClassName } ` ) . shadow$ ( "ui5-responsive-popover" ) ;
22
29
23
- timepickerPopover . setProperty ( "opened" , true ) ;
30
+ // act
31
+ timepickerPopover . setProperty ( "opened" , true ) ;
24
32
timepickerPopover . $ ( ".ui5-timepicker-hours-wheelslider" ) . setProperty ( "value" , "14" ) ;
25
33
timepickerPopover . $ ( ".ui5-timepicker-minutes-wheelslider" ) . setProperty ( "value" , "15" ) ;
26
34
timepickerPopover . $ ( ".ui5-timepicker-seconds-wheelslider" ) . setProperty ( "value" , "16" ) ;
27
35
timepickerPopover . $ ( "#submit" ) . click ( ) ;
28
36
29
- const textValue = browser . $ ( "# timepicker" ) . shadow$$ ( "#ui5wc_5-inner" ) [ 0 ] . getValue ( ) ;
37
+ const textValue = timepicker . shadow$ ( "ui5-input" ) . getValue ( ) ;
30
38
assert . strictEqual ( textValue . substring ( 0 , 2 ) , "14" , "Hours are equal" ) ;
31
39
assert . strictEqual ( textValue . substring ( 3 , 5 ) , "15" , "Minutes are equal" ) ;
32
40
} ) ;
33
41
34
42
it ( "tests submit wrong value" , ( ) => {
35
- browser . $ ( "#timepicker" ) . click ( ) ;
36
- browser . $ ( "#timepicker" ) . keys ( "123123123" ) ;
37
- browser . $ ( "#timepicker" ) . keys ( "Enter" ) ;
43
+ const timepicker = browser . $ ( "#timepicker" ) ;
44
+
45
+ timepicker . click ( ) ;
46
+ timepicker . keys ( "123123123" ) ;
47
+ timepicker . keys ( "Enter" ) ;
48
+
49
+ assert . strictEqual ( timepicker . shadow$ ( "ui5-input" ) . getProperty ( "valueState" ) , "Error" , "The value state is on error" ) ;
50
+ } ) ;
51
+
52
+ it ( "tests value state" , ( ) => {
53
+ const timepicker = browser . $ ( "#timepickerEmptyValue" ) ;
54
+ const button = browser . $ ( "#testBtn" ) ;
55
+
56
+ // act
57
+ timepicker . click ( ) ;
58
+ while ( timepicker . shadow$ ( "ui5-input" ) . getProperty ( "value" ) !== "" ) {
59
+ timepicker . keys ( "Backspace" ) ;
60
+ }
61
+ button . click ( ) ;
38
62
39
- assert . strictEqual ( browser . $ ( "#timepicker" ) . shadow$ ( "ui5-input" ) . getProperty ( "valueState" ) , "Error" , "The value state is on error" ) ;
63
+ // assert
64
+ assert . strictEqual ( timepicker . shadow$ ( "ui5-input" ) . getProperty ( "valueState" ) , "None" , "The value state is None" ) ;
40
65
} ) ;
41
66
} ) ;
0 commit comments