WA-232 Reducing executing time of transactions DOM tests by 40%

This commit is contained in:
apanizo 2018-07-04 10:51:57 +02:00
parent c40488493d
commit 91b2fa8e0e
7 changed files with 13 additions and 29 deletions

View File

@ -10,6 +10,7 @@ import { checkMinedThresholdTx, sendChangeThresholdForm, checkThresholdOf } from
import { sendWithdrawForm, checkMinedWithdrawTx } from '~/test/utils/transactions/withdraw.helper' import { sendWithdrawForm, checkMinedWithdrawTx } from '~/test/utils/transactions/withdraw.helper'
import { processTransaction } from '~/routes/safe/component/Transactions/processTransactions' import { processTransaction } from '~/routes/safe/component/Transactions/processTransactions'
import { checkBalanceOf } from '~/test/utils/tokenMovements' import { checkBalanceOf } from '~/test/utils/tokenMovements'
import { sleep } from '~/utils/timer'
describe('DOM > Feature > SAFE MULTISIG Transactions', () => { describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
let domSafe: DomSafe let domSafe: DomSafe
@ -26,6 +27,7 @@ describe('DOM > Feature > SAFE MULTISIG Transactions', () => {
await sendMoveFundsForm(SafeDom, safeButtons[EXPAND_BALANCE_INDEX], '0.01', accounts[1]) await sendMoveFundsForm(SafeDom, safeButtons[EXPAND_BALANCE_INDEX], '0.01', accounts[1])
await sendWithdrawForm(SafeDom, safeButtons[WITHDRAW_INDEX], '0.01', accounts[3]) await sendWithdrawForm(SafeDom, safeButtons[WITHDRAW_INDEX], '0.01', accounts[3])
await sendAddOwnerForm(SafeDom, safeButtons[ADD_OWNERS_INDEX], 'Adol Metamask 2', 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') await sendChangeThresholdForm(SafeDom, safeButtons[EDIT_THRESHOLD_INDEX], '2')
// THEN // THEN

View File

@ -3,7 +3,7 @@ import TestUtils from 'react-dom/test-utils'
import { sleep } from '~/utils/timer' import { sleep } from '~/utils/timer'
import { checkMinedTx, checkPendingTx } from '~/test/builder/safe.dom.utils' import { checkMinedTx, checkPendingTx } from '~/test/builder/safe.dom.utils'
export const sendAddOwnerForm = ( export const sendAddOwnerForm = async (
SafeDom: React$Component<any, any>, SafeDom: React$Component<any, any>,
addOwner: React$Component<any, any>, addOwner: React$Component<any, any>,
ownerName: string, ownerName: string,
@ -13,7 +13,7 @@ export const sendAddOwnerForm = (
// load add multisig form component // load add multisig form component
TestUtils.Simulate.click(addOwner) TestUtils.Simulate.click(addOwner)
// give time to re-render it // give time to re-render it
sleep(600) await sleep(400)
// fill the form // fill the form
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input')
@ -33,9 +33,6 @@ export const sendAddOwnerForm = (
// submit it // submit it
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
// give time to process transaction
return sleep(2500)
} }
export const checkMinedAddOwnerTx = (Transaction: React$Component<any, any>, name: string) => { export const checkMinedAddOwnerTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -12,13 +12,13 @@ export const sendMoveFundsForm = async (
// load add multisig form component // load add multisig form component
TestUtils.Simulate.click(expandBalance) TestUtils.Simulate.click(expandBalance)
// give time to re-render it // give time to re-render it
await sleep(600) await sleep(400)
const ethList = TestUtils.findRenderedDOMComponentWithClass(SafeDom, 'ETH') const ethList = TestUtils.findRenderedDOMComponentWithClass(SafeDom, 'ETH')
if (!ethList) throw new Error() if (!ethList) throw new Error()
const ethButton = ethList.getElementsByTagName('button') const ethButton = ethList.getElementsByTagName('button')
TestUtils.Simulate.click(ethButton[0]) TestUtils.Simulate.click(ethButton[0])
await sleep(850) await sleep(450)
// fill the form // fill the form
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input')
@ -32,9 +32,6 @@ export const sendMoveFundsForm = async (
// submit it // submit it
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
// give time to process transaction
return sleep(2500)
} }
export const checkMinedMoveFundsTx = (Transaction: React$Component<any, any>, name: string) => { export const checkMinedMoveFundsTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -14,7 +14,7 @@ export const sendMoveTokensForm = async (
destination: string, destination: string,
) => { ) => {
TestUtils.Simulate.click(expandBalance) TestUtils.Simulate.click(expandBalance)
await sleep(800) await sleep(500)
// $FlowFixMe // $FlowFixMe
const balanceButtons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button') const balanceButtons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button')
@ -23,7 +23,7 @@ export const sendMoveTokensForm = async (
// load move tokens form component // load move tokens form component
TestUtils.Simulate.click(tokenButton) TestUtils.Simulate.click(tokenButton)
await sleep(800) await sleep(500)
// fill the form // fill the form
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input')
@ -37,9 +37,6 @@ export const sendMoveTokensForm = async (
// submit it // submit it
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
// give time to process transaction
return sleep(1250)
} }
export const dispatchTknBalance = async (store: Store, tokenAddress: string, address: string) => { export const dispatchTknBalance = async (store: Store, tokenAddress: string, address: string) => {

View File

@ -10,7 +10,7 @@ export const sendRemoveOwnerForm = async (
) => { ) => {
// Expand owners // Expand owners
TestUtils.Simulate.click(expandOwners) TestUtils.Simulate.click(expandOwners)
await sleep(600) await sleep(400)
// Get delete button user // Get delete button user
const allButtons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button') const allButtons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button')
@ -20,7 +20,7 @@ export const sendRemoveOwnerForm = async (
// render form for deleting the user // render form for deleting the user
TestUtils.Simulate.click(removeUserButton) TestUtils.Simulate.click(removeUserButton)
await sleep(600) await sleep(400)
// $FlowFixMe // $FlowFixMe
const form = TestUtils.findRenderedDOMComponentWithTag(SafeDom, 'form') const form = TestUtils.findRenderedDOMComponentWithTag(SafeDom, 'form')
@ -28,9 +28,6 @@ export const sendRemoveOwnerForm = async (
// submit it // submit it
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
// give time to process transaction
return sleep(2500)
} }
export const checkMinedRemoveOwnerTx = (Transaction: React$Component<any, any>, name: string) => { export const checkMinedRemoveOwnerTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -4,14 +4,14 @@ import { sleep } from '~/utils/timer'
import { checkMinedTx } from '~/test/builder/safe.dom.utils' import { checkMinedTx } from '~/test/builder/safe.dom.utils'
import { getGnosisSafeInstanceAt } from '~/wallets/safeContracts' import { getGnosisSafeInstanceAt } from '~/wallets/safeContracts'
export const sendChangeThresholdForm = ( export const sendChangeThresholdForm = async (
SafeDom: React$Component<any, any>, SafeDom: React$Component<any, any>,
changeThreshold: React$Component<any, any>, changeThreshold: React$Component<any, any>,
threshold: string, threshold: string,
) => { ) => {
// Load the Threshold Form // Load the Threshold Form
TestUtils.Simulate.click(changeThreshold) TestUtils.Simulate.click(changeThreshold)
sleep(600) await sleep(400)
// fill the form // fill the form
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input')
@ -23,9 +23,6 @@ export const sendChangeThresholdForm = (
// submit it // submit it
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
// give time to process transaction
return sleep(2500)
} }
export const checkMinedThresholdTx = (Transaction: React$Component<any, any>, name: string) => { export const checkMinedThresholdTx = (Transaction: React$Component<any, any>, name: string) => {

View File

@ -13,7 +13,7 @@ export const sendWithdrawForm = async (
// load add multisig form component // load add multisig form component
TestUtils.Simulate.click(withdrawButton) TestUtils.Simulate.click(withdrawButton)
// give time to re-render it // give time to re-render it
await sleep(600) await sleep(400)
// fill the form // fill the form
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input')
@ -27,9 +27,6 @@ export const sendWithdrawForm = async (
// submit it // submit it
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form)
// give time to process transaction
return sleep(2500)
} }
export const checkMinedWithdrawTx = async ( export const checkMinedWithdrawTx = async (