File tree Expand file tree Collapse file tree
src/ui/src/dashboard/flow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from 'vitest'
2+ import { render } from '@testing-library/react'
3+ import { FlowItem } from './FlowItem'
4+ import type { FlowItemData } from './flow-data'
5+
6+ function makeItem ( direction : boolean ) : FlowItemData {
7+ return {
8+ id : '1' ,
9+ idx : 1 ,
10+ method : 'INVITE' ,
11+ description : 'desc' ,
12+ srcIp : '10.0.0.1' ,
13+ dstIp : '10.0.0.2' ,
14+ srcPort : 5060 ,
15+ dstPort : 5070 ,
16+ callid : 'c1' ,
17+ callidColors : {
18+ color : '#000000' ,
19+ tabColor : '#000000' ,
20+ arrowColor : '#00ff00' ,
21+ } ,
22+ methodColor : '#00ff00' ,
23+ timeStr : '' ,
24+ fullDateStr : '' ,
25+ diffStr : '+0.0ms' ,
26+ protoLabel : 'UDP' ,
27+ payloadType : 'SIP' ,
28+ start : 0 ,
29+ middle : 1 ,
30+ rightEnd : 0 ,
31+ direction,
32+ isRadial : false ,
33+ isLastHost : false ,
34+ arrowStyleSolid : true ,
35+ raw : { } ,
36+ }
37+ }
38+
39+ describe ( 'FlowItem port labels' , ( ) => {
40+ it ( 'shows src on left and dst on right for left-to-right packets' , ( ) => {
41+ const { container } = render (
42+ < FlowItem item = { makeItem ( false ) } isSimplify = { false } isAbsoluteTime = { false } /> ,
43+ )
44+
45+ expect ( container . querySelector ( '.port-label-left' ) ?. textContent ) . toBe ( '5060' )
46+ expect ( container . querySelector ( '.port-label-right' ) ?. textContent ) . toBe ( '5070' )
47+ } )
48+
49+ it ( 'shows dst on left and src on right for right-to-left packets' , ( ) => {
50+ const { container } = render (
51+ < FlowItem item = { makeItem ( true ) } isSimplify = { false } isAbsoluteTime = { false } /> ,
52+ )
53+
54+ expect ( container . querySelector ( '.port-label-left' ) ?. textContent ) . toBe ( '5070' )
55+ expect ( container . querySelector ( '.port-label-right' ) ?. textContent ) . toBe ( '5060' )
56+ } )
57+ } )
Original file line number Diff line number Diff line change @@ -74,10 +74,10 @@ export function FlowItem({
7474 ) : (
7575 < >
7676 < div className = { item . direction ? 'port-label-right' : 'port-label-left' } >
77- { item . direction ? item . dstPort || '' : item . srcPort || '' }
77+ { item . srcPort || '' }
7878 </ div >
7979 < div className = { item . direction ? 'port-label-left' : 'port-label-right' } >
80- { item . direction ? item . srcPort || '' : item . dstPort || '' }
80+ { item . dstPort || '' }
8181 </ div >
8282 </ >
8383 ) }
You can’t perform that action at this time.
0 commit comments