Просмотр исходного кода

remove grant and modify parent grant check

yohei0125 3 лет назад
Родитель
Сommit
21909b430e
1 измененных файлов с 8 добавлено и 7 удалено
  1. 8 7
      packages/app/test/integration/models/v5.page.test.js

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

@@ -358,7 +358,7 @@ describe('Page', () => {
         creator: pModelUserId1,
         creator: pModelUserId1,
         lastUpdateUser: pModelUserId1,
         lastUpdateUser: pModelUserId1,
         isEmpty: false,
         isEmpty: false,
-        parent: rootPage,
+        parent: pageIdUpd14,
         descendantCount: 0,
         descendantCount: 0,
       },
       },
       {
       {
@@ -368,7 +368,6 @@ describe('Page', () => {
         lastUpdateUser: pModelUserId1,
         lastUpdateUser: pModelUserId1,
         isEmpty: false,
         isEmpty: false,
         descendantCount: 0,
         descendantCount: 0,
-        parent: rootPage._id,
       },
       },
       {
       {
         _id: pageIdUpd15,
         _id: pageIdUpd15,
@@ -705,7 +704,7 @@ describe('Page', () => {
           const path2 = '/mup24_pub/mup25_pub';
           const path2 = '/mup24_pub/mup25_pub';
           // page
           // page
           const _page1 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC }); // out of update scope
           const _page1 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC }); // out of update scope
-          const _page2 = await Page.findOne({ path: path2, grant: Page.GRANT_PUBLIC }); // update target
+          const _page2 = await Page.findOne({ path: path2, grant: Page.GRANT_PUBLIC, parent: _page1._id }); // update target
           expect(_page1).toBeTruthy();
           expect(_page1).toBeTruthy();
           expect(_page2).toBeTruthy();
           expect(_page2).toBeTruthy();
 
 
@@ -731,10 +730,6 @@ describe('Page', () => {
           const _page1 = await Page.findOne({ path: _path1, grant: Page.GRANT_RESTRICTED });
           const _page1 = await Page.findOne({ path: _path1, grant: Page.GRANT_RESTRICTED });
           expect(_page1).toBeTruthy();
           expect(_page1).toBeTruthy();
 
 
-          // parent's grant check
-          const _parent = await Page.findById(_page1.parent);
-          expect(_parent.grant).toBe(Page.GRANT_PUBLIC);
-
           const options = { grant: Page.GRANT_USER_GROUP, grantUserGroupId: groupIdA };
           const options = { grant: Page.GRANT_USER_GROUP, grantUserGroupId: groupIdA };
           const updatedPage = await updatePage(_page1, 'new', 'old', pModelUser1, options); // from GRANT_RESTRICTED to GRANT_USER_GROUP(groupIdA)
           const updatedPage = await updatePage(_page1, 'new', 'old', pModelUser1, options); // from GRANT_RESTRICTED to GRANT_USER_GROUP(groupIdA)
 
 
@@ -743,8 +738,14 @@ describe('Page', () => {
           expect(updatedPage).toBeTruthy();
           expect(updatedPage).toBeTruthy();
           expect(updatedPage._id).toStrictEqual(page1._id);
           expect(updatedPage._id).toStrictEqual(page1._id);
 
 
+          // updated page
           expect(page1.grant).toBe(Page.GRANT_USER_GROUP);
           expect(page1.grant).toBe(Page.GRANT_USER_GROUP);
           expect(page1.grantedGroup._id).toStrictEqual(groupIdA);
           expect(page1.grantedGroup._id).toStrictEqual(groupIdA);
+
+          // parent's grant check
+          const _parent = await Page.findById(page1.parent);
+          expect(_parent.grant).toBe(Page.GRANT_PUBLIC);
+
         });
         });
 
 
         test('successfully change to GRANT_USER_GROUP from GRANT_OWNER if parent page is GRANT_PUBLIC', async() => {
         test('successfully change to GRANT_USER_GROUP from GRANT_OWNER if parent page is GRANT_PUBLIC', async() => {