@@ -15,7 +15,7 @@ import { transactionsAtom } from '../data'
1515import { lookupTransactionById } from '@algorandfoundation/algokit-utils'
1616import { HttpError } from '@/tests/errors'
1717import { base64LogicsigTabLabel , tealLogicsigTabLabel , logicsigLabel } from '../components/logicsig'
18- import { algod } from '@/features/common/data'
18+ import { algod , indexer } from '@/features/common/data'
1919import {
2020 tableTransactionDetailsTabLabel ,
2121 transactionDetailsLabel ,
@@ -427,7 +427,7 @@ describe('transaction-page', () => {
427427 } )
428428 } )
429429
430- describe ( 'when rendering a asset transfer transaction' , ( ) => {
430+ describe ( 'when rendering an asset transfer transaction' , ( ) => {
431431 const transaction = transactionResultMother [ 'mainnet-V7GQPE5TDMB4BIW2GCTPCBMXYMCF3HQGLYOYHGWP256GQHN5QAXQ' ] ( ) . build ( )
432432 const asset = assetResultMother [ 'mainnet-140479105' ] ( ) . build ( )
433433
@@ -490,7 +490,7 @@ describe('transaction-page', () => {
490490 } )
491491 } )
492492
493- describe ( 'when rendering a asset opt-in transaction' , ( ) => {
493+ describe ( 'when rendering an asset opt-in transaction' , ( ) => {
494494 const transaction = transactionResultMother [ 'mainnet-563MNGEL2OF4IBA7CFLIJNMBETT5QNKZURSLIONJBTJFALGYOAUA' ] ( ) . build ( )
495495 const asset = assetResultMother [ 'mainnet-312769' ] ( ) . build ( )
496496
@@ -515,7 +515,7 @@ describe('transaction-page', () => {
515515 } )
516516 } )
517517
518- describe ( 'when rendering a asset clawback transaction' , ( ) => {
518+ describe ( 'when rendering an asset clawback transaction' , ( ) => {
519519 const transaction = transactionResultMother [ 'testnet-VIXTUMAPT7NR4RB2WVOGMETW4QY43KIDA3HWDWWXS3UEDKGTEECQ' ] ( ) . build ( )
520520 const asset = assetResultMother [ 'testnet-642327435' ] ( ) . build ( )
521521
@@ -549,4 +549,64 @@ describe('transaction-page', () => {
549549 )
550550 } )
551551 } )
552+
553+ describe ( 'when rendering an asset transfer transaction for a deleted asset' , ( ) => {
554+ const transaction = transactionResultMother [ 'mainnet-UFYPQDLWCVK3L5XVVHE7WBQWTW4YMHHKZSDIWXXV2AGCS646HTQA' ] ( ) . build ( )
555+ // const asset = assetResultMother['mainnet-140479105']().build()
556+
557+ it ( 'should be rendered with the correct data' , ( ) => {
558+ vi . mocked ( useParams ) . mockImplementation ( ( ) => ( { transactionId : transaction . id } ) )
559+ vi . mocked ( indexer . lookupAssetByID ( 0 ) . do ) . mockImplementation ( ( ) => Promise . reject ( new HttpError ( 'boom' , 404 ) ) )
560+ const myStore = createStore ( )
561+ myStore . set ( transactionsAtom , new Map ( [ [ transaction . id , transaction ] ] ) )
562+
563+ return executeComponentTest (
564+ ( ) => {
565+ return render ( < TransactionPage /> , undefined , myStore )
566+ } ,
567+ async ( component , user ) => {
568+ // waitFor the loading state to be finished
569+ await waitFor ( ( ) => expect ( getByDescriptionTerm ( component . container , transactionIdLabel ) . textContent ) . toBe ( transaction . id ) )
570+ const transactionTypeDescription = getByDescriptionTerm ( component . container , transactionTypeLabel ) . textContent
571+ expect ( transactionTypeDescription ) . toContain ( 'Asset Transfer' )
572+ expect ( getByDescriptionTerm ( component . container , transactionTimestampLabel ) . textContent ) . toBe ( 'Wed, 17 April 2024 05:39:26' )
573+ expect ( getByDescriptionTerm ( component . container , transactionBlockLabel ) . textContent ) . toBe ( '38008738' )
574+ expect ( getByDescriptionTerm ( component . container , transactionGroupLabel ) . textContent ) . toBe (
575+ 'XeNQmhxvtoWpue/7SAk6RNfuu/8Fp8tw8Nfn+HnIz00='
576+ )
577+
578+ expect ( getByDescriptionTerm ( component . container , transactionFeeLabel ) . textContent ) . toBe ( '0.001' )
579+
580+ expect ( getByDescriptionTerm ( component . container , transactionSenderLabel ) . textContent ) . toBe (
581+ 'QUESTA6XV2JZ2XAV3EK3GKBHYCJO57JWUX6L6ENHGNLR6UE3OPCUCT2WLI'
582+ )
583+ expect ( getByDescriptionTerm ( component . container , transactionReceiverLabel ) . textContent ) . toBe (
584+ 'JQ76KXBOL3Z2EKRW43OPHOHKBZJQUULDAH33IIWDX2UWEYEMTKSX2PRS54'
585+ )
586+ expect ( getByDescriptionTerm ( component . container , assetLabel ) . textContent ) . toBe ( '1753701469 (DELETED)' )
587+ expect ( getByDescriptionTerm ( component . container , transactionAmountLabel ) . textContent ) . toBe ( '1 DELETED' )
588+
589+ const viewTransactionTabList = component . getByRole ( 'tablist' , { name : transactionDetailsLabel } )
590+ expect ( viewTransactionTabList ) . toBeTruthy ( )
591+ expect (
592+ component . getByRole ( 'tabpanel' , { name : visualTransactionDetailsTabLabel } ) . getAttribute ( 'data-state' ) ,
593+ 'Visual tab should be active'
594+ ) . toBe ( 'active' )
595+
596+ // After click on the Table tab
597+ await user . click ( getByRole ( viewTransactionTabList , 'tab' , { name : tableTransactionDetailsTabLabel } ) )
598+ const tableViewTab = component . getByRole ( 'tabpanel' , { name : tableTransactionDetailsTabLabel } )
599+ await waitFor ( ( ) => expect ( tableViewTab . getAttribute ( 'data-state' ) , 'Table tab should be active' ) . toBe ( 'active' ) )
600+
601+ // Test the table data
602+ const dataRow = getAllByRole ( tableViewTab , 'row' ) [ 1 ]
603+ expect ( getAllByRole ( dataRow , 'cell' ) [ 0 ] . textContent ) . toBe ( 'UFYPQDL...' )
604+ expect ( getAllByRole ( dataRow , 'cell' ) [ 1 ] . textContent ) . toBe ( 'QUES...2WLI' )
605+ expect ( getAllByRole ( dataRow , 'cell' ) [ 2 ] . textContent ) . toBe ( 'JQ76...RS54' )
606+ expect ( getAllByRole ( dataRow , 'cell' ) [ 3 ] . textContent ) . toBe ( 'Asset Transfer' )
607+ expect ( getAllByRole ( dataRow , 'cell' ) [ 4 ] . textContent ) . toBe ( '1 DELETED' )
608+ }
609+ )
610+ } )
611+ } )
552612} )
0 commit comments