@@ -77,30 +77,31 @@ describe('OpenCloud node', () => {
7777 it ( 'create → list → delete a folder under tmp root' , async ( ) => {
7878 const folderName = `folder-${ Date . now ( ) } ` ;
7979 const folderPath = tmpPath ( folderName ) ;
80+ const parentItemId = `${ driveId } !parent` ;
81+ const subItemId = `${ driveId } !sub` ;
8082
8183 // Create
8284 if ( ! IS_INTEGRATION ) {
8385 nock ( TEST_SERVER )
84- . intercept ( `/dav/spaces/${ driveIdEnc } ${ encodePath ( TMP_ROOT ) } ` , 'MKCOL' )
85- . optionally ( )
86- . reply ( 201 )
8786 . intercept ( `/dav/spaces/${ driveIdEnc } ${ encodePath ( folderPath ) } ` , 'MKCOL' )
8887 . reply ( 201 ) ;
88+ // Post-MKCOL path-walk resolves the new folder to a driveItem.
89+ nockChildrenWalk (
90+ [ { id : parentItemId , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ,
91+ [ { id : subItemId , name : folderName , folder : { } } ] ,
92+ ) ;
8993 }
90- // Make sure the parent exists in integration mode (idempotent).
9194 if ( IS_INTEGRATION ) await ensureFolder ( driveId , TMP_ROOT ) ;
92- const created = await runCreate ( driveId , '' , TMP_ROOT . slice ( 1 ) ) . catch ( ( ) => null ) ; // ok if exists
93- void created ;
9495 const createdSub = await runCreate ( driveId , TMP_ROOT , folderName ) ;
95- expect ( createdSub ) . toMatchObject ( { success : true , name : folderName } ) ;
96+ expect ( createdSub ) . toMatchObject ( { name : folderName , folder : { } } ) ;
97+ expect ( typeof createdSub . id ) . toBe ( 'string' ) ;
9698
9799 // List parent — folder should appear
98100 if ( ! IS_INTEGRATION ) {
99- // Mock the path-walk + children listing
100- nockChildrenWalk ( [ { id : `${ driveId } !parent` , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ) ;
101+ nockChildrenWalk ( [ { id : parentItemId , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ) ;
101102 nock ( TEST_SERVER )
102- . get ( `/graph/v1.0/drives/${ driveIdEnc } /items/${ encodeURIComponent ( ` ${ driveId } !parent` ) } /children` )
103- . reply ( 200 , { value : [ { id : 'child' , name : folderName , folder : { } } ] } ) ;
103+ . get ( `/graph/v1.0/drives/${ driveIdEnc } /items/${ encodeURIComponent ( parentItemId ) } /children` )
104+ . reply ( 200 , { value : [ { id : subItemId , name : folderName , folder : { } } ] } ) ;
104105 }
105106 const { fns : listFns } = makeExecuteFunctions ( {
106107 parameters : { resource : 'folder' , operation : 'list' , space : driveId , path : TMP_ROOT } ,
@@ -117,7 +118,7 @@ describe('OpenCloud node', () => {
117118 parameters : { resource : 'folder' , operation : 'delete' , space : driveId , path : folderPath } ,
118119 } ) ;
119120 const deleted = await node . execute . call ( delFns ) ;
120- expect ( deleted [ 0 ] [ 0 ] . json ) . toMatchObject ( { success : true , path : folderPath } ) ;
121+ expect ( deleted [ 0 ] [ 0 ] . json ) . toEqual ( { } ) ;
121122 } ) ;
122123 } ) ;
123124
@@ -130,11 +131,17 @@ describe('OpenCloud node', () => {
130131 if ( IS_INTEGRATION ) await ensureFolder ( driveId , TMP_ROOT ) ;
131132
132133 // Upload
134+ const parentItemId = `${ driveId } !parent` ;
135+ const fileItemId = `${ driveId } !file` ;
133136 if ( ! IS_INTEGRATION ) {
134137 nock ( TEST_SERVER )
135138 . put ( `/dav/spaces/${ driveIdEnc } ${ encodePath ( filePath ) } ` , content )
136139 . matchHeader ( 'Content-Type' , 'text/plain; charset=utf-8' )
137140 . reply ( 201 ) ;
141+ nockChildrenWalk (
142+ [ { id : parentItemId , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ,
143+ [ { id : fileItemId , name : fileName , file : { mimeType : 'text/plain' } } ] ,
144+ ) ;
138145 }
139146 const uploaded = await runOnceJson ( {
140147 resource : 'file' ,
@@ -145,13 +152,18 @@ describe('OpenCloud node', () => {
145152 binaryDataUpload : false ,
146153 fileContent : content ,
147154 } ) ;
148- expect ( uploaded ) . toMatchObject ( { success : true , name : fileName } ) ;
155+ expect ( uploaded ) . toMatchObject ( { name : fileName , file : { mimeType : 'text/plain' } } ) ;
156+ expect ( typeof uploaded . id ) . toBe ( 'string' ) ;
149157
150158 // Download
151159 if ( ! IS_INTEGRATION ) {
152160 nock ( TEST_SERVER )
153161 . get ( `/dav/spaces/${ driveIdEnc } ${ encodePath ( filePath ) } ` )
154162 . reply ( 200 , Buffer . from ( content ) , { 'Content-Type' : 'text/plain' } ) ;
163+ nockChildrenWalk (
164+ [ { id : parentItemId , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ,
165+ [ { id : fileItemId , name : fileName , file : { mimeType : 'text/plain' } } ] ,
166+ ) ;
155167 }
156168 const { fns : dlFns } = makeExecuteFunctions ( {
157169 parameters : {
@@ -165,6 +177,7 @@ describe('OpenCloud node', () => {
165177 const downloaded = await node . execute . call ( dlFns ) ;
166178 const binary = downloaded [ 0 ] [ 0 ] . binary as Record < string , { data : string } > ;
167179 expect ( Buffer . from ( binary . data . data , 'base64' ) . toString ( 'utf8' ) ) . toBe ( content ) ;
180+ expect ( downloaded [ 0 ] [ 0 ] . json ) . toMatchObject ( { name : fileName , file : { mimeType : 'text/plain' } } ) ;
168181
169182 // Delete
170183 if ( ! IS_INTEGRATION ) {
@@ -191,6 +204,10 @@ describe('OpenCloud node', () => {
191204 . put ( `/dav/spaces/${ driveIdEnc } ${ encodePath ( filePath ) } ` )
192205 . matchHeader ( 'Content-Type' , 'application/octet-stream' )
193206 . reply ( 201 ) ;
207+ nockChildrenWalk (
208+ [ { id : `${ driveId } !parent` , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ,
209+ [ { id : `${ driveId } !img` , name : fileName , file : { mimeType : 'image/png' } } ] ,
210+ ) ;
194211 }
195212 const { fns } = makeExecuteFunctions ( {
196213 parameters : {
@@ -234,17 +251,26 @@ describe('OpenCloud node', () => {
234251 . intercept ( `/dav/spaces/${ driveIdEnc } ${ encodePath ( srcPath ) } ` , 'COPY' )
235252 . matchHeader ( 'Destination' , `${ TEST_SERVER } /dav/spaces/${ driveIdEnc } ${ encodePath ( copyPath ) } ` )
236253 . reply ( 201 ) ;
254+ nockChildrenWalk (
255+ [ { id : `${ driveId } !parent` , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ,
256+ [ { id : `${ driveId } !copy` , name : 'copy.txt' , file : { mimeType : 'text/plain' } } ] ,
257+ ) ;
237258 }
238- await runOnceJson ( {
259+ const copied = await runOnceJson ( {
239260 resource : 'file' , operation : 'copy' , space : driveId ,
240261 path : srcPath , destSpace : '' , destParentPath : TMP_ROOT , destName : 'copy.txt' ,
241262 } ) ;
263+ expect ( copied ) . toMatchObject ( { name : 'copy.txt' , file : { mimeType : 'text/plain' } } ) ;
242264
243265 if ( ! IS_INTEGRATION ) {
244266 nock ( TEST_SERVER )
245267 . intercept ( `/dav/spaces/${ driveIdEnc } ${ encodePath ( copyPath ) } ` , 'MOVE' )
246268 . matchHeader ( 'Destination' , `${ TEST_SERVER } /dav/spaces/${ driveIdEnc } ${ encodePath ( renamedPath ) } ` )
247269 . reply ( 201 ) ;
270+ nockChildrenWalk (
271+ [ { id : `${ driveId } !parent` , name : TMP_ROOT . slice ( 1 ) , folder : { } } ] ,
272+ [ { id : `${ driveId } !ren` , name : 'renamed.txt' , file : { mimeType : 'text/plain' } } ] ,
273+ ) ;
248274 }
249275 await runOnceJson ( {
250276 resource : 'file' , operation : 'move' , space : driveId ,
@@ -451,15 +477,21 @@ describe('OpenCloud node', () => {
451477 } ) ;
452478
453479 mockOnly . it ( 'cross-space folder COPY (mock — depends on a second drive)' , async ( ) => {
454- const otherDriveEnc = encodeURIComponent ( 'storage-users-2$other-space-id' ) ;
480+ const otherDriveId = 'storage-users-2$other-space-id' ;
481+ const otherDriveEnc = encodeURIComponent ( otherDriveId ) ;
455482 nock ( TEST_SERVER )
456483 . intercept ( `/dav/spaces/${ driveIdEnc } /Documents/Reports` , 'COPY' )
457484 . matchHeader ( 'Destination' , `${ TEST_SERVER } /dav/spaces/${ otherDriveEnc } /Shared/Reports` )
458- . reply ( 201 ) ;
485+ . reply ( 201 )
486+ // Post-COPY path-walk on the destination drive.
487+ . get ( `/graph/v1.0/drives/${ otherDriveEnc } /items/${ otherDriveEnc } /children` )
488+ . reply ( 200 , { value : [ { id : `${ otherDriveId } !shared` , name : 'Shared' , folder : { } } ] } )
489+ . get ( `/graph/v1.0/drives/${ otherDriveEnc } /items/${ encodeURIComponent ( `${ otherDriveId } !shared` ) } /children` )
490+ . reply ( 200 , { value : [ { id : `${ otherDriveId } !reports` , name : 'Reports' , folder : { } } ] } ) ;
459491 await runOnceJson ( {
460492 resource : 'folder' , operation : 'copy' , space : driveId ,
461493 path : '/Documents/Reports' ,
462- destSpace : 'storage-users-2$other-space-id' ,
494+ destSpace : otherDriveId ,
463495 destParentPath : '/Shared' , destName : '' ,
464496 } ) ;
465497 } ) ;
0 commit comments