|
|
@@ -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();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
});
|