Transaction list tests for txs with threshold=1
This commit is contained in:
parent
034c15d1f3
commit
a963c09050
|
@ -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) => (
|
||||
<Paragraph noMargin>
|
||||
<Paragraph noMargin data-testid={TRANSACTIONS_DESC_SEND_TEST_ID}>
|
||||
<Bold>
|
||||
Send
|
||||
{' '}
|
||||
|
@ -51,21 +56,21 @@ to:
|
|||
const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: DescriptionDescProps) => (
|
||||
<>
|
||||
{removedOwner && (
|
||||
<Paragraph>
|
||||
<Paragraph data-testid={TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID}>
|
||||
<Bold>Remove owner:</Bold>
|
||||
<br />
|
||||
<EtherscanLink type="address" value={removedOwner} />
|
||||
</Paragraph>
|
||||
)}
|
||||
{addedOwner && (
|
||||
<Paragraph>
|
||||
<Paragraph data-testid={TRANSACTIONS_DESC_ADD_OWNER_TEST_ID}>
|
||||
<Bold>Add owner:</Bold>
|
||||
<br />
|
||||
<EtherscanLink type="address" value={addedOwner} />
|
||||
</Paragraph>
|
||||
)}
|
||||
{newThreshold && (
|
||||
<Paragraph>
|
||||
<Paragraph data-testid={TRANSACTIONS_DESC_CHANGE_THRESHOLD_TEST_ID}>
|
||||
<Bold>Change required confirmations:</Bold>
|
||||
<br />
|
||||
{newThreshold}
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
export * from './moveFunds.helper'
|
||||
export * from './moveTokens.helper'
|
||||
export * from './threshold.helper'
|
||||
export * from './transactionList.helper'
|
||||
|
|
|
@ -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<any, any>) => {
|
||||
|
@ -21,6 +22,18 @@ export const getLastTransaction = async (SafeDom: React.Component<any, any>) =>
|
|||
fireEvent.click(transactionRows[0])
|
||||
}
|
||||
|
||||
export const checkRegisteredTxSend = async (
|
||||
SafeDom: React.Component<any, any>,
|
||||
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<any, any>,
|
||||
ownerAddress: string,
|
||||
|
|
Loading…
Reference in New Issue