@@ -2281,7 +2281,7 @@ const runSpaceUpdatesWithNestedMoves = () => {
22812281 contentChangeType : ContentChangeType . create ,
22822282 ancestors : [
22832283 {
2284- id : "fake-parent" ,
2284+ id : "fake-parent-id " ,
22852285 } ,
22862286 ] ,
22872287 body : {
@@ -2310,6 +2310,79 @@ const runSpaceUpdatesWithNestedMoves = () => {
23102310 assertEquals ( expected , actual ) ;
23112311 } ) ;
23122312
2313+ unitTest ( suiteLabel ( "from_root_to_existing_parent" ) , async ( ) => {
2314+ const fileMetadataList : SiteFileMetadata [ ] = [
2315+ fakeNestedFile ,
2316+ fakeNestedFile2 ,
2317+ ] ;
2318+ const existingSite = [
2319+ {
2320+ id : "fake-title-id" ,
2321+ title : "fake-title" ,
2322+ metadata : { fileName : "fake-file-name.xml" } ,
2323+ ancestors : [ { id : "fake-grand-parent-id" } ] ,
2324+ } ,
2325+ {
2326+ id : "fake-title2-id" ,
2327+ title : "fake-title" ,
2328+ metadata : { fileName : "fake-parent/fake-file-name2.xml" } ,
2329+ ancestors : [ { id : "fake-grand-parent-id" } , { id : "fake-parent-id" } ] ,
2330+ } ,
2331+ {
2332+ title : "Fake Parent" ,
2333+ id : "fake-parent-id" ,
2334+ metadata : { editor : "v2" , fileName : "fake-parent" } ,
2335+ ancestors : [ { id : "fake-grand-parent-id" } ] ,
2336+ } ,
2337+ ] ;
2338+
2339+ const expected : ConfluenceSpaceChange [ ] = [
2340+ { contentChangeType : ContentChangeType . delete , id : "fake-title-id" } ,
2341+ {
2342+ contentChangeType : ContentChangeType . create ,
2343+ ancestors : [
2344+ {
2345+ id : "fake-parent-id" ,
2346+ } ,
2347+ ] ,
2348+ body : {
2349+ storage : {
2350+ representation : "storage" ,
2351+ value : "fake-value" ,
2352+ } ,
2353+ } ,
2354+ fileName : "fake-parent/fake-file-name.xml" ,
2355+ space : {
2356+ key : "fake-space-key" ,
2357+ id : "fake-space-id" ,
2358+ homepage : buildFakeContent ( ) ,
2359+ } ,
2360+ status : "current" ,
2361+ title : "fake-title" ,
2362+ type : "page" ,
2363+ } ,
2364+ {
2365+ contentChangeType : ContentChangeType . update ,
2366+ id : "fake-title2-id" ,
2367+ version : null ,
2368+ title : "fake-title2" ,
2369+ type : "page" ,
2370+ status : "current" ,
2371+ ancestors : [ { id : "fake-parent-id" } ] ,
2372+ body : { storage : { value : "fake-value" , representation : "storage" } } ,
2373+ fileName : "fake-parent/fake-file-name2.xml" ,
2374+ } ,
2375+ ] ;
2376+ const actual : ConfluenceSpaceChange [ ] = buildSpaceChanges (
2377+ fileMetadataList ,
2378+ FAKE_PARENT ,
2379+ fakeSpace ,
2380+ existingSite
2381+ ) ;
2382+ console . log ( "actual" , actual ) ;
2383+ assertEquals ( expected , actual ) ;
2384+ } ) ;
2385+
23132386 // TODO Delete orphaned parents
23142387 // unitTest(suiteLabel("parent_to_root_del_parent"), async () => {
23152388 // const fileMetadataList: SiteFileMetadata[] = [fakeRootFile];
@@ -2878,6 +2951,6 @@ if (runAllTests) {
28782951 runUpdateImagePathsForContentBody ( ) ;
28792952} else {
28802953 // runSpaceCreatesWithNesting();
2881- // runSpaceUpdatesWithNestedMoves();
2882- runSpaceUpdatesWithNesting ( ) ;
2954+ runSpaceUpdatesWithNestedMoves ( ) ;
2955+ // runSpaceUpdatesWithNesting();
28832956}
0 commit comments