-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cypress can now sign programmatically (#367)
- Loading branch information
Showing
17 changed files
with
237 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { InjectedAccount } from '@polkadot/extension-inject/types' | ||
|
||
export interface InjectedAccountWitMnemonic extends InjectedAccount { | ||
mnemonic: string | ||
} | ||
export const injectedAccounts = [ | ||
{ | ||
address: '7NPoMQbiA6trJKkjB35uk96MeJD4PGWkLQLH7k7hXEkZpiba', | ||
name: 'Alice', | ||
type: 'sr25519' | ||
address: '5H679cx9tkuHqyReUgBxeTqXKjVikVwLySDH1buiYuoqhi2w', | ||
name: 'TestAccount 1', | ||
type: 'sr25519', | ||
mnemonic: 'climb worth pioneer mushroom cloth expose tube high half final curtain toward' | ||
}, | ||
{ | ||
address: '5DqVySMC366P8NRjdyp948TJj64hAvg17eaiEn4ZbuKCNZHc', | ||
name: 'Bob', | ||
type: 'sr25519' | ||
address: '5GCXBrumiRDQ8KQsgbG39HdBNLQKt6XCQbeHZJccGdZbYTgt', | ||
name: 'TestAccount 2', | ||
type: 'sr25519', | ||
mnemonic: 'divorce lottery slender again adapt process slow pigeon suit chase news begin' | ||
} | ||
] as InjectedAccount[] | ||
] as InjectedAccountWitMnemonic[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const multisigPage = { | ||
newTransactionButton: () => cy.get('[data-cy="button-new-transaction"]') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const notifications = { | ||
successNotificationIcon: () => cy.get('[data-cy="notification-icon-success"]'), | ||
errorNotificationIcon: () => cy.get('[data-cy="notification-icon-error"]'), | ||
loadingNotificationIcon: () => cy.get('[data-cy="notification-icon-loading"]'), | ||
notificationWrapper: () => cy.get('[data-cy="notification-wrapper"]') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const sendTxModal = { | ||
sendTxTitle: () => cy.get('[data-cy="title-send-tx"]'), | ||
fieldTo: () => cy.get('[data-cy="field-to"]'), | ||
fieldAmount: () => cy.get('[data-cy="field-amount"]'), | ||
buttonSend: () => cy.get('[data-cy="button-send"]') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { injectedAccounts } from '../fixtures/injectedAccounts' | ||
import { landingPageUrl } from '../fixtures/landingData' | ||
import { landingPage } from '../support/page-objects/landingPage' | ||
import { multisigPage } from '../support/page-objects/multisigPage' | ||
import { notifications } from '../support/page-objects/notifications' | ||
import { sendTxModal } from '../support/page-objects/sendTxModal' | ||
import { topMenuItems } from '../support/page-objects/topMenuItems' | ||
|
||
const AliceAddress = Object.values(injectedAccounts)[0].address | ||
|
||
const fillAndSubmitTransactionForm = () => { | ||
sendTxModal.fieldTo().click().type(`${AliceAddress}{enter}`) | ||
sendTxModal.fieldAmount().click().type('0.001') | ||
sendTxModal.buttonSend().should('be.enabled').click() | ||
} | ||
|
||
describe('Perform transactions', () => { | ||
beforeEach(() => { | ||
cy.visit(landingPageUrl) | ||
cy.initExtension(injectedAccounts) | ||
topMenuItems.connectButton().click() | ||
landingPage.accountsOrRpcLoader().should('contain', 'Loading accounts') | ||
cy.getAuthRequests().then((authRequests) => { | ||
const requests = Object.values(authRequests) | ||
// we should have 1 connection request to the extension | ||
cy.wrap(requests.length).should('eq', 1) | ||
// this request should be from the application Multix | ||
cy.wrap(requests[0].origin).should('eq', 'Multix') | ||
// let's allow it for Alice | ||
cy.enableAuth(requests[0].id, [AliceAddress]) | ||
// the ui should then move on to connecting to the rpcs | ||
topMenuItems.multiproxySelector().should('be.visible') | ||
}) | ||
}) | ||
|
||
it('Abort a tx with Alice', () => { | ||
multisigPage.newTransactionButton().click() | ||
sendTxModal.sendTxTitle().should('be.visible') | ||
fillAndSubmitTransactionForm() | ||
cy.getTxRequests().then((req) => { | ||
const txRequests = Object.values(req) | ||
console.log('txRequests', JSON.stringify(txRequests)) | ||
cy.wrap(txRequests.length).should('eq', 1) | ||
cy.wrap(txRequests[0].payload.address).should('eq', AliceAddress) | ||
sendTxModal.buttonSend().should('be.disabled') | ||
const errorMessage = 'Whuuuut' | ||
cy.rejectTx(txRequests[0].id, errorMessage) | ||
notifications.errorNotificationIcon().should('be.visible') | ||
notifications.notificationWrapper().should('have.length', 1) | ||
notifications.notificationWrapper().should('contain', errorMessage) | ||
}) | ||
}) | ||
|
||
it.skip('Makes a balance transfer with Alice', () => { | ||
multisigPage.newTransactionButton().click() | ||
sendTxModal.sendTxTitle().should('be.visible') | ||
fillAndSubmitTransactionForm() | ||
cy.getTxRequests().then((req) => { | ||
const txRequests = Object.values(req) | ||
cy.wrap(txRequests.length).should('eq', 1) | ||
cy.wrap(txRequests[0].payload.address).should('eq', AliceAddress) | ||
sendTxModal.buttonSend().should('be.disabled') | ||
cy.approveTx(txRequests[0].id) | ||
notifications.loadingNotificationIcon().should('be.visible') | ||
notifications.notificationWrapper().should('have.length', 1) | ||
notifications.notificationWrapper().should('contain', 'broadcast') | ||
}) | ||
}) | ||
}) |
8 changes: 4 additions & 4 deletions
8
.../watched-acccounts/watched-accounts.cy.ts → ...s/ui/cypress/tests/watched-accounts.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.