Commit f6c393b0 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

test(e2e): de-flake activity-history (#6583)

parent 15f8d343
import { getTestSelector } from '../../utils' import { getTestSelector } from '../../utils'
describe('mini-portfolio activity history', () => { describe('mini-portfolio activity history', () => {
afterEach(() => { beforeEach(() => {
cy.intercept( cy.hardhat()
{
method: 'POST',
url: 'https://beta.api.uniswap.org/v1/graphql',
},
// Pass an empty object to allow the original behavior
{}
).as('restoreOriginalBehavior')
})
it('should deduplicate activity history by nonce', () => {
cy.visit('/swap', { ethereum: 'hardhat' })
.hardhat({ automine: false })
.then((hardhat) => hardhat.wallet.getTransactionCount()) .then((hardhat) => hardhat.wallet.getTransactionCount())
.then((currentNonce) => { .then((nonce) => {
const nextNonce = currentNonce + 1 // Mock graphql response to include specific nonces.
// Mock graphql response to include a specific nonce.
cy.intercept( cy.intercept(
{ {
method: 'POST', method: 'POST',
...@@ -43,7 +30,7 @@ describe('mini-portfolio activity history', () => { ...@@ -43,7 +30,7 @@ describe('mini-portfolio activity history', () => {
status: 'CONFIRMED', status: 'CONFIRMED',
to: '0x034a40764485f7e08ca16366e503491a6af7850d', to: '0x034a40764485f7e08ca16366e503491a6af7850d',
from: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', from: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
nonce: currentNonce, nonce,
__typename: 'Transaction', __typename: 'Transaction',
}, },
assetChanges: [], assetChanges: [],
...@@ -61,7 +48,7 @@ describe('mini-portfolio activity history', () => { ...@@ -61,7 +48,7 @@ describe('mini-portfolio activity history', () => {
status: 'CONFIRMED', status: 'CONFIRMED',
to: '0x1b5154aa4b8f027b9fd19341132fc9dae10f7359', to: '0x1b5154aa4b8f027b9fd19341132fc9dae10f7359',
from: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', from: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
nonce: nextNonce, nonce: nonce + 1,
__typename: 'Transaction', __typename: 'Transaction',
}, },
assetChanges: [ assetChanges: [
...@@ -101,7 +88,12 @@ describe('mini-portfolio activity history', () => { ...@@ -101,7 +88,12 @@ describe('mini-portfolio activity history', () => {
}, },
}, },
} }
).as('graphqlMock') ).as('graphql')
})
})
it('should deduplicate activity history by nonce', () => {
cy.visit('/swap', { ethereum: 'hardhat' }).hardhat({ automine: false })
// Input swap info. // Input swap info.
cy.get('#swap-currency-input .token-amount-input').clear().type('1') cy.get('#swap-currency-input .token-amount-input').clear().type('1')
...@@ -129,5 +121,4 @@ describe('mini-portfolio activity history', () => { ...@@ -129,5 +121,4 @@ describe('mini-portfolio activity history', () => {
// Assert that the local pending transaction is replaced by a remote transaction with the same nonce. // Assert that the local pending transaction is replaced by a remote transaction with the same nonce.
cy.contains('Swapping').should('not.exist') cy.contains('Swapping').should('not.exist')
}) })
})
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment