fix: e2e tests (#6941)
* fix: e2e test * fix: set flag for buy-crypto-modal test * fix: fund DAI --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
This commit is contained in:
parent
da90738ba1
commit
dab445f237
@ -1,8 +1,9 @@
|
||||
import { FeatureFlag } from '../../src/featureFlags'
|
||||
import { getTestSelector } from '../utils'
|
||||
|
||||
describe('Buy Crypto Modal', () => {
|
||||
it('should open and close', () => {
|
||||
cy.visit('/')
|
||||
cy.visit('/', { featureFlags: [FeatureFlag.fiatOnRampButtonOnSwap] })
|
||||
|
||||
// Open the fiat onramp modal
|
||||
cy.get(getTestSelector('buy-fiat-button')).click()
|
||||
|
@ -28,15 +28,19 @@ describe('Permit2', () => {
|
||||
// check token approval
|
||||
cy.hardhat()
|
||||
.then(({ approval, wallet }) => approval.getTokenAllowanceForPermit2({ owner: wallet, token: inputToken }))
|
||||
.should('deep.equal', MaxUint256)
|
||||
.then((allowance) => {
|
||||
Cypress.log({ name: `Token allowace: ${allowance.toString()}` })
|
||||
cy.wrap(allowance).should('deep.equal', MaxUint256)
|
||||
})
|
||||
}
|
||||
|
||||
/** Asserts the universal router has a max permit2 approval for spend of the input token on-chain. */
|
||||
function expectPermit2AllowanceForUniversalRouterToBeMax(inputToken: Token) {
|
||||
cy.hardhat()
|
||||
.then((hardhat) => hardhat.approval.getPermit2Allowance({ owner: hardhat.wallet, token: inputToken }))
|
||||
.then(({ approval, wallet }) => approval.getPermit2Allowance({ owner: wallet, token: inputToken }))
|
||||
.then((allowance) => {
|
||||
cy.wrap(MaxUint160.eq(allowance.amount)).should('eq', true)
|
||||
Cypress.log({ name: `Permit2 allowace: ${allowance.amount.toString()}` })
|
||||
cy.wrap(allowance.amount).should('deep.equal', MaxUint160)
|
||||
// Asserts that the on-chain expiration is in 30 days, within a tolerance of 40 seconds.
|
||||
const THIRTY_DAYS_SECONDS = 2_592_000
|
||||
const expected = Math.floor(Date.now() / 1000 + THIRTY_DAYS_SECONDS)
|
||||
@ -44,6 +48,13 @@ describe('Permit2', () => {
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(() =>
|
||||
cy.hardhat().then(async (hardhat) => {
|
||||
await hardhat.fund(hardhat.wallet, CurrencyAmount.fromRawAmount(DAI, 1e18))
|
||||
await hardhat.mine()
|
||||
})
|
||||
)
|
||||
|
||||
describe('approval process (with intermediate screens)', () => {
|
||||
// Turn off automine so that intermediate screens are available to assert on.
|
||||
beforeEach(() => cy.hardhat({ automine: false }))
|
||||
|
@ -6,7 +6,7 @@ require('dotenv').config()
|
||||
// Block selection is arbitrary, as e2e tests will build up their own state.
|
||||
// The only requirement is that all infrastructure under test (eg Permit2 contracts) are already deployed.
|
||||
// TODO(WEB-2187): Make more dynamic to avoid manually updating
|
||||
const BLOCK_NUMBER = 17388567
|
||||
const BLOCK_NUMBER = 17693163
|
||||
const POLYGON_BLOCK_NUMBER = 43600000
|
||||
|
||||
const forkingConfig = {
|
||||
|
@ -121,7 +121,7 @@ export function useNftActivity(filter: NftActivityFilterInput, first?: number, f
|
||||
toAddress: activity.toAddress,
|
||||
transactionHash: activity.transactionHash,
|
||||
orderStatus: activity.orderStatus,
|
||||
price: wrapScientificNotation(activity.price?.value),
|
||||
price: wrapScientificNotation(activity.price?.value ?? 0),
|
||||
symbol: asset?.collection?.image?.url,
|
||||
quantity: activity.quantity,
|
||||
url: activity.url,
|
||||
|
@ -75,8 +75,9 @@ export const formatWeiToDecimal = (amount: string, removeZeroes = false) => {
|
||||
}
|
||||
|
||||
// prevent BigNumber overflow by properly handling scientific notation and comma delimited values
|
||||
export function wrapScientificNotation(value?: string | number): string {
|
||||
return value
|
||||
? parseFloat(value.toString()).toLocaleString('fullwide', { useGrouping: false }).replace(',', '.').replace(' ', '')
|
||||
: ''
|
||||
export function wrapScientificNotation(value: string | number): string {
|
||||
return parseFloat(value.toString())
|
||||
.toLocaleString('fullwide', { useGrouping: false })
|
||||
.replace(',', '.')
|
||||
.replace(' ', '')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user