Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve reliability of E2E tests #1182

Merged
merged 3 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cypress/e2e/safe-apps/apps_list.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ describe('The Safe Apps list', () => {

describe('When searching apps', () => {
it('should filter the list by app name', () => {
cy.findByRole('textbox').type('walletconnect')
cy.findAllByRole('link', { name: /logo/i }).should('have.length', 1)
// Wait for /safe-apps response
cy.intercept('GET', '/**/safe-apps').then(() => {
cy.findByRole('textbox').type('walletconnect')
cy.findAllByRole('link', { name: /logo/i }).should('have.length', 1)
})
})

it('should filter the list by app description', () => {
Expand Down
147 changes: 73 additions & 74 deletions cypress/e2e/smoke/create_tx.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ describe('Queue a transaction on 1/N', () => {
})

it('should create and queue a transaction', () => {
// Assert that "New transaction" button is visible
cy.contains('New transaction', {
timeout: 60_000, // `lastWallet` takes a while initialize in CI
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is horribly long but 30s was sometimes too short. It doesn't seem to need this long but I'd sooner have it longer than necessary. As soon as the button is present, it continues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the long timeout in this assertion? There is no request before this modal opens.
If this is a bottleneck disregard my comment -> I thought the timeout would come only with the /estimations request

}).should('be.visible')

// Open the new transaction modal
cy.contains('New transaction', { timeout: 10000 }).click()
cy.contains('New transaction').click()

// Modal is open
cy.contains('h2', 'New transaction').should('be.visible')
Expand All @@ -35,89 +40,83 @@ describe('Queue a transaction on 1/N', () => {
})

it('should create a queued transaction', () => {
// Spy the /estimations request
cy.intercept('POST', '/**/multisig-transactions/estimations').as('estimations')

// Alias for New transaction modal
cy.contains('h2', 'Review transaction').parents('div').as('modal')

// Wait for /estimations response
cy.wait('@estimations', { timeout: 30_000 })

// Estimation is loaded
cy.get('button[type="submit"]').should('not.be.disabled')

// Gets the recommended nonce
cy.contains('Signing the transaction with nonce').should(($div) => {
// get the number in the string
recommendedNonce = $div.text().match(/\d+$/)[0]
cy.intercept('POST', '/**/multisig-transactions/estimations').then(() => {
DiogoSoaress marked this conversation as resolved.
Show resolved Hide resolved
// Estimation is loaded
cy.get('button[type="submit"]').should('not.be.disabled')

// Gets the recommended nonce
cy.contains('Signing the transaction with nonce').should(($div) => {
// get the number in the string
recommendedNonce = $div.text().match(/\d+$/)[0]
})

// Changes nonce to next one
cy.contains('Signing the transaction with nonce').click()
cy.contains('button', 'Edit').click()
cy.get('label').contains('Safe transaction nonce').next().clear().type('3')
cy.contains('Confirm').click()

// Asserts the execute checkbox exists
cy.get('@modal').within(() => {
cy.get('input[type="checkbox"]')
.parent('span')
.should(($div) => {
// Turn the classList into a string
const classListString = Array.from($div[0].classList).join()
// Check if it contains the error class
expect(classListString).to.include('checked')
})
})
cy.contains('Estimated fee').should('exist')

// Asserts the execute checkbox is uncheckable
cy.contains('Execute transaction').click()
cy.get('@modal').within(() => {
cy.get('input[type="checkbox"]')
.parent('span')
.should(($div) => {
// Turn the classList into a string
const classListString = Array.from($div[0].classList).join()
// Check if it contains the error class
expect(classListString).not.to.include('checked')
})
})
cy.contains('Signing the transaction with nonce').should('exist')

// Changes back to recommended nonce
cy.contains('Signing the transaction with nonce').click()
cy.contains('Edit').click()
cy.get('button[aria-label="Reset to recommended nonce"]').click()

// Accepts the values
cy.contains('Confirm').click()

cy.get('@modal').within(() => {
cy.get('input[type="checkbox"]').should('not.exist')
})

cy.contains('Submit').click()
})

// Changes nonce to next one
cy.contains('Signing the transaction with nonce').click()
cy.contains('button', 'Edit').click()
cy.get('label').contains('Safe transaction nonce').next().clear().type('3')
cy.contains('Confirm').click()

// Asserts the execute checkbox exists
cy.get('@modal').within(() => {
cy.get('input[type="checkbox"]')
.parent('span')
.should(($div) => {
// Turn the classList into a string
const classListString = Array.from($div[0].classList).join()
// Check if it contains the error class
expect(classListString).to.include('checked')
})
})
cy.contains('Estimated fee').should('exist')

// Asserts the execute checkbox is uncheckable
cy.contains('Execute transaction').click()
cy.get('@modal').within(() => {
cy.get('input[type="checkbox"]')
.parent('span')
.should(($div) => {
// Turn the classList into a string
const classListString = Array.from($div[0].classList).join()
// Check if it contains the error class
expect(classListString).not.to.include('checked')
})
})
cy.contains('Signing the transaction with nonce').should('exist')

// Changes back to recommended nonce
cy.contains('Signing the transaction with nonce').click()
cy.contains('Edit').click()
cy.get('button[aria-label="Reset to recommended nonce"]').click()

// Accepts the values
cy.contains('Confirm').click()

cy.get('@modal').within(() => {
cy.get('input[type="checkbox"]').should('not.exist')
})

cy.contains('Submit').click()

// Spy the /propose request and give it an alias
cy.intercept('POST', '/**/propose').as('propose')

// Wait for the /propose request
cy.wait('@propose', { timeout: 30_000 })
})

it('should click the notification and see the transaction queued', () => {
// Click on the notification
cy.contains('View transaction').click()
// Wait for the /propose request
cy.intercept('POST', '/**/propose').then(() => {
// Click on the notification
cy.contains('View transaction').click()

// Single Tx page
cy.contains('h3', 'Transaction details').should('be.visible')
// Single Tx page
cy.contains('h3', 'Transaction details').should('be.visible')

// Queue label
cy.contains('Queued - transaction with nonce 3 needs to be executed first').should('be.visible')
// Queue label
cy.contains('Queued - transaction with nonce 3 needs to be executed first').should('be.visible')

// Transaction summary
cy.contains(`${recommendedNonce}` + 'Send' + '-' + `${sendValue} GOR`).should('exist')
// Transaction summary
cy.contains(`${recommendedNonce}` + 'Send' + '-' + `${sendValue} GOR`).should('exist')
})
})
})