|
@@ -228,6 +228,7 @@ describe('Page', () => {
|
|
|
const pageIdUpd11 = new mongoose.Types.ObjectId();
|
|
const pageIdUpd11 = new mongoose.Types.ObjectId();
|
|
|
const pageIdUpd12 = new mongoose.Types.ObjectId();
|
|
const pageIdUpd12 = new mongoose.Types.ObjectId();
|
|
|
const pageIdUpd13 = new mongoose.Types.ObjectId();
|
|
const pageIdUpd13 = new mongoose.Types.ObjectId();
|
|
|
|
|
+ const pageIdUpd14 = new mongoose.Types.ObjectId();
|
|
|
|
|
|
|
|
await Page.insertMany([
|
|
await Page.insertMany([
|
|
|
{
|
|
{
|
|
@@ -401,6 +402,33 @@ describe('Page', () => {
|
|
|
parent: pageIdUpd13,
|
|
parent: pageIdUpd13,
|
|
|
descendantCount: 0,
|
|
descendantCount: 0,
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ _id: pageIdUpd14,
|
|
|
|
|
+ path: '/mup24_pub',
|
|
|
|
|
+ grant: Page.GRANT_PUBLIC,
|
|
|
|
|
+ creator: pModelUserId1,
|
|
|
|
|
+ lastUpdateUser: pModelUserId1,
|
|
|
|
|
+ isEmpty: false,
|
|
|
|
|
+ parent: rootPage,
|
|
|
|
|
+ descendantCount: 1,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '/mup24_pub/mup25_pub',
|
|
|
|
|
+ grant: Page.GRANT_PUBLIC,
|
|
|
|
|
+ creator: pModelUserId1,
|
|
|
|
|
+ lastUpdateUser: pModelUserId1,
|
|
|
|
|
+ isEmpty: false,
|
|
|
|
|
+ parent: rootPage,
|
|
|
|
|
+ descendantCount: 0,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '/mup26_awl',
|
|
|
|
|
+ grant: Page.GRANT_RESTRICTED,
|
|
|
|
|
+ creator: pModelUserId1,
|
|
|
|
|
+ lastUpdateUser: pModelUserId1,
|
|
|
|
|
+ isEmpty: false,
|
|
|
|
|
+ descendantCount: 0,
|
|
|
|
|
+ },
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
});
|
|
});
|
|
@@ -686,6 +714,60 @@ describe('Page', () => {
|
|
|
const page2 = await Page.findOne({ path2 });
|
|
const page2 = await Page.findOne({ path2 });
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+ describe('Changing grant to GRANT_USER_GROUP', () => {
|
|
|
|
|
+ describe('update grant of a page under a page with GRANT_PUBLIC', () => {
|
|
|
|
|
+ test('successfully change to GRANT_USER_GROUP from GRANT_PUBLIC if parent page is GRANT_PUBLIC', async() => {
|
|
|
|
|
+ const path1 = '/mup24_pub';
|
|
|
|
|
+ const path2 = '/mup24_pub/mup25_pub';
|
|
|
|
|
+ const _page1 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
|
|
|
|
|
+ const _page2 = await Page.findOne({ path: path2, grant: Page.GRANT_PUBLIC });
|
|
|
|
|
+ const options = { grant: Page.GRANT_USER_GROUP, grantUserGroupId: groupIdA };
|
|
|
|
|
+ expect(_page1).toBeTruthy();
|
|
|
|
|
+ expect(_page2).toBeTruthy();
|
|
|
|
|
+
|
|
|
|
|
+ const updatedPage = await updatePage(_page2, 'new', 'old', pModelUser1, options);
|
|
|
|
|
+
|
|
|
|
|
+ const page1 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
|
|
|
|
|
+ const page2 = await Page.findOne({ path: path2 });
|
|
|
|
|
+ expect(updatedPage).toBeTruthy();
|
|
|
|
|
+ expect(page1).toBeTruthy();
|
|
|
|
|
+ expect(page2).toBeTruthy();
|
|
|
|
|
+ expect(updatedPage._id).toStrictEqual(page2._id);
|
|
|
|
|
+
|
|
|
|
|
+ expect(page2.grant).toBe(Page.GRANT_USER_GROUP);
|
|
|
|
|
+ expect(page2.grantedGroup).toStrictEqual(groupIdA);
|
|
|
|
|
+ });
|
|
|
|
|
+ test('successfully change to GRANT_USER_GROUP from GRANT_RESTRICTED if parent page is GRANT_PUBLIC', async() => {
|
|
|
|
|
+ const path1 = '/mup26_awl';
|
|
|
|
|
+ const _page1 = await Page.findOne({ path: path1, grant: Page.GRANT_RESTRICTED });
|
|
|
|
|
+ const options = { grant: Page.GRANT_USER_GROUP, grantUserGroupId: groupIdA };
|
|
|
|
|
+ expect(_page1).toBeTruthy();
|
|
|
|
|
+
|
|
|
|
|
+ const updatedPage = await updatePage(_page1, 'new', 'old', pModelUser1, options);
|
|
|
|
|
+
|
|
|
|
|
+ const page1 = await Page.findOne({ path: path1 });
|
|
|
|
|
+ expect(updatedPage).toBeTruthy();
|
|
|
|
|
+ expect(page1).toBeTruthy();
|
|
|
|
|
+ expect(updatedPage._id).toStrictEqual(page1._id);
|
|
|
|
|
+
|
|
|
|
|
+ expect(page1.grant).toBe(Page.GRANT_USER_GROUP);
|
|
|
|
|
+ expect(page1.grantedGroup).toStrictEqual(groupIdA);
|
|
|
|
|
+ expect(page1.parent).toStrictEqual(rootPage._id);
|
|
|
|
|
+ });
|
|
|
|
|
+ test('successfully change to GRANT_USER_GROUP from GRANT_OWNER if parent page is GRANT_PUBLIC', async() => {});
|
|
|
|
|
+ });
|
|
|
|
|
+ describe('update grant of a page under a page with GRANT_USER_GROUP', () => {
|
|
|
|
|
+ test('successfully change to GRANT_USER_GROUP if the group to set is the child or descendant of the parent page group', async() => {});
|
|
|
|
|
+ test('Fail to change to GRANT_USER_GROUP if the group to set is not the child or descendant of the parent page group', async() => {});
|
|
|
|
|
+ test('Fail to change to GRANT_USER_GROUP if the group to set is an ancestor of the parent page group', async() => {});
|
|
|
|
|
+ });
|
|
|
|
|
+ describe('update grant of a page under a page with GRANT_OWNER', () => {
|
|
|
|
|
+ test('Fail to change from GRNAT_OWNER', async() => {
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|