Skip to content

Commit 7b7e5ff

Browse files
committed
infra(tests): add test for links scrolled into viewport
1 parent 972eacc commit 7b7e5ff

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/sample.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ describe('quicklink tests', function () {
3737
expect(responseURLs).to.include(`${server}/3.html`);
3838
});
3939

40+
it('should prefetch in-viewport links that scroll into view correctly (UMD)', async function () {
41+
const responseURLs = [];
42+
page.on('response', resp => {
43+
responseURLs.push(resp.url());
44+
});
45+
await page.goto(`${server}/test-basic-usage.html`);
46+
await page.setViewport({
47+
width: 1200,
48+
height: 800,
49+
});
50+
await page.evaluate(_ => {
51+
window.scrollBy(0, window.innerHeight);
52+
});
53+
await page.waitFor(1000);
54+
expect(responseURLs).to.be.an('array');
55+
expect(responseURLs).to.include(`${server}/1.html`);
56+
expect(responseURLs).to.include(`${server}/2.html`);
57+
expect(responseURLs).to.include(`${server}/3.html`);
58+
expect(responseURLs).to.include(`${server}/4.html`);
59+
});
60+
4061
it('should prefetch a static list of URLs correctly', async function () {
4162
const responseURLs = [];
4263
page.on('response', resp => {

0 commit comments

Comments
 (0)