فهرست منبع

return updated document

yohei0125 4 سال پیش
والد
کامیت
9897b34272
2فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 2 2
      packages/app/src/server/models/page.ts
  2. 1 1
      packages/app/test/integration/models/v5.page.test.js

+ 2 - 2
packages/app/src/server/models/page.ts

@@ -607,8 +607,8 @@ schema.statics.getParentAndFillAncestors = async function(path: string, user): P
   });
   await this.bulkWrite(operations);
 
-  const createdParent = ancestorsMap.get(parentPath);
-
+  const parentId = ancestorsMap.get(parentPath)._id; // get parent page id to fetch updated parent parent
+  const createdParent = await this.findOne({ _id: parentId }) as PageDocument;
   return createdParent;
 };
 

+ 1 - 1
packages/app/test/integration/models/v5.page.test.js

@@ -553,7 +553,7 @@ describe('Page', () => {
 
       expect(parent._id).toStrictEqual(page2._id);
       expect(parent.path).toStrictEqual(page2.path);
-      // expect(parent.parent).toStrictEqual(page2.parent); // this shows error as parent property of the returned page is not updated
+      expect(parent.parent).toStrictEqual(page2.parent);
 
       expect(parent).toBeTruthy();
       expect(page1).toBeTruthy();