remove outdated tests
This commit is contained in:
parent
4c5143f228
commit
02fbb74f72
|
@ -3,7 +3,6 @@ import { storiesOf } from '@storybook/react'
|
|||
import { List } from 'immutable'
|
||||
import * as React from 'react'
|
||||
import styles from '~/components/layout/PageFrame/index.scss'
|
||||
import { SafeFactory } from '~/routes/safe/store/test/builder/safe.builder'
|
||||
import Component from './Layout'
|
||||
|
||||
const FrameDecorator = story => <div className={styles.frame}>{story()}</div>
|
||||
|
@ -12,7 +11,3 @@ storiesOf('Routes /safes', module)
|
|||
.addDecorator(FrameDecorator)
|
||||
.add('Safe List whithout safes and connected', () => <Component provider="METAMASK" safes={List([])} />)
|
||||
.add('Safe List whithout safes and NOT connected', () => <Component provider="" safes={List([])} />)
|
||||
.add('Safe List whith 2 safes', () => {
|
||||
const safes = List([SafeFactory.oneOwnerSafe(), SafeFactory.twoOwnersSafe()])
|
||||
return <Component provider="METAMASK" safes={safes} />
|
||||
})
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
// @flow
|
||||
import safesSelectorTests from './safes.selector'
|
||||
|
||||
describe('SafeList Test suite', () => {
|
||||
// safesSelector SELECTOR
|
||||
safesSelectorTests()
|
||||
})
|
|
@ -1,122 +0,0 @@
|
|||
// @flow
|
||||
import { List, Map } from 'immutable'
|
||||
import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe'
|
||||
import { type Safe } from '~/routes/safe/store/models/safe'
|
||||
import { getProviderInfo } from '~/logic/wallets/getWeb3'
|
||||
import { SafeFactory } from '~/routes/safe/store/test/builder/safe.builder'
|
||||
import { PROVIDER_REDUCER_ID } from '~/logic/wallets/store/reducer/provider'
|
||||
import { makeProvider, type Provider } from '~/logic/wallets/store/model/provider'
|
||||
import { safesByOwnerSelector } from '../selectors'
|
||||
|
||||
const safesListSelectorTests = () => {
|
||||
let walletRecord: Provider
|
||||
beforeEach(async () => {
|
||||
const provider = await getProviderInfo()
|
||||
walletRecord = makeProvider(provider)
|
||||
})
|
||||
|
||||
describe('Safes Selector[safesByOwnerSelector]', () => {
|
||||
it('should return empty list when no safes', () => {
|
||||
// GIVEN
|
||||
const reduxStore = {
|
||||
[PROVIDER_REDUCER_ID]: walletRecord,
|
||||
[SAFE_REDUCER_ID]: Map(),
|
||||
tokens: undefined,
|
||||
transactions: undefined,
|
||||
}
|
||||
const emptyList = List([])
|
||||
|
||||
// WHEN
|
||||
const safes = safesByOwnerSelector(reduxStore, {})
|
||||
|
||||
// THEN
|
||||
expect(safes).toEqual(emptyList)
|
||||
})
|
||||
|
||||
it('should return a list of size 0 when 0 of 2 safes contains the user as owner', () => {
|
||||
// GIVEN
|
||||
let map: Map<string, Safe> = Map()
|
||||
map = map.set('fooAddress', SafeFactory.oneOwnerSafe('foo'))
|
||||
map = map.set('barAddress', SafeFactory.twoOwnersSafe('foo', 'bar'))
|
||||
|
||||
const reduxStore = {
|
||||
[PROVIDER_REDUCER_ID]: walletRecord,
|
||||
[SAFE_REDUCER_ID]: map,
|
||||
tokens: undefined,
|
||||
transactions: undefined,
|
||||
}
|
||||
|
||||
// WHEN
|
||||
const safes = safesByOwnerSelector(reduxStore, {})
|
||||
|
||||
// THEN
|
||||
expect(safes.count()).toEqual(0)
|
||||
})
|
||||
|
||||
it('should return a list of size 1 when 1 of 2 safes contains the user as owner', () => {
|
||||
// GIVEN
|
||||
let map: Map<string, Safe> = Map()
|
||||
map = map.set('fooAddress', SafeFactory.oneOwnerSafe(walletRecord.account))
|
||||
map = map.set('barAddress', SafeFactory.twoOwnersSafe('foo', 'bar'))
|
||||
|
||||
const reduxStore = {
|
||||
[PROVIDER_REDUCER_ID]: walletRecord,
|
||||
[SAFE_REDUCER_ID]: map,
|
||||
tokens: undefined,
|
||||
transactions: undefined,
|
||||
}
|
||||
|
||||
// WHEN
|
||||
const safes = safesByOwnerSelector(reduxStore, {})
|
||||
|
||||
// THEN
|
||||
expect(safes.count()).toEqual(1)
|
||||
})
|
||||
|
||||
it('should return a list of size 2 when 2 of 2 safes contains the user as owner', () => {
|
||||
// GIVEN
|
||||
let map: Map<string, Safe> = Map()
|
||||
const userAccount = walletRecord.account
|
||||
map = map.set('fooAddress', SafeFactory.oneOwnerSafe(userAccount))
|
||||
map = map.set('barAddress', SafeFactory.twoOwnersSafe('foo', userAccount))
|
||||
|
||||
const reduxStore = {
|
||||
[SAFE_REDUCER_ID]: map,
|
||||
[PROVIDER_REDUCER_ID]: walletRecord,
|
||||
tokens: undefined,
|
||||
transactions: undefined,
|
||||
}
|
||||
|
||||
// WHEN
|
||||
const safes = safesByOwnerSelector(reduxStore, {})
|
||||
|
||||
// THEN
|
||||
expect(safes.count()).toEqual(2)
|
||||
expect(safes.get(0)).not.toEqual(safes.get(1))
|
||||
})
|
||||
|
||||
it('should return safes under owners case-insensitive', () => {
|
||||
// GIVEN
|
||||
let map: Map<string, Safe> = Map()
|
||||
const userAccountUpper = walletRecord.account.toUpperCase()
|
||||
map = map.set('fooAddress', SafeFactory.oneOwnerSafe(userAccountUpper))
|
||||
map = map.set('barAddress', SafeFactory.twoOwnersSafe('foo', userAccountUpper))
|
||||
|
||||
const reduxStore = {
|
||||
[SAFE_REDUCER_ID]: map,
|
||||
[PROVIDER_REDUCER_ID]: walletRecord,
|
||||
tokens: undefined,
|
||||
transactions: undefined,
|
||||
}
|
||||
|
||||
// WHEN
|
||||
const safes = safesByOwnerSelector(reduxStore, {})
|
||||
|
||||
// THEN
|
||||
expect(safes.count()).toEqual(2)
|
||||
expect(safes.get(0)).not.toEqual(safes.get(1))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default safesListSelectorTests
|
|
@ -1,27 +1,19 @@
|
|||
// @flow
|
||||
import { type Store } from 'redux'
|
||||
import TestUtils from 'react-dom/test-utils'
|
||||
import SafeView from '~/routes/safe/components/Safe'
|
||||
import { aNewStore, type GlobalState } from '~/store'
|
||||
import { sleep } from '~/utils/timer'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { sendEtherTo } from '~/test/utils/tokenMovements'
|
||||
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
|
||||
import { renderSafeView } from '~/test/builder/safe.dom.utils'
|
||||
import { MOVE_FUNDS_BUTTON_TEXT } from '~/routes/safe/components/Safe/BalanceInfo'
|
||||
|
||||
export type DomSafe = {
|
||||
address: string,
|
||||
safeButtons: Element[],
|
||||
safe: React.Component<any, any>,
|
||||
accounts: string[],
|
||||
store: Store<GlobalState>,
|
||||
SafeDom: any,
|
||||
}
|
||||
|
||||
export const filterMoveButtonsFrom = (buttons: Element[]) => buttons.filter(
|
||||
(button: Element): boolean => button.getElementsByTagName('span')[0].textContent !== MOVE_FUNDS_BUTTON_TEXT,
|
||||
)
|
||||
|
||||
export const renderSafeInDom = async (owners: number = 1, threshold: number = 1): Promise<DomSafe> => {
|
||||
// create store
|
||||
const store = aNewStore()
|
||||
|
@ -37,16 +29,9 @@ export const renderSafeInDom = async (owners: number = 1, threshold: number = 1)
|
|||
// wait until funds are displayed and buttons are enabled
|
||||
await sleep(3000)
|
||||
|
||||
// $FlowFixMe
|
||||
const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView)
|
||||
// $FlowFixMe
|
||||
const buttons = TestUtils.scryRenderedDOMComponentsWithTag(Safe, 'button')
|
||||
const filteredButtons = filterMoveButtonsFrom(buttons)
|
||||
|
||||
return {
|
||||
address,
|
||||
safeButtons: filteredButtons,
|
||||
safe: SafeDom,
|
||||
SafeDom,
|
||||
accounts,
|
||||
store,
|
||||
}
|
||||
|
|
|
@ -18,11 +18,7 @@ export const enableFirstToken = async (store: Store, safeAddress: string) => {
|
|||
TestUtils.Simulate.change(firstTokenInput, { target: { checked: 'true' } })
|
||||
}
|
||||
|
||||
export const testToken = (token: Token | typeof undefined, symbol: string, status: boolean, funds?: string) => {
|
||||
export const testToken = (token: Token | typeof undefined, symbol: string) => {
|
||||
if (!token) throw new Error()
|
||||
expect(token.get('symbol')).toBe(symbol)
|
||||
expect(token.get('status')).toBe(status)
|
||||
if (funds) {
|
||||
expect(token.get('funds')).toBe(funds)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
// @flow
|
||||
|
||||
import TestUtils from 'react-dom/test-utils'
|
||||
import * as fetchBalancesAction from '~/logic/tokens/store/actions/fetchTokens'
|
||||
import { aNewStore } from '~/store'
|
||||
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
|
||||
import { addTknTo, getFirstTokenContract } from '~/test/utils/tokenMovements'
|
||||
import { EXPAND_BALANCE_INDEX, travelToSafe } from '~/test/builder/safe.dom.utils'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { sendMoveTokensForm, dispatchTknBalance } from '~/test/utils/transactions/moveTokens.helper'
|
||||
import { sleep } from '~/utils/timer'
|
||||
|
||||
describe('DOM > Feature > SAFE ERC20 TOKENS', () => {
|
||||
let accounts
|
||||
beforeEach(async () => {
|
||||
accounts = await getWeb3().eth.getAccounts()
|
||||
})
|
||||
|
||||
it('sends ERC20 tokens', async () => {
|
||||
// GIVEN
|
||||
const store = aNewStore()
|
||||
const safeAddress = await aMinedSafe(store)
|
||||
|
||||
const numTokens = '100'
|
||||
const tokenAddress = await addTknTo(safeAddress, numTokens)
|
||||
|
||||
await dispatchTknBalance(store, tokenAddress, safeAddress)
|
||||
// const StandardToken = await fetchBalancesAction.getStandardTokenContract()
|
||||
// const myToken = await StandardToken.at(tokenAddress)
|
||||
// console.log(await myToken.allowance(safeAddress, accounts[2]))
|
||||
// console.log(await myToken.balanceOf(safeAddress))
|
||||
|
||||
// WHEN
|
||||
const SafeDom = await travelToSafe(store, safeAddress)
|
||||
await sleep(800)
|
||||
// $FlowFixMe
|
||||
const buttons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button')
|
||||
const expandBalance = buttons[EXPAND_BALANCE_INDEX]
|
||||
const receiver = accounts[2]
|
||||
await sendMoveTokensForm(SafeDom, expandBalance, 20, accounts[2])
|
||||
|
||||
// THEN
|
||||
const safeFunds = await fetchBalancesAction.calculateBalanceOf(tokenAddress, safeAddress, 18)
|
||||
expect(Number(safeFunds)).toBe(80)
|
||||
const receiverFunds = await fetchBalancesAction.calculateBalanceOf(tokenAddress, receiver, 18)
|
||||
expect(Number(receiverFunds)).toBe(20)
|
||||
|
||||
const token = await getFirstTokenContract(getWeb3(), accounts[0])
|
||||
const nativeSafeFunds = await token.balanceOf(safeAddress)
|
||||
expect(Number(nativeSafeFunds.valueOf())).toEqual(80 * 10 ** 18)
|
||||
})
|
||||
|
||||
it('disables send token button when balance is 0', async () => {
|
||||
// GIVEN
|
||||
const token = await getFirstTokenContract(getWeb3(), accounts[0])
|
||||
await dispatchTknBalance(store, token.address, safeAddress)
|
||||
|
||||
// WHEN
|
||||
const SafeDom = travelToSafe(store, safeAddress)
|
||||
|
||||
// $FlowFixMe
|
||||
const buttons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button')
|
||||
const expandBalance = buttons[EXPAND_BALANCE_INDEX]
|
||||
|
||||
TestUtils.Simulate.click(expandBalance)
|
||||
await sleep(800)
|
||||
|
||||
// $FlowFixMe
|
||||
const balanceButtons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button')
|
||||
const tokenButton = balanceButtons[EXPAND_BALANCE_INDEX + 1] // expand button, and the next one is for sending
|
||||
expect(tokenButton.hasAttribute('disabled')).toBe(true)
|
||||
})
|
||||
})
|
|
@ -1,147 +1,17 @@
|
|||
// @flow
|
||||
import TestUtils from 'react-dom/test-utils'
|
||||
import { List } from 'immutable'
|
||||
import Transaction from '~/routes/safe/components/Transactions/Transaction'
|
||||
import {
|
||||
listTxsClickingOn,
|
||||
LIST_TXS_INDEX,
|
||||
ADD_OWNERS_INDEX,
|
||||
EXPAND_OWNERS_INDEX,
|
||||
EDIT_THRESHOLD_INDEX,
|
||||
refreshTransactions,
|
||||
EXPAND_BALANCE_INDEX,
|
||||
} from '~/test/builder/safe.dom.utils'
|
||||
import { renderSafeInDom, type DomSafe } from '~/test/builder/safe.dom.builder'
|
||||
import {
|
||||
sendMoveFundsForm,
|
||||
checkMinedMoveFundsTx,
|
||||
checkPendingMoveFundsTx,
|
||||
} from '~/test/utils/transactions/moveFunds.helper'
|
||||
import {
|
||||
sendAddOwnerForm,
|
||||
checkMinedAddOwnerTx,
|
||||
checkPendingAddOwnerTx,
|
||||
} from '~/test/utils/transactions/addOwner.helper'
|
||||
import {
|
||||
sendRemoveOwnerForm,
|
||||
checkMinedRemoveOwnerTx,
|
||||
checkPendingRemoveOwnerTx,
|
||||
} from '~/test/utils/transactions/removeOwner.helper'
|
||||
import {
|
||||
checkMinedThresholdTx,
|
||||
sendChangeThresholdForm,
|
||||
checkThresholdOf,
|
||||
} from '~/test/utils/transactions/threshold.helper'
|
||||
import { checkBalanceOf } from '~/test/utils/tokenMovements'
|
||||
import { sleep } from '~/utils/timer'
|
||||
import { processTransaction } from '~/logic/safe/safeFrontendOperations'
|
||||
|
||||
// TBD
|
||||
|
||||
describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
|
||||
let domSafe: DomSafe
|
||||
it.only('mines correctly all multisig txs in a 1 owner & 1 threshold safe', async () => {
|
||||
// GIVEN one safe with 1 owner and 1 threshold
|
||||
const owners = 1
|
||||
const threshold = 1
|
||||
domSafe = await renderSafeInDom(owners, threshold)
|
||||
const {
|
||||
address, safe: SafeDom, safeButtons, accounts, store,
|
||||
} = domSafe
|
||||
|
||||
// WHEN
|
||||
await sendMoveFundsForm(SafeDom, safeButtons[EXPAND_BALANCE_INDEX], '0.01', accounts[1])
|
||||
await sendAddOwnerForm(SafeDom, safeButtons[ADD_OWNERS_INDEX], 'Adol Metamask 2', accounts[1])
|
||||
await sleep(1200)
|
||||
await sendChangeThresholdForm(SafeDom, safeButtons[EDIT_THRESHOLD_INDEX], '2')
|
||||
|
||||
// THEN
|
||||
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX], address)
|
||||
const transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
|
||||
|
||||
checkMinedMoveFundsTx(transactions[0], 'Send 0.01 ETH to')
|
||||
checkMinedAddOwnerTx(transactions[1], 'Add Owner Adol Metamask 2')
|
||||
checkMinedThresholdTx(transactions[2], "Change Safe's threshold")
|
||||
})
|
||||
|
||||
it.only('mines withdraw process correctly all multisig txs in a 2 owner & 2 threshold safe', async () => {
|
||||
// GIVEN reusing the state from previous test
|
||||
const {
|
||||
address, safe: SafeDom, safeButtons, accounts, store,
|
||||
} = domSafe
|
||||
|
||||
// WHEN
|
||||
await sendMoveFundsForm(SafeDom, safeButtons[EXPAND_BALANCE_INDEX], '0.01', accounts[1])
|
||||
const increaseThreshold = true
|
||||
await sendAddOwnerForm(SafeDom, safeButtons[ADD_OWNERS_INDEX], 'Adol Metamask 3', accounts[2], increaseThreshold)
|
||||
|
||||
// THEN
|
||||
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX], address)
|
||||
const transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
|
||||
|
||||
const statusses = ['Adol 1 Eth Account [Confirmed]']
|
||||
await checkPendingMoveFundsTx(transactions[3], 2, 'Send 0.01 ETH to', statusses)
|
||||
await checkPendingAddOwnerTx(transactions[4], 2, 'Add Owner Adol Metamask 3', statusses)
|
||||
await checkBalanceOf(address, '0.09')
|
||||
})
|
||||
|
||||
it.only('approves and executes pending transactions', async () => {
|
||||
// GIVEN reusing the state from previous test
|
||||
const {
|
||||
address, safe: SafeDom, safeButtons, accounts, store,
|
||||
} = domSafe
|
||||
|
||||
let transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
|
||||
expect(transactions.length).toBe(5)
|
||||
await checkThresholdOf(address, 2)
|
||||
|
||||
// WHEN... processing pending TXs
|
||||
await processTransaction(address, transactions[3].props.transaction, 1, accounts[1], 2, List([accounts[0]]))
|
||||
await processTransaction(address, transactions[4].props.transaction, 1, accounts[1], 2, List([accounts[0]]))
|
||||
await refreshTransactions(store, address)
|
||||
|
||||
// THEN
|
||||
checkMinedMoveFundsTx(transactions[3], 'Send 0.01 ETH to')
|
||||
await checkBalanceOf(address, '0.08')
|
||||
checkMinedAddOwnerTx(transactions[4], 'Add Owner Adol Metamask 3')
|
||||
await checkThresholdOf(address, 3)
|
||||
|
||||
// WHEN... reducing threshold
|
||||
await sendRemoveOwnerForm(SafeDom, safeButtons[EXPAND_OWNERS_INDEX])
|
||||
|
||||
// THEN
|
||||
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX], address)
|
||||
transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
|
||||
expect(transactions.length).toBe(6)
|
||||
let statusses = ['Adol 1 Eth Account [Confirmed]']
|
||||
await checkPendingRemoveOwnerTx(transactions[5], 3, 'Remove Owner Adol Metamask 3', statusses)
|
||||
|
||||
await processTransaction(address, transactions[5].props.transaction, 1, accounts[2], 3, List([accounts[0]]))
|
||||
await refreshTransactions(store, address)
|
||||
|
||||
transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
|
||||
statusses = ['Adol Metamask 3 [Confirmed]', 'Adol 1 Eth Account [Confirmed]']
|
||||
await checkPendingRemoveOwnerTx(transactions[5], 3, 'Remove Owner Adol Metamask 3', statusses)
|
||||
await checkThresholdOf(address, 3)
|
||||
await processTransaction(
|
||||
address,
|
||||
transactions[5].props.transaction,
|
||||
2,
|
||||
accounts[1],
|
||||
3,
|
||||
List([accounts[0], accounts[2]]),
|
||||
)
|
||||
|
||||
await refreshTransactions(store, address)
|
||||
await checkThresholdOf(address, 2)
|
||||
transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
|
||||
await checkMinedRemoveOwnerTx(transactions[5], 'Remove Owner')
|
||||
|
||||
// WHEN... changing threshold
|
||||
await sendChangeThresholdForm(SafeDom, safeButtons[EDIT_THRESHOLD_INDEX], '1')
|
||||
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX], address)
|
||||
|
||||
// THEN
|
||||
transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
|
||||
await processTransaction(address, transactions[6].props.transaction, 1, accounts[1], 2, List([accounts[0]]))
|
||||
await checkThresholdOf(address, 1)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -12,7 +12,6 @@ import { tokenListSelector } from '~/logic/tokens/store/selectors'
|
|||
import { testToken } from '~/test/builder/tokens.dom.utils'
|
||||
import * as fetchTokensModule from '~/logic/tokens/store/actions/fetchTokens'
|
||||
import * as enhancedFetchModule from '~/utils/fetch'
|
||||
import { clickOnAddToken, fillAddress, fillHumanReadableInfo } from '~/test/utils/tokens/addToken.helper'
|
||||
|
||||
describe('DOM > Feature > Add new ERC 20 Tokens', () => {
|
||||
// let web3
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
// @flow
|
||||
import * as TestUtils from 'react-dom/test-utils'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { getFirstTokenContract, getSecondTokenContract } from '~/test/utils/tokenMovements'
|
||||
import { aNewStore } from '~/store'
|
||||
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
|
||||
import { travelToTokens } from '~/test/builder/safe.dom.utils'
|
||||
import * as fetchTokensModule from '~/logic/tokens/store/actions/fetchTokens'
|
||||
import * as enhancedFetchModule from '~/utils/fetch'
|
||||
import addToken from '~/logic/tokens/store/actions/addToken'
|
||||
import { sleep } from '~/utils/timer'
|
||||
import { testToken } from '~/test/builder/tokens.dom.utils'
|
||||
|
||||
describe('DOM > Feature > Add new ERC 20 Tokens', () => {
|
||||
// let web3
|
||||
// let accounts
|
||||
// let firstErc20Token
|
||||
// let secondErc20Token
|
||||
// beforeAll(async () => {
|
||||
// web3 = getWeb3()
|
||||
// accounts = await web3.eth.getAccounts()
|
||||
// firstErc20Token = await getFirstTokenContract(web3, accounts[0])
|
||||
// secondErc20Token = await getSecondTokenContract(web3, accounts[0])
|
||||
// // $FlowFixMe
|
||||
// enhancedFetchModule.enhancedFetch = jest.fn()
|
||||
// enhancedFetchModule.enhancedFetch.mockImplementation(() => Promise.resolve({
|
||||
// results: [
|
||||
// {
|
||||
// address: firstErc20Token.address,
|
||||
// name: 'First Token Example',
|
||||
// symbol: 'FTE',
|
||||
// decimals: 18,
|
||||
// logoUri: 'https://upload.wikimedia.org/wikipedia/commons/c/c0/Earth_simple_icon.png',
|
||||
// },
|
||||
// ],
|
||||
// }))
|
||||
// })
|
||||
// it('remove custom ERC 20 tokens', async () => {
|
||||
// // GIVEN
|
||||
// const store = aNewStore()
|
||||
// const safeAddress = await aMinedSafe(store)
|
||||
// await store.dispatch(fetchTokensModule.fetchTokens(safeAddress))
|
||||
// const values = {
|
||||
// [TOKEN_ADRESS_PARAM]: secondErc20Token.address,
|
||||
// [TOKEN_NAME_PARAM]: 'Custom ERC20 Token',
|
||||
// [TOKEN_SYMBOL_PARAM]: 'CTS',
|
||||
// [TOKEN_DECIMALS_PARAM]: '10',
|
||||
// [TOKEN_LOGO_URL_PARAM]: 'https://example.com',
|
||||
// }
|
||||
// const customAddTokensFn: any = (...args) => store.dispatch(addToken(...args))
|
||||
// await addTokenFnc(values, customAddTokensFn, safeAddress)
|
||||
// const TokensDom = travelToTokens(store, safeAddress)
|
||||
// await sleep(400)
|
||||
// // WHEN
|
||||
// const buttons = TestUtils.scryRenderedDOMComponentsWithTag(TokensDom, 'button')
|
||||
// expect(buttons.length).toBe(2)
|
||||
// const removeUserButton = buttons[0]
|
||||
// expect(removeUserButton.getAttribute('aria-label')).toBe('Delete')
|
||||
// TestUtils.Simulate.click(removeUserButton)
|
||||
// await sleep(400)
|
||||
// const form = TestUtils.findRenderedDOMComponentWithTag(TokensDom, 'form')
|
||||
// // submit it
|
||||
// TestUtils.Simulate.submit(form)
|
||||
// TestUtils.Simulate.submit(form)
|
||||
// await sleep(400)
|
||||
// const tokens = TestUtils.scryRenderedComponentsWithType(TokensDom, TokenComponent)
|
||||
// expect(tokens.length).toBe(2)
|
||||
// testToken(tokens[0].props.token, 'FTE', false)
|
||||
// testToken(tokens[1].props.token, 'ETH', true)
|
||||
// })
|
||||
})
|
|
@ -1,10 +0,0 @@
|
|||
// @flow
|
||||
import * as React from 'react'
|
||||
|
||||
type WrapperProps = {
|
||||
children: React.Node,
|
||||
}
|
||||
|
||||
const Wrapper = ({ children }: WrapperProps) => <React.Fragment>{children}</React.Fragment>
|
||||
|
||||
export default Wrapper
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
import { type Match } from 'react-router-dom'
|
||||
|
||||
export const buildMathPropsFrom = (address: string): Match => ({
|
||||
export const buildMatchPropsFrom = (address: string): Match => ({
|
||||
params: {
|
||||
address,
|
||||
},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// @flow
|
||||
import React from 'react'
|
||||
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
|
||||
import GnoStepper from '~/components/Stepper'
|
||||
import Stepper from '@material-ui/core/Stepper'
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// @flow
|
||||
import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps'
|
||||
import { buildMatchPropsFrom } from '~/test/utils/buildReactRouterProps'
|
||||
import { safeSelector } from '~/routes/safe/store/selectors/index'
|
||||
import { type Match } from 'react-router-dom'
|
||||
import { type GlobalState } from '~/store'
|
||||
import { type Safe } from '~/routes/safe/store/models/safe'
|
||||
|
||||
export const getSafeFrom = (state: GlobalState, safeAddress: string): Safe => {
|
||||
const match: Match = buildMathPropsFrom(safeAddress)
|
||||
const match: Match = buildMatchPropsFrom(safeAddress)
|
||||
const safe = safeSelector(state, { match })
|
||||
if (!safe) throw new Error()
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
// @flow
|
||||
import { sleep } from '~/utils/timer'
|
||||
import * as TestUtils from 'react-dom/test-utils'
|
||||
import AddToken from '~/logic/tokens/component/AddToken'
|
||||
import { whenOnNext, whenExecuted } from '~/test/utils/logTransactions'
|
||||
|
||||
export const clickOnAddToken = async (TokensDom: React.Component<any, any>) => {
|
||||
const buttons = TestUtils.scryRenderedDOMComponentsWithTag(TokensDom, 'button')
|
||||
expect(buttons.length).toBe(1)
|
||||
TestUtils.Simulate.click(buttons[0])
|
||||
await sleep(400)
|
||||
}
|
||||
|
||||
export const fillAddress = async (TokensDom: React.Component<any, any>, secondErc20Token: any) => {
|
||||
// fill the form
|
||||
const AddTokenComponent = TestUtils.findRenderedComponentWithType(TokensDom, AddToken)
|
||||
if (!AddTokenComponent) throw new Error()
|
||||
|
||||
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(AddTokenComponent, 'input')
|
||||
expect(inputs.length).toBe(1)
|
||||
const tokenAddressInput = inputs[0]
|
||||
TestUtils.Simulate.change(tokenAddressInput, { target: { value: `${secondErc20Token.address}` } })
|
||||
// $FlowFixMe
|
||||
const form = TestUtils.findRenderedDOMComponentWithTag(AddTokenComponent, 'form')
|
||||
// submit it
|
||||
TestUtils.Simulate.submit(form)
|
||||
|
||||
return whenOnNext(TokensDom, AddToken, 1)
|
||||
}
|
||||
|
||||
export const fillHumanReadableInfo = async (TokensDom: React.Component<any, any>) => {
|
||||
// fill the form
|
||||
const AddTokenComponent = TestUtils.findRenderedComponentWithType(TokensDom, AddToken)
|
||||
if (!AddTokenComponent) throw new Error()
|
||||
|
||||
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(AddTokenComponent, 'input')
|
||||
expect(inputs.length).toBe(4)
|
||||
TestUtils.Simulate.change(inputs[3], { target: { value: 'https://my.token.image/foo' } })
|
||||
const form = TestUtils.findRenderedDOMComponentWithTag(AddTokenComponent, 'form')
|
||||
|
||||
// submit it
|
||||
TestUtils.Simulate.submit(form)
|
||||
TestUtils.Simulate.submit(form)
|
||||
|
||||
return whenExecuted(TokensDom, AddToken)
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
// @flow
|
||||
import * as React from 'react'
|
||||
import TestUtils from 'react-dom/test-utils'
|
||||
import { sleep } from '~/utils/timer'
|
||||
import { checkMinedTx, EXPAND_OWNERS_INDEX, checkPendingTx } from '~/test/builder/safe.dom.utils'
|
||||
|
|
Loading…
Reference in New Issue