Skip to content

Commit

Permalink
address bar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Sep 11, 2024
1 parent 4a6ee08 commit a75ec4f
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 69 deletions.
2 changes: 1 addition & 1 deletion packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ It correctly bundles React in production mode and optimizes the build for the be

To ease the development of the front-end, you don't have to run an indexer.
After `yarn && yarn start` you can directly visit the locally hosted front-end at [http://localhost:3333](http://localhost:3333).
You will be connected to the default network, e.g http://localhost:3333?network=rococo
You will be connected to the default network, e.g http://localhost:3333?network=paseo

The front-end will automatically connect to a hosted blockchain node, as well as its associated indexer.

Expand Down
31 changes: 21 additions & 10 deletions packages/ui/cypress/fixtures/knownMultisigs.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import { testAccounts } from './testAccounts'

export const knownMultisigs = {
'test-multisig-1': {
address: '5CmwqwwLEkEtsmB9gFaTJdCfurz33xyggHnvwHaGKtvmQNxq',
'test-simple-multisig-1': {
address: '1iEzHCQ6XWNKJBfdtdTSn2pmUygkGXpknXR6aZcsyxHaped',
publicKey: '0x1f7425dfe88e50fbef6826d117bb06c9d7d672b6ddfc1d578c581c7359beeb52',
threshold: 2,
hashOfUknownCall: '0x15d556c6576d26ff46f46ce9032d4a2a2107ceb2974a7bfc84124faa36d5cee7',
callData: '0x0000286d756c74697820667477',
signatories: [
testAccounts['Multisig Member Account 1'].address,
testAccounts['Multisig Member Account 2'].address
]
},
'multisig-with-unknown-transaction': {
address: '5CNUH7K6RgXqEo4zK3i9cEDX1CDozJkmvuK6cRZ3z8ovY5CN',
pureAddress: '5GeQBX3xT9oV5PVjnuakx6tRFEwxKGqnohfduWpp4MVt1uC6',
purePublicKey: '0xcaa3c7393cdc0d101797a216222c1d44a92bdc3653f6d0fadfad040adad4e091',
'multisig-with-pure': {
address: '1gkDr5CdZZ6BodjWkVTgALLH75vVKU1SSSgibBC7UPMXS3A',
pureAddress: '161hfudUKvdgBMRzHviDGm6MZM55VoyA1thjnUFN12fYD7Jv',
purePublicKey: '0xddb613d315b4a0bb1aeb28fb256cc28d41f4704cc92191faae0881ebf99412d4',
threshold: 2,
hashOfUknownCall: '0x49478dcdda5a328ba4918e8faca68f347462f41903c461122a36b7c51483768f',
callData: '0x000060556e6b6e6f776e205472616e73616374696f6e2054657374',
signatories: [
testAccounts['Signatory 1 Of Multisig With Unknown Tx'].address,
testAccounts['Signatory 2 Of Multisig With Unknown Tx'].address
testAccounts['Multisig Member Account 1'].address,
testAccounts['Multisig Member Account 2'].address,
testAccounts['Multisig Member Account 3'].address
]
},
'multisigs-unique-users': {
address: '1MJF5WZd31i3vvsLmvgVx4uN1y9AqAGrCXhjnNThxPUVbM1',
publicKey: '0x0f7af3c714b7cb4b0365aca43c586371bb10560b770f53f20a2dddad8db1365d',
threshold: 2,
signatories: [
testAccounts['Multisig Member Account 4'].address,
testAccounts['Multisig Member Account 5'].address
]
}
}
4 changes: 2 additions & 2 deletions packages/ui/cypress/fixtures/landingData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const baseUrl = 'http://localhost:3333'
export const defaultNetwork = 'rococo'
export const defaultNetwork = 'paseo'
const WATCH_ACCOUNT_ANCHOR = 'watched-accounts'
export const landingPageNetwork = (networkName: string) => `${baseUrl}?network=${networkName}`
export const landingPageUrl = landingPageNetwork('rococo')
export const landingPageUrl = landingPageNetwork(defaultNetwork)
export const getSettingsPageUrl = (network = defaultNetwork) =>
`${baseUrl}/settings?network=${network}`
export const getSettingsPageWatchAccountUrl = (network = defaultNetwork) =>
Expand Down
30 changes: 26 additions & 4 deletions packages/ui/cypress/fixtures/testAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,43 @@ export interface InjectedAccountWitMnemonic extends InjectedAccount {

export const testAccounts = {
'Multisig Member Account 1': {
address: '5H679cx9tkuHqyReUgBxeTqXKjVikVwLySDH1buiYuoqhi2w',
address: '162QHxDDkYAmHWSASKExncfgBMVNSoVV3vwmAtu56zqMt1mJ',
publicKey: '0xde3ed24acdfe71c13b4d42539c5390ddee147ba6b29b0593ce842e77ff034445',
name: 'Multisig Member Account 1',
type: 'sr25519',
mnemonic: 'climb worth pioneer mushroom cloth expose tube high half final curtain toward'
} as InjectedAccountWitMnemonic,
'Multisig Member Account 2': {
address: '5GCXBrumiRDQ8KQsgbG39HdBNLQKt6XCQbeHZJccGdZbYTgt',
address: '158pLCAqaCUsZrRPeEK3HSTLDxPyaQ5LV6Nmibbxpib7iu4R',
publicKey: '0xb6e6fb4f2a2268bf6e8a211d958cbf602881418bcc533216cadfae3e24785f28',
name: 'Multisig Member Account 2',
type: 'sr25519',
mnemonic: 'divorce lottery slender again adapt process slow pigeon suit chase news begin'
} as InjectedAccountWitMnemonic,
'Multisig Member Account 3': {
address: '14fm5WcyMvkVkEpTyEhFFgjDQRZspee5jfuX9QtsyNEuc9if',
publicKey: '0xa244679c3186eb336beb3a8335e0a6f6ab0256618f0fcb0cbc493a14cfdc765d',
name: 'Multisig Member Account 3',
type: 'sr25519',
mnemonic: 'double smoke neglect nasty door atom general health doctor subject regret romance'
} as InjectedAccountWitMnemonic,
'Multisig Member Account 4': {
address: '15a1VoMnixXyQnCf7nae89gkmbu5WMGZTniWiixxJD36NGLZ',
publicKey: '0xca1db422d29bc27114e68e10e98f6ae6d5981ae412de2e21b8647b46a221ae53',
name: 'Multisig Member Account 4',
type: 'sr25519',
mnemonic: 'prefer live muscle virtual embrace arm stone museum weasel escape ten float'
} as InjectedAccountWitMnemonic,
'Multisig Member Account 5': {
address: '1t8g1ZXypq36LpGCDG5nbiW42chjTScGPhAVBiejZFU5A5s',
publicKey: '0x26ff58054d290e16efedc0e9be37d9197791d50ad071c1a9bff12eda2737992a',
name: 'Multisig Member Account 5',
type: 'sr25519',
mnemonic: 'hunt pause dawn identify month ahead ship ribbon brother fit fabric fabric'
} as InjectedAccountWitMnemonic,

'Non Multisig Member 1': {
address: '5EnfL3AjWckttY6xuUqfFsfjcbxr1KqdzUKHTmh7cWrDKjGd',
address: '13ixUNRoNQ2NL57Us7tfQ2VtUDxVhdPn4y3md4gUAbsjW8PS',
publicKey: '0x78784374dbeba13ff9789fca0e46c4960e219a1fff11ea69d6f0b57a7f3bfb61',
name: 'Non Multisig Member 1',
type: 'sr25519',
Expand All @@ -35,7 +57,7 @@ export const testAccounts = {
mnemonic: 'erosion never fee pill vocal fetch enforce soap betray zero answer hollow'
} as InjectedAccountWitMnemonic,
'Many Multisig And Pure Member 1': {
address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
address: '155x2TMK25Kc6vhGFcwW5neSZmkr2cwy3wp9xJGdSWPfkf2T',
publicKey: '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d',
name: 'Many Multisig And Pure Member 1',
type: 'sr25519',
Expand Down
23 changes: 8 additions & 15 deletions packages/ui/cypress/fixtures/watchAccounts/watchMultisigs.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { watchSignatories } from './watchSignatories'

export const watchMultisigs = {
'multisig-with-pure': {
name: 'Multisig With Pure',
address: '5EwAYK9noidJUqDXT7RmDABzh8Ag1PEd4HWy9DW82KU3H6tq',
publicKey: '0x7ef48fd94cff8f6a6e03f3bf1d3b7a9606b1b85ad09f7a056fe56ba484942974',
pureAddress: '5EfdqwwuyjjtEa4UhdjbZJu3UxHEHbzh8LMRvE13xTD7z6Wd',
purePublicKey: '0x731c8c8da47c7b980f4f6968fdc461dc7d67b6d255974937761e510a927b6e55',
address: '12sRk3vQ8CQb8HjXwBpp22QBT8ep6L9x919evDrwZXbsvaYi',
publicKey: '0x52b1cb22ddaf992455d8a0bec7f7aec86095715292f08f55fcd28b178b2de545',
pureAddress: '13RLuy3muymPYb8JR3Yqyy5uYP2fuA3WvKiZtCLo2XfcGj5Z',
purePublicKey: '0x6b0963f535d131f0fbf49a064b91f27d6106cf1522a93669e0d45175481665a3',
threshold: 2,
signatories: [watchSignatories[0].address, watchSignatories[1].address]
},

'multisig-without-pure': {
name: 'Multisig No Pure',
address: '5GysXAKXrGjNvpQruKWH3RwxtYrJqqWLN1A15gUMht6EXmzC',
publicKey: '0xd97d7896b3cc0410dbb83bf0a8d9c5a87b293c077165fc1c154546718d1a10e0',
threshold: 2,
signatories: [watchSignatories[2].address, watchSignatories[3].address]
signatories: [
'13EUU9775dB3Cai7fuR92UitxW4gZ3erzjcPFqyn3BUXWRtL',
'16Am9gucwcbW92W4P7Y8gqXvNb3U98KGWBsg4zkBUyfePfn4'
]
}
}
45 changes: 22 additions & 23 deletions packages/ui/cypress/tests/address-bar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import { knownMultisigs } from '../fixtures/knownMultisigs'
import { landingPageAddressUrl, landingPageUrl } from '../fixtures/landingData'
import { testAccounts } from '../fixtures/testAccounts'
import { watchMultisigs } from '../fixtures/watchAccounts/watchMultisigs'
import { watchSignatories } from '../fixtures/watchAccounts/watchSignatories'
import { accountDisplay } from '../support/page-objects/components/accountDisplay'
import { landingPage } from '../support/page-objects/landingPage'
import { multisigPage } from '../support/page-objects/multisigPage'
import { topMenuItems } from '../support/page-objects/topMenuItems'

describe('Account address in the address bar', () => {
it('shows multi and update address with 1 watched (multi), 0 connected account, no linked address', () => {
const { address, publicKey } = watchMultisigs['multisig-without-pure']
const { address, publicKey } = knownMultisigs['test-simple-multisig-1']

// we have a watched account that is a multisig
cy.setupAndVisit({
Expand All @@ -27,12 +26,12 @@ describe('Account address in the address bar', () => {
})

it('shows multi and update address with 0 watched, 1 connected account (multi), no linked address', () => {
const { address } = knownMultisigs['test-multisig-1']
const { address } = knownMultisigs['multisigs-unique-users']

cy.setupAndVisit({
url: landingPageUrl,
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [testAccounts['Multisig Member Account 1']]
injectExtensionWithAccounts: [testAccounts['Multisig Member Account 4']]
})

cy.url({ timeout: 10000 }).should('include', address)
Expand All @@ -48,13 +47,13 @@ describe('Account address in the address bar', () => {
.linkedAddressNotFound()
.should(
'contain.text',
"The linked address can't be found in your accounts or watched accounts on rococo"
"The linked address can't be found in your accounts or watched accounts on paseo"
)
topMenuItems.multiproxySelectorDesktop().should('not.exist')
})

it('shows an error and can reset with 1 watched (multi), 0 connected account, unknown linked address', () => {
const { publicKey, address: multisigAddress } = watchMultisigs['multisig-without-pure']
const { publicKey, address: multisigAddress } = knownMultisigs['test-simple-multisig-1']

// we have a watched account that is a multisig
cy.setupAndVisit({
Expand All @@ -67,7 +66,7 @@ describe('Account address in the address bar', () => {
.linkedAddressNotFound()
.should(
'contain.text',
"The linked address can't be found in your accounts or watched accounts on rococo"
"The linked address can't be found in your accounts or watched accounts on paseo"
)
cy.url().should('include', testAccounts['Non Multisig Member 1'].address)
topMenuItems.multiproxySelectorDesktop().should('be.visible')
Expand Down Expand Up @@ -96,7 +95,7 @@ describe('Account address in the address bar', () => {
.linkedAddressNotFound()
.should(
'contain.text',
"The linked address can't be found in your accounts or watched accounts on rococo"
"The linked address can't be found in your accounts or watched accounts on paseo"
)
cy.url().should('include', testAccounts['Non Multisig Member 1'].address)
topMenuItems.multiproxySelectorDesktop().should('be.visible')
Expand All @@ -113,20 +112,20 @@ describe('Account address in the address bar', () => {
})

it('shows an error and can reset with 0 watched, 1 connected account (multi), unknown linked address', () => {
const { address } = knownMultisigs['test-multisig-1']
const { address } = knownMultisigs['multisigs-unique-users']
const nonMulitisigAccountAddress = testAccounts['Non Multisig Member 1'].address

cy.setupAndVisit({
url: landingPageAddressUrl(nonMulitisigAccountAddress),
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [testAccounts['Multisig Member Account 1']]
injectExtensionWithAccounts: [testAccounts['Multisig Member Account 4']]
})

landingPage
.linkedAddressNotFound()
.should(
'contain.text',
"The linked address can't be found in your accounts or watched accounts on rococo"
"The linked address can't be found in your accounts or watched accounts on paseo"
)
cy.url().should('include', nonMulitisigAccountAddress)
topMenuItems.multiproxySelectorDesktop().should('be.visible')
Expand All @@ -143,7 +142,7 @@ describe('Account address in the address bar', () => {
})

it('shows the pure with 1 watched (pure), 0 connected account, pure linked address', () => {
const { purePublicKey, pureAddress } = watchMultisigs['multisig-with-pure']
const { purePublicKey, pureAddress } = knownMultisigs['multisig-with-pure']

// we have a watched account that is a pure
cy.setupAndVisit({
Expand Down Expand Up @@ -176,8 +175,8 @@ describe('Account address in the address bar', () => {
})

it('shows the pure with 1 watched (signatory pure), 0 connected account, pure linked address', () => {
const { pureAddress } = watchMultisigs['multisig-with-pure']
const { publickey: signatoryPublicKey } = watchSignatories[0]
const { pureAddress } = knownMultisigs['multisig-with-pure']
const { publicKey: signatoryPublicKey } = testAccounts['Multisig Member Account 3']

// we have a watched account that is a pure
cy.setupAndVisit({
Expand All @@ -194,11 +193,11 @@ describe('Account address in the address bar', () => {
})

it('shows a pure with 0 watched, 1 connected account (many multi & pure), pure linked address', () => {
const expectedPureAddress = '5EXePPDNnucmLgrirMPQatFfu4WjncVbVoDZXx1gq75e3JcF'
const expectedPureAddress = '161hfudUKvdgBMRzHviDGm6MZM55VoyA1thjnUFN12fYD7Jv'
cy.setupAndVisit({
url: landingPageAddressUrl(expectedPureAddress),
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [testAccounts['Many Multisig And Pure Member 1']]
injectExtensionWithAccounts: [testAccounts['Multisig Member Account 1']]
})

cy.url().should('include', expectedPureAddress)
Expand All @@ -209,12 +208,12 @@ describe('Account address in the address bar', () => {
})

it('shows a multi with 0 watched, 1 connected account (many multi & pure), multi linked address', () => {
const expectedMultiAddress = '5DxNgjvfJLfDTAAgFD1kWtJAh2KVNTTkwytr7S37dZwVpXd7'
const expectedMultiAddress = '1iEzHCQ6XWNKJBfdtdTSn2pmUygkGXpknXR6aZcsyxHaped'

cy.setupAndVisit({
url: landingPageAddressUrl(expectedMultiAddress),
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [testAccounts['Many Multisig And Pure Member 1']]
injectExtensionWithAccounts: [testAccounts['Multisig Member Account 1']]
})

cy.url().should('include', expectedMultiAddress)
Expand All @@ -225,13 +224,13 @@ describe('Account address in the address bar', () => {
})

it('switching accounts changes the address in the address bar', () => {
const expectedPureAddress = '5EXePPDNnucmLgrirMPQatFfu4WjncVbVoDZXx1gq75e3JcF'
const multiAddress = '5DxNgjvfJLfDTAAgFD1kWtJAh2KVNTTkwytr7S37dZwVpXd7'
const expectedPureAddress = knownMultisigs['multisig-with-pure'].pureAddress
const multiAddress = knownMultisigs['test-simple-multisig-1'].address
const first6Letters = multiAddress.slice(0, 6)

cy.setupAndVisit({
url: landingPageAddressUrl(expectedPureAddress),
watchedAccounts: [testAccounts['Many Multisig And Pure Member 1'].publicKey!]
watchedAccounts: [testAccounts['Multisig Member Account 1'].publicKey!]
})

// check that there is the pure address in the address bar
Expand All @@ -249,7 +248,7 @@ describe('Account address in the address bar', () => {
})

it('switching networks resets address in the address bar', () => {
const { address, publicKey } = watchMultisigs['multisig-without-pure']
const { address, publicKey } = knownMultisigs['test-simple-multisig-1']

// we have a watched account that is a multisig
cy.setupAndVisit({
Expand All @@ -270,7 +269,7 @@ describe('Account address in the address bar', () => {
})

it('navigating to home, settings, about, overview does not change the address bar', () => {
const { address, publicKey } = watchMultisigs['multisig-without-pure']
const { address, publicKey } = knownMultisigs['test-simple-multisig-1']

// we have a watched account that is a multisig
cy.setupAndVisit({
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/cypress/tests/landing-messaging.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Landing Page Messaging', () => {
cy.connectAccounts([testAccounts['Non Multisig Member 1'].address])
landingPage
.noMultisigFoundError()
.should('contain.text', 'No multisig found for your accounts or watched accounts on rococo.')
.should('contain.text', 'No multisig found for your accounts or watched accounts on paseo.')
landingPage.createOneButton().should('be.visible').should('be.enabled')
landingPage.watchAccountButton().should('be.visible').should('be.enabled')
})
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Landing Page Messaging', () => {
})
landingPage
.noMultisigFoundError()
.should('contain.text', 'No multisig found for your accounts or watched accounts on rococo.')
.should('contain.text', 'No multisig found for your accounts or watched accounts on paseo.')
landingPage.connectWalletButton().should('be.visible').should('be.enabled')
landingPage.watchAccountButton().should('be.visible').should('be.enabled')
})
Expand All @@ -93,7 +93,7 @@ describe('Landing Page Messaging', () => {

landingPage
.noMultisigFoundError()
.should('contain.text', 'No multisig found for your accounts or watched accounts on rococo.')
.should('contain.text', 'No multisig found for your accounts or watched accounts on paseo.')
landingPage.createOneButton().should('be.visible').should('be.enabled')
landingPage.watchAccountButton().should('be.visible').should('be.enabled')
})
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/cypress/tests/network-switch.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Network can be switched', () => {
watchedAccounts: [multisigPublicKey]
})

cy.url().should('contain', 'network=rococo')
cy.url().should('contain', 'network=paseo')
cy.url().should('contain', `address=${multisigPureAddress}`)

settingsPage.accountContainer().within(() => {
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/cypress/tests/transactions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ describe('Perform transactions', () => {
cy.rejectCurrentMultisigTx({
account: testAccounts['Multisig Member Account 1'],
multisigInfo: {
address: knownMultisigs['test-multisig-1'].address,
threshold: knownMultisigs['test-multisig-1'].threshold,
otherSignatories: knownMultisigs['test-multisig-1'].signatories.filter(
address: knownMultisigs['test-simple-multisig-1'].address,
threshold: knownMultisigs['test-simple-multisig-1'].threshold,
otherSignatories: knownMultisigs['test-simple-multisig-1'].signatories.filter(
(address) => address !== testAccount1Address
)
},
WSendpoint: 'wss://rococo-rpc.polkadot.io'
WSendpoint: 'wss://paseo-rpc.polkadot.io'
})
multisigPage.accountHeader().within(() => {
accountDisplay.addressLabel().should('not.have.text', '')
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/cypress/tests/unknown-transaction.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ describe('Unknown Transaction', () => {
})
})

const { hashOfUknownCall: expectedCallHash, callData } =
knownMultisigs['multisig-with-unknown-transaction']
const { hashOfUknownCall: expectedCallHash, callData } = knownMultisigs['multisig-with-pure']
const testAccount2Address = testAccounts['Signatory 2 Of Multisig With Unknown Tx'].address

txSigningModal
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/cypress/tests/watched-accounts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('Watched Accounts', () => {
// ensure the correct subscan url is opened
cy.get('@open').should(
'have.been.calledOnceWith',
`https://rococo.subscan.io/account/${pureAddress}`
`https://paseo.subscan.io/account/${pureAddress}`
)
})

Expand Down
Loading

0 comments on commit a75ec4f

Please sign in to comment.