186d0352cf
* test(wip): add ui tests * fix: correct website upload path * fix: use includes * test: rewrite ui tests * build: remove concurrently * ci: run puppeteer in headless * test: add regression tests * test: add website regression 03 test * test: add react test website * chore: revert newlines Co-authored-by: Cafe137 <aron@aronsoos.com>
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
const axios = require('axios')
|
|
const puppeteer = require('puppeteer')
|
|
const { Assert, Click, sleep, Wait } = require('./library')
|
|
|
|
/**
|
|
* @param {puppeteer.Page} page Puppeteer Page object returned by `browser.newPage()`
|
|
* @returns {Promise<string>} Swarm hash
|
|
*/
|
|
async function selectStampAndUpload(page) {
|
|
await Click.elementWithText(page, 'button', 'Add Postage Stamp')
|
|
// select the first available stamp
|
|
await Click.elementWithClass(page, 'div', '.MuiSelect-select')
|
|
await Click.elementWithClass(page, 'li', '.MuiListItem-button')
|
|
await Wait.forEnabledStateXPath(page, 'button', 'Proceed With Selected Stamp')
|
|
// seems necessary, even though button is enabled by the previous step, it is only highlighted and not clicked
|
|
await sleep(500)
|
|
await Click.elementWithText(page, 'button', 'Proceed With Selected Stamp')
|
|
await Click.elementWithText(page, 'button', 'Upload To Your Node')
|
|
// check if the upload was successful
|
|
await Assert.elementWithTextExists(page, 'button', 'Download')
|
|
await Assert.elementWithTextExists(page, 'button', 'Update Feed')
|
|
|
|
// get the swarm hash
|
|
return page.url().split('/').pop()
|
|
}
|
|
|
|
async function assertUploadedContentAtPath(swarmHash, path, contentType) {
|
|
const response = await axios.get(`http://localhost:1633/bzz/${swarmHash}/${path}`)
|
|
|
|
if (response.status !== 200) {
|
|
throw new Error(`Expected 200 OK, got ${response.status}`)
|
|
}
|
|
|
|
if (response.headers['content-type'] !== contentType) {
|
|
throw new Error(`Expected content-type ${contentType}, got ${response.headers['content-type']}`)
|
|
}
|
|
|
|
const { data } = response
|
|
|
|
if (data.length === 0) {
|
|
throw new Error(`Expected non-empty data, got ${data}`)
|
|
}
|
|
}
|
|
|
|
module.exports = { selectStampAndUpload, assertUploadedContentAtPath }
|