Skip to content

Commit 29908c9

Browse files
asnaithTbaut
andauthored
Additional watched account tests (#396)
Co-authored-by: Thibaut Sardan <[email protected]>
1 parent f3040eb commit 29908c9

File tree

17 files changed

+234
-22
lines changed

17 files changed

+234
-22
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { watchSignatories } from './watchSignatories'
2+
3+
export const watchMultisigs = {
4+
'multisig-with-pure': {
5+
name: 'Multisig With Pure',
6+
address: '5Fa3UUF3S6SVdXZtPrCw2tGUqxJiRJLxEGfujozfZ4xFeAKn',
7+
pureAddress: '5EfdqwwuyjjtEa4UhdjbZJu3UxHEHbzh8LMRvE13xTD7z6Wd',
8+
threshold: 2,
9+
signatories: [watchSignatories[0].address, watchSignatories[1].address]
10+
},
11+
12+
'multisig-without-pure': {
13+
name: 'Multisig No Pure',
14+
address: '5GysXAKXrGjNvpQruKWH3RwxtYrJqqWLN1A15gUMht6EXmzC',
15+
threshold: 2,
16+
signatories: [watchSignatories[2].address, watchSignatories[3].address]
17+
}
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const watchSignatories = [
2+
// signatories of multisig-with-pure
3+
{
4+
address: '5GGjPYsz8B8mxAzNScFNDPkZ1g97VWFCPCMexPSkPnibPBez',
5+
name: 'Pure Signatory 1',
6+
type: 'sr25519',
7+
mnemonic: 'citizen heavy warrior cattle enter chef label split differ seek turtle gorilla'
8+
},
9+
{
10+
address: '5EkbU3anZKYP98aXF5MvmCUxvwvM4kxp7osc2Xhj1wHYL6ym',
11+
name: 'Pure Signatory 2',
12+
type: 'sr25519',
13+
mnemonic: 'script spoon elder spawn kite burst theme property hip fatal flight amount'
14+
},
15+
16+
// signatories of multisig-without-pure
17+
{
18+
address: '5HfzjVSWj6mxBnqgJhPfUTpkAJKro9BKToxXB3nozbu2MTpV',
19+
name: 'No Pure Signatory 1',
20+
type: 'sr25519',
21+
mnemonic: 'spring banana desert horse ecology resist tag matrix burden heart stereo fix'
22+
},
23+
{
24+
address: '5Df1JyC6KSbjSp3pQEn85PCnvTtknGiN7JyE7bSZ9zqNL76E',
25+
name: 'No Pure Signatory 2',
26+
type: 'sr25519',
27+
mnemonic: 'mutual pluck punch boy gym key brush dune master aunt track dynamic'
28+
}
29+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const accountDisplay = {
2+
identicon: () => cy.get('[data-cy=icon-identicon]'),
3+
pureBadge: () => cy.get('[data-cy=badge-pure]'),
4+
multisigBadge: () => cy.get('[data-cy=badge-multi]'),
5+
nameLabel: () => cy.get('[data-cy=label-account-name]'),
6+
addressLabel: () => cy.get('[data-cy=label-account-address]')
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const editNamesModal = {
2+
body: () => cy.get('[data-cy=modal-edit-names]'),
3+
inputEditPureName: () => cy.get('[data-cy=input-edit-pure-name]'),
4+
inputEditMultisigName: () => cy.get('[data-cy=input-edit-multisig-name]'),
5+
inputEditSignatoryName: () => cy.get('[data-cy=input-edit-signatory-name]'),
6+
saveButton: () => cy.get('[data-cy=button-save-edited-names]')
7+
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
export const multisigPage = {
2-
newTransactionButton: () => cy.get('[data-cy="button-new-transaction"]')
2+
// header elements
3+
accountHeader: () => cy.get('[data-cy=header-account]'),
4+
seeOverviewButton: () => cy.get('[data-cy=button-see-overview]'),
5+
newTransactionButton: () => cy.get('[data-cy=button-new-transaction]'),
6+
optionsMenuButton: () => cy.get('[data-cy=button-options-menu]'),
7+
editNamesMenuOption: () => cy.get('[data-cy=menu-option-edit-names]'),
8+
subscanMenuOption: () => cy.get('[data-cy=menu-option-subscan]')
39
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const notifications = {
2-
successNotificationIcon: () => cy.get('[data-cy="notification-icon-success"]'),
3-
errorNotificationIcon: () => cy.get('[data-cy="notification-icon-error"]'),
4-
loadingNotificationIcon: () => cy.get('[data-cy="notification-icon-loading"]'),
5-
notificationWrapper: () => cy.get('[data-cy="notification-wrapper"]')
2+
successNotificationIcon: () => cy.get('[data-cy=notification-icon-success]'),
3+
errorNotificationIcon: () => cy.get('[data-cy=notification-icon-error]'),
4+
loadingNotificationIcon: () => cy.get('[data-cy=notification-icon-loading]'),
5+
notificationWrapper: () => cy.get('[data-cy=notification-wrapper]')
66
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const sendTxModal = {
2-
sendTxTitle: () => cy.get('[data-cy="title-send-tx"]'),
3-
fieldTo: () => cy.get('[data-cy="field-to"]'),
4-
fieldAmount: () => cy.get('[data-cy="field-amount"]'),
5-
buttonSend: () => cy.get('[data-cy="button-send"]')
2+
sendTxTitle: () => cy.get('[data-cy=title-send-tx]'),
3+
fieldTo: () => cy.get('[data-cy=field-to]'),
4+
fieldAmount: () => cy.get('[data-cy=field-amount]'),
5+
buttonSend: () => cy.get('[data-cy=button-send]')
66
}

packages/ui/cypress/support/page-objects/settingsPage.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ export const settingsPage = {
33
accountNameInput: () => cy.get('[data-cy=input-account-name]'),
44
addButton: () => cy.get('[data-cy=button-add-watched-account]'),
55
accountContainer: () => cy.get('[data-cy=container-account-details]', { timeout: 20000 }),
6-
accountIcon: () => cy.get('[data-cy=icon-identicon]'),
7-
accountNameLabel: () => cy.get('[data-cy=label-account-name]'),
8-
accountAddressLabel: () => cy.get('[data-cy=label-account-address]'),
96
accountDeleteButton: () => cy.get('[data-cy=button-delete-watched-account]'),
107
errorLabel: () => cy.get('[data-cy=label-watch-account-error]')
118
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
export const topMenuItems = {
2-
connectButton: () => cy.get('[data-cy="button-menu-connect"]'),
3-
multiproxySelector: () => cy.get('[data-cy="select-multiproxy"]')
2+
homeButton: () => cy.get('[data-cy=button-navigate-home]'),
3+
newMultisigButton: () => cy.get('[data-cy=button-new-multisig]'),
4+
settingsButton: () => cy.get('[data-cy=button-navigate-settings]'),
5+
overviewButton: () => cy.get('[data-cy=button-navigate-overview]'),
6+
aboutButton: () => cy.get('[data-cy=button-navigate-about]'),
7+
connectButton: () => cy.get('[data-cy=button-menu-connect]'),
8+
multiproxySelector: () => cy.get('[data-cy=select-multiproxy]', { timeout: 20000 }),
9+
multiproxySelectorOption: () => cy.get('[data-cy=select-multiproxy-option]')
410
}

packages/ui/cypress/tests/watched-accounts.cy.ts

Lines changed: 133 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { addresses } from '../fixtures/accounts'
2+
import { accountDisplay } from '../support/page-objects/components/accountDisplay'
23
import { landingPageUrl, settingsPageWatchAccountUrl } from '../fixtures/landingData'
34
import { landingPage } from '../support/page-objects/landingPage'
45
import { settingsPage } from '../support/page-objects/settingsPage'
6+
import { topMenuItems } from '../support/page-objects/topMenuItems'
7+
import { watchMultisigs } from '../fixtures/watchAccounts/watchMultisigs'
8+
import { multisigPage } from '../support/page-objects/multisigPage'
9+
import { editNamesModal } from '../support/page-objects/modals/editNamesModal'
510

611
const addWatchAccount = (address: string, name?: string) => {
712
settingsPage.accountAddressInput().type(`${address}{enter}`, { delay: 20 })
@@ -19,9 +24,9 @@ describe('Watched Accounts', () => {
1924
landingPage.watchAccountButton().click()
2025
addWatchAccount(addresses.Alice, 'Alice')
2126
settingsPage.accountContainer().within(() => {
22-
settingsPage.accountIcon().should('be.visible')
23-
settingsPage.accountAddressLabel().should('be.visible')
24-
settingsPage.accountNameLabel().should('be.visible')
27+
accountDisplay.identicon().should('be.visible')
28+
accountDisplay.addressLabel().should('be.visible')
29+
accountDisplay.nameLabel().should('be.visible')
2530
settingsPage.accountDeleteButton().should('be.visible')
2631
})
2732
})
@@ -33,8 +38,8 @@ describe('Watched Accounts', () => {
3338
// now remove it
3439
settingsPage.accountContainer().within(() => {
3540
settingsPage.accountDeleteButton().click()
36-
settingsPage.accountIcon().should('not.exist')
37-
settingsPage.accountAddressLabel().should('not.exist')
41+
accountDisplay.identicon().should('not.exist')
42+
accountDisplay.addressLabel().should('not.exist')
3843
})
3944
settingsPage.accountContainer().should('have.length', 0)
4045
})
@@ -58,4 +63,127 @@ describe('Watched Accounts', () => {
5863
settingsPage.accountContainer().should('have.length', 0)
5964
settingsPage.addButton().should('be.disabled')
6065
})
66+
67+
it('can see the expected account details displayed for a watched multisig', () => {
68+
cy.visit(settingsPageWatchAccountUrl)
69+
addWatchAccount(
70+
watchMultisigs['multisig-without-pure'].address,
71+
watchMultisigs['multisig-without-pure'].name
72+
)
73+
// ensure the multisig name is displayed in the settings account container
74+
settingsPage.accountContainer().within(() => {
75+
accountDisplay.identicon().should('be.visible')
76+
accountDisplay
77+
.nameLabel()
78+
.should('be.visible')
79+
.should('have.text', watchMultisigs['multisig-without-pure'].name)
80+
})
81+
// ensure the name is included in the selectable drop-down option
82+
topMenuItems.multiproxySelector().should('be.visible').first().click()
83+
topMenuItems.multiproxySelectorOption().within(() => {
84+
accountDisplay.identicon().should('be.visible')
85+
accountDisplay.multisigBadge().should('be.visible')
86+
accountDisplay.pureBadge().should('not.exist')
87+
accountDisplay.nameLabel().should('have.text', watchMultisigs['multisig-without-pure'].name)
88+
})
89+
// ensure the name is displayed in the home page header
90+
topMenuItems.homeButton().click()
91+
multisigPage.accountHeader().within(() => {
92+
accountDisplay.identicon().should('be.visible')
93+
accountDisplay.multisigBadge().should('be.visible')
94+
accountDisplay.pureBadge().should('not.exist')
95+
accountDisplay.nameLabel().should('have.text', watchMultisigs['multisig-without-pure'].name)
96+
})
97+
})
98+
99+
it('can see the expected account details displayed for a watched pure', () => {
100+
cy.visit(settingsPageWatchAccountUrl)
101+
addWatchAccount(
102+
watchMultisigs['multisig-with-pure'].pureAddress,
103+
watchMultisigs['multisig-with-pure'].name
104+
)
105+
// ensure the multisig name is displayed in the settings account container
106+
settingsPage.accountContainer().within(() => {
107+
accountDisplay.identicon().should('be.visible')
108+
accountDisplay
109+
.nameLabel()
110+
.should('be.visible')
111+
.should('have.text', watchMultisigs['multisig-with-pure'].name)
112+
})
113+
// ensure the name is included in the selectable drop-down option
114+
topMenuItems.multiproxySelector().should('be.visible').first().click()
115+
topMenuItems.multiproxySelectorOption().within(() => {
116+
accountDisplay.identicon().should('be.visible')
117+
accountDisplay.pureBadge().should('be.visible')
118+
accountDisplay.multisigBadge().should('not.exist')
119+
accountDisplay.nameLabel().should('have.text', watchMultisigs['multisig-with-pure'].name)
120+
})
121+
// navigate to the multisig page and ensure the name is included in the home page header
122+
topMenuItems.homeButton().click()
123+
multisigPage.accountHeader().within(() => {
124+
accountDisplay.identicon().should('be.visible')
125+
accountDisplay.pureBadge().should('be.visible')
126+
accountDisplay.multisigBadge().should('not.exist')
127+
accountDisplay.nameLabel().should('have.text', watchMultisigs['multisig-with-pure'].name)
128+
})
129+
})
130+
131+
it('can edit the name of a watched pure', () => {
132+
cy.visit(settingsPageWatchAccountUrl)
133+
addWatchAccount(
134+
watchMultisigs['multisig-with-pure'].pureAddress,
135+
watchMultisigs['multisig-with-pure'].name
136+
)
137+
// navigate to the home page and edit the name
138+
topMenuItems.homeButton().click()
139+
multisigPage.optionsMenuButton().click()
140+
multisigPage.editNamesMenuOption().click()
141+
editNamesModal.body().should('be.visible')
142+
cy.clock()
143+
editNamesModal.inputEditPureName().type(`{selectall}{del}${`Edited Name Test`}`)
144+
// name edition is debounced by 300ms
145+
cy.tick(300)
146+
editNamesModal.saveButton().should('be.enabled').click()
147+
// ensure the edited name is now displayed in the home page header
148+
multisigPage.accountHeader().within(() => {
149+
accountDisplay.nameLabel().should('have.text', 'Edited Name Test')
150+
})
151+
// navigate to settings and ensure the edited name is displayed
152+
cy.visit(settingsPageWatchAccountUrl)
153+
settingsPage.accountContainer().within(() => {
154+
accountDisplay.nameLabel().should('have.text', 'Edited Name Test')
155+
})
156+
})
157+
158+
it('can open the correct subscan link for a watched pure', () => {
159+
cy.visit(settingsPageWatchAccountUrl)
160+
addWatchAccount(
161+
watchMultisigs['multisig-with-pure'].pureAddress,
162+
watchMultisigs['multisig-with-pure'].name
163+
)
164+
topMenuItems.homeButton().click()
165+
multisigPage.optionsMenuButton().click()
166+
multisigPage.subscanMenuOption().should('be.visible')
167+
// stub window.open to prevent opening a new tab
168+
cy.window().then((win) => {
169+
cy.stub(win, 'open').as('open')
170+
})
171+
multisigPage.subscanMenuOption().click()
172+
// ensure the correct subscan url is opened
173+
cy.get('@open').should(
174+
'have.been.calledOnceWith',
175+
`https://rococo.subscan.io/account/${watchMultisigs['multisig-with-pure'].pureAddress}`
176+
)
177+
})
178+
179+
it('can not see the "New Transaction" button when only a watched account', () => {
180+
cy.visit(settingsPageWatchAccountUrl)
181+
addWatchAccount(
182+
watchMultisigs['multisig-with-pure'].pureAddress,
183+
watchMultisigs['multisig-with-pure'].name
184+
)
185+
topMenuItems.homeButton().click()
186+
multisigPage.accountHeader().should('be.visible')
187+
multisigPage.newTransactionButton().should('not.exist')
188+
})
61189
})

0 commit comments

Comments
 (0)