feat: sync and update with all changes from fork (#720)
* feat: sync and update with all changes from fork * refactor: extract clipboard copy logic into custom hook * fix: correct spelling of DEFAULT_REFRESH_FREQUENCY_MS in Stamps and WalletBalance providers * refactor(ui-tests): replace fixed sleeps with condition-based waits * fix: handle null values for size and granteeCount in infoGroups * fix(lint): add newline at end of file in useClipboardCopy hook * fix(ui-tests): page.goto URL * refactor: update import paths for useClipboardCopy --------- Co-authored-by: Ferenc Sárai <sarai.ferenc@gmail.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const axios = require('axios')
|
||||
const { Assert, Click, 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 page.click('[role="combobox"]') // Click the select trigger
|
||||
await page.click('[role="option"]') // Click first option in the dropdown
|
||||
await Wait.forEnabledStateXPath(page, 'button', 'Proceed With Selected Stamp')
|
||||
await Click.elementWithText(page, 'button', 'Proceed With Selected Stamp')
|
||||
await Wait.forElementXPath(page, "//button[contains(., 'Upload To Your Node')]")
|
||||
await Click.elementWithText(page, 'button', 'Upload To Your Node')
|
||||
await Wait.forElementXPath(page, "//button[contains(., 'Download')]")
|
||||
// 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}/${encodeURI(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 }
|
||||
Reference in New Issue
Block a user