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 EtherscanLink from '~/components/EtherscanLink'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
import { md, lg, secondary } from '~/theme/variables'
|
import { md, lg } from '~/theme/variables'
|
||||||
import { getTxData } from './utils'
|
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 = () => ({
|
export const styles = () => ({
|
||||||
txDataContainer: {
|
txDataContainer: {
|
||||||
padding: `${lg} ${md}`,
|
padding: `${lg} ${md}`,
|
||||||
|
@ -33,7 +38,7 @@ type DescriptionDescProps = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const TransferDescription = ({ value = '', symbol, recipient }: TransferDescProps) => (
|
const TransferDescription = ({ value = '', symbol, recipient }: TransferDescProps) => (
|
||||||
<Paragraph noMargin>
|
<Paragraph noMargin data-testid={TRANSACTIONS_DESC_SEND_TEST_ID}>
|
||||||
<Bold>
|
<Bold>
|
||||||
Send
|
Send
|
||||||
{' '}
|
{' '}
|
||||||
|
@ -51,21 +56,21 @@ to:
|
||||||
const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: DescriptionDescProps) => (
|
const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: DescriptionDescProps) => (
|
||||||
<>
|
<>
|
||||||
{removedOwner && (
|
{removedOwner && (
|
||||||
<Paragraph>
|
<Paragraph data-testid={TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID}>
|
||||||
<Bold>Remove owner:</Bold>
|
<Bold>Remove owner:</Bold>
|
||||||
<br />
|
<br />
|
||||||
<EtherscanLink type="address" value={removedOwner} />
|
<EtherscanLink type="address" value={removedOwner} />
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
)}
|
)}
|
||||||
{addedOwner && (
|
{addedOwner && (
|
||||||
<Paragraph>
|
<Paragraph data-testid={TRANSACTIONS_DESC_ADD_OWNER_TEST_ID}>
|
||||||
<Bold>Add owner:</Bold>
|
<Bold>Add owner:</Bold>
|
||||||
<br />
|
<br />
|
||||||
<EtherscanLink type="address" value={addedOwner} />
|
<EtherscanLink type="address" value={addedOwner} />
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
)}
|
)}
|
||||||
{newThreshold && (
|
{newThreshold && (
|
||||||
<Paragraph>
|
<Paragraph data-testid={TRANSACTIONS_DESC_CHANGE_THRESHOLD_TEST_ID}>
|
||||||
<Bold>Change required confirmations:</Bold>
|
<Bold>Change required confirmations:</Bold>
|
||||||
<br />
|
<br />
|
||||||
{newThreshold}
|
{newThreshold}
|
||||||
|
|
|
@ -13,8 +13,8 @@ import { calculateBalanceOf } from '~/routes/safe/store/actions/fetchTokenBalanc
|
||||||
import updateActiveTokens from '~/routes/safe/store/actions/updateActiveTokens'
|
import updateActiveTokens from '~/routes/safe/store/actions/updateActiveTokens'
|
||||||
import '@testing-library/jest-dom/extend-expect'
|
import '@testing-library/jest-dom/extend-expect'
|
||||||
import updateSafe from '~/routes/safe/store/actions/updateSafe'
|
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 { BALANCE_ROW_TEST_ID } from '~/routes/safe/components/Balances'
|
||||||
import { fillAndSubmitSendFundsForm } from './utils/transactions'
|
|
||||||
|
|
||||||
afterEach(cleanup)
|
afterEach(cleanup)
|
||||||
|
|
||||||
|
@ -60,6 +60,9 @@ describe('DOM > Feature > Sending Funds', () => {
|
||||||
expect(Number(parseInt(receiverBalanceAfterTx, 10) - parseInt(receiverBalanceBeforeTx, 10))).toBeGreaterThan(
|
expect(Number(parseInt(receiverBalanceAfterTx, 10) - parseInt(receiverBalanceBeforeTx, 10))).toBeGreaterThan(
|
||||||
parseInt(ethAmount, 10) - ESTIMATED_GASCOSTS,
|
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 () => {
|
it('Sends Tokens with threshold = 1', async () => {
|
||||||
|
@ -98,5 +101,8 @@ describe('DOM > Feature > Sending Funds', () => {
|
||||||
expect(Number(safeFunds)).toBe(0)
|
expect(Number(safeFunds)).toBe(0)
|
||||||
const receiverFunds = await calculateBalanceOf(tokenAddress, tokenReceiver, 18)
|
const receiverFunds = await calculateBalanceOf(tokenAddress, tokenReceiver, 18)
|
||||||
expect(receiverFunds).toBe(tokensAmount)
|
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 './moveFunds.helper'
|
||||||
export * from './moveTokens.helper'
|
export * from './moveTokens.helper'
|
||||||
export * from './threshold.helper'
|
export * from './threshold.helper'
|
||||||
|
export * from './transactionList.helper'
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { TRANSACTION_ROW_TEST_ID } from '~/routes/safe/components/TransactionsNe
|
||||||
import {
|
import {
|
||||||
TRANSACTIONS_DESC_ADD_OWNER_TEST_ID,
|
TRANSACTIONS_DESC_ADD_OWNER_TEST_ID,
|
||||||
TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID,
|
TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID,
|
||||||
|
TRANSACTIONS_DESC_SEND_TEST_ID,
|
||||||
} from '~/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription'
|
} from '~/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription'
|
||||||
|
|
||||||
export const getLastTransaction = async (SafeDom: React.Component<any, any>) => {
|
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])
|
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 (
|
export const checkRegisteredTxAddOwner = async (
|
||||||
SafeDom: React.Component<any, any>,
|
SafeDom: React.Component<any, any>,
|
||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
|
|
Loading…
Reference in New Issue