From 91b2fa8e0e6f91925c15a3e630e5d15febc26f1d Mon Sep 17 00:00:00 2001 From: apanizo Date: Wed, 4 Jul 2018 10:51:57 +0200 Subject: [PATCH] WA-232 Reducing executing time of transactions DOM tests by 40% --- src/test/safe.dom.transactions.test.js | 2 ++ src/test/utils/transactions/addOwner.helper.js | 7 ++----- src/test/utils/transactions/moveFunds.helper.js | 7 ++----- src/test/utils/transactions/moveTokens.helper.js | 7 ++----- src/test/utils/transactions/removeOwner.helper.js | 7 ++----- src/test/utils/transactions/threshold.helper.js | 7 ++----- src/test/utils/transactions/withdraw.helper.js | 5 +---- 7 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/test/safe.dom.transactions.test.js b/src/test/safe.dom.transactions.test.js index a7dba53e..0283cc96 100644 --- a/src/test/safe.dom.transactions.test.js +++ b/src/test/safe.dom.transactions.test.js @@ -10,6 +10,7 @@ import { checkMinedThresholdTx, sendChangeThresholdForm, checkThresholdOf } from import { sendWithdrawForm, checkMinedWithdrawTx } from '~/test/utils/transactions/withdraw.helper' import { processTransaction } from '~/routes/safe/component/Transactions/processTransactions' import { checkBalanceOf } from '~/test/utils/tokenMovements' +import { sleep } from '~/utils/timer' describe('DOM > Feature > SAFE MULTISIG Transactions', () => { 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 sendWithdrawForm(SafeDom, safeButtons[WITHDRAW_INDEX], '0.01', accounts[3]) await sendAddOwnerForm(SafeDom, safeButtons[ADD_OWNERS_INDEX], 'Adol Metamask 2', accounts[1]) + await sleep(1200) await sendChangeThresholdForm(SafeDom, safeButtons[EDIT_THRESHOLD_INDEX], '2') // THEN diff --git a/src/test/utils/transactions/addOwner.helper.js b/src/test/utils/transactions/addOwner.helper.js index 2d88fb4f..941f3f43 100644 --- a/src/test/utils/transactions/addOwner.helper.js +++ b/src/test/utils/transactions/addOwner.helper.js @@ -3,7 +3,7 @@ import TestUtils from 'react-dom/test-utils' import { sleep } from '~/utils/timer' import { checkMinedTx, checkPendingTx } from '~/test/builder/safe.dom.utils' -export const sendAddOwnerForm = ( +export const sendAddOwnerForm = async ( SafeDom: React$Component, addOwner: React$Component, ownerName: string, @@ -13,7 +13,7 @@ export const sendAddOwnerForm = ( // load add multisig form component TestUtils.Simulate.click(addOwner) // give time to re-render it - sleep(600) + await sleep(400) // fill the form const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') @@ -33,9 +33,6 @@ export const sendAddOwnerForm = ( // submit it TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form) - - // give time to process transaction - return sleep(2500) } export const checkMinedAddOwnerTx = (Transaction: React$Component, name: string) => { diff --git a/src/test/utils/transactions/moveFunds.helper.js b/src/test/utils/transactions/moveFunds.helper.js index fff9e749..5a988927 100644 --- a/src/test/utils/transactions/moveFunds.helper.js +++ b/src/test/utils/transactions/moveFunds.helper.js @@ -12,13 +12,13 @@ export const sendMoveFundsForm = async ( // load add multisig form component TestUtils.Simulate.click(expandBalance) // give time to re-render it - await sleep(600) + await sleep(400) const ethList = TestUtils.findRenderedDOMComponentWithClass(SafeDom, 'ETH') if (!ethList) throw new Error() const ethButton = ethList.getElementsByTagName('button') TestUtils.Simulate.click(ethButton[0]) - await sleep(850) + await sleep(450) // fill the form const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') @@ -32,9 +32,6 @@ export const sendMoveFundsForm = async ( // submit it TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form) - - // give time to process transaction - return sleep(2500) } export const checkMinedMoveFundsTx = (Transaction: React$Component, name: string) => { diff --git a/src/test/utils/transactions/moveTokens.helper.js b/src/test/utils/transactions/moveTokens.helper.js index 78c494e8..81094a69 100644 --- a/src/test/utils/transactions/moveTokens.helper.js +++ b/src/test/utils/transactions/moveTokens.helper.js @@ -14,7 +14,7 @@ export const sendMoveTokensForm = async ( destination: string, ) => { TestUtils.Simulate.click(expandBalance) - await sleep(800) + await sleep(500) // $FlowFixMe const balanceButtons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button') @@ -23,7 +23,7 @@ export const sendMoveTokensForm = async ( // load move tokens form component TestUtils.Simulate.click(tokenButton) - await sleep(800) + await sleep(500) // fill the form const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') @@ -37,9 +37,6 @@ export const sendMoveTokensForm = async ( // submit it 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) => { diff --git a/src/test/utils/transactions/removeOwner.helper.js b/src/test/utils/transactions/removeOwner.helper.js index 0e6b2588..30ceda46 100644 --- a/src/test/utils/transactions/removeOwner.helper.js +++ b/src/test/utils/transactions/removeOwner.helper.js @@ -10,7 +10,7 @@ export const sendRemoveOwnerForm = async ( ) => { // Expand owners TestUtils.Simulate.click(expandOwners) - await sleep(600) + await sleep(400) // Get delete button user const allButtons = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'button') @@ -20,7 +20,7 @@ export const sendRemoveOwnerForm = async ( // render form for deleting the user TestUtils.Simulate.click(removeUserButton) - await sleep(600) + await sleep(400) // $FlowFixMe const form = TestUtils.findRenderedDOMComponentWithTag(SafeDom, 'form') @@ -28,9 +28,6 @@ export const sendRemoveOwnerForm = async ( // submit it TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form) - - // give time to process transaction - return sleep(2500) } export const checkMinedRemoveOwnerTx = (Transaction: React$Component, name: string) => { diff --git a/src/test/utils/transactions/threshold.helper.js b/src/test/utils/transactions/threshold.helper.js index c2f32e4c..9168aa42 100644 --- a/src/test/utils/transactions/threshold.helper.js +++ b/src/test/utils/transactions/threshold.helper.js @@ -4,14 +4,14 @@ import { sleep } from '~/utils/timer' import { checkMinedTx } from '~/test/builder/safe.dom.utils' import { getGnosisSafeInstanceAt } from '~/wallets/safeContracts' -export const sendChangeThresholdForm = ( +export const sendChangeThresholdForm = async ( SafeDom: React$Component, changeThreshold: React$Component, threshold: string, ) => { // Load the Threshold Form TestUtils.Simulate.click(changeThreshold) - sleep(600) + await sleep(400) // fill the form const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') @@ -23,9 +23,6 @@ export const sendChangeThresholdForm = ( // submit it TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form) - - // give time to process transaction - return sleep(2500) } export const checkMinedThresholdTx = (Transaction: React$Component, name: string) => { diff --git a/src/test/utils/transactions/withdraw.helper.js b/src/test/utils/transactions/withdraw.helper.js index 7aab043e..d8e34d05 100644 --- a/src/test/utils/transactions/withdraw.helper.js +++ b/src/test/utils/transactions/withdraw.helper.js @@ -13,7 +13,7 @@ export const sendWithdrawForm = async ( // load add multisig form component TestUtils.Simulate.click(withdrawButton) // give time to re-render it - await sleep(600) + await sleep(400) // fill the form const inputs = TestUtils.scryRenderedDOMComponentsWithTag(SafeDom, 'input') @@ -27,9 +27,6 @@ export const sendWithdrawForm = async ( // submit it TestUtils.Simulate.submit(form) TestUtils.Simulate.submit(form) - - // give time to process transaction - return sleep(2500) } export const checkMinedWithdrawTx = async (