WIP: Fixing tests, use window.web3 in test setup

This commit is contained in:
mmv 2019-11-05 17:58:49 +04:00
parent 5b89a2c66a
commit db54ad812e
8 changed files with 11 additions and 10 deletions

View File

@ -36,8 +36,7 @@ class HeaderComponent extends React.PureComponent<Props, State> {
async componentDidMount() {
const lastUsedProvider = await loadLastUsedProvider()
if (INJECTED_PROVIDERS.includes(lastUsedProvider)) {
if (INJECTED_PROVIDERS.includes(lastUsedProvider) || process.env.NODE_ENV === 'test') {
web3Connect.connectToInjected()
}
}

View File

@ -73,7 +73,7 @@ const SafeList = ({
{safes.map((safe) => (
<React.Fragment key={safe.address}>
<Link
to={`${SAFELIST_ADDRESS}/${safe.address}`}
to={`${SAFELIST_ADDRESS}/${safe.address}/balances`}
onClick={onSafeClick}
data-testid={SIDEBAR_SAFELIST_ROW_TESTID}
>

View File

@ -64,7 +64,9 @@ const getInfuraUrl = () => {
// With some wallets from web3connect you have to use their provider instance only for signing
// And our own one to fetch data
export const web3RO = new Web3(new Web3.providers.HttpProvider(getInfuraUrl()))
export const web3RO = process.env.NODE_ENV !== 'test'
? new Web3(new Web3.providers.HttpProvider(getInfuraUrl()))
: new Web3(window.web3.currentProvider)
let web3 = web3RO
export const getWeb3 = () => web3

View File

@ -47,7 +47,7 @@ class Load extends React.Component<Props> {
await loadSafe(safeName, safeAddress, owners, addSafe)
const url = `${SAFELIST_ADDRESS}/${safeAddress}`
const url = `${SAFELIST_ADDRESS}/${safeAddress}/balances`
history.push(url)
} catch (error) {
console.error('Error while loading the Safe', error)

View File

@ -42,10 +42,9 @@ export const createSafe = async (values: Object, userAccount: string, addSafe: A
safeProps.owners = owners
addSafe(safeProps)
if (stillInOpeningView()) {
const url = {
pathname: `${SAFELIST_ADDRESS}/${safeContract.address}`,
pathname: `${SAFELIST_ADDRESS}/${safeContract.address}/balances`,
state: {
name,
tx: safe.tx,

View File

@ -102,7 +102,7 @@ const renderApp = (store: Store) => ({
export const renderSafeView = (store: Store<GlobalState>, address: string) => {
const app = renderApp(store)
const url = `${SAFELIST_ADDRESS}/${address}`
const url = `${SAFELIST_ADDRESS}/${address}/balances`
history.push(url)
return app

View File

@ -1,4 +1,5 @@
// @flow
/* eslint-disable max-classes-per-file */
import SafeRecord, { type Safe } from '~/routes/safe/store/models/safe'
import addSafe, { buildOwnersFrom } from '~/routes/safe/store/actions/addSafe'
import {
@ -74,7 +75,7 @@ export const aMinedSafe = async (
threshold: number = 1,
name: string = 'Safe Name',
): Promise<string> => {
const provider = await getProviderInfo()
const provider = await getProviderInfo(window.web3.currentProvider)
const walletRecord = makeProvider(provider)
store.dispatch(addProvider(walletRecord))

View File

@ -38,7 +38,7 @@ describe('DOM > Feature > Sending Funds', () => {
// WHEN
const SafeDom = renderSafeView(store, safeAddress)
await sleep(1300)
await sleep(3500)
// Open send funds modal
const balanceRows = SafeDom.getAllByTestId(BALANCE_ROW_TEST_ID)