Skip to content

Commit

Permalink
feat(mv3): 🧪 Adding a final resolution check
Browse files Browse the repository at this point in the history
Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
  • Loading branch information
whizzzkid committed Sep 8, 2023
1 parent 6d4fca3 commit 8d36b96
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/e2e/ipfs-companion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ async function getNumberOfConnectedPeers (browser, url) {
return parseInt(peers)
}

async function getFinalUrl (browser, initialUrl) {
await browser.get(initialUrl)
console.info('Checking the final url')
const finalUrl = await backOff(async () => {
const currentUrl = await browser.getCurrentUrl()
return currentUrl
}, {
delayFirstAttempt: true,
numOfAttempts: 5,
startingDelay: 500
})
return finalUrl
}

async function runBrowserTest (browserName, testFunc) {
const extension = getExtension(browserName)

Expand Down Expand Up @@ -192,6 +206,29 @@ describe('ipfs-companion', () => {
expect(peers).not.to.equal(0)
})
})

it(`should resolve urls in ${browserName}`, async () => {
await runBrowserTest(browserName, async (browser, url) => {
const urlsToTest = [{
initialUrl: 'https://ipfs.io/ipfs/QmTqZhR6f7jzdhLgPArDPnsbZpvvgxzCZycXK7ywkLxSyU?filename=ipfs-logo.3ea91a2f.svg',
finalUrl: 'http://bafybeicrwkoherkuzwp2zk3cd4jc3miwp7mrkz2blxrd5afbdibqv5ivo4.ipfs.localhost:8080/?filename=ipfs-logo.3ea91a2f.svg'
}, {
initialUrl: 'https://awesome.ipfs.io',
finalUrl: 'http://awesome.ipfs.io.ipns.localhost:8080/'
}, {
initialUrl: 'https://docs.ipfs.tech',
finalUrl: 'http://docs.ipfs.tech.ipns.localhost:8080/'
}, {
initialUrl: 'https://en.wikipedia-on-ipfs.org/wiki/InterPlanetary_File_System',
finalUrl: 'http://en.wikipedia-on-ipfs.org.ipns.localhost:8080/wiki/InterPlanetary_File_System'
}]

for (const { initialUrl, finalUrl } of urlsToTest) {
const resolvedUrl = await getFinalUrl(browser, initialUrl)
expect(resolvedUrl).to.equal(finalUrl)
}
})
})
})
}
})

0 comments on commit 8d36b96

Please sign in to comment.