@@ -682,6 +682,141 @@ describe('ExportAssets', () => {
682682 await exportAssets . getAssets ( 10 ) ;
683683 expect ( makeConcurrentCallStub . called ) . to . be . true ;
684684 } ) ;
685+
686+ it ( 'should handle assets with versioned assets enabled' , async ( ) => {
687+ ( exportAssets as any ) . assetsRootPath = '/test/data/assets' ;
688+ mockExportConfig . modules . assets . includeVersionedAssets = true ;
689+
690+ // Stub FsUtility methods to prevent fs operations
691+ sinon . stub ( FsUtility . prototype , 'writeIntoFile' ) . resolves ( ) ;
692+ sinon . stub ( FsUtility . prototype , 'completeFile' ) . resolves ( ) ;
693+ sinon . stub ( FsUtility . prototype , 'createFolderIfNotExist' ) . resolves ( ) ;
694+
695+ makeConcurrentCallStub . callsFake ( async ( options : any ) => {
696+ const onSuccess = options . apiParams . resolve ;
697+ // Mock versioned assets
698+ onSuccess ( {
699+ response : {
700+ items : [
701+ { uid : '1' , _version : 2 , url : 'url1' , filename : 'test.jpg' } ,
702+ { uid : '2' , _version : 1 , url : 'url2' , filename : 'test2.jpg' }
703+ ]
704+ }
705+ } ) ;
706+ } ) ;
707+
708+ await exportAssets . getAssets ( 10 ) ;
709+ expect ( makeConcurrentCallStub . called ) . to . be . true ;
710+ } ) ;
711+
712+ it ( 'should apply query filters when configured' , async ( ) => {
713+ ( exportAssets as any ) . assetsRootPath = '/test/data/assets' ;
714+ mockExportConfig . modules . assets . invalidKeys = [ 'SYS_ACL' ] ;
715+
716+ // Stub FsUtility methods to prevent fs operations
717+ sinon . stub ( FsUtility . prototype , 'writeIntoFile' ) . resolves ( ) ;
718+ sinon . stub ( FsUtility . prototype , 'completeFile' ) . resolves ( ) ;
719+ sinon . stub ( FsUtility . prototype , 'createFolderIfNotExist' ) . resolves ( ) ;
720+
721+ makeConcurrentCallStub . callsFake ( async ( options : any ) => {
722+ const onSuccess = options . apiParams . resolve ;
723+ onSuccess ( { response : { items : [ { uid : '1' , url : 'url1' , filename : 'test.jpg' } ] } } ) ;
724+ } ) ;
725+
726+ await exportAssets . getAssets ( 10 ) ;
727+ expect ( makeConcurrentCallStub . called ) . to . be . true ;
728+ } ) ;
729+ } ) ;
730+
731+ describe ( 'getAssetsFolders() - Additional Coverage' , ( ) => {
732+ it ( 'should handle folders with empty items response' , async ( ) => {
733+ ( exportAssets as any ) . assetsRootPath = '/test/data/assets' ;
734+ const makeConcurrentCallStub = sinon . stub ( exportAssets as any , 'makeConcurrentCall' ) . resolves ( ) ;
735+
736+ makeConcurrentCallStub . callsFake ( async ( options : any ) => {
737+ const onSuccess = options . apiParams . resolve ;
738+ onSuccess ( { response : { items : [ ] } } ) ;
739+ } ) ;
740+
741+ await exportAssets . getAssetsFolders ( 10 ) ;
742+ expect ( makeConcurrentCallStub . called ) . to . be . true ;
743+
744+ makeConcurrentCallStub . restore ( ) ;
745+ } ) ;
746+
747+ it ( 'should add folders to assetsFolder array' , async ( ) => {
748+ ( exportAssets as any ) . assetsRootPath = '/test/data/assets' ;
749+
750+ const makeConcurrentCallStub = sinon . stub ( exportAssets as any , 'makeConcurrentCall' ) . resolves ( ) ;
751+
752+ // Stub FsUtility methods to prevent file system operations
753+ sinon . stub ( FsUtility . prototype , 'writeFile' ) . resolves ( ) ;
754+ sinon . stub ( FsUtility . prototype , 'createFolderIfNotExist' ) . resolves ( ) ;
755+
756+ makeConcurrentCallStub . callsFake ( async ( options : any ) => {
757+ const onSuccess = options . apiParams . resolve ;
758+ // Simulate adding folders to the array
759+ ( exportAssets as any ) . assetsFolder . push ( { uid : 'folder-1' , name : 'Test Folder' } ) ;
760+ onSuccess ( { response : { items : [ { uid : 'folder-1' , name : 'Test Folder' } ] } } ) ;
761+ } ) ;
762+
763+ await exportAssets . getAssetsFolders ( 10 ) ;
764+
765+ expect ( makeConcurrentCallStub . called ) . to . be . true ;
766+ // Verify folders were added
767+ expect ( ( exportAssets as any ) . assetsFolder . length ) . to . be . greaterThan ( 0 ) ;
768+
769+ makeConcurrentCallStub . restore ( ) ;
770+ } ) ;
771+ } ) ;
772+
773+ describe ( 'downloadAssets() - Additional Coverage' , ( ) => {
774+ it ( 'should handle download with secured assets' , async ( ) => {
775+ mockExportConfig . modules . assets . securedAssets = true ;
776+ ( exportAssets as any ) . assetsRootPath = '/test/data/assets' ;
777+
778+ const getPlainMetaStub = sinon . stub ( FsUtility . prototype , 'getPlainMeta' ) . returns ( {
779+ 'file-1' : [ { uid : '1' , url : 'url1' , filename : 'test.jpg' } ]
780+ } ) ;
781+ const makeConcurrentCallStub = sinon . stub ( exportAssets as any , 'makeConcurrentCall' ) . resolves ( ) ;
782+
783+ await exportAssets . downloadAssets ( ) ;
784+
785+ expect ( makeConcurrentCallStub . called ) . to . be . true ;
786+ getPlainMetaStub . restore ( ) ;
787+ makeConcurrentCallStub . restore ( ) ;
788+ } ) ;
789+
790+ it ( 'should handle download with enableDownloadStatus' , async ( ) => {
791+ mockExportConfig . modules . assets . enableDownloadStatus = true ;
792+ ( exportAssets as any ) . assetsRootPath = '/test/data/assets' ;
793+
794+ const getPlainMetaStub = sinon . stub ( FsUtility . prototype , 'getPlainMeta' ) . returns ( {
795+ 'file-1' : [ { uid : '1' , url : 'url1' , filename : 'test.jpg' } ]
796+ } ) ;
797+ const makeConcurrentCallStub = sinon . stub ( exportAssets as any , 'makeConcurrentCall' ) . resolves ( ) ;
798+
799+ await exportAssets . downloadAssets ( ) ;
800+
801+ expect ( makeConcurrentCallStub . called ) . to . be . true ;
802+ getPlainMetaStub . restore ( ) ;
803+ makeConcurrentCallStub . restore ( ) ;
804+ } ) ;
805+
806+ it ( 'should handle download with concurrent call structure' , async ( ) => {
807+ ( exportAssets as any ) . assetsRootPath = '/test/data/assets' ;
808+
809+ const getPlainMetaStub = sinon . stub ( FsUtility . prototype , 'getPlainMeta' ) . returns ( {
810+ 'file-1' : [ { uid : '1' , url : 'url1' , filename : 'test.jpg' } ]
811+ } ) ;
812+ const makeConcurrentCallStub = sinon . stub ( exportAssets as any , 'makeConcurrentCall' ) . resolves ( ) ;
813+
814+ await exportAssets . downloadAssets ( ) ;
815+
816+ expect ( makeConcurrentCallStub . called ) . to . be . true ;
817+ getPlainMetaStub . restore ( ) ;
818+ makeConcurrentCallStub . restore ( ) ;
819+ } ) ;
685820 } ) ;
686821} ) ;
687822
0 commit comments