Commit dab445f2 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: e2e tests (#6941)

* fix: e2e test

* fix: set flag for buy-crypto-modal test

* fix: fund DAI

---------
Co-authored-by: default avatarZach Pomerantz <zzmp@uniswap.org>
parent da90738b
import { FeatureFlag } from '../../src/featureFlags'
import { getTestSelector } from '../utils' import { getTestSelector } from '../utils'
describe('Buy Crypto Modal', () => { describe('Buy Crypto Modal', () => {
it('should open and close', () => { it('should open and close', () => {
cy.visit('/') cy.visit('/', { featureFlags: [FeatureFlag.fiatOnRampButtonOnSwap] })
// Open the fiat onramp modal // Open the fiat onramp modal
cy.get(getTestSelector('buy-fiat-button')).click() cy.get(getTestSelector('buy-fiat-button')).click()
......
...@@ -28,15 +28,19 @@ describe('Permit2', () => { ...@@ -28,15 +28,19 @@ describe('Permit2', () => {
// check token approval // check token approval
cy.hardhat() cy.hardhat()
.then(({ approval, wallet }) => approval.getTokenAllowanceForPermit2({ owner: wallet, token: inputToken })) .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. */ /** Asserts the universal router has a max permit2 approval for spend of the input token on-chain. */
function expectPermit2AllowanceForUniversalRouterToBeMax(inputToken: Token) { function expectPermit2AllowanceForUniversalRouterToBeMax(inputToken: Token) {
cy.hardhat() cy.hardhat()
.then((hardhat) => hardhat.approval.getPermit2Allowance({ owner: hardhat.wallet, token: inputToken })) .then(({ approval, wallet }) => approval.getPermit2Allowance({ owner: wallet, token: inputToken }))
.then((allowance) => { .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. // Asserts that the on-chain expiration is in 30 days, within a tolerance of 40 seconds.
const THIRTY_DAYS_SECONDS = 2_592_000 const THIRTY_DAYS_SECONDS = 2_592_000
const expected = Math.floor(Date.now() / 1000 + THIRTY_DAYS_SECONDS) const expected = Math.floor(Date.now() / 1000 + THIRTY_DAYS_SECONDS)
...@@ -44,6 +48,13 @@ describe('Permit2', () => { ...@@ -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)', () => { describe('approval process (with intermediate screens)', () => {
// Turn off automine so that intermediate screens are available to assert on. // Turn off automine so that intermediate screens are available to assert on.
beforeEach(() => cy.hardhat({ automine: false })) beforeEach(() => cy.hardhat({ automine: false }))
......
...@@ -6,7 +6,7 @@ require('dotenv').config() ...@@ -6,7 +6,7 @@ require('dotenv').config()
// Block selection is arbitrary, as e2e tests will build up their own state. // 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. // 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 // TODO(WEB-2187): Make more dynamic to avoid manually updating
const BLOCK_NUMBER = 17388567 const BLOCK_NUMBER = 17693163
const POLYGON_BLOCK_NUMBER = 43600000 const POLYGON_BLOCK_NUMBER = 43600000
const forkingConfig = { const forkingConfig = {
......
...@@ -121,7 +121,7 @@ export function useNftActivity(filter: NftActivityFilterInput, first?: number, f ...@@ -121,7 +121,7 @@ export function useNftActivity(filter: NftActivityFilterInput, first?: number, f
toAddress: activity.toAddress, toAddress: activity.toAddress,
transactionHash: activity.transactionHash, transactionHash: activity.transactionHash,
orderStatus: activity.orderStatus, orderStatus: activity.orderStatus,
price: wrapScientificNotation(activity.price?.value), price: wrapScientificNotation(activity.price?.value ?? 0),
symbol: asset?.collection?.image?.url, symbol: asset?.collection?.image?.url,
quantity: activity.quantity, quantity: activity.quantity,
url: activity.url, url: activity.url,
......
...@@ -75,8 +75,9 @@ export const formatWeiToDecimal = (amount: string, removeZeroes = false) => { ...@@ -75,8 +75,9 @@ export const formatWeiToDecimal = (amount: string, removeZeroes = false) => {
} }
// prevent BigNumber overflow by properly handling scientific notation and comma delimited values // prevent BigNumber overflow by properly handling scientific notation and comma delimited values
export function wrapScientificNotation(value?: string | number): string { export function wrapScientificNotation(value: string | number): string {
return value return parseFloat(value.toString())
? parseFloat(value.toString()).toLocaleString('fullwide', { useGrouping: false }).replace(',', '.').replace(' ', '') .toLocaleString('fullwide', { useGrouping: false })
: '' .replace(',', '.')
.replace(' ', '')
} }
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