@@ -42,6 +42,25 @@ const mockEntityWithoutAnnotations = {
4242 } ,
4343} ;
4444
45+ const mockRuntimeScanV1 = {
46+ resultId : 'result-abc123' ,
47+ resourceId : 'sha256:a1b2c3d4e5f6' ,
48+ mainAssetName : 'nginx:latest' ,
49+ policyEvaluationResult : 'failed' ,
50+ isRiskSpotlightEnabled : true ,
51+ sbomId : 'sbom-xyz' ,
52+ scope : {
53+ 'asset.type' : 'workload' ,
54+ 'kubernetes.cluster.name' : 'test-cluster' ,
55+ 'kubernetes.namespace.name' : 'test-namespace' ,
56+ 'kubernetes.workload.name' : 'nginx' ,
57+ 'kubernetes.workload.type' : 'deployment' ,
58+ 'kubernetes.pod.container.name' : 'nginx' ,
59+ } ,
60+ vulnTotalBySeverity : { critical : 2 , high : 5 , medium : 10 , low : 3 , negligible : 1 } ,
61+ runningVulnTotalBySeverity : { critical : 1 , high : 2 , medium : 4 , low : 1 , negligible : 0 } ,
62+ } ;
63+
4564const mockSysdigApi = {
4665 fetchVulnRuntime : jest . fn ( ) . mockResolvedValue ( { data : [ ] } ) ,
4766 fetchVulnRegistry : jest . fn ( ) . mockResolvedValue ( { data : [ ] } ) ,
@@ -93,4 +112,48 @@ describe('SysdigVMRuntimeFetchComponent', () => {
93112 const message = await screen . findByText ( / m i s s i n g a n n o t a t i o n / i) ;
94113 expect ( message ) . toBeInTheDocument ( ) ;
95114 } ) ;
115+
116+ it ( 'renders rows using v1 policyEvaluationResult field (without s)' , async ( ) => {
117+ const apiWithData = {
118+ ...mockSysdigApi ,
119+ fetchVulnRuntime : jest . fn ( ) . mockResolvedValue ( { data : [ mockRuntimeScanV1 ] } ) ,
120+ } ;
121+
122+ await renderInTestApp (
123+ < TestApiProvider apis = { [
124+ [ sysdigApiRef , apiWithData ] ,
125+ [ configApiRef , mockConfig ] ,
126+ ] } >
127+ < EntityProvider entity = { mockEntity } >
128+ < SysdigVMRuntimeFetchComponent />
129+ </ EntityProvider >
130+ </ TestApiProvider >
131+ ) ;
132+
133+ expect ( await screen . findByText ( 'nginx:latest' ) ) . toBeInTheDocument ( ) ;
134+ expect ( screen . getByText ( 'failed' ) ) . toBeInTheDocument ( ) ;
135+ } ) ;
136+
137+ it ( 'filters out rows with null policyEvaluationResult' , async ( ) => {
138+ const scanWithNullPolicy = { ...mockRuntimeScanV1 , policyEvaluationResult : null as any } ;
139+ const apiWithData = {
140+ ...mockSysdigApi ,
141+ fetchVulnRuntime : jest . fn ( ) . mockResolvedValue ( { data : [ scanWithNullPolicy , mockRuntimeScanV1 ] } ) ,
142+ } ;
143+
144+ await renderInTestApp (
145+ < TestApiProvider apis = { [
146+ [ sysdigApiRef , apiWithData ] ,
147+ [ configApiRef , mockConfig ] ,
148+ ] } >
149+ < EntityProvider entity = { mockEntity } >
150+ < SysdigVMRuntimeFetchComponent />
151+ </ EntityProvider >
152+ </ TestApiProvider >
153+ ) ;
154+
155+ // Only the scan with a non-null policyEvaluationResult should appear (1 row = 1 asset name)
156+ const rows = await screen . findAllByText ( 'nginx:latest' ) ;
157+ expect ( rows ) . toHaveLength ( 1 ) ;
158+ } ) ;
96159} ) ;
0 commit comments