yohei0125 4 лет назад
Родитель
Сommit
0d6ccefffe
1 измененных файлов с 27 добавлено и 0 удалено
  1. 27 0
      packages/app/test/integration/models/v5.page.test.js

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

@@ -401,6 +401,16 @@ describe('Page', () => {
         parent: pageIdUpd13,
         parent: pageIdUpd13,
         descendantCount: 0,
         descendantCount: 0,
       },
       },
+      {
+        path: '/mup24',
+        grant: Page.GRANT_OWNER,
+        grantedUsers: [dummyUser1._id],
+        creator: dummyUser1,
+        lastUpdateUser: dummyUser1._id,
+        isEmpty: false,
+        parent: rootPage._id,
+        descendantCount: 0,
+      },
     ]);
     ]);
 
 
   });
   });
@@ -576,6 +586,22 @@ describe('Page', () => {
         expect(_pageT.descendantCount).toBe(0);
         expect(_pageT.descendantCount).toBe(0);
       });
       });
     });
     });
+
+    describe('Changing grant to GRANT_RESTRICTED', () => {
+      test('successfully change to GRANT_RESTRICTED from GRANT_OWNER', async() => {
+        const path = '/mup24';
+        const _page = await Page.findOne({ path, grant: Page.GRANT_OWNER, grantedUsers: [dummyUser1._id] });
+        expect(_page).toBeTruthy();
+
+        await updatePage(_page, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_RESTRICTED });
+
+        const page = await Page.findOne({ path });
+        expect(page).toBeTruthy();
+        expect(page.grant).toBe(Page.GRANT_RESTRICTED);
+        expect(page.grantedUsers).toBeNull();
+      });
+    });
+
     describe('Changing grant from RESTRICTED to PUBLIC of', () => {
     describe('Changing grant from RESTRICTED to PUBLIC of', () => {
       test('a page will create ancestors if they do not exist', async() => {
       test('a page will create ancestors if they do not exist', async() => {
         const pathT = '/mup16_top';
         const pathT = '/mup16_top';
@@ -634,6 +660,7 @@ describe('Page', () => {
         expect(_pageT.descendantCount).toBe(2);
         expect(_pageT.descendantCount).toBe(2);
       });
       });
     });
     });
+
     describe('Changing grant to GRANT_OWNER(onlyme)', () => {
     describe('Changing grant to GRANT_OWNER(onlyme)', () => {
       test('successfully change to GRANT_OWNER from GRANT_PUBLIC', async() => {
       test('successfully change to GRANT_OWNER from GRANT_PUBLIC', async() => {
         const path = '/mup19';
         const path = '/mup19';