diff --git a/cypress/e2e/buy-crypto-modal.test.ts b/cypress/e2e/buy-crypto-modal.test.ts index 9357cc31fc..0ae0ce1823 100644 --- a/cypress/e2e/buy-crypto-modal.test.ts +++ b/cypress/e2e/buy-crypto-modal.test.ts @@ -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() diff --git a/cypress/e2e/permit2.test.ts b/cypress/e2e/permit2.test.ts index ed4bf7d5bb..4abcc743ce 100644 --- a/cypress/e2e/permit2.test.ts +++ b/cypress/e2e/permit2.test.ts @@ -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 })) diff --git a/hardhat.config.js b/hardhat.config.js index 0ea36c98c3..cc64ef83be 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -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 = { diff --git a/src/graphql/data/nft/NftActivity.ts b/src/graphql/data/nft/NftActivity.ts index afb90c2dae..d204ff76ee 100644 --- a/src/graphql/data/nft/NftActivity.ts +++ b/src/graphql/data/nft/NftActivity.ts @@ -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, diff --git a/src/nft/utils/currency.ts b/src/nft/utils/currency.ts index 8facf44b6a..6be4569d53 100644 --- a/src/nft/utils/currency.ts +++ b/src/nft/utils/currency.ts @@ -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(' ', '') }