|
| 1 | +import { accountDisplay } from '../support/page-objects/components/accountDisplay' |
| 2 | +import { getSettingsPageWatchAccountUrl, landingPageNetwork } from '../fixtures/landingData' |
| 3 | +import { settingsPage } from '../support/page-objects/settingsPage' |
| 4 | +import { topMenuItems } from '../support/page-objects/topMenuItems' |
| 5 | +import { watchMultisigs } from '../fixtures/watchAccounts/watchMultisigs' |
| 6 | +import { multisigPage } from '../support/page-objects/multisigPage' |
| 7 | +import { multisigWithKusamaIdentity } from '../fixtures/nameDisplay' |
| 8 | + |
| 9 | +describe('Name Edition and Display', () => { |
| 10 | + it('can see the edit button with no name', () => { |
| 11 | + const { purePublicKey } = watchMultisigs['multisig-with-pure'] |
| 12 | + |
| 13 | + cy.setupAndVisit({ |
| 14 | + url: getSettingsPageWatchAccountUrl('polkadot'), |
| 15 | + watchedAccounts: [purePublicKey] |
| 16 | + }) |
| 17 | + |
| 18 | + settingsPage.accountContainer().within(() => { |
| 19 | + accountDisplay.identicon().should('be.visible') |
| 20 | + accountDisplay.addressLabel().should('be.visible') |
| 21 | + accountDisplay.noNameLabel().should('have.text', 'No Name') |
| 22 | + accountDisplay.nameEditButton().should('be.visible') |
| 23 | + }) |
| 24 | + }) |
| 25 | + |
| 26 | + it('can edit with no name before', () => { |
| 27 | + const { purePublicKey } = watchMultisigs['multisig-with-pure'] |
| 28 | + const newName = 'some name' |
| 29 | + const newName2 = 'new name 2' |
| 30 | + cy.setupAndVisit({ |
| 31 | + url: getSettingsPageWatchAccountUrl('polkadot'), |
| 32 | + watchedAccounts: [purePublicKey] |
| 33 | + }) |
| 34 | + |
| 35 | + settingsPage.accountContainer().within(() => { |
| 36 | + accountDisplay.nameEditButton().click() |
| 37 | + accountDisplay.nameEditionInput().should('be.focused') |
| 38 | + // editing with enter |
| 39 | + accountDisplay.nameEditionInput().type(`${newName}{Enter}`) |
| 40 | + accountDisplay.nameEditionInput().should('not.exist') |
| 41 | + accountDisplay.nameLabel().should('have.text', newName) |
| 42 | + accountDisplay.noNameLabel().should('not.exist') |
| 43 | + |
| 44 | + //editing with validate button |
| 45 | + accountDisplay.nameEditButton().click() |
| 46 | + accountDisplay.nameEditionInput().should('have.value', newName) |
| 47 | + accountDisplay.nameEditionInput().type(`{selectAll}${newName2}`) |
| 48 | + accountDisplay.validateEditButton().click() |
| 49 | + accountDisplay.nameEditionInput().should('not.exist') |
| 50 | + accountDisplay.nameLabel().should('have.text', newName2) |
| 51 | + accountDisplay.noNameLabel().should('not.exist') |
| 52 | + }) |
| 53 | + }) |
| 54 | + |
| 55 | + it('can edit and cancel with a name before', () => { |
| 56 | + const { purePublicKey } = watchMultisigs['multisig-with-pure'] |
| 57 | + const originalName = 'some name' |
| 58 | + const newName = 'new name' |
| 59 | + cy.setupAndVisit({ |
| 60 | + url: getSettingsPageWatchAccountUrl('polkadot'), |
| 61 | + watchedAccounts: [purePublicKey], |
| 62 | + accountNames: { [purePublicKey]: originalName } |
| 63 | + }) |
| 64 | + |
| 65 | + settingsPage.accountContainer().within(() => { |
| 66 | + //edit and cancel with Escape |
| 67 | + accountDisplay.nameEditButton().click() |
| 68 | + accountDisplay.nameEditionInput().should('have.value', originalName) |
| 69 | + accountDisplay.nameEditionInput().type(`{selectAll}${newName}{esc}`) |
| 70 | + accountDisplay.nameEditionInput().should('not.exist') |
| 71 | + accountDisplay.nameLabel().should('have.text', originalName) |
| 72 | + accountDisplay.noNameLabel().should('not.exist') |
| 73 | + |
| 74 | + //edit and cancel with cancel button |
| 75 | + accountDisplay.nameEditButton().click() |
| 76 | + accountDisplay.nameEditionInput().should('have.value', originalName) |
| 77 | + accountDisplay.nameEditionInput().type(`{selectAll}${newName}`) |
| 78 | + accountDisplay.cancelEditButton().click() |
| 79 | + accountDisplay.nameEditionInput().should('not.exist') |
| 80 | + accountDisplay.nameLabel().should('have.text', originalName) |
| 81 | + accountDisplay.noNameLabel().should('not.exist') |
| 82 | + |
| 83 | + //back to no name |
| 84 | + accountDisplay.nameEditButton().click() |
| 85 | + accountDisplay.nameEditionInput().should('have.value', originalName) |
| 86 | + accountDisplay.nameEditionInput().type(`{selectAll}{del}{enter}`) |
| 87 | + accountDisplay.nameEditionInput().should('not.exist') |
| 88 | + accountDisplay.nameLabel().should('be.empty') |
| 89 | + accountDisplay.noNameLabel().should('have.text', 'No Name') |
| 90 | + }) |
| 91 | + }) |
| 92 | + |
| 93 | + it('can display a local name with identity', () => { |
| 94 | + const { publicKey, address } = multisigWithKusamaIdentity |
| 95 | + const originalName = 'some name' |
| 96 | + |
| 97 | + cy.setupAndVisit({ |
| 98 | + url: landingPageNetwork('kusama'), |
| 99 | + watchedAccounts: [publicKey], |
| 100 | + accountNames: { [publicKey]: originalName } |
| 101 | + }) |
| 102 | + |
| 103 | + // show the local name |
| 104 | + topMenuItems.multiproxySelectorInputDesktop().should('have.value', originalName) |
| 105 | + |
| 106 | + multisigPage |
| 107 | + .accountHeader() |
| 108 | + .should('be.visible') |
| 109 | + .within(() => { |
| 110 | + accountDisplay.addressLabel().should('contain.text', address.slice(0, 6)) |
| 111 | + accountDisplay.nameLabel().should('have.text', originalName) |
| 112 | + accountDisplay.identityIcon().should('be.visible') |
| 113 | + accountDisplay.subIdentityLabel().should('not.exist') |
| 114 | + }) |
| 115 | + }) |
| 116 | + |
| 117 | + it('can edit a local name with identity', () => { |
| 118 | + const { publicKey } = multisigWithKusamaIdentity |
| 119 | + const originalName = 'some name' |
| 120 | + const newName = 'new name' |
| 121 | + |
| 122 | + cy.setupAndVisit({ |
| 123 | + url: landingPageNetwork('kusama'), |
| 124 | + watchedAccounts: [publicKey], |
| 125 | + accountNames: { [publicKey]: originalName } |
| 126 | + }) |
| 127 | + |
| 128 | + // show the local name |
| 129 | + topMenuItems.multiproxySelectorInputDesktop().should('have.value', originalName) |
| 130 | + |
| 131 | + multisigPage |
| 132 | + .accountHeader() |
| 133 | + .should('be.visible') |
| 134 | + .within(() => { |
| 135 | + accountDisplay.nameEditButton().click() |
| 136 | + accountDisplay.nameEditionInput().should('have.value', originalName) |
| 137 | + accountDisplay.nameEditionInput().type(`{selectAll}${newName}{Enter}`) |
| 138 | + }) |
| 139 | + |
| 140 | + topMenuItems.multiproxySelectorInputDesktop().should('have.value', newName) |
| 141 | + }) |
| 142 | + |
| 143 | + it('can delete local name and see identity and sub', () => { |
| 144 | + const { publicKey, identityMain, subIdentity } = multisigWithKusamaIdentity |
| 145 | + const originalName = 'some name' |
| 146 | + |
| 147 | + cy.setupAndVisit({ |
| 148 | + url: landingPageNetwork('kusama'), |
| 149 | + watchedAccounts: [publicKey], |
| 150 | + accountNames: { [publicKey]: originalName } |
| 151 | + }) |
| 152 | + |
| 153 | + // show the local name |
| 154 | + topMenuItems.multiproxySelectorInputDesktop().should('have.value', originalName) |
| 155 | + |
| 156 | + multisigPage |
| 157 | + .accountHeader() |
| 158 | + .should('be.visible') |
| 159 | + .within(() => { |
| 160 | + accountDisplay.nameEditButton().click() |
| 161 | + accountDisplay.nameEditionInput().should('have.value', originalName) |
| 162 | + |
| 163 | + // remove the local name shows the identity name and sub |
| 164 | + accountDisplay.nameEditionInput().type(`{selectAll}{del}{Enter}`) |
| 165 | + accountDisplay.identityIcon().should('be.visible') |
| 166 | + accountDisplay.nameLabel().should('have.text', `${identityMain}/${subIdentity}`) |
| 167 | + }) |
| 168 | + |
| 169 | + topMenuItems.multiproxySelectorInputDesktop().should('have.value', identityMain) |
| 170 | + }) |
| 171 | +}) |
0 commit comments