From a963c090507ca38cda30e21fa3d3ce7189f2c928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Sat, 20 Jul 2019 20:51:38 +0200 Subject: [PATCH] Transaction list tests for txs with threshold=1 --- .../TxsTable/ExpandedTx/TxDescription/index.jsx | 15 ++++++++++----- src/test/safe.dom.funds.threshold=1.test.js | 8 +++++++- src/test/utils/transactions/index.js | 1 + .../utils/transactions/transactionList.helper.js | 13 +++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx index cc523ced..8508e9d3 100644 --- a/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx +++ b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx @@ -6,9 +6,14 @@ import Bold from '~/components/layout/Bold' import EtherscanLink from '~/components/EtherscanLink' import Paragraph from '~/components/layout/Paragraph' import Block from '~/components/layout/Block' -import { md, lg, secondary } from '~/theme/variables' +import { md, lg } from '~/theme/variables' import { getTxData } from './utils' +export const TRANSACTIONS_DESC_ADD_OWNER_TEST_ID = 'tx-description-add-owner' +export const TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID = 'tx-description-remove-owner' +export const TRANSACTIONS_DESC_CHANGE_THRESHOLD_TEST_ID = 'tx-description-change-threshold' +export const TRANSACTIONS_DESC_SEND_TEST_ID = 'tx-description-send' + export const styles = () => ({ txDataContainer: { padding: `${lg} ${md}`, @@ -33,7 +38,7 @@ type DescriptionDescProps = { } const TransferDescription = ({ value = '', symbol, recipient }: TransferDescProps) => ( - + Send {' '} @@ -51,21 +56,21 @@ to: const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: DescriptionDescProps) => ( <> {removedOwner && ( - + Remove owner:
)} {addedOwner && ( - + Add owner:
)} {newThreshold && ( - + Change required confirmations:
{newThreshold} diff --git a/src/test/safe.dom.funds.threshold=1.test.js b/src/test/safe.dom.funds.threshold=1.test.js index 22ef1861..9ae989d7 100644 --- a/src/test/safe.dom.funds.threshold=1.test.js +++ b/src/test/safe.dom.funds.threshold=1.test.js @@ -13,8 +13,8 @@ import { calculateBalanceOf } from '~/routes/safe/store/actions/fetchTokenBalanc import updateActiveTokens from '~/routes/safe/store/actions/updateActiveTokens' import '@testing-library/jest-dom/extend-expect' import updateSafe from '~/routes/safe/store/actions/updateSafe' +import { checkRegisteredTxSend, fillAndSubmitSendFundsForm } from './utils/transactions' import { BALANCE_ROW_TEST_ID } from '~/routes/safe/components/Balances' -import { fillAndSubmitSendFundsForm } from './utils/transactions' afterEach(cleanup) @@ -60,6 +60,9 @@ describe('DOM > Feature > Sending Funds', () => { expect(Number(parseInt(receiverBalanceAfterTx, 10) - parseInt(receiverBalanceBeforeTx, 10))).toBeGreaterThan( parseInt(ethAmount, 10) - ESTIMATED_GASCOSTS, ) + + // Check that the transaction was registered + await checkRegisteredTxSend(SafeDom, ethAmount, 'ETH', accounts[9]) }) it('Sends Tokens with threshold = 1', async () => { @@ -98,5 +101,8 @@ describe('DOM > Feature > Sending Funds', () => { expect(Number(safeFunds)).toBe(0) const receiverFunds = await calculateBalanceOf(tokenAddress, tokenReceiver, 18) expect(receiverFunds).toBe(tokensAmount) + + // Check that the transaction was registered + await checkRegisteredTxSend(SafeDom, tokensAmount, 'OMG', tokenReceiver) }) }) diff --git a/src/test/utils/transactions/index.js b/src/test/utils/transactions/index.js index 8c9d029a..a46d1181 100644 --- a/src/test/utils/transactions/index.js +++ b/src/test/utils/transactions/index.js @@ -2,3 +2,4 @@ export * from './moveFunds.helper' export * from './moveTokens.helper' export * from './threshold.helper' +export * from './transactionList.helper' diff --git a/src/test/utils/transactions/transactionList.helper.js b/src/test/utils/transactions/transactionList.helper.js index d54fc721..0998d8bd 100644 --- a/src/test/utils/transactions/transactionList.helper.js +++ b/src/test/utils/transactions/transactionList.helper.js @@ -7,6 +7,7 @@ import { TRANSACTION_ROW_TEST_ID } from '~/routes/safe/components/TransactionsNe import { TRANSACTIONS_DESC_ADD_OWNER_TEST_ID, TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID, + TRANSACTIONS_DESC_SEND_TEST_ID, } from '~/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription' export const getLastTransaction = async (SafeDom: React.Component) => { @@ -21,6 +22,18 @@ export const getLastTransaction = async (SafeDom: React.Component) => fireEvent.click(transactionRows[0]) } +export const checkRegisteredTxSend = async ( + SafeDom: React.Component, + ethAmount: number, + symbol: string, + ethAddress: string, +) => { + await getLastTransaction(SafeDom) + + const txDescription = SafeDom.getAllByTestId(TRANSACTIONS_DESC_SEND_TEST_ID)[0] + expect(txDescription).toHaveTextContent(`Send ${ethAmount} ${symbol} ${shortVersionOf(ethAddress, 4)}`) +} + export const checkRegisteredTxAddOwner = async ( SafeDom: React.Component, ownerAddress: string,