@@ -109,7 +109,7 @@ describe('Data Fetcher', () => {
109109 expect ( result . vms ) . toEqual ( [ ] ) ;
110110 expect ( result . containers ) . toEqual ( [ ] ) ;
111111 expect ( result . pbs ) . toEqual ( [ ] ) ; // PBS fetch should still run
112- expect ( consoleLogSpy ) . toHaveBeenCalledWith ( "[DataFetcher] Discovery cycle completed. Found: 0 PVE nodes, 0 VMs, 0 CTs, 0 PBS instances." ) ;
112+ expect ( consoleLogSpy ) . toHaveBeenCalledWith ( "[DataFetcher] Discovery cycle completed. Found: 0 PVE nodes, 0 VMs, 0 CTs, 0 PBS instances, 0 PVE backup tasks, 0 guest snapshots ." ) ;
113113 expect ( mockPbsFunction ) . toHaveBeenCalled ( ) ; // Ensure PBS was still called
114114
115115 consoleLogSpy . mockRestore ( ) ;
@@ -132,20 +132,27 @@ describe('Data Fetcher', () => {
132132 . mockResolvedValueOnce ( { data : { data : { cpu : 0.1 , mem : 2 * 1024 ** 3 , rootfs : { total : 100 * 1024 ** 3 , used : 20 * 1024 ** 3 } , uptime : 12345 } } } ) // 4. /nodes/mock-node/status
133133 . mockResolvedValueOnce ( { data : { data : [ { storage : 'local-lvm' , type : 'lvmthin' , content : 'images,rootdir' , total : 500 * 1024 ** 3 , used : 150 * 1024 ** 3 } ] } } ) // 5. /nodes/mock-node/storage
134134 . mockResolvedValueOnce ( { data : { data : [ { vmid : vmId , name : 'test-vm' , status : 'running' , cpu : 0.5 , mem : 1 * 1024 ** 3 , maxmem : 2 * 1024 ** 3 , maxdisk : 32 * 1024 ** 3 } ] } } ) // 6. /nodes/mock-node/qemu
135- . mockResolvedValueOnce ( { data : { data : [ { vmid : ctId , name : 'test-ct' , status : 'running' , cpu : 0.2 , mem : 512 * 1024 ** 2 , maxmem : 1 * 1024 ** 3 , maxdisk : 8 * 1024 ** 3 } ] } } ) ; // 7. /nodes/mock-node/lxc
135+ . mockResolvedValueOnce ( { data : { data : [ { vmid : ctId , name : 'test-ct' , status : 'running' , cpu : 0.2 , mem : 512 * 1024 ** 2 , maxmem : 1 * 1024 ** 3 , maxdisk : 8 * 1024 ** 3 } ] } } ) // 7. /nodes/mock-node/lxc
136+ // Additional calls for backup data
137+ . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 8. /nodes/mock-node/tasks (backup tasks)
138+ . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 9. /nodes/mock-node/qemu/100/snapshot (VM snapshots)
139+ . mockResolvedValueOnce ( { data : { data : [ ] } } ) ; // 10. /nodes/mock-node/lxc/101/snapshot (CT snapshots)
136140
137141 // Act: Call function with the clients provided by the (mocked) default setup
138142 const result = await fetchDiscoveryData ( mockPveApiClient , mockPbsApiClient ) ;
139143
140144 // Assert
141- expect ( mockPveClientInstance . get ) . toHaveBeenCalledTimes ( 7 ) ; // Updated to 7
145+ expect ( mockPveClientInstance . get ) . toHaveBeenCalledTimes ( 10 ) ; // Updated to 10 for backup calls
142146 expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 1 , '/cluster/status' ) ;
143147 expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 2 , '/nodes' ) ; // For standaloneNodeName
144148 expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 3 , '/nodes' ) ; // Main nodes call
145149 expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 4 , `/nodes/${ nodeName } /status` ) ;
146150 expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 5 , `/nodes/${ nodeName } /storage` ) ;
147151 expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 6 , `/nodes/${ nodeName } /qemu` ) ;
148152 expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 7 , `/nodes/${ nodeName } /lxc` ) ;
153+ expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 8 , `/nodes/${ nodeName } /tasks` , { params : { typefilter : 'vzdump' , limit : 1000 } } ) ;
154+ expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 9 , `/nodes/${ nodeName } /qemu/${ vmId } /snapshot` ) ;
155+ expect ( mockPveClientInstance . get ) . toHaveBeenNthCalledWith ( 10 , `/nodes/${ nodeName } /lxc/${ ctId } /snapshot` ) ;
149156
150157 // Assert Nodes
151158 expect ( result . nodes ) . toHaveLength ( 1 ) ;
@@ -189,6 +196,12 @@ describe('Data Fetcher', () => {
189196 id : `${ endpointId } -${ nodeName } -${ ctId } ` // Check constructed ID
190197 } ) ;
191198
199+ // Assert PVE Backups
200+ expect ( result . pveBackups ) . toBeDefined ( ) ;
201+ expect ( result . pveBackups . backupTasks ) . toEqual ( [ ] ) ;
202+ expect ( result . pveBackups . storageBackups ) . toEqual ( [ ] ) ;
203+ expect ( result . pveBackups . guestSnapshots ) . toEqual ( [ ] ) ;
204+
192205 // Assert PBS (should be empty)
193206 expect ( result . pbs ) . toBeDefined ( ) ;
194207 expect ( result . pbs ) . toHaveLength ( 0 ) ;
@@ -289,7 +302,8 @@ describe('Data Fetcher', () => {
289302 . mockResolvedValueOnce ( { data : { data : { cpu : 0.1 , uptime : 10 } } } ) // 4. /nodes/node-pve2/status
290303 . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 5. /nodes/node-pve2/storage
291304 . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 6. /nodes/node-pve2/qemu
292- . mockResolvedValueOnce ( { data : { data : [ ] } } ) ; // 7. /nodes/node-pve2/lxc <<< SHOULD BE EMPTY
305+ . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 7. /nodes/node-pve2/lxc <<< SHOULD BE EMPTY
306+ . mockResolvedValueOnce ( { data : { data : [ ] } } ) ; // 8. /nodes/node-pve2/tasks (backup tasks)
293307
294308 const result = await fetchDiscoveryData ( mockClients , { } ) ; // Pass custom clients
295309
@@ -300,7 +314,7 @@ describe('Data Fetcher', () => {
300314 // );
301315
302316 // Assert mockPveClientInstance2 (successful endpoint)
303- expect ( mockPveClientInstance2 . get ) . toHaveBeenCalledTimes ( 7 ) ;
317+ expect ( mockPveClientInstance2 . get ) . toHaveBeenCalledTimes ( 8 ) ;
304318
305319 // Should still return data from the successful endpoint (pve2)
306320 expect ( result . nodes ) . toHaveLength ( 1 ) ;
@@ -700,7 +714,8 @@ describe('Data Fetcher', () => {
700714 . mockRejectedValueOnce ( statusFetchError ) // 4. /nodes/${nodeName}/status << THIS FAILS
701715 . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 5. /nodes/${nodeName}/storage (subsequent calls should still be mocked)
702716 . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 6. /nodes/${nodeName}/qemu
703- . mockResolvedValueOnce ( { data : { data : [ ] } } ) ; // 7. /nodes/${nodeName}/lxc
717+ . mockResolvedValueOnce ( { data : { data : [ ] } } ) // 7. /nodes/${nodeName}/lxc
718+ . mockResolvedValueOnce ( { data : { data : [ ] } } ) ; // 8. /nodes/${nodeName}/tasks (backup tasks)
704719
705720 const result = await fetchDiscoveryData ( mockPveApiClient , mockPbsApiClient ) ;
706721
@@ -801,7 +816,12 @@ describe('Data Fetcher', () => {
801816 nodes : [ ] ,
802817 vms : [ ] ,
803818 containers : [ ] ,
804- pbs : [ ]
819+ pbs : [ ] ,
820+ pveBackups : {
821+ backupTasks : [ ] ,
822+ guestSnapshots : [ ] ,
823+ storageBackups : [ ]
824+ }
805825 } ) ;
806826
807827 consoleErrorSpy . mockRestore ( ) ;
0 commit comments