Skip to content

Commit 39be889

Browse files
test(end to end): Added function to wait for loading of specific image by srcSet attribute.
Prevents tests from running before the next image is loaded.
1 parent 454aa09 commit 39be889

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

e2e/app.e2e-spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,19 @@ describe('ImageLoader Lib E2E Tests', function () {
7878

7979
page.setWindowSize(768, 580)
8080
.then(() => {
81-
browser.wait(() => page.getLoadedImageElement());
81+
browser.wait(() => page.getLoadedImageElementBySrcSet(
82+
'http://via.placeholder.com/350x250?text=md+1x 1x, http://via.placeholder.com/700x500?text=md+2x 2x'
83+
), 5000);
8284
});
8385

8486
imgSrc = page.getImageElement().getAttribute('srcset');
8587
expect(imgSrc).toEqual('http://via.placeholder.com/350x250?text=md+1x 1x, http://via.placeholder.com/700x500?text=md+2x 2x');
8688

8789
page.setWindowSize(1024, 580)
8890
.then(() => {
89-
browser.wait(() => page.getLoadedImageElement());
91+
browser.wait(() => page.getLoadedImageElementBySrcSet(
92+
'http://via.placeholder.com/700x400?text=lg+1x 1x, http://via.placeholder.com/1400x800?text=lg+2x 2x'
93+
), 5000);
9094
});
9195

9296
imgSrc = page.getImageElement().getAttribute('srcset');
@@ -105,13 +109,17 @@ describe('ImageLoader Lib E2E Tests', function () {
105109

106110
page.setWindowSize(768, 580)
107111
.then(() => {
108-
browser.wait(() => page.getLoadedImageElement());
112+
browser.wait(() => page.getLoadedImageElementBySrcSet(
113+
'http://via.placeholder.com/350x250?text=md+1x 1x, http://via.placeholder.com/700x500?text=md+2x 2x'
114+
), 5000);
109115
});
110116
expect(page.getFullResCountElement().getText()).toEqual('2');
111117

112118
page.setWindowSize(1024, 580)
113119
.then(() => {
114-
browser.wait(() => page.getLoadedImageElement());
120+
browser.wait(() => page.getLoadedImageElementBySrcSet(
121+
'http://via.placeholder.com/700x400?text=lg+1x 1x, http://via.placeholder.com/1400x800?text=lg+2x 2x'
122+
), 5000);
115123
});
116124
expect(page.getFullResCountElement().getText()).toEqual('3');
117125
});

e2e/app.po.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export class AppPage {
2525
return element(by.css('.sn-image-loaded')).isPresent();
2626
}
2727

28+
getLoadedImageElementBySrcSet(srcSet) {
29+
return element(by.css(`img[srcSet="${srcSet}"]`)).isPresent();
30+
}
31+
2832
getplaceholderBooleanElement() {
2933
return element(by.css('.placeholder-boolean'));
3034
}

0 commit comments

Comments
 (0)