diff --git a/src/frontend/src/lib/components/transactions/AllTransactionsList.svelte b/src/frontend/src/lib/components/transactions/AllTransactionsList.svelte index f4ab1f2f01..0d95cc9a99 100644 --- a/src/frontend/src/lib/components/transactions/AllTransactionsList.svelte +++ b/src/frontend/src/lib/components/transactions/AllTransactionsList.svelte @@ -7,6 +7,8 @@ import { ethTransactionsStore } from '$eth/stores/eth-transactions.store'; import type { EthTransactionUi } from '$eth/types/eth-transaction'; import IcTransactionModal from '$icp/components/transactions/IcTransactionModal.svelte'; + import { btcStatusesStore } from '$icp/stores/btc.store'; + import { icTransactionsStore } from '$icp/stores/ic-transactions.store'; import type { IcTransactionUi } from '$icp/types/ic-transaction'; import { ckEthMinterInfoStore } from '$icp-eth/stores/cketh.store'; import TransactionsDateGroup from '$lib/components/transactions/TransactionsDateGroup.svelte'; @@ -28,15 +30,14 @@ import { mapAllTransactionsUi, sortTransactions } from '$lib/utils/transactions.utils'; let transactions: AllTransactionsUi; - // TODO: add icTransactions and btcStatuses $: transactions = mapAllTransactionsUi({ tokens: $enabledTokens, $btcTransactions: $btcTransactionsStore, $ethTransactions: $ethTransactionsStore, $ckEthMinterInfo: $ckEthMinterInfoStore, $ethAddress: $ethAddress, - $icTransactions: {}, - $btcStatuses: {} + $icTransactions: $icTransactionsStore, + $btcStatuses: $btcStatusesStore }); let sortedTransactions: AllTransactionsUi; diff --git a/src/frontend/src/tests/lib/components/transactions/AllTransactionsList.spec.ts b/src/frontend/src/tests/lib/components/transactions/AllTransactionsList.spec.ts index dc4c94a31c..f85ae207cd 100644 --- a/src/frontend/src/tests/lib/components/transactions/AllTransactionsList.spec.ts +++ b/src/frontend/src/tests/lib/components/transactions/AllTransactionsList.spec.ts @@ -4,13 +4,15 @@ import * as networkEnv from '$env/networks.env'; import { ETHEREUM_NETWORK_ID, SEPOLIA_NETWORK_ID } from '$env/networks.env'; import * as ethEnv from '$env/networks.eth.env'; import { BTC_MAINNET_TOKEN_ID } from '$env/tokens.btc.env'; -import { ETHEREUM_TOKEN_ID } from '$env/tokens.env'; +import { ETHEREUM_TOKEN_ID, ICP_TOKEN_ID } from '$env/tokens.env'; import { ethTransactionsStore } from '$eth/stores/eth-transactions.store'; +import { icTransactionsStore } from '$icp/stores/ic-transactions.store'; import AllTransactionsList from '$lib/components/transactions/AllTransactionsList.svelte'; import * as transactionsUtils from '$lib/utils/transactions.utils'; import { createMockBtcTransactionsUi } from '$tests/mocks/btc.mock'; import { createMockEthTransactions } from '$tests/mocks/eth-transactions.mock'; import en from '$tests/mocks/i18n.mock'; +import { createMockIcTransactionsUi } from '$tests/mocks/ic-transactions.mock'; import { render } from '@testing-library/svelte'; describe('AllTransactionsList', () => { @@ -35,27 +37,12 @@ describe('AllTransactionsList', () => { describe('when the transactions list is not empty', () => { const btcTransactionsNumber = 5; const ethTransactionsNumber = 3; + const icTransactionsNumber = 7; const todayTimestamp = new Date().getTime(); const yesterdayTimestamp = todayTimestamp - 24 * 60 * 60 * 1000; - btcTransactionsStore.append({ - tokenId: BTC_MAINNET_TOKEN_ID, - transactions: createMockBtcTransactionsUi(btcTransactionsNumber).map((transaction) => ({ - data: { ...transaction, timestamp: BigInt(todayTimestamp) }, - certified: false - })) - }); - - ethTransactionsStore.add({ - tokenId: ETHEREUM_TOKEN_ID, - transactions: createMockEthTransactions(ethTransactionsNumber).map((transaction) => ({ - ...transaction, - timestamp: yesterdayTimestamp - })) - }); - - beforeEach(() => { + beforeAll(() => { vi.resetAllMocks(); vi.spyOn(btcEnv, 'BTC_MAINNET_ENABLED', 'get').mockImplementation(() => true); @@ -65,6 +52,30 @@ describe('AllTransactionsList', () => { ETHEREUM_NETWORK_ID, SEPOLIA_NETWORK_ID ]); + + btcTransactionsStore.append({ + tokenId: BTC_MAINNET_TOKEN_ID, + transactions: createMockBtcTransactionsUi(btcTransactionsNumber).map((transaction) => ({ + data: { ...transaction, timestamp: BigInt(todayTimestamp) }, + certified: false + })) + }); + + ethTransactionsStore.add({ + tokenId: ETHEREUM_TOKEN_ID, + transactions: createMockEthTransactions(ethTransactionsNumber).map((transaction) => ({ + ...transaction, + timestamp: yesterdayTimestamp + })) + }); + + icTransactionsStore.append({ + tokenId: ICP_TOKEN_ID, + transactions: createMockIcTransactionsUi(icTransactionsNumber).map((transaction) => ({ + data: { ...transaction, timestamp: BigInt(todayTimestamp) }, + certified: false + })) + }); }); it('should not render the placeholder', () => { @@ -93,7 +104,9 @@ describe('AllTransactionsList', () => { (el) => el.parentElement?.parentElement === container ); - expect(transactionComponents).toHaveLength(btcTransactionsNumber + ethTransactionsNumber); + expect(transactionComponents).toHaveLength( + btcTransactionsNumber + ethTransactionsNumber + icTransactionsNumber + ); }); }); }); diff --git a/src/frontend/src/tests/mocks/ic-transactions.mock.ts b/src/frontend/src/tests/mocks/ic-transactions.mock.ts index 1ab7eec083..9c4de5a3b7 100644 --- a/src/frontend/src/tests/mocks/ic-transactions.mock.ts +++ b/src/frontend/src/tests/mocks/ic-transactions.mock.ts @@ -4,5 +4,6 @@ export const createMockIcTransactionsUi = (n: number): IcTransactionUi[] => Array.from({ length: n }, () => ({ id: crypto.randomUUID(), type: 'send', - status: 'executed' + status: 'executed', + value: BigInt(1) }));