Taichi Masuyama 4 лет назад
Родитель
Сommit
caa25e4b36

+ 3 - 3
packages/app/src/server/service/page.ts

@@ -745,7 +745,7 @@ class PageService {
         /*
          * Sub Operation
          */
-        await this.duplicateDescendantsSubOperation(page, newPagePath, user, duplicatedTarget._id, nDuplicatedPages);
+        await this.duplicateDescendantsSubOperation(page, newPagePath, user, duplicatedTarget, nDuplicatedPages);
       })();
     }
 
@@ -754,7 +754,7 @@ class PageService {
     return result;
   }
 
-  async duplicateDescendantsSubOperation(page, newPagePath: string, user, duplicatedTargetId: ObjectIdLike, nDuplicatedPages: number): Promise<void> {
+  async duplicateDescendantsSubOperation(page, newPagePath: string, user, duplicatedTarget, nDuplicatedPages: number): Promise<void> {
     // normalize parent of descendant pages
     const shouldNormalize = this.shouldNormalizeParent(page);
     if (shouldNormalize) {
@@ -767,7 +767,7 @@ class PageService {
         throw err;
       }
     }
-    await this.updateDescendantCountOfAncestors(duplicatedTargetId, nDuplicatedPages, false);
+    await this.updateDescendantCountOfAncestors(duplicatedTarget._id, nDuplicatedPages, false);
   }
 
   async duplicateV4(page, newPagePath, user, isRecursively) {

+ 2 - 3
packages/app/test/integration/service/v5-migration.test.js

@@ -62,11 +62,10 @@ describe('V5 page migration', () => {
         pages = [...additionalPages, ...pages];
       }
 
-      const nroot = await Page.count({ path: '/' });
-      expect(nroot).toBe(1);
+      const rootPage = await Page.findOne({ path: '/' });
 
       // migrate
-      await crowi.pageService.normalizeParentRecursivelyByPages(pages, testUser1);
+      await crowi.pageService.normalizeParentRecursivelyByPages([rootPage], testUser1);
 
       const migratedPages = await Page.find({
         path: {