File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed
frontend/src/components/ConsumerGroups Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ const List = () => {
6262 header : 'Consumer Lag' ,
6363 accessorKey : 'consumerLag' ,
6464 cell : ( args ) => {
65- return args . getValue ( ) || 'N/A' ;
65+ return args . getValue ( ) ?? 'N/A' ;
6666 } ,
6767 } ,
6868 {
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { screen } from '@testing-library/react' ;
3+ import { render } from 'lib/testHelpers' ;
4+ import { useConsumerGroups } from 'lib/hooks/api/consumers' ;
5+ import List from 'components/ConsumerGroups/List' ;
6+
7+ // Mock hooks
8+ jest . mock ( 'lib/hooks/api/consumers' , ( ) => ( {
9+ useConsumerGroups : jest . fn ( ) ,
10+ } ) ) ;
11+
12+ jest . mock ( 'react-router-dom' , ( ) => ( {
13+ ...jest . requireActual ( 'react-router-dom' ) ,
14+ useSearchParams : ( ) => [ new URLSearchParams ( ) , jest . fn ( ) ] ,
15+ useNavigate : ( ) => jest . fn ( ) ,
16+ } ) ) ;
17+
18+ const mockUseConsumerGroups = useConsumerGroups as jest . Mock ;
19+
20+ describe ( 'ConsumerGroups List' , ( ) => {
21+ beforeEach ( ( ) => {
22+ mockUseConsumerGroups . mockImplementation ( ( ) => ( {
23+ data : {
24+ consumerGroups : [
25+ {
26+ groupId : 'group1' ,
27+ consumerLag : 0 ,
28+ members : 1 ,
29+ topics : 1 ,
30+ coordinator : { id : 1 } ,
31+ state : 'STABLE' ,
32+ } ,
33+ {
34+ groupId : 'group2' ,
35+ consumerLag : null ,
36+ members : 1 ,
37+ topics : 1 ,
38+ coordinator : { id : 2 } ,
39+ state : 'STABLE' ,
40+ } ,
41+ ] ,
42+ pageCount : 1 ,
43+ } ,
44+ isSuccess : true ,
45+ isFetching : false ,
46+ } ) ) ;
47+ } ) ;
48+
49+ it ( 'renders consumer lag values correctly' , ( ) => {
50+ render ( < List /> ) ;
51+ const tableRows = screen . getAllByRole ( 'row' ) ;
52+ expect ( tableRows [ 1 ] ) . toHaveTextContent ( '0' ) ;
53+ expect ( tableRows [ 2 ] ) . toHaveTextContent ( 'N/A' ) ;
54+ } ) ;
55+ } ) ;
You can’t perform that action at this time.
0 commit comments