Skip to content

Commit

Permalink
feat: add decoded url links, fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Schmidt <[email protected]>
  • Loading branch information
Sheng-Long committed Oct 12, 2023
1 parent 3f04587 commit 38d8b67
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
15 changes: 14 additions & 1 deletion src/components/values/BlobValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<template>
<a v-if="isURL && blobValue" v-bind:href="blobValue">{{ blobValue }}</a>
<a v-else-if="decodedURL" :href="decodedURL.toString()">{{ decodedURL }}</a>
<a v-else-if="ipfsAddress" :href="ipfsAddress">{{ decodedValue }}</a>
<div v-else-if="jsonValue"
class="h-is-json is-inline-block has-text-left is-family-monospace h-is-text-size-3">{{ jsonValue }}</div>
Expand Down Expand Up @@ -88,6 +89,17 @@ export default defineComponent({
return result
})

const decodedURL = computed(() => {
if (decodedValue.value.startsWith("http://") || decodedValue.value.startsWith("https://")) {
try {
return new URL(decodedValue.value)
} catch {
return null
}
}
return null
})

const jsonValue = computed(() => {
let result
if (decodedValue.value && props.pretty) {
Expand Down Expand Up @@ -139,7 +151,8 @@ export default defineComponent({
jsonValue,
decodedValue,
initialLoading,
ipfsAddress
ipfsAddress,
decodedURL
}
}
})
Expand Down
28 changes: 15 additions & 13 deletions tests/e2e/specs/TokenNavigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,21 @@ describe('Token Navigation', () => {
cy.contains('Token ID:' + nftId)

cy.get('#nft-holder-table')
.find('tbody tr')
.should('be.visible')
.should('have.length.at.least', 2)
.eq(0)
.find('td')
.eq(1)
.find('a')
.click()
.then(($id) => {
// cy.log('Selected account Id: ' + $id.text())
cy.url().should('include', '/mainnet/account/' + $id.text())
cy.contains('Account ID:' + $id.text())
})
.find('tbody tr')
.should('be.visible')
.should('have.length.at.least', 2)
.eq(0)
.find('td')
.eq(0)
.click()
.then(($id) => {
cy.url().should('include', '/mainnet/token/' + nftId + '/' + $id.text())
cy.contains('Serial Number ' + $id.text())
cy.contains('Token ID')
cy.contains('Account ID')
cy.contains('Metadata')
cy.contains('Recent Transactions')
})
})

const tokenId = "0.0.1738807"
Expand Down

0 comments on commit 38d8b67

Please sign in to comment.