715555f340
* test(cypress): disable infura from browser * build: typecheck cypress * build: es5 * build: rm cypress videos * fix failing tests * skip nft failure and rm infra-175 * feat: implement tts metric * wip e2e test * fix: improve v2 network support (#7012) * fix: improve v2 network support * add an unsupported message to all v2 pages * test: add v2 pool tests * add guard on transaction callbacks * fix: dep array --------- Co-authored-by: eddie <66155195+just-toby@users.noreply.github.com> * test: adjust test options * fix: move to helper method * fix: merge and make code style change * fix: use local variable to track first event * fix: amplitude cypress command * fix: use file-level var * fix: clear input in test --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> Co-authored-by: Jordan Frankfurt <jordanwfrankfurt@gmail.com>
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
// @ts-ignore
|
|
import TokenListJSON from '@uniswap/default-token-list'
|
|
import { CyHttpMessages } from 'cypress/types/net-stubbing'
|
|
|
|
beforeEach(() => {
|
|
// Many API calls enforce that requests come from our app, so we must mock Origin and Referer.
|
|
cy.intercept('*', (req) => {
|
|
req.headers['referer'] = 'https://app.uniswap.org'
|
|
req.headers['origin'] = 'https://app.uniswap.org'
|
|
})
|
|
|
|
// Infura is disabled for cypress tests - calls should be routed through the connected wallet instead.
|
|
cy.intercept(/infura.io/, { statusCode: 404 })
|
|
|
|
// Log requests to hardhat.
|
|
cy.intercept(/:8545/, logJsonRpc)
|
|
|
|
// Mock analytics responses to avoid analytics in tests.
|
|
cy.intercept('https://api.uniswap.org/v1/amplitude-proxy', (req) => {
|
|
const requestBody = JSON.stringify(req.body)
|
|
const byteSize = new Blob([requestBody]).size
|
|
req.alias = 'amplitude'
|
|
req.reply(
|
|
JSON.stringify({
|
|
code: 200,
|
|
server_upload_time: Date.now(),
|
|
payload_size_bytes: byteSize,
|
|
events_ingested: req.body.events.length,
|
|
})
|
|
)
|
|
}).intercept('https://*.sentry.io', { statusCode: 200 })
|
|
|
|
// Mock our own token list responses to avoid the latency of IPFS.
|
|
cy.intercept('https://gateway.ipfs.io/ipns/tokens.uniswap.org', TokenListJSON)
|
|
.intercept('https://gateway.ipfs.io/ipns/extendedtokens.uniswap.org', { statusCode: 404 })
|
|
.intercept('https://gateway.ipfs.io/ipns/unsupportedtokens.uniswap.org', { statusCode: 404 })
|
|
|
|
// Reset hardhat between tests to ensure isolation.
|
|
// This resets the fork, as well as options like automine.
|
|
cy.hardhat().then((hardhat) => hardhat.reset())
|
|
})
|
|
|
|
function logJsonRpc(req: CyHttpMessages.IncomingHttpRequest) {
|
|
req.alias = req.body.method
|
|
const log = Cypress.log({
|
|
autoEnd: false,
|
|
name: req.body.method,
|
|
message: req.body.params?.map((param: any) =>
|
|
typeof param === 'object' ? '{...}' : param?.toString().substring(0, 10)
|
|
),
|
|
})
|
|
req.on('after:response', (res) => {
|
|
if (res.statusCode === 200) {
|
|
log.end()
|
|
} else {
|
|
log.error(new Error(`${res.statusCode}: ${res.statusMessage}`))
|
|
}
|
|
})
|
|
}
|