Skip to content

Commit

Permalink
Shows the right asset with the right decimals in tx overview (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Jan 28, 2025
1 parent baf6c56 commit 3ba1dca
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { InjectedAccountWitMnemonic } from './testAccounts'

export const expectedKusamaAHMultisigAddress = '13cJVjVjHpabhge4XEjdXmVPgD6w2UaSp8bpnYX9sDcgwp45'
export const expectedPolkadotAHMultisigAddress = '13cJVjVjHpabhge4XEjdXmVPgD6w2UaSp8bpnYX9sDcgwp45'

export const kusamaAHMemberAccount = {
export const polkadotAHMemberAccount = {
// this is the member of a multisig on Polkadot Asset hub with 1 DOT and 1 USDC
Nikos: {
address: '15DCZocYEM2ThYCAj22QE4QENRvUNVrDtoLBVbCm5x4EQncr',
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/cypress/support/page-objects/multisigPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export const multisigPage = {
dateLabel: () => cy.get('[data-cy=label-date]'),
pendingTransactionCallName: () => cy.get('[data-cy=label-call-name]'),
unknownCallIcon: () => cy.get('[data-cy=icon-unknown-call]'),
unknownCallAlert: () => cy.get('[data-cy=alert-no-call-data]')
unknownCallAlert: () => cy.get('[data-cy=alert-no-call-data]'),
batchItem: () => cy.get('[data-cy=batch-call-item]')
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { multisigPage } from '../support/page-objects/multisigPage'
import { sendTxModal } from '../support/page-objects/sendTxModal'
import { waitForTxRequest } from '../utils/waitForTxRequests'
import { kusamaAHMemberAccount } from '../fixtures/kusamaAssetHub'
import { polkadotAHMemberAccount } from '../fixtures/polkadotAssetHub'
import { landingPageNetwork } from '../fixtures/landingData'
import { SignerPayloadJSON } from '@polkadot-api/tx-utils'

const testAccount1Address = kusamaAHMemberAccount.Nikos.address
const testAccount1Address = polkadotAHMemberAccount.Nikos.address

const fillAndSubmitTransactionForm = (assetSymbol = '') => {
sendTxModal.sendTokensFieldTo().click().type(`${testAccount1Address}{enter}`)
Expand All @@ -23,7 +23,7 @@ describe('Crafts the correct extrinsics for asset hub foreign and native assets'
cy.setupAndVisit({
url: landingPageNetwork('asset-hub-polkadot'),
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [kusamaAHMemberAccount.Nikos]
injectExtensionWithAccounts: [polkadotAHMemberAccount.Nikos]
})
})

Expand Down
15 changes: 9 additions & 6 deletions packages/ui/cypress/tests/multisig-pure-display.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { multisigPage } from '../support/page-objects/multisigPage'
import { accountDisplay } from '../support/page-objects/components/accountDisplay'
import { kusamaAHMemberAccount, expectedKusamaAHMultisigAddress } from '../fixtures/kusamaAssetHub'
import {
polkadotAHMemberAccount,
expectedPolkadotAHMultisigAddress
} from '../fixtures/polkadotAssetHub'
import { landingPageNetwork, landingPageNetworkAddress } from '../fixtures/landingData'
import {
expectedPolkadotMultisigAddressClow,
Expand All @@ -12,7 +15,7 @@ describe('Shows the right assets depending on the network', () => {
cy.setupAndVisit({
url: landingPageNetwork('asset-hub-polkadot'),
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [kusamaAHMemberAccount.Nikos]
injectExtensionWithAccounts: [polkadotAHMemberAccount.Nikos]
})

multisigPage
Expand All @@ -22,11 +25,11 @@ describe('Shows the right assets depending on the network', () => {
accountDisplay
.addressLabel()
.should('be.visible')
.and('contain.text', expectedKusamaAHMultisigAddress.slice(0, 6))
.and('contain.text', expectedPolkadotAHMultisigAddress.slice(0, 6))
multisigPage.assetHubBalance('1337').should('be.visible')
multisigPage.assetHubBalance('1337').should('contain.text', '1 USDC')
multisigPage.assetHubBalance('1984').should('be.visible')
multisigPage.assetHubBalance('1984').should('contain.text', '0 USDt')
multisigPage.assetHubBalance('1984').should('contain.text', '0 USDT')
multisigPage.nativeBalance().should('be.visible')
multisigPage.nativeBalance().should('contain.text', '1 DOT')
})
Expand Down Expand Up @@ -107,7 +110,7 @@ describe('Shows the right assets depending on the network', () => {
multisigPage.assetHubBalance('1337').should('exist')
multisigPage.assetHubBalance('1337').should('contain.text', 'USDC')
multisigPage.assetHubBalance('1984').should('exist')
multisigPage.assetHubBalance('1984').should('contain.text', 'USDt')
multisigPage.assetHubBalance('1984').should('contain.text', 'USDT')
multisigPage.nativeBalance().should('be.visible')
multisigPage.nativeBalance().should('contain.text', 'DOT')
})
Expand All @@ -119,7 +122,7 @@ describe('Shows the right assets depending on the network', () => {
multisigPage.assetHubBalance('1337').should('exist')
multisigPage.assetHubBalance('1337').should('contain.text', 'USDC')
multisigPage.assetHubBalance('1984').should('exist')
multisigPage.assetHubBalance('1984').should('contain.text', 'USDt')
multisigPage.assetHubBalance('1984').should('contain.text', 'USDT')
multisigPage.nativeBalance().should('be.visible')
multisigPage.nativeBalance().should('contain.text', 'DOT')
})
Expand Down
69 changes: 68 additions & 1 deletion packages/ui/cypress/tests/transaction-display.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { testAccounts } from '../fixtures/testAccounts'
import { landingPageUrl } from '../fixtures/landingData'
import { landingPageNetwork, landingPageUrl } from '../fixtures/landingData'
import { multisigPage } from '../support/page-objects/multisigPage'
import { txSigningModal } from '../support/page-objects/modals/txSigningModal'
import { knownMultisigs } from '../fixtures/knownMultisigs'
import { polkadotAHMemberAccount } from '../fixtures/polkadotAssetHub'
import { expander } from '../support/page-objects/components/expander'
import { accountDisplay } from '../support/page-objects/components/accountDisplay'

describe('Unknown Transaction', () => {
beforeEach(() => {
Expand Down Expand Up @@ -111,3 +114,67 @@ describe('Unknown Transaction', () => {
})
})
})

describe('Asset hub transactions', () => {
it('can display a simple asset hub transactions with the right decimal and symbol', () => {
cy.setupAndVisit({
url: landingPageNetwork('asset-hub-polkadot'),
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [polkadotAHMemberAccount.Nikos]
})

multisigPage
.pendingTransactionItem(8000)
.eq(1)
.within(() => {
multisigPage
.pendingTransactionCallName()
.should('contain.text', 'Assets.transfer_keep_alive')

expander.paramExpander().click()
accountDisplay.identicon().should('be.visible')
expander.contentExpander().should('contain', 'id: 1337 (USD Coin)')
expander.contentExpander().should('contain', 'amount: 0.01 USDC')
expander.contentExpander().should('contain', '1ThiBx..hDvvjg')
})

multisigPage
.pendingTransactionItem(8000)
.eq(0)
.within(() => {
multisigPage.pendingTransactionCallName().should('contain.text', 'Utility.batch_all')

expander.paramExpander().click()
multisigPage.batchItem().should('have.length', 3)
multisigPage
.batchItem()
.eq(0)
.within((el) => {
accountDisplay.identicon().should('be.visible')
cy.wrap(el).should('contain', 'id: 1337 (USD Coin)')
cy.wrap(el).should('contain', 'amount: 2 USDC')
cy.wrap(el).should('contain', 'Nikos')
})

multisigPage
.batchItem()
.eq(1)
.within((el) => {
accountDisplay.identicon().should('be.visible')
cy.wrap(el).should('contain', 'id: 1984 (Tether USD)')
cy.wrap(el).should('contain', 'amount: 0.001 USDT')
cy.wrap(el).should('contain', 'Thibaut')
})

multisigPage
.batchItem()
.eq(2)
.within((el) => {
accountDisplay.identicon().should('be.visible')
cy.wrap(el).should('contain', 'id: 420')
cy.wrap(el).should('contain', `amount: '1'`)
cy.wrap(el).should('contain', 'Thibaut')
})
})
})
})
3 changes: 3 additions & 0 deletions packages/ui/cypress/tests/watched-accounts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('Watched Accounts', () => {
cy.visit(landingPageUrl)
landingPage.watchAccountButton().click()
addWatchAccount(testAccountAddress, testAccountName)
settingsPage.accountContainer().should('be.visible')
settingsPage.accountContainer().within(() => {
accountDisplay.identicon().should('be.visible')
accountDisplay.addressLabel().should('be.visible')
Expand All @@ -44,6 +45,8 @@ describe('Watched Accounts', () => {
// add an account first
cy.visit(getSettingsPageWatchAccountUrl())
addWatchAccount(testAccountAddress)
settingsPage.accountContainer().should('be.visible')

// now remove it
settingsPage.accountContainer().within(() => {
settingsPage.accountDeleteButton().click()
Expand Down
Loading

0 comments on commit 3ba1dca

Please sign in to comment.