WIP: Fixing tests, use window.web3 in test setup
This commit is contained in:
parent
5b89a2c66a
commit
db54ad812e
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}
|
||||
>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue