2019-11-15 14:16:10 +03:00
|
|
|
const PercyScript = require('@percy/script')
|
|
|
|
|
|
|
|
PercyScript.run(async (page, percySnapshot) => {
|
2019-11-27 19:01:30 +03:00
|
|
|
const defaultProcessing = async (name, id, location) => {
|
|
|
|
await page.goto(location)
|
|
|
|
await page.waitFor(`#${id}`)
|
|
|
|
await percySnapshot(name)
|
|
|
|
console.log(`Snapshot complete for ${name}`)
|
|
|
|
}
|
|
|
|
const specialProcessing = {
|
2019-11-27 21:10:35 +03:00
|
|
|
'All': async (_) => {
|
|
|
|
},
|
2019-11-27 19:01:30 +03:00
|
|
|
'Modals': async (name, id, location) => {
|
|
|
|
await defaultProcessing(name, id, location)
|
|
|
|
await page.click('#launch-info-modal')
|
|
|
|
await page.waitFor('[role="dialog"]')
|
|
|
|
await percySnapshot('Full Info Modal')
|
|
|
|
await page.click('[aria-label="Close modal"]')
|
|
|
|
await page.click('#launch-warning-modal')
|
|
|
|
await page.waitFor('[role="dialog"]')
|
|
|
|
await percySnapshot('Full Warning Modal')
|
|
|
|
await page.click('[aria-label="Close modal"]')
|
|
|
|
}
|
|
|
|
}
|
2019-11-27 14:40:29 +03:00
|
|
|
await page.goto('http://localhost:8000')
|
2019-11-27 19:01:30 +03:00
|
|
|
await page.waitFor('#categories').then(category => {
|
|
|
|
return category.$$('a').then(links => {
|
|
|
|
return links.reduce((acc, link) => {
|
|
|
|
return acc.then(_ => {
|
|
|
|
return link.evaluate(node => [node.innerText, node.innerText.toLowerCase().replace(/ /g, "-"), node.href]).then(([name, id, location]) => {
|
|
|
|
let handler = specialProcessing[name] || defaultProcessing
|
|
|
|
return handler(name, id, location)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
2019-11-27 21:10:35 +03:00
|
|
|
}, Promise.resolve())
|
2019-11-27 19:01:30 +03:00
|
|
|
})
|
2019-11-27 14:43:41 +03:00
|
|
|
})
|
2019-11-27 21:10:35 +03:00
|
|
|
})
|