This repository has been archived by the owner on Sep 5, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps-dev): bump puppeteer from 5.2.0 to 5.3.0 (#138)
* chore(deps-dev): bump puppeteer from 5.2.0 to 5.3.0 Bumps [puppeteer](https://github.com/puppeteer/puppeteer) from 5.2.0 to 5.3.0. - [Release notes](https://github.com/puppeteer/puppeteer/releases) - [Commits](puppeteer/puppeteer@v5.2.0...v5.3.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * test: fix example-3 test * test: fix api tests * test: fix api tests using more await delay Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: sebnitu <nitu.seb@gmail.com>
- Loading branch information
1 parent
29b63b1
commit 9a3520a
Showing
7 changed files
with
167 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
module.exports = { | ||
launch: { | ||
args: ['--window-size=1000,1000'], | ||
headless: true, | ||
// slowMo: 100, | ||
args: ['--window-size=1000,1000'], | ||
}, | ||
browserContext: 'incognito', | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'expect-puppeteer'; | ||
import path from 'path'; | ||
|
||
const scrollAnimationDelay = 300; | ||
|
||
let eLog = { | ||
anchor: [], | ||
saved: [], | ||
}; | ||
|
||
test('should properly destroy scroll-stash instance on api call', async () => { | ||
await page.exposeFunction('onCustomEvent', ({ type, detail, target }) => { | ||
if (type == 'scroll-stash:anchor') { | ||
eLog.anchor.push({ type, detail, target }); | ||
} else if (type == 'scroll-stash:saved') { | ||
eLog.saved.push({ type, detail, target }); | ||
} | ||
}); | ||
|
||
await page.evaluateOnNewDocument(() => { | ||
window.addEventListener('scroll-stash:anchor', ({ type, detail, target }) => { | ||
window.onCustomEvent({ type, detail, target }); | ||
}); | ||
window.addEventListener('scroll-stash:saved', ({ type, detail, target }) => { | ||
window.onCustomEvent({ type, detail, target }); | ||
}); | ||
}); | ||
|
||
await page.goto(`file:${path.join(__dirname, '../example.html')}`); | ||
|
||
const result = await page.evaluate(() => { | ||
document.querySelector('.js-api-destroy').click(); | ||
return localStorage.getItem('ScrollStash'); | ||
}); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
expect(result).toBe(null); | ||
|
||
const eCount = eLog.saved.length; | ||
await page.$eval('#page', (el) => { | ||
el.scrollTop = 0; | ||
}); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
expect(eLog.saved.length).toBe(eCount); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'expect-puppeteer'; | ||
import path from 'path'; | ||
|
||
const scrollAnimationDelay = 300; | ||
|
||
let eLog = { | ||
anchor: [], | ||
saved: [], | ||
}; | ||
|
||
test('should re-initialize scroll-stash instance on api call', async () => { | ||
await page.exposeFunction('onCustomEvent', ({ type, detail, target }) => { | ||
if (type == 'scroll-stash:anchor') { | ||
eLog.anchor.push({ type, detail, target }); | ||
} else if (type == 'scroll-stash:saved') { | ||
eLog.saved.push({ type, detail, target }); | ||
} | ||
}); | ||
|
||
await page.evaluateOnNewDocument(() => { | ||
window.addEventListener('scroll-stash:anchor', ({ type, detail, target }) => { | ||
window.onCustomEvent({ type, detail, target }); | ||
}); | ||
window.addEventListener('scroll-stash:saved', ({ type, detail, target }) => { | ||
window.onCustomEvent({ type, detail, target }); | ||
}); | ||
}); | ||
|
||
await page.goto(`file:${path.join(__dirname, '../example.html')}`); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
let result = await page.evaluate(() => { | ||
document.querySelector('.js-api-destroy').click(); | ||
return localStorage.getItem('ScrollStash'); | ||
}); | ||
|
||
await page.waitForTimeout(scrollAnimationDelay); | ||
expect(result).toBe(null); | ||
|
||
const eSavedCount = eLog.saved.length; | ||
const eAnchorCount = eLog.anchor.length; | ||
|
||
result = await page.evaluate(() => { | ||
document.querySelector('.js-api-init').click(); | ||
return localStorage.getItem('ScrollStash'); | ||
}); | ||
|
||
await page.waitForTimeout(scrollAnimationDelay); | ||
expect(result).not.toBe(null); | ||
expect(eLog.saved.length).toBe(eSavedCount + 1); | ||
expect(eLog.anchor.length).toBe(eAnchorCount); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,133 +1,101 @@ | ||
import 'expect-puppeteer'; | ||
import path from 'path'; | ||
import { throttleDelay } from './helpers/throttleDelay'; | ||
|
||
const scrollAnimationDelay = 300; | ||
|
||
let eLog = { | ||
anchor: [], | ||
saved: [], | ||
}; | ||
|
||
beforeAll(async () => { | ||
await page.exposeFunction('onCustomEvent', ({ type, detail, target }) => { | ||
if (type == 'scroll-stash:anchor') { | ||
eLog.anchor.push({ type, detail, target }); | ||
} else if (type == 'scroll-stash:saved') { | ||
eLog.saved.push({ type, detail, target }); | ||
} | ||
}); | ||
|
||
await page.evaluateOnNewDocument(() => { | ||
window.addEventListener('scroll-stash:anchor', ({ type, detail, target }) => { | ||
window.onCustomEvent({ type, detail, target }); | ||
}); | ||
window.addEventListener('scroll-stash:saved', ({ type, detail, target }) => { | ||
window.onCustomEvent({ type, detail, target }); | ||
}); | ||
}); | ||
|
||
await page.goto(`file:${path.join(__dirname, '../example.html')}`); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
}); | ||
|
||
test('should scroll to anchor on anchorShow api call', async () => { | ||
// Setup | ||
let result = await page.$eval('[data-scroll-stash="example-2"]', (el) => { | ||
document.querySelector('#example-2').scrollIntoView(); | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
el.scrollTop = 0; | ||
btn.click(); | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(0); | ||
await throttleDelay(scrollAnimationDelay); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
// Click button and wait for animation | ||
await page.$eval('[data-scroll-stash="example-2"]', (el) => { | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
btn.click(); | ||
}); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
// Check scroll position | ||
result = await page.$eval('[data-scroll-stash="example-2"]', (el) => { | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(217); | ||
}); | ||
|
||
test('should scroll to anchor with space adjustments on anchorShow api call', async () => { | ||
test('should scroll to anchor from top with space adjustments on anchorShow api call', async () => { | ||
// Setup | ||
let result = await page.$eval('[data-scroll-stash="example-3"]', (el) => { | ||
document.querySelector('#example-3').scrollIntoView(); | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
el.scrollTop = 0; | ||
btn.click(); | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(0); | ||
await throttleDelay(scrollAnimationDelay); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
// Click button and wait for animation | ||
await page.$eval('[data-scroll-stash="example-3"]', (el) => { | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
btn.click(); | ||
}); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
// Check scroll position | ||
result = await page.$eval('[data-scroll-stash="example-3"]', (el) => { | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(107); | ||
}); | ||
|
||
result = await page.$eval('[data-scroll-stash="example-3"]', (el) => { | ||
document.querySelector('#example-3').scrollIntoView(); | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
test('should scroll to anchor from bottom with space adjustments on anchorShow api call', async () => { | ||
// Setup | ||
let result = await page.$eval('[data-scroll-stash="example-3"]', (el) => { | ||
el.scrollTop = 9999; | ||
btn.click(); | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(517); | ||
await throttleDelay(scrollAnimationDelay); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
// Click button and wait for animation | ||
await page.$eval('[data-scroll-stash="example-3"]', (el) => { | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
btn.click(); | ||
}); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
// Check scroll position | ||
result = await page.$eval('[data-scroll-stash="example-3"]', (el) => { | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(369); | ||
}); | ||
|
||
test('should scroll to custom anchor on anchorShow api call', async () => { | ||
// Setup | ||
let result = await page.$eval('[data-scroll-stash="example-4"]', (el) => { | ||
document.querySelector('#example-4').scrollIntoView(); | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
el.scrollTop = 0; | ||
btn.click(); | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(0); | ||
await throttleDelay(scrollAnimationDelay); | ||
result = await page.$eval('[data-scroll-stash="example-4"]', (el) => { | ||
return el.scrollTop; | ||
}); | ||
expect(result).toBe(217); | ||
}); | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
test('should properly destroy scroll-stash instance on api call', async () => { | ||
const result = await page.evaluate(() => { | ||
document.querySelector('#example-api').scrollIntoView(); | ||
document.querySelector('.js-api-destroy').click(); | ||
return localStorage.getItem('ScrollStash'); | ||
}); | ||
await throttleDelay(); | ||
expect(result).toBe(null); | ||
|
||
const eCount = eLog.saved.length; | ||
await page.$eval('#page', (el) => { | ||
el.scrollTop = 0; | ||
}); | ||
await throttleDelay(); | ||
expect(eLog.saved.length).toBe(eCount); | ||
}); | ||
|
||
test('should re-initialize scroll-stash instance on api call', async () => { | ||
// await throttleDelay(); | ||
let result = await page.evaluate(() => { | ||
document.querySelector('#example-api').scrollIntoView(); | ||
document.querySelector('.js-api-destroy').click(); | ||
return localStorage.getItem('ScrollStash'); | ||
// Click button and wait for animation | ||
await page.$eval('[data-scroll-stash="example-4"]', (el) => { | ||
const btn = el.closest('.example').querySelector('.js-api-anchor-show'); | ||
btn.click(); | ||
}); | ||
await throttleDelay(); | ||
expect(result).toBe(null); | ||
|
||
const eSavedCount = eLog.saved.length; | ||
const eAnchorCount = eLog.anchor.length; | ||
await page.waitForTimeout(scrollAnimationDelay); | ||
|
||
result = await page.evaluate(() => { | ||
document.querySelector('.js-api-init').click(); | ||
return localStorage.getItem('ScrollStash'); | ||
// Check scroll position | ||
result = await page.$eval('[data-scroll-stash="example-4"]', (el) => { | ||
return el.scrollTop; | ||
}); | ||
await throttleDelay(); | ||
expect(result).not.toBe(null); | ||
expect(eLog.saved.length).toBe(eSavedCount + 1); | ||
expect(eLog.anchor.length).toBe(eAnchorCount); | ||
expect(result).toBe(217); | ||
}); |