mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-24 08:53:33 +03:00
Updated to use async and dynamically load category pages.
This commit is contained in:
parent
a3577705e3
commit
b7ab87b652
@ -1,19 +1,46 @@
|
||||
const PercyScript = require('@percy/script')
|
||||
|
||||
async function openLink(target) {
|
||||
return target.click();
|
||||
}
|
||||
|
||||
PercyScript.run(async (page, percySnapshot) => {
|
||||
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 = {
|
||||
'All': async (_) => {},
|
||||
'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"]')
|
||||
}
|
||||
}
|
||||
await page.goto('http://localhost:8000')
|
||||
await page.waitFor('#categories').then(x => {
|
||||
console.log(x)
|
||||
const categories = Array.from(document.querySelectorAll('#categories a'))
|
||||
console.log(categories)
|
||||
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)
|
||||
})
|
||||
}
|
||||
)
|
||||
}, Promise.resolve( ))
|
||||
})
|
||||
})
|
||||
|
||||
const homepage = await page.evaluate (() => {
|
||||
let categories = Array.from(document.querySelectorAll('#categories a'))
|
||||
console.log(categories)
|
||||
console.log('test')
|
||||
})
|
||||
|
||||
/*
|
||||
|
||||
await page.goto('http://localhost:8000/#category/Animations')
|
||||
await page.waitFor('#animations')
|
||||
@ -70,4 +97,6 @@ PercyScript.run(async (page, percySnapshot) => {
|
||||
await page.goto('http://localhost:8000/#category/Messaging')
|
||||
await page.waitFor('#alerts-and-messages')
|
||||
await percySnapshot('Messaging')
|
||||
})
|
||||
|
||||
*/
|
||||
}, {headless: false})
|
||||
|
Loading…
Reference in New Issue
Block a user