@@ -7,44 +7,44 @@ describe('scroll blocking', () => {
7
7
afterEach ( ( ) => clickOn ( 'disable' ) ) ;
8
8
9
9
it ( 'should not be able to scroll programmatically along the x axis' , async ( ) => {
10
- scrollPage ( 0 , 100 ) ;
10
+ await scrollPage ( 0 , 100 ) ;
11
11
expect ( ( await getScrollPosition ( ) ) . y ) . toBe ( 100 , 'Expected the page to be scrollable.' ) ;
12
12
13
- clickOn ( 'enable' ) ;
14
- scrollPage ( 0 , 200 ) ;
13
+ await clickOn ( 'enable' ) ;
14
+ await scrollPage ( 0 , 200 ) ;
15
15
expect ( ( await getScrollPosition ( ) ) . y ) . toBe ( 100 , 'Expected the page not to be scrollable.' ) ;
16
16
17
- clickOn ( 'disable' ) ;
18
- scrollPage ( 0 , 300 ) ;
17
+ await clickOn ( 'disable' ) ;
18
+ await scrollPage ( 0 , 300 ) ;
19
19
expect ( ( await getScrollPosition ( ) ) . y ) . toBe ( 300 , 'Exected page to be scrollable again.' ) ;
20
20
} ) ;
21
21
22
22
it ( 'should not be able to scroll programmatically along the y axis' , async ( ) => {
23
- scrollPage ( 100 , 0 ) ;
23
+ await scrollPage ( 100 , 0 ) ;
24
24
expect ( ( await getScrollPosition ( ) ) . x ) . toBe ( 100 , 'Expected the page to be scrollable.' ) ;
25
25
26
- clickOn ( 'enable' ) ;
27
- scrollPage ( 200 , 0 ) ;
26
+ await clickOn ( 'enable' ) ;
27
+ await scrollPage ( 200 , 0 ) ;
28
28
expect ( ( await getScrollPosition ( ) ) . x ) . toBe ( 100 , 'Expected the page not to be scrollable.' ) ;
29
29
30
- clickOn ( 'disable' ) ;
31
- scrollPage ( 300 , 0 ) ;
30
+ await clickOn ( 'disable' ) ;
31
+ await scrollPage ( 300 , 0 ) ;
32
32
expect ( ( await getScrollPosition ( ) ) . x ) . toBe ( 300 , 'Exected page to be scrollable again.' ) ;
33
33
} ) ;
34
34
35
35
it ( 'should not be able to scroll via the keyboard along the y axis' , async ( ) => {
36
36
const body = element ( by . tagName ( 'body' ) ) ;
37
37
38
- scrollPage ( 0 , 100 ) ;
38
+ await scrollPage ( 0 , 100 ) ;
39
39
expect ( ( await getScrollPosition ( ) ) . y ) . toBe ( 100 , 'Expected the page to be scrollable.' ) ;
40
40
41
- clickOn ( 'enable' ) ;
41
+ await clickOn ( 'enable' ) ;
42
42
await body . sendKeys ( Key . ARROW_DOWN ) ;
43
43
await body . sendKeys ( Key . ARROW_DOWN ) ;
44
44
await body . sendKeys ( Key . ARROW_DOWN ) ;
45
45
expect ( ( await getScrollPosition ( ) ) . y ) . toBe ( 100 , 'Expected the page not to be scrollable.' ) ;
46
46
47
- clickOn ( 'disable' ) ;
47
+ await clickOn ( 'disable' ) ;
48
48
await body . sendKeys ( Key . ARROW_DOWN ) ;
49
49
await body . sendKeys ( Key . ARROW_DOWN ) ;
50
50
await body . sendKeys ( Key . ARROW_DOWN ) ;
@@ -55,16 +55,16 @@ describe('scroll blocking', () => {
55
55
it ( 'should not be able to scroll via the keyboard along the x axis' , async ( ) => {
56
56
const body = element ( by . tagName ( 'body' ) ) ;
57
57
58
- scrollPage ( 100 , 0 ) ;
58
+ await scrollPage ( 100 , 0 ) ;
59
59
expect ( ( await getScrollPosition ( ) ) . x ) . toBe ( 100 , 'Expected the page to be scrollable.' ) ;
60
60
61
- clickOn ( 'enable' ) ;
61
+ await clickOn ( 'enable' ) ;
62
62
await body . sendKeys ( Key . ARROW_RIGHT ) ;
63
63
await body . sendKeys ( Key . ARROW_RIGHT ) ;
64
64
await body . sendKeys ( Key . ARROW_RIGHT ) ;
65
65
expect ( ( await getScrollPosition ( ) ) . x ) . toBe ( 100 , 'Expected the page not to be scrollable.' ) ;
66
66
67
- clickOn ( 'disable' ) ;
67
+ await clickOn ( 'disable' ) ;
68
68
await body . sendKeys ( Key . ARROW_RIGHT ) ;
69
69
await body . sendKeys ( Key . ARROW_RIGHT ) ;
70
70
await body . sendKeys ( Key . ARROW_RIGHT ) ;
@@ -76,40 +76,42 @@ describe('scroll blocking', () => {
76
76
async ( ) => {
77
77
const scroller = element ( by . id ( 'scroller' ) ) ;
78
78
79
- browser . executeScript ( `document.getElementById('scroller').scrollTop = 200;` ) ;
80
- scrollPage ( 0 , 100 ) ;
79
+ await browser . executeScript ( `document.getElementById('scroller').scrollTop = 200;` ) ;
80
+ await scrollPage ( 0 , 100 ) ;
81
81
expect ( ( await getScrollPosition ( ) ) . y ) . toBe ( 100 , 'Expected the page to be scrollable.' ) ;
82
82
83
- clickOn ( 'enable' ) ;
84
- scroller . sendKeys ( Key . ARROW_DOWN ) ;
85
- scroller . sendKeys ( Key . ARROW_DOWN ) ;
86
- scroller . sendKeys ( Key . ARROW_DOWN ) ;
83
+ await clickOn ( 'enable' ) ;
84
+ await scroller . sendKeys ( Key . ARROW_DOWN ) ;
85
+ await scroller . sendKeys ( Key . ARROW_DOWN ) ;
86
+ await scroller . sendKeys ( Key . ARROW_DOWN ) ;
87
+
87
88
expect ( ( await getScrollPosition ( ) ) . y ) . toBe ( 100 , 'Expected the page not to have scrolled.' ) ;
88
89
} ) ;
89
90
90
91
it ( 'should not be able to scroll the page after reaching the end of an element along the x axis' ,
91
92
async ( ) => {
92
93
const scroller = element ( by . id ( 'scroller' ) ) ;
93
94
94
- browser . executeScript ( `document.getElementById('scroller').scrollLeft = 200;` ) ;
95
- scrollPage ( 100 , 0 ) ;
95
+ await browser . executeScript ( `document.getElementById('scroller').scrollLeft = 200;` ) ;
96
+ await scrollPage ( 100 , 0 ) ;
96
97
expect ( ( await getScrollPosition ( ) ) . x ) . toBe ( 100 , 'Expected the page to be scrollable.' ) ;
97
98
98
- clickOn ( 'enable' ) ;
99
- scroller . sendKeys ( Key . ARROW_RIGHT ) ;
100
- scroller . sendKeys ( Key . ARROW_RIGHT ) ;
101
- scroller . sendKeys ( Key . ARROW_RIGHT ) ;
99
+ await clickOn ( 'enable' ) ;
100
+ await scroller . sendKeys ( Key . ARROW_RIGHT ) ;
101
+ await scroller . sendKeys ( Key . ARROW_RIGHT ) ;
102
+ await scroller . sendKeys ( Key . ARROW_RIGHT ) ;
103
+
102
104
expect ( ( await getScrollPosition ( ) ) . x ) . toBe ( 100 , 'Expected the page not to have scrolled.' ) ;
103
105
} ) ;
104
106
} ) ;
105
107
106
108
// Clicks on a button programmatically. Note that we can't use Protractor's `.click`, because
107
109
// it performs a real click, which will scroll the button into view.
108
- function clickOn ( id : string ) {
109
- browser . executeScript ( `document.getElementById('${ id } ').click()` ) ;
110
+ async function clickOn ( id : string ) {
111
+ await browser . executeScript ( `document.getElementById('${ id } ').click()` ) ;
110
112
}
111
113
112
114
// Scrolls the page to the specified coordinates.
113
- function scrollPage ( x : number , y : number ) {
114
- return browser . executeScript ( `window.scrollTo(${ x } , ${ y } );` ) ;
115
+ async function scrollPage ( x : number , y : number ) {
116
+ await browser . executeScript ( `window.scrollTo(${ x } , ${ y } );` ) ;
115
117
}
0 commit comments