@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
22import {
33 buildExplorerNetworkHref ,
44 EXPLORER_NETWORK_OPTIONS ,
5+ isExplorerNetworkPathPreservable ,
56} from '#lib/explorer-network.ts'
67
78const MAINNET_HOST = 'https://explore.tempo.xyz'
@@ -41,20 +42,29 @@ describe('explorer network switcher hrefs', () => {
4142 )
4243 } )
4344
44- it ( 'links to the target network homepage from not-found pages' , ( ) => {
45+ it ( 'preserves resource paths even when the current route rendered not found' , ( ) => {
46+ expect ( isExplorerNetworkPathPreservable ( `/receipt/${ SAMPLE_HASH } ` ) ) . toBe (
47+ true ,
48+ )
49+ expect (
50+ isExplorerNetworkPathPreservable ( `/tx/${ SAMPLE_HASH } ?tab=logs#top` ) ,
51+ ) . toBe ( true )
52+ expect (
53+ buildExplorerNetworkHref ( TESTNET_HOST , `/receipt/${ SAMPLE_HASH } ` ) ,
54+ ) . toBe ( `${ TESTNET_HOST } /receipt/${ SAMPLE_HASH } ` )
55+ expect (
56+ buildExplorerNetworkHref ( MAINNET_HOST , `/tx/${ SAMPLE_HASH } ?tab=logs#top` ) ,
57+ ) . toBe ( `${ MAINNET_HOST } /tx/${ SAMPLE_HASH } ?tab=logs#top` )
58+ } )
59+
60+ it ( 'still links unknown not-found routes to the target network homepage' , ( ) => {
61+ expect ( isExplorerNetworkPathPreservable ( '/definitely-not-a-route' ) ) . toBe (
62+ false ,
63+ )
4564 expect (
46- buildExplorerNetworkHref ( TESTNET_HOST , `/receipt/ ${ SAMPLE_HASH } ` , {
65+ buildExplorerNetworkHref ( TESTNET_HOST , '/definitely-not-a-route' , {
4766 fallbackToHome : true ,
4867 } ) ,
4968 ) . toBe ( `${ TESTNET_HOST } /` )
50- expect (
51- buildExplorerNetworkHref (
52- MAINNET_HOST ,
53- `/tx/${ SAMPLE_HASH } ?tab=logs#top` ,
54- {
55- fallbackToHome : true ,
56- } ,
57- ) ,
58- ) . toBe ( `${ MAINNET_HOST } /` )
5969 } )
6070} )
0 commit comments