WA-232 Fix tests

This commit is contained in:
apanizo 2018-07-04 16:31:15 +02:00
parent c13711906d
commit ca53182b65
11 changed files with 31 additions and 15 deletions

View File

@ -45,13 +45,12 @@ export const removeOwner = async (
const newThreshold = values[DECREASE_PARAM] ? threshold - 1 : threshold
const safeAddress = safe.get('address')
const gnosisSafe = await getSafeEthereumInstance(safeAddress)
const storedOwners = await gnosisSafe.getOwners()
const index = storedOwners.findIndex(ownerAddress => ownerAddress === userToRemove)
const prevAddress = index === 0 ? SENTINEL_ADDRESS : storedOwners[index - 1]
const data = gnosisSafe.contract.removeOwner.getData(prevAddress, userToRemove, newThreshold)
const text = name || userToRemove
return createTransaction(safe, `Remove Owner ${text}`, safeAddress, 0, nonce, executor, data)
}
@ -65,7 +64,7 @@ class RemoveOwner extends React.Component<Props, State> {
const {
safe, threshold, executor, fetchTransactions, userToRemove, name,
} = this.props
await removeOwner(values, safe, threshold, userToRemove, executor, name)
await removeOwner(values, safe, threshold, userToRemove, name, executor)
fetchTransactions()
this.setState({ done: true })
} catch (error) {

View File

@ -20,6 +20,7 @@ import { type DailyLimitProps } from '~/routes/safe/store/model/dailyLimit'
import { WITHDRAW_INDEX } from '~/test/builder/safe.dom.utils'
import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps'
import { safeSelector } from '~/routes/safe/store/selectors/index'
import { filterMoveButtonsFrom } from '~/test/builder/safe.dom.builder'
describe('React DOM TESTS > Withdraw funds from safe', () => {
let SafeDom
@ -48,7 +49,8 @@ describe('React DOM TESTS > Withdraw funds from safe', () => {
const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView)
// $FlowFixMe
const buttons = TestUtils.scryRenderedDOMComponentsWithTag(Safe, 'button')
const expandedButtons = TestUtils.scryRenderedDOMComponentsWithTag(Safe, 'button')
const buttons = filterMoveButtonsFrom(expandedButtons)
const addWithdrawButton = buttons[WITHDRAW_INDEX]
expect(addWithdrawButton.getElementsByTagName('span')[0].innerHTML).toEqual(WITHDRAW_BUTTON_TEXT)
TestUtils.Simulate.click(addWithdrawButton)

View File

@ -20,12 +20,14 @@ export const EDIT_INDEX = 4
export const WITHDRAW_INDEX = 5
export const LIST_TXS_INDEX = 6
export const listTxsClickingOn = async (seeTxsButton: Element) => {
export const listTxsClickingOn = async (store: Store, seeTxsButton: Element) => {
await store.dispatch(fetchTransactions())
await sleep(1200)
expect(seeTxsButton.getElementsByTagName('span')[0].innerHTML).toEqual(SEE_MULTISIG_BUTTON_TEXT)
TestUtils.Simulate.click(seeTxsButton)
// give some time to expand the transactions
await sleep(1500)
await sleep(800)
}
export const checkMinedTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -39,6 +39,7 @@ describe('DOM > Feature > SAFE ERC20 TOKENS', () => {
const expandBalance = buttons[EXPAND_BALANCE_INDEX]
const receiver = accounts[2]
await sendMoveTokensForm(SafeDom, expandBalance, 20, accounts[2])
await sleep(800)
// THEN
const safeFunds = await fetchBalancesAction.calculateBalanceOf(tokenAddress, safeAddress)

View File

@ -20,7 +20,7 @@ describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
const threshold = 1
domSafe = await renderSafeInDom(owners, threshold)
const {
address, safe: SafeDom, safeButtons, accounts,
address, safe: SafeDom, safeButtons, accounts, store,
} = domSafe
// WHEN
@ -31,7 +31,7 @@ describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
await sendChangeThresholdForm(SafeDom, safeButtons[EDIT_THRESHOLD_INDEX], '2')
// THEN
await listTxsClickingOn(safeButtons[LIST_TXS_INDEX])
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX])
const transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
checkMinedMoveFundsTx(transactions[0], 'Send 0.01 ETH to')
@ -43,7 +43,7 @@ describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
it('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,
address, safe: SafeDom, safeButtons, accounts, store,
} = domSafe
// WHEN
@ -53,10 +53,10 @@ describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
await sendWithdrawForm(SafeDom, safeButtons[WITHDRAW_INDEX], '0.01', accounts[3])
// THEN
await listTxsClickingOn(safeButtons[LIST_TXS_INDEX])
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX])
const transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
const statusses = ['Adol Metamask 2 [Not confirmed]', 'Adolfo 1 Eth Account [Confirmed]']
const statusses = ['Adol Metamask 2 [Not confirmed]', 'Adol 1 Eth Account [Confirmed]']
await checkPendingMoveFundsTx(transactions[4], 2, 'Send 0.01 ETH to', statusses)
await checkPendingAddOwnerTx(transactions[5], 2, 'Add Owner Adol Metamask 3', statusses)
// checkMinedThresholdTx(transactions[4], 'Add Owner Adol Metamask 3')
@ -87,16 +87,16 @@ describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
await sendRemoveOwnerForm(SafeDom, safeButtons[EXPAND_OWNERS_INDEX])
// THEN
await listTxsClickingOn(safeButtons[LIST_TXS_INDEX])
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX])
transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
expect(transactions.length).toBe(8)
let statusses = ['Adol Metamask 3 [Not confirmed]', 'Adol Metamask 2 [Not confirmed]', 'Adolfo 1 Eth Account [Confirmed]']
let statusses = ['Adol Metamask 3 [Not confirmed]', 'Adol Metamask 2 [Not confirmed]', 'Adol 1 Eth Account [Confirmed]']
await checkPendingRemoveOwnerTx(transactions[7], 3, 'Remove Owner Adol Metamask 3', statusses)
await processTransaction(address, transactions[7].props.transaction, 1, accounts[1])
await refreshTransactions(store)
transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)
statusses = ['Adol Metamask 3 [Not confirmed]', 'Adol Metamask 2 [Confirmed]', 'Adolfo 1 Eth Account [Confirmed]']
statusses = ['Adol Metamask 3 [Not confirmed]', 'Adol Metamask 2 [Confirmed]', 'Adol 1 Eth Account [Confirmed]']
await checkPendingRemoveOwnerTx(transactions[7], 2, 'Remove Owner Adol Metamask 3', statusses)
await checkThresholdOf(address, 3)
@ -108,7 +108,7 @@ describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
// WHEN... changing threshold
await sendChangeThresholdForm(SafeDom, safeButtons[EDIT_THRESHOLD_INDEX], '1')
await listTxsClickingOn(safeButtons[LIST_TXS_INDEX])
await listTxsClickingOn(store, safeButtons[LIST_TXS_INDEX])
// THEN
transactions = TestUtils.scryRenderedComponentsWithType(SafeDom, Transaction)

View File

@ -33,6 +33,8 @@ export const sendAddOwnerForm = async (
// submit it
TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form)
return sleep(200)
}
export const checkMinedAddOwnerTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -32,6 +32,8 @@ export const sendMoveFundsForm = async (
// submit it
TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form)
return sleep(200)
}
export const checkMinedMoveFundsTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -37,6 +37,8 @@ export const sendMoveTokensForm = async (
// submit it
TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form)
return sleep(200)
}
export const dispatchTknBalance = async (store: Store, tokenAddress: string, address: string) => {

View File

@ -28,6 +28,8 @@ export const sendRemoveOwnerForm = async (
// submit it
TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form)
return sleep(200)
}
export const checkMinedRemoveOwnerTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -23,6 +23,8 @@ export const sendChangeThresholdForm = async (
// submit it
TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form)
return sleep(200)
}
export const checkMinedThresholdTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -27,6 +27,8 @@ export const sendWithdrawForm = async (
// submit it
TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form)
return sleep(200)
}
export const checkMinedWithdrawTx = async (