2019-11-15 14:16:10 +03:00
|
|
|
const PercyScript = require('@percy/script')
|
|
|
|
|
|
|
|
PercyScript.run(async (page, percySnapshot) => {
|
2020-09-09 22:05:26 +03:00
|
|
|
const defaultProcessing = async (name, location) => {
|
2019-11-27 19:01:30 +03:00
|
|
|
await page.goto(location)
|
2020-09-09 22:05:26 +03:00
|
|
|
await page.waitFor(`#${name}`)
|
2019-11-27 19:01:30 +03:00
|
|
|
await percySnapshot(name)
|
|
|
|
console.log(`Snapshot complete for ${name}`)
|
|
|
|
}
|
|
|
|
const specialProcessing = {
|
2020-09-09 22:05:26 +03:00
|
|
|
'Modal': async (name, location) => {
|
|
|
|
await defaultProcessing(name, location)
|
2020-09-09 02:13:30 +03:00
|
|
|
await page.click('#launch-modal')
|
2019-11-27 19:01:30 +03:00
|
|
|
await page.waitFor('[role="dialog"]')
|
|
|
|
await percySnapshot('Full Info Modal')
|
|
|
|
await page.click('[aria-label="Close modal"]')
|
2020-09-09 02:13:30 +03:00
|
|
|
await page.select('select', 'warning')
|
|
|
|
await page.click('#launch-modal')
|
2019-11-27 19:01:30 +03:00
|
|
|
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')
|
2020-09-09 22:05:26 +03:00
|
|
|
await page.waitFor('.module-example__doodad-link').then(doodads => {
|
|
|
|
return doodads.$$('a').then(links => {
|
2019-11-27 19:01:30 +03:00
|
|
|
return links.reduce((acc, link) => {
|
|
|
|
return acc.then(_ => {
|
2020-09-09 22:05:26 +03:00
|
|
|
return link.evaluate(node => [node["dataset"]["percyName"], node.href]).then(([name, location]) => {
|
2019-11-27 19:01:30 +03:00
|
|
|
let handler = specialProcessing[name] || defaultProcessing
|
2020-09-09 22:05:26 +03:00
|
|
|
return handler(name, location)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2019-11-27 19:01:30 +03:00
|
|
|
)
|
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
|
|
|
})
|