@@ -6,23 +6,27 @@ describe('ImageLoader Lib E2E Tests', function () {
6
6
7
7
const browserWaitTimeout = 10000 ;
8
8
9
- beforeEach ( ( ) => page = new AppPage ( ) ) ;
10
-
11
- beforeEach ( ( ) => page . navigateTo ( ) ) ;
12
-
13
- beforeEach ( ( ) => page . scrollTo ( ) ) ;
9
+ beforeEach ( ( ) => {
10
+ page = new AppPage ( ) ;
11
+ page . navigateTo ( ) ;
12
+ page . scrollTo ( ) ;
13
+ } ) ;
14
14
15
15
afterEach ( ( ) => {
16
- browser . manage ( ) . logs ( ) . get ( 'browser' ) . then ( ( browserLog : any [ ] ) => {
17
- expect ( browserLog ) . toEqual ( [ ] ) ;
18
- } ) ;
16
+ // ensure no errors appear in console
17
+ browser . manage ( )
18
+ . logs ( )
19
+ . get ( 'browser' )
20
+ . then ( ( browserLog ) => {
21
+ expect ( browserLog ) . toEqual ( [ ] ) ;
22
+ } ) ;
19
23
} ) ;
20
24
21
25
describe ( 'placeholder image' , ( ) => {
22
- beforeEach ( ( ) => page . setWindowSize ( 300 , 580 ) ) ;
26
+ beforeEach ( ( ) => page . setWindowSize ( 400 , 580 ) ) ;
23
27
24
28
it ( 'should load placeholder image' , ( ) => {
25
- expect ( page . getImageBottomElement ( ) . getAttribute ( 'src' ) ) . toEqual ( 'http://via.placeholder.com/35x15 ?text=placeholder' ) ;
29
+ expect ( page . getImageBottomElement ( ) . getAttribute ( 'src' ) ) . toEqual ( 'http://via.placeholder.com/40x40 ?text=placeholder' ) ;
26
30
} ) ;
27
31
28
32
it ( 'should update placeholder loaded boolean on init' , ( ) => {
@@ -31,39 +35,37 @@ describe('ImageLoader Lib E2E Tests', function () {
31
35
} ) ;
32
36
33
37
describe ( 'inviewport image on load' , ( ) => {
34
- beforeEach ( ( ) => page . setWindowSize ( 300 , 580 ) ) ;
38
+ beforeEach ( ( ) => page . setWindowSize ( 400 , 580 ) ) ;
35
39
36
40
it ( 'should load full res image if image is in viewport on page load' , ( ) => {
37
-
38
- page . setWindowSize ( 300 , 580 ) ;
39
41
browser . wait ( ( ) => page . getLoadedImageTopElement ( ) ) ;
40
42
41
43
const imageLoaderCompClass = page . getImageTopLoaderComp ( ) . getAttribute ( 'class' ) ;
42
44
const imgSrc = page . getImageTopElement ( ) . getAttribute ( 'srcset' ) ;
43
45
expect ( imageLoaderCompClass ) . toContain ( 'sn-image-loaded' ) ;
44
- expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/150x350 ?text=xs+1x 1x, http://via.placeholder.com/300x700 ?text=xs+2x 2x' ) ;
46
+ expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/400x400 ?text=xs+1x 1x, http://via.placeholder.com/800x800 ?text=xs+2x 2x' ) ;
45
47
46
48
47
49
} ) ;
48
50
49
51
} ) ;
50
52
51
53
describe ( 'lazy load image' , ( ) => {
52
- beforeEach ( ( ) => page . setWindowSize ( 300 , 580 ) ) ;
54
+ beforeEach ( ( ) => page . setWindowSize ( 400 , 580 ) ) ;
53
55
54
56
it ( 'should load image when scrolled into viewport' , ( ) => {
55
57
let imageLoaderCompClass = page . getImageBottomLoaderComp ( ) . getAttribute ( 'class' ) ;
56
58
let imgSrc = page . getImageBottomElement ( ) . getAttribute ( 'src' ) ;
57
59
expect ( imageLoaderCompClass ) . toContain ( 'sn-image-not-loaded' ) ;
58
- expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/35x15 ?text=placeholder' ) ;
60
+ expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/40x40 ?text=placeholder' ) ;
59
61
60
62
page . scrollTo ( 0 , 580 * 2 ) ;
61
63
browser . wait ( ( ) => page . getLoadedImageBottomElement ( ) ) ;
62
64
63
65
imageLoaderCompClass = page . getImageBottomLoaderComp ( ) . getAttribute ( 'class' ) ;
64
66
imgSrc = page . getImageBottomElement ( ) . getAttribute ( 'srcset' ) ;
65
67
expect ( imageLoaderCompClass ) . toContain ( 'sn-image-loaded' ) ;
66
- expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/150x350 ?text=xs+1x 1x, http://via.placeholder.com/300x700 ?text=xs+2x 2x' ) ;
68
+ expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/400x400 ?text=xs+1x 1x, http://via.placeholder.com/800x800 ?text=xs+2x 2x' ) ;
67
69
68
70
} ) ;
69
71
@@ -80,37 +82,37 @@ describe('ImageLoader Lib E2E Tests', function () {
80
82
describe ( 'responsive image' , ( ) => {
81
83
82
84
it ( 'should load correct image for "xs" device size' , ( ) => {
83
- page . setWindowSize ( 300 , 580 ) ;
85
+ page . setWindowSize ( 400 , 580 ) ;
84
86
page . scrollTo ( 0 , 580 * 2 ) ;
85
87
browser . wait ( ( ) => page . getLoadedImageBottomElement ( ) ) ;
86
88
const imageLoaderCompClass = page . getImageBottomLoaderComp ( ) . getAttribute ( 'class' ) ;
87
89
const imgSrc = page . getImageBottomElement ( ) . getAttribute ( 'srcset' ) ;
88
90
expect ( imageLoaderCompClass ) . toContain ( 'sn-image-loaded' ) ;
89
- expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/150x350 ?text=xs+1x 1x, http://via.placeholder.com/300x700 ?text=xs+2x 2x' ) ;
91
+ expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/400x400 ?text=xs+1x 1x, http://via.placeholder.com/800x800 ?text=xs+2x 2x' ) ;
90
92
} ) ;
91
93
92
94
it ( 'should load correct image for "md" device size' , ( ) => {
93
95
page . setWindowSize ( 768 , 580 ) ;
94
- page . scrollTo ( 0 , 580 * 2 ) ;
96
+ page . scrollTo ( 0 , 580 * 2.5 ) ;
95
97
browser . wait ( ( ) => page . getLoadedImageBottomElement ( ) ) ;
96
98
97
99
const imgSrc = page . getImageBottomElement ( ) . getAttribute ( 'srcset' ) ;
98
- expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/350x250 ?text=md+1x 1x, http://via.placeholder.com/700x500 ?text=md+2x 2x' ) ;
100
+ expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/768x400 ?text=md+1x 1x, http://via.placeholder.com/1536x800 ?text=md+2x 2x' ) ;
99
101
} ) ;
100
102
101
103
it ( 'should load correct image for "lg" device size' , ( ) => {
102
104
page . setWindowSize ( 1024 , 580 ) ;
103
- page . scrollTo ( 0 , 580 * 2 ) ;
105
+ page . scrollTo ( 0 , 580 * 2.5 ) ;
104
106
browser . wait ( ( ) => page . getLoadedImageBottomElement ( ) ) ;
105
107
106
108
const imgSrc = page . getImageBottomElement ( ) . getAttribute ( 'srcset' ) ;
107
- expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/700x400 ?text=lg+1x 1x, http://via.placeholder.com/1400x800 ?text=lg+2x 2x' ) ;
109
+ expect ( imgSrc ) . toEqual ( 'http://via.placeholder.com/1024x400 ?text=lg+1x 1x, http://via.placeholder.com/2048x800 ?text=lg+2x 2x' ) ;
108
110
} ) ;
109
111
110
112
it ( 'should update image loaded event count on window resize when image in viewport' , ( ) => {
111
113
expect ( page . getBottomFullResCountElement ( ) . getText ( ) ) . toEqual ( '0' ) ;
112
114
113
- page . setWindowSize ( 320 , 580 ) ;
115
+ page . setWindowSize ( 400 , 580 ) ;
114
116
page . scrollTo ( 0 , 580 * 3 ) ;
115
117
browser . wait ( ( ) => page . getLoadedImageBottomElement ( ) ) ;
116
118
expect ( page . getBottomFullResCountElement ( ) . getText ( ) ) . toEqual ( '1' ) ;
0 commit comments