@@ -69,7 +69,6 @@ vi.mock('@nextcloud/files', () => ({
6969 }
7070 } ,
7171 registerFileAction : vi . fn ( ) ,
72- getSidebar : vi . fn ( ( ) => mockSidebar ) ,
7372} ) )
7473
7574vi . mock ( '@nextcloud/capabilities' , ( ) => ( {
@@ -131,6 +130,12 @@ describe('openInLibreSignAction rules', () => {
131130 mockSidebar . open . mockClear ( )
132131 mockSidebar . setActiveTab . mockClear ( )
133132
133+ // Set up NC32-compatible window.OCA.Files.Sidebar mock
134+ window . OCA = {
135+ Libresign : { } ,
136+ Files : { Sidebar : mockSidebar as OCAFilesSidebar } ,
137+ }
138+
134139 const { loadState : loadStateModule } = await import ( '@nextcloud/initial-state' )
135140 const { getCapabilities : getCapabilitiesModule } = await import ( '@nextcloud/capabilities' )
136141
@@ -304,11 +309,11 @@ describe('openInLibreSignAction rules', () => {
304309 } )
305310
306311 it ( 'opens sidebar with file' , async ( ) => {
307- const node = { type : 'file' , mime : 'application/pdf' , fileid : 123 }
312+ const node = { type : 'file' , mime : 'application/pdf' , fileid : 123 , path : '/test.pdf' }
308313
309314 await action . exec ( { nodes : [ node ] } )
310315
311- expect ( mockSidebar . open ) . toHaveBeenCalledWith ( node , 'libresign ')
316+ expect ( mockSidebar . open ) . toHaveBeenCalledWith ( '/test.pdf ')
312317 expect ( mockSidebar . setActiveTab ) . toHaveBeenCalledWith ( 'libresign' )
313318 } )
314319
@@ -317,15 +322,16 @@ describe('openInLibreSignAction rules', () => {
317322 type : 'folder' ,
318323 attributes : { 'libresign-signature-status' : 'signed' } ,
319324 fileid : 456 ,
325+ path : '/Documents' ,
320326 }
321327
322328 await action . exec ( { nodes : [ node ] } )
323329
324- expect ( mockSidebar . open ) . toHaveBeenCalledWith ( node , 'libresign ')
330+ expect ( mockSidebar . open ) . toHaveBeenCalledWith ( '/Documents ')
325331 } )
326332
327333 it ( 'returns null after execution' , async ( ) => {
328- const node = { type : 'file' , mime : 'application/pdf' }
334+ const node = { type : 'file' , mime : 'application/pdf' , path : '/test.pdf' }
329335 const result = await action . exec ( { nodes : [ node ] } )
330336
331337 expect ( result ) . toBeNull ( )
@@ -382,11 +388,11 @@ let spawnDialog: typeof import('@nextcloud/vue/functions/dialog').spawnDialog
382388
383389 it ( 'opens sidebar after envelope creation' , async ( ) => {
384390 const nodes = [
385- { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Docs' } ,
386- { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Docs' } ,
391+ { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Docs' , path : '/Docs/file1.pdf' } ,
392+ { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Docs' , path : '/Docs/file2.pdf' } ,
387393 ]
388394
389- window . OCA = { Libresign : { } }
395+ window . OCA = { Libresign : { } , Files : { Sidebar : mockSidebar as OCAFilesSidebar } }
390396
391397 await action . execBatch ( { nodes } )
392398
@@ -396,11 +402,11 @@ let spawnDialog: typeof import('@nextcloud/vue/functions/dialog').spawnDialog
396402
397403 it ( 'creates correct pending envelope structure' , async ( ) => {
398404 const nodes = [
399- { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Docs' } ,
400- { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Docs' } ,
405+ { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Docs' , path : '/Docs/file1.pdf' } ,
406+ { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Docs' , path : '/Docs/file2.pdf' } ,
401407 ]
402408
403- window . OCA = { Libresign : { } }
409+ window . OCA = { Libresign : { } , Files : { Sidebar : mockSidebar as OCAFilesSidebar } }
404410
405411 await action . execBatch ( { nodes } )
406412
@@ -413,11 +419,11 @@ let spawnDialog: typeof import('@nextcloud/vue/functions/dialog').spawnDialog
413419
414420 it ( 'calculates envelope path correctly with subdirectory' , async ( ) => {
415421 const nodes = [
416- { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Documents/Contracts' } ,
417- { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Documents/Contracts' } ,
422+ { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Documents/Contracts' , path : '/Documents/Contracts/a.pdf' } ,
423+ { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Documents/Contracts' , path : '/Documents/Contracts/b.pdf' } ,
418424 ]
419425
420- window . OCA = { Libresign : { } }
426+ window . OCA = { Libresign : { } , Files : { Sidebar : mockSidebar as OCAFilesSidebar } }
421427
422428 await action . execBatch ( { nodes } )
423429
@@ -427,11 +433,11 @@ let spawnDialog: typeof import('@nextcloud/vue/functions/dialog').spawnDialog
427433
428434 it ( 'calculates envelope path correctly in root' , async ( ) => {
429435 const nodes = [
430- { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/' } ,
431- { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/' } ,
436+ { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/' , path : '/file1.pdf' } ,
437+ { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/' , path : '/file2.pdf' } ,
432438 ]
433439
434- window . OCA = { Libresign : { } }
440+ window . OCA = { Libresign : { } , Files : { Sidebar : mockSidebar as OCAFilesSidebar } }
435441
436442 await action . execBatch ( { nodes } )
437443
@@ -441,11 +447,11 @@ let spawnDialog: typeof import('@nextcloud/vue/functions/dialog').spawnDialog
441447
442448 it ( 'handles trailing slashes in dirname' , async ( ) => {
443449 const nodes = [
444- { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Docs/' } ,
445- { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Docs/' } ,
450+ { type : 'file' , mime : 'application/pdf' , fileid : 1 , dirname : '/Docs/' , path : '/Docs/file1.pdf' } ,
451+ { type : 'file' , mime : 'application/pdf' , fileid : 2 , dirname : '/Docs/' , path : '/Docs/file2.pdf' } ,
446452 ]
447453
448- window . OCA = { Libresign : { } }
454+ window . OCA = { Libresign : { } , Files : { Sidebar : mockSidebar as OCAFilesSidebar } }
449455
450456 await action . execBatch ( { nodes } )
451457
@@ -460,18 +466,20 @@ let spawnDialog: typeof import('@nextcloud/vue/functions/dialog').spawnDialog
460466 mime : 'application/pdf' ,
461467 fileid : 123 ,
462468 dirname : '/Test' ,
469+ path : '/Test/document.pdf' ,
463470 name : 'document.pdf' ,
464471 } ,
465472 {
466473 type : 'file' ,
467474 mime : 'application/pdf' ,
468475 fileid : 456 ,
469476 dirname : '/Test' ,
477+ path : '/Test/contract.pdf' ,
470478 name : 'contract.pdf' ,
471479 } ,
472480 ]
473481
474- window . OCA = { Libresign : { } }
482+ window . OCA = { Libresign : { } , Files : { Sidebar : mockSidebar as OCAFilesSidebar } }
475483
476484 await action . execBatch ( { nodes } )
477485
0 commit comments