Explorar o código

Renamed variables with unique prefix

Taichi Masuyama %!s(int64=3) %!d(string=hai) anos
pai
achega
67c2634eb7

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

@@ -1,10 +1,13 @@
 import mongoose from 'mongoose';
 
+import { PageGrant } from '~/interfaces/page';
 
 import { getInstance } from '../setup-crowi';
 
 describe('Page', () => {
   let crowi;
+  let pageGrantService;
+
   let Page;
   let Revision;
   let User;
@@ -27,8 +30,292 @@ describe('Page', () => {
   let userGroupIdPModelB;
   let userGroupIdPModelC;
 
+  // To test updatePage overwriting descendants (prefix `upod`)
+  let upodUserA;
+  let upodUserB;
+  let upodUserC;
+  let upodGroupAB;
+  let upodGroupA;
+  let upodGroupAIsolated;
+  let upodGroupB;
+  let upodGroupC;
+  const upodUserGroupIdA = new mongoose.Types.ObjectId();
+  const upodUserGroupIdAIsolated = new mongoose.Types.ObjectId();
+  const upodUserGroupIdB = new mongoose.Types.ObjectId();
+  const upodUserGroupIdC = new mongoose.Types.ObjectId();
+  const upodUserGroupIdAB = new mongoose.Types.ObjectId();
+  const createDocumentsToTestUpdatePageOverwritingDescendants = async() => {
+    // Users
+    await User.insertMany([
+      { name: 'upodUserA', username: 'upodUserA', email: 'upoduserA@example.com' },
+      { name: 'upodUserB', username: 'upodUserB', email: 'upoduserB@example.com' },
+      { name: 'upodUserC', username: 'upodUserC', email: 'upodUserC@example.com' },
+    ]);
+
+    upodUserA = await User.findOne({ username: 'upodUserA' });
+    upodUserB = await User.findOne({ username: 'upodUserB' });
+    upodUserC = await User.findOne({ username: 'upodUserC' });
+
+    await UserGroup.insertMany([
+      {
+        _id: upodUserGroupIdAB,
+        name: 'upodGroupAB',
+        parent: null,
+      },
+      {
+        _id: upodUserGroupIdA,
+        name: 'upodGroupA',
+        parent: upodUserGroupIdAB,
+      },
+      {
+        _id: upodUserGroupIdAIsolated,
+        name: 'upodGroupAIsolated',
+        parent: null,
+      },
+      {
+        _id: upodUserGroupIdB,
+        name: 'upodGroupB',
+        parent: upodUserGroupIdAB,
+      },
+      {
+        _id: upodUserGroupIdC,
+        name: 'upodGroupC',
+        parent: null,
+      },
+    ]);
+
+    upodGroupAB = await UserGroup.findOne({ name: 'upodGroupAB' });
+    upodGroupA = await UserGroup.findOne({ name: 'upodGroupA' });
+    upodGroupAIsolated = await UserGroup.findOne({ name: 'upodGroupAIsolated' });
+    upodGroupB = await UserGroup.findOne({ name: 'upodGroupB' });
+    upodGroupC = await UserGroup.findOne({ name: 'upodGroupC' });
+
+    // UserGroupRelations
+    await UserGroupRelation.insertMany([
+      {
+        relatedGroup: upodUserGroupIdAB,
+        relatedUser: upodUserA._id,
+      },
+      {
+        relatedGroup: upodUserGroupIdAB,
+        relatedUser: upodUserB._id,
+      },
+      {
+        relatedGroup: upodUserGroupIdA,
+        relatedUser: upodUserA._id,
+      },
+      {
+        relatedGroup: upodUserGroupIdAIsolated,
+        relatedUser: upodUserA._id,
+      },
+      {
+        relatedGroup: upodUserGroupIdB,
+        relatedUser: upodUserB._id,
+      },
+      {
+        relatedGroup: upodUserGroupIdC,
+        relatedUser: upodUserC._id,
+      },
+    ]);
+
+    // Pages
+    const pageIdgAB1 = new mongoose.Types.ObjectId();
+    const pageIdPublic2 = new mongoose.Types.ObjectId();
+    const pageIdPublic3 = new mongoose.Types.ObjectId();
+    const pageIdPublic4 = new mongoose.Types.ObjectId();
+    const pageIdPublic5 = new mongoose.Types.ObjectId();
+    const pageIdPublic6 = new mongoose.Types.ObjectId();
+    await Page.insertMany([
+      // case 1
+      {
+        _id: pageIdgAB1,
+        path: '/gAB_canOverwriteDescendants_1', // to GRANT_PUBLIC
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdAB,
+        parent: rootPage._id,
+      },
+      {
+        path: '/gB_canOverwriteDescendants_1',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserB,
+        lastUpdateUser: upodUserB,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdB,
+        parent: pageIdgAB1,
+      },
+      {
+        path: '/onlyB_canOverwriteDescendants_1',
+        grant: PageGrant.GRANT_OWNER,
+        creator: upodUserB,
+        lastUpdateUser: upodUserB,
+        grantedUsers: [upodUserB._id],
+        grantedGroup: null,
+        parent: pageIdgAB1,
+      },
+      // case 2
+      {
+        _id: pageIdPublic2,
+        path: '/public_canOverwriteDescendants_2', // to Anything
+        grant: PageGrant.GRANT_PUBLIC,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: null,
+        parent: rootPage._id,
+      },
+      {
+        path: '/gA_canOverwriteDescendants_2',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdA,
+        parent: pageIdPublic2,
+      },
+      {
+        path: '/gAIsolated_canOverwriteDescendants_2',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdAIsolated,
+        parent: pageIdPublic2,
+      },
+      {
+        path: '/onlyA_canOverwriteDescendants_2',
+        grant: PageGrant.GRANT_OWNER,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: [upodUserA._id],
+        grantedGroup: null,
+        parent: pageIdPublic2,
+      },
+      // case 3
+      {
+        _id: pageIdPublic3,
+        path: '/public_canOverwriteDescendants_3', // to GRANT_USER_GROUP with upodGroupAB
+        grant: PageGrant.GRANT_PUBLIC,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: null,
+        parent: rootPage._id,
+      },
+      {
+        path: '/gAB_canOverwriteDescendants_3',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdAB,
+        parent: pageIdPublic3,
+      },
+      {
+        path: '/gB_canOverwriteDescendants_3',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserB,
+        lastUpdateUser: upodUserB,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdB,
+        parent: pageIdPublic3,
+      },
+      {
+        path: '/onlyB_canOverwriteDescendants_3',
+        grant: PageGrant.GRANT_OWNER,
+        creator: upodUserB,
+        lastUpdateUser: upodUserB,
+        grantedUsers: [upodUserB._id],
+        grantedGroup: null,
+        parent: pageIdPublic3,
+      },
+      // case 4
+      {
+        _id: pageIdPublic4,
+        path: '/public_canOverwriteDescendants_4', // to GRANT_USER_GROUP with upodGroupAB
+        grant: PageGrant.GRANT_PUBLIC,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: null,
+        parent: rootPage._id,
+      },
+      {
+        path: '/gA_canOverwriteDescendants_4',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdA,
+        parent: pageIdPublic4,
+      },
+      {
+        path: '/gC_canOverwriteDescendants_4',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserC,
+        lastUpdateUser: upodUserC,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdC,
+        parent: pageIdPublic4,
+      },
+      // case 5
+      {
+        _id: pageIdPublic5,
+        path: '/public_canOverwriteDescendants_5', // to GRANT_USER_GROUP with upodGroupAB
+        grant: PageGrant.GRANT_PUBLIC,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: null,
+        parent: rootPage._id,
+      },
+      {
+        path: '/gA_canOverwriteDescendants_5',
+        grant: PageGrant.GRANT_USER_GROUP,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: upodUserGroupIdA,
+        parent: pageIdPublic5,
+      },
+      {
+        path: '/onlyC_canOverwriteDescendants_5',
+        grant: PageGrant.GRANT_OWNER,
+        creator: upodUserC,
+        lastUpdateUser: upodUserC,
+        grantedUsers: [upodUserC._id],
+        grantedGroup: null,
+        parent: pageIdPublic5,
+      },
+      // case 6
+      {
+        _id: pageIdPublic6,
+        path: '/public_canOverwriteDescendants_6', // to GRANT_USER_GROUP with upodGroupAB
+        grant: PageGrant.GRANT_PUBLIC,
+        creator: upodUserA,
+        lastUpdateUser: upodUserA,
+        grantedUsers: null,
+        grantedGroup: null,
+        parent: rootPage._id,
+      },
+      {
+        path: '/onlyC_canOverwriteDescendants_6',
+        grant: PageGrant.GRANT_OWNER,
+        creator: upodUserC,
+        lastUpdateUser: upodUserC,
+        grantedUsers: [upodUserC._id],
+        grantedGroup: null,
+        parent: pageIdPublic6,
+      },
+    ]);
+  };
+
   beforeAll(async() => {
     crowi = await getInstance();
+    pageGrantService = crowi.pageGrantService;
+
     await crowi.configManager.updateConfigsInTheSameNamespace('crowi', { 'app:isV5Compatible': true });
 
     jest.restoreAllMocks();
@@ -485,14 +772,15 @@ describe('Page', () => {
       },
     ]);
 
+    await createDocumentsToTestUpdatePageOverwritingDescendants();
   });
 
   describe('update', () => {
 
     const updatePage = async(page, newRevisionBody, oldRevisionBody, user, options = {}) => {
-      const mockedRenameSubOperation = jest.spyOn(Page, 'emitPageEventUpdate').mockReturnValue(null);
+      const mockedEmitPageEventUpdate = jest.spyOn(Page, 'emitPageEventUpdate').mockReturnValue(null);
       const savedPage = await Page.updatePage(page, newRevisionBody, oldRevisionBody, user, options);
-      mockedRenameSubOperation.mockRestore();
+      mockedEmitPageEventUpdate.mockRestore();
       return savedPage;
     };
 
@@ -905,4 +1193,92 @@ describe('Page', () => {
     });
 
   });
+
+
+  // see: https://dev.growi.org/635a314eac6bcd85cbf359fc about the specification
+  describe('updatePage with overwriteScopesOfDescendants true', () => {
+    test('(case 1) it should return true when update grant is GRANT_PUBLIC', async() => {
+      const updateGrantInfo = {
+        targetPage: {},
+        grant: PageGrant.GRANT_PUBLIC,
+        grantedUser: null,
+        grantedUserGroup: null,
+      };
+
+      const res = await pageGrantService.canOverwriteDescendants(upodUserA, updateGrantInfo);
+
+      expect(res).toBe(true);
+    });
+    test('(case 2) it should return true when all descendant pages are granted by the operator', async() => {
+      const updateGrantInfo = {
+        targetPage: {},
+        grant: PageGrant.GRANT_OWNER,
+        grantedUser: upodUserA,
+        grantedUserGroup: null,
+      };
+      // TODO: expect page tree
+
+      const res = await pageGrantService.canOverwriteDescendants(upodUserA, updateGrantInfo);
+
+      expect(res).toBe(true);
+    });
+    test(`(case 3) it should return true when update grant is GRANT_USER_GROUP
+    , all user groups of descendants are the children or itself of the update user group
+    , and all users of descendants belong to the update user group`, async() => {
+      const updateGrantInfo = {
+        targetPage: {},
+        grant: PageGrant.GRANT_USER_GROUP,
+        grantedUser: null,
+        grantedUserGroup: upodGroupAB,
+      };
+      // TODO: expect page tree
+
+      const res = await pageGrantService.canOverwriteDescendants(upodUserA, updateGrantInfo);
+
+      expect(res).toBe(true);
+    });
+    test(`(case 4) it should return false when some of descendants is not granted
+    , update grant is GRANT_USER_GROUP
+    , and some of user groups of descendants are not children or itself of the update user group`, async() => {
+      const updateGrantInfo = {
+        targetPage: {},
+        grant: PageGrant.GRANT_USER_GROUP,
+        grantedUser: null,
+        grantedUserGroup: upodGroupAB,
+      };
+      // TODO: expect page tree (include page with gC)
+
+      const res = await pageGrantService.canOverwriteDescendants(upodUserA, updateGrantInfo);
+
+      expect(res).toBe(false);
+    });
+    test(`(case 5) it should return false when some of descendants is not granted
+    , update grant is GRANT_USER_GROUP
+    , and some of users of descendants does NOT belong to the update user group`, async() => {
+      const updateGrantInfo = {
+        targetPage: {},
+        grant: PageGrant.GRANT_USER_GROUP,
+        grantedUser: null,
+        grantedUserGroup: null,
+      };
+      // TODO: expect page tree (include page with onlyC)
+
+      const res = await pageGrantService.canOverwriteDescendants(upodUserA, updateGrantInfo);
+
+      expect(res).toBe(false);
+    });
+    test('(case 6) it should return false when some of descendants is not granted and update grant is GRANT_OWNER', async() => {
+      const updateGrantInfo = {
+        targetPage: {},
+        grant: PageGrant.GRANT_OWNER,
+        grantedUser: upodUserA,
+        grantedUserGroup: null,
+      };
+      // TODO: expect page tree (include page with onlyC)
+
+      const res = await pageGrantService.canOverwriteDescendants(upodUserA, updateGrantInfo);
+
+      expect(res).toBe(false);
+    });
+  });
 });

+ 0 - 374
packages/app/test/integration/service/page-grant.test.js

@@ -26,27 +26,12 @@ describe('PageGrantService', () => {
 
   let user1;
   let user2;
-  let user3;
-  let userA;
-  let userB;
-  let userC;
 
   let groupParent;
   let groupChild;
-  let groupAB;
-  let groupA;
-  let groupAIsolated;
-  let groupB;
-  let groupC;
 
   const userGroupIdParent = new mongoose.Types.ObjectId();
 
-  const userGroupIdA = new mongoose.Types.ObjectId();
-  const userGroupIdAIsolated = new mongoose.Types.ObjectId();
-  const userGroupIdB = new mongoose.Types.ObjectId();
-  const userGroupIdC = new mongoose.Types.ObjectId();
-  const userGroupIdAB = new mongoose.Types.ObjectId();
-
   let rootPage;
   let rootPublicPage;
   let rootOnlyMePage;
@@ -324,274 +309,6 @@ describe('PageGrantService', () => {
     pageE3User1 = await Page.findOne({ path: pageE3User1Path });
   };
 
-  const createDocumentsToTestCanOverwriteDescendants = async() => {
-    // Users
-    await User.insertMany([
-      { name: 'UserA', username: 'UserA', email: 'userA@example.com' },
-      { name: 'UserB', username: 'UserB', email: 'userB@example.com' },
-      { name: 'UserC', username: 'UserC', email: 'userC@example.com' },
-    ]);
-
-    userA = await User.findOne({ username: 'UserA' });
-    userB = await User.findOne({ username: 'UserB' });
-    userC = await User.findOne({ username: 'UserC' });
-
-    await UserGroup.insertMany([
-      {
-        _id: userGroupIdAB,
-        name: 'GroupAB',
-        parent: null,
-      },
-      {
-        _id: userGroupIdA,
-        name: 'GroupA',
-        parent: userGroupIdAB,
-      },
-      {
-        _id: userGroupIdAIsolated,
-        name: 'GroupAIsolated',
-        parent: null, // isolated
-      },
-      {
-        _id: userGroupIdB,
-        name: 'GroupB',
-        parent: userGroupIdAB,
-      },
-      {
-        _id: userGroupIdC,
-        name: 'GroupC',
-        parent: null,
-      },
-    ]);
-
-    groupAB = await UserGroup.findOne({ name: 'GroupAB' });
-    groupA = await UserGroup.findOne({ name: 'GroupA' });
-    groupAIsolated = await UserGroup.findOne({ name: 'GroupAIsolated' });
-    groupB = await UserGroup.findOne({ name: 'GroupB' });
-    groupC = await UserGroup.findOne({ name: 'GroupC' });
-
-    // UserGroupRelations
-    await UserGroupRelation.insertMany([
-      {
-        relatedGroup: userGroupIdAB,
-        relatedUser: userA._id,
-      },
-      {
-        relatedGroup: userGroupIdAB,
-        relatedUser: userB._id,
-      },
-      {
-        relatedGroup: userGroupIdA,
-        relatedUser: userA._id,
-      },
-      {
-        relatedGroup: userGroupIdAIsolated,
-        relatedUser: userA._id,
-      },
-      {
-        relatedGroup: userGroupIdB,
-        relatedUser: userB._id,
-      },
-      {
-        relatedGroup: userGroupIdC,
-        relatedUser: userC._id,
-      },
-    ]);
-
-    // Pages
-    const pageIdgAB1 = new mongoose.Types.ObjectId();
-    const pageIdPublic2 = new mongoose.Types.ObjectId();
-    const pageIdPublic3 = new mongoose.Types.ObjectId();
-    const pageIdPublic4 = new mongoose.Types.ObjectId();
-    const pageIdPublic5 = new mongoose.Types.ObjectId();
-    const pageIdPublic6 = new mongoose.Types.ObjectId();
-    await Page.insertMany([
-      // case 1
-      {
-        _id: pageIdgAB1,
-        path: '/gAB_canOverwriteDescendants_1', // to GRANT_PUBLIC
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: userGroupIdAB,
-        parent: rootPage._id,
-      },
-      {
-        path: '/gB_canOverwriteDescendants_1',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userB,
-        lastUpdateUser: userB,
-        grantedUsers: null,
-        grantedGroup: userGroupIdB,
-        parent: pageIdgAB1,
-      },
-      {
-        path: '/onlyB_canOverwriteDescendants_1',
-        grant: PageGrant.GRANT_OWNER,
-        creator: userB,
-        lastUpdateUser: userB,
-        grantedUsers: [userB._id],
-        grantedGroup: null,
-        parent: pageIdgAB1,
-      },
-      // case 2
-      {
-        _id: pageIdPublic2,
-        path: '/public_canOverwriteDescendants_2', // to Anything
-        grant: PageGrant.GRANT_PUBLIC,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: null,
-        parent: rootPage._id,
-      },
-      {
-        path: '/gA_canOverwriteDescendants_2',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: userGroupIdA,
-        parent: pageIdPublic2,
-      },
-      {
-        path: '/gAIsolated_canOverwriteDescendants_2',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: userGroupIdAIsolated,
-        parent: pageIdPublic2,
-      },
-      {
-        path: '/onlyA_canOverwriteDescendants_2',
-        grant: PageGrant.GRANT_OWNER,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: [userA._id],
-        grantedGroup: null,
-        parent: pageIdPublic2,
-      },
-      // case 3
-      {
-        _id: pageIdPublic3,
-        path: '/public_canOverwriteDescendants_3', // to GRANT_USER_GROUP with GroupAB
-        grant: PageGrant.GRANT_PUBLIC,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: null,
-        parent: rootPage._id,
-      },
-      {
-        path: '/gAB_canOverwriteDescendants_3',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: userGroupIdAB,
-        parent: pageIdPublic3,
-      },
-      {
-        path: '/gB_canOverwriteDescendants_3',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userB,
-        lastUpdateUser: userB,
-        grantedUsers: null,
-        grantedGroup: userGroupIdB,
-        parent: pageIdPublic3,
-      },
-      {
-        path: '/onlyB_canOverwriteDescendants_3',
-        grant: PageGrant.GRANT_OWNER,
-        creator: userB,
-        lastUpdateUser: userB,
-        grantedUsers: [userB._id],
-        grantedGroup: null,
-        parent: pageIdPublic3,
-      },
-      // case 4
-      {
-        _id: pageIdPublic4,
-        path: '/public_canOverwriteDescendants_4', // to GRANT_USER_GROUP with GroupAB
-        grant: PageGrant.GRANT_PUBLIC,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: null,
-        parent: rootPage._id,
-      },
-      {
-        path: '/gA_canOverwriteDescendants_4',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: userGroupIdA,
-        parent: pageIdPublic4,
-      },
-      {
-        path: '/gC_canOverwriteDescendants_4',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userC,
-        lastUpdateUser: userC,
-        grantedUsers: null,
-        grantedGroup: userGroupIdC,
-        parent: pageIdPublic4,
-      },
-      // case 5
-      {
-        _id: pageIdPublic5,
-        path: '/public_canOverwriteDescendants_5', // to GRANT_USER_GROUP with GroupAB
-        grant: PageGrant.GRANT_PUBLIC,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: null,
-        parent: rootPage._id,
-      },
-      {
-        path: '/gA_canOverwriteDescendants_5',
-        grant: PageGrant.GRANT_USER_GROUP,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: userGroupIdA,
-        parent: pageIdPublic5,
-      },
-      {
-        path: '/onlyC_canOverwriteDescendants_5',
-        grant: PageGrant.GRANT_OWNER,
-        creator: userC,
-        lastUpdateUser: userC,
-        grantedUsers: [userC._id],
-        grantedGroup: null,
-        parent: pageIdPublic5,
-      },
-      // case 6
-      {
-        _id: pageIdPublic6,
-        path: '/public_canOverwriteDescendants_6', // to GRANT_USER_GROUP with GroupAB
-        grant: PageGrant.GRANT_PUBLIC,
-        creator: userA,
-        lastUpdateUser: userA,
-        grantedUsers: null,
-        grantedGroup: null,
-        parent: rootPage._id,
-      },
-      {
-        path: '/onlyC_canOverwriteDescendants_6',
-        grant: PageGrant.GRANT_OWNER,
-        creator: userC,
-        lastUpdateUser: userC,
-        grantedUsers: [userC._id],
-        grantedGroup: null,
-        parent: pageIdPublic6,
-      },
-    ]);
-  };
-
   /*
    * prepare before all tests
    */
@@ -607,7 +324,6 @@ describe('PageGrantService', () => {
     rootPage = await Page.findOne({ path: '/' });
 
     await createDocumentsToTestIsGrantNormalized();
-    await createDocumentsToTestCanOverwriteDescendants();
 
     xssSpy = jest.spyOn(crowi.xss, 'process').mockImplementation(path => path);
   });
@@ -953,94 +669,4 @@ describe('PageGrantService', () => {
       );
     });
   });
-
-  // see: https://dev.growi.org/635a314eac6bcd85cbf359fc about the specification
-  describe('canOverwriteDescendants', () => {
-    test('(case 1) it should return true when update grant is GRANT_PUBLIC', async() => {
-      const updateGrantInfo = {
-        targetPage: {},
-        grant: PageGrant.GRANT_PUBLIC,
-        grantedUser: null,
-        grantedUserGroup: null,
-      };
-      // TODO: expect page tree
-
-      const res = await pageGrantService.canOverwriteDescendants(userA, updateGrantInfo);
-
-      expect(res).toBe(true);
-    });
-    test('(case 2) it should return true when all descendant pages are granted by the operator', async() => {
-      const updateGrantInfo = {
-        targetPage: {},
-        grant: PageGrant.GRANT_OWNER,
-        grantedUser: userA,
-        grantedUserGroup: null,
-      };
-      // TODO: expect page tree
-
-      const res = await pageGrantService.canOverwriteDescendants(userA, updateGrantInfo);
-
-      expect(res).toBe(true);
-    });
-    test(`(case 3) it should return true when update grant is GRANT_USER_GROUP
-    , all user groups of descendants are the children or itself of the update user group
-    , and all users of descendants belong to the update user group`, async() => {
-      const userGroupAB = {};
-      const updateGrantInfo = {
-        targetPage: {},
-        grant: PageGrant.GRANT_USER_GROUP,
-        grantedUser: null,
-        grantedUserGroup: userGroupAB,
-      };
-      // TODO: expect page tree
-
-      const res = await pageGrantService.canOverwriteDescendants(userA, updateGrantInfo);
-
-      expect(res).toBe(true);
-    });
-    test(`(case 4) it should return false when some of descendants is not granted
-    , update grant is GRANT_USER_GROUP
-    , and some of user groups of descendants are not children or itself of the update user group`, async() => {
-      const userGroupAB = {};
-      const updateGrantInfo = {
-        targetPage: {},
-        grant: PageGrant.GRANT_USER_GROUP,
-        grantedUser: null,
-        grantedUserGroup: userGroupAB,
-      };
-      // TODO: expect page tree (include page with gC)
-
-      const res = await pageGrantService.canOverwriteDescendants(userA, updateGrantInfo);
-
-      expect(res).toBe(false);
-    });
-    test(`(case 5) it should return false when some of descendants is not granted
-    , update grant is GRANT_USER_GROUP
-    , and some of users of descendants does NOT belong to the update user group`, async() => {
-      const updateGrantInfo = {
-        targetPage: {},
-        grant: PageGrant.GRANT_USER_GROUP,
-        grantedUser: null,
-        grantedUserGroup: null,
-      };
-      // TODO: expect page tree (include page with onlyC)
-
-      const res = await pageGrantService.canOverwriteDescendants(userA, updateGrantInfo);
-
-      expect(res).toBe(false);
-    });
-    test('(case 6) it should return false when some of descendants is not granted and update grant is GRANT_OWNER', async() => {
-      const updateGrantInfo = {
-        targetPage: {},
-        grant: PageGrant.GRANT_OWNER,
-        grantedUser: userA,
-        grantedUserGroup: null,
-      };
-      // TODO: expect page tree (include page with onlyC)
-
-      const res = await pageGrantService.canOverwriteDescendants(userA, updateGrantInfo);
-
-      expect(res).toBe(false);
-    });
-  });
 });