Преглед изворни кода

Public is only Applicable in case of top page

kaori пре 3 година
родитељ
комит
4b024c89d4
1 измењених фајлова са 18 додато и 1 уклоњено
  1. 18 1
      packages/app/test/integration/service/page-grant.test.js

+ 18 - 1
packages/app/test/integration/service/page-grant.test.js

@@ -1,8 +1,9 @@
 import mongoose from 'mongoose';
 
-import { getInstance } from '../setup-crowi';
 import UserGroup from '~/server/models/user-group';
 
+import { getInstance } from '../setup-crowi';
+
 /*
  * There are 3 grant types to test.
  * GRANT_PUBLIC, GRANT_OWNER, GRANT_USER_GROUP
@@ -37,6 +38,8 @@ describe('PageGrantService', () => {
   const emptyPagePath2 = '/E2';
   const emptyPagePath3 = '/E3';
 
+  const topPagePath = '/';
+
   let pageRootPublic;
   let pageRootGroupParent;
   const pageRootPublicPath = '/Public';
@@ -149,6 +152,10 @@ describe('PageGrantService', () => {
         grantedGroup: groupParent._id,
         parent: rootPage._id,
       },
+      {
+        path: topPagePath,
+        grant: Page.GRANT_PUBLIC,
+      },
     ]);
 
     emptyPage1 = await Page.findOne({ path: emptyPagePath1 });
@@ -360,4 +367,14 @@ describe('PageGrantService', () => {
     });
   });
 
+
+  describe('Test for calcApplicableGrantData', () => {
+    test('Public is only Applicable in case of top page', async() => {
+      const topPage = await Page.findOne({ path: topPagePath });
+      const result = await pageGrantService.calcApplicableGrantData(topPage, user1);
+
+      await expect(result[1]).toBeNull();
+    });
+  });
+
 });