|
|
@@ -1,5 +1,5 @@
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
-import type { GrantedGroup } from '@growi/core';
|
|
|
+import { GroupType, type GrantedGroup } from '@growi/core';
|
|
|
import mongoose from 'mongoose';
|
|
|
|
|
|
import { ExternalGroupProviderType } from '../../../src/features/external-user-group/interfaces/external-user-group';
|
|
|
@@ -203,6 +203,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
+ // same group structure as user groups for external user groups
|
|
|
externalGroupIdIsolate = new mongoose.Types.ObjectId();
|
|
|
externalGroupIdA = new mongoose.Types.ObjectId();
|
|
|
externalGroupIdB = new mongoose.Types.ObjectId();
|
|
|
@@ -421,7 +422,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRename2,
|
|
|
path: '/np_rename2',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdB }],
|
|
|
+ grantedGroups: [{ item: groupIdB, type: GroupType.userGroup }, { item: externalGroupIdB, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser2._id,
|
|
|
lastUpdateUser: npDummyUser2._id,
|
|
|
parent: rootPage._id,
|
|
|
@@ -430,7 +431,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRename3,
|
|
|
path: '/np_rename2/np_rename3',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdC }],
|
|
|
+ grantedGroups: [{ item: groupIdC, type: GroupType.userGroup }, { item: externalGroupIdC, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser3._id,
|
|
|
lastUpdateUser: npDummyUser3._id,
|
|
|
parent: pageIdRename2._id,
|
|
|
@@ -439,7 +440,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRename4,
|
|
|
path: '/np_rename4_destination',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdIsolate }],
|
|
|
+ grantedGroups: [{ item: groupIdIsolate, type: GroupType.userGroup }, { item: externalGroupIdIsolate, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser3._id,
|
|
|
lastUpdateUser: npDummyUser3._id,
|
|
|
parent: rootPage._id,
|
|
|
@@ -448,7 +449,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRename5,
|
|
|
path: '/np_rename5',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdB }],
|
|
|
+ grantedGroups: [{ item: groupIdB, type: GroupType.userGroup }, { item: externalGroupIdB, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser2._id,
|
|
|
lastUpdateUser: npDummyUser2._id,
|
|
|
parent: rootPage._id,
|
|
|
@@ -457,7 +458,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRename6,
|
|
|
path: '/np_rename5/np_rename6',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdB }],
|
|
|
+ grantedGroups: [{ item: groupIdB, type: GroupType.userGroup }, { item: externalGroupIdB, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser2._id,
|
|
|
lastUpdateUser: npDummyUser2._id,
|
|
|
parent: pageIdRename5,
|
|
|
@@ -466,7 +467,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRename7,
|
|
|
path: '/np_rename7_destination',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdIsolate }],
|
|
|
+ grantedGroups: [{ item: groupIdIsolate, type: GroupType.userGroup }, { item: externalGroupIdIsolate, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser2._id,
|
|
|
lastUpdateUser: npDummyUser2._id,
|
|
|
parent: pageIdRename5,
|
|
|
@@ -502,7 +503,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdDuplicate2,
|
|
|
path: '/np_duplicate2',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdA }],
|
|
|
+ grantedGroups: [{ item: groupIdA, type: GroupType.userGroup }, { item: externalGroupIdA, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser1._id,
|
|
|
lastUpdateUser: npDummyUser1._id,
|
|
|
revision: revisionIdDuplicate2,
|
|
|
@@ -512,7 +513,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdDuplicate3,
|
|
|
path: '/np_duplicate2/np_duplicate3',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdB }],
|
|
|
+ grantedGroups: [{ item: groupIdB, type: GroupType.userGroup }, { item: externalGroupIdB, type: GroupType.externalUserGroup }],
|
|
|
creator: npDummyUser2._id,
|
|
|
lastUpdateUser: npDummyUser2._id,
|
|
|
revision: revisionIdDuplicate3,
|
|
|
@@ -609,7 +610,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdDelete2,
|
|
|
path: '/npdel2_ug',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdA }],
|
|
|
+ grantedGroups: [{ item: groupIdA, type: GroupType.userGroup }, { item: externalGroupIdA, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: rootPage._id,
|
|
|
@@ -619,7 +620,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdDelete3,
|
|
|
path: '/npdel3_top',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdA }],
|
|
|
+ grantedGroups: [{ item: groupIdA, type: GroupType.userGroup }, { item: externalGroupIdA, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: rootPage._id,
|
|
|
@@ -629,7 +630,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdDelete4,
|
|
|
path: '/npdel3_top/npdel4_ug',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdB }],
|
|
|
+ grantedGroups: [{ item: groupIdB, type: GroupType.userGroup }, { item: externalGroupIdB, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: pageIdDelete3._id,
|
|
|
@@ -644,7 +645,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
{
|
|
|
path: '/npdel3_top/npdel4_ug/npdel5_ug',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdC }],
|
|
|
+ grantedGroups: [{ item: groupIdC, type: GroupType.userGroup }, { item: externalGroupIdC, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: pageIdDelete4._id,
|
|
|
@@ -667,7 +668,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
{
|
|
|
path: '/npdc2_ug',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdA }],
|
|
|
+ grantedGroups: [{ item: groupIdA, type: GroupType.userGroup }, { item: externalGroupIdA, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: rootPage._id,
|
|
|
@@ -676,7 +677,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdDeleteComp1,
|
|
|
path: '/npdc3_ug',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdA }],
|
|
|
+ grantedGroups: [{ item: groupIdA, type: GroupType.userGroup }, { item: externalGroupIdA, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: rootPage._id,
|
|
|
@@ -685,7 +686,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdDeleteComp2,
|
|
|
path: '/npdc3_ug/npdc4_ug',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdB }],
|
|
|
+ grantedGroups: [{ item: groupIdB, type: GroupType.userGroup }, { item: externalGroupIdB, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: pageIdDeleteComp1,
|
|
|
@@ -693,7 +694,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
{
|
|
|
path: '/npdc3_ug/npdc4_ug/npdc5_ug',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdC }],
|
|
|
+ grantedGroups: [{ item: groupIdC, type: GroupType.userGroup }, { item: externalGroupIdC, type: GroupType.externalUserGroup }],
|
|
|
status: Page.STATUS_PUBLISHED,
|
|
|
isEmpty: false,
|
|
|
parent: pageIdDeleteComp2,
|
|
|
@@ -721,7 +722,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRevert2,
|
|
|
path: '/trash/np_revert2',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdA }],
|
|
|
+ grantedGroups: [{ item: groupIdA, type: GroupType.userGroup }, { item: externalGroupIdA, type: GroupType.externalUserGroup }],
|
|
|
revision: revisionIdRevert2,
|
|
|
status: Page.STATUS_DELETED,
|
|
|
},
|
|
|
@@ -743,7 +744,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRevert5,
|
|
|
path: '/trash/np_revert5',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdA }],
|
|
|
+ grantedGroups: [{ item: groupIdA, type: GroupType.userGroup }, { item: externalGroupIdA, type: GroupType.externalUserGroup }],
|
|
|
revision: revisionIdRevert5,
|
|
|
status: Page.STATUS_DELETED,
|
|
|
},
|
|
|
@@ -751,7 +752,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
_id: pageIdRevert6,
|
|
|
path: '/trash/np_revert5/middle/np_revert6',
|
|
|
grant: Page.GRANT_USER_GROUP,
|
|
|
- grantedGroups: [{ item: groupIdB }],
|
|
|
+ grantedGroups: [{ item: groupIdB, type: GroupType.userGroup }, { item: externalGroupIdB, type: GroupType.externalUserGroup }],
|
|
|
revision: revisionIdRevert6,
|
|
|
status: Page.STATUS_DELETED,
|
|
|
},
|
|
|
@@ -1143,8 +1144,14 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
expect(duplicatedPage2).toBeTruthy();
|
|
|
expect(duplicatedRevision1).toBeTruthy();
|
|
|
expect(duplicatedRevision2).toBeTruthy();
|
|
|
- expect(normalizeGrantedGroups(duplicatedPage1.grantedGroups)).toStrictEqual([{ item: groupIdA._id.toString(), type: 'UserGroup' }]);
|
|
|
- expect(normalizeGrantedGroups(duplicatedPage2.grantedGroups)).toStrictEqual([{ item: groupIdB._id.toString(), type: 'UserGroup' }]);
|
|
|
+ expect(normalizeGrantedGroups(duplicatedPage1.grantedGroups)).toStrictEqual([
|
|
|
+ { item: groupIdA.toString(), type: GroupType.userGroup },
|
|
|
+ { item: externalGroupIdA.toString(), type: GroupType.externalUserGroup },
|
|
|
+ ]);
|
|
|
+ expect(normalizeGrantedGroups(duplicatedPage2.grantedGroups)).toStrictEqual([
|
|
|
+ { item: groupIdB.toString(), type: GroupType.userGroup },
|
|
|
+ { item: externalGroupIdB.toString(), type: GroupType.externalUserGroup },
|
|
|
+ ]);
|
|
|
expect(duplicatedPage1.parent).toStrictEqual(_page1.parent);
|
|
|
expect(duplicatedPage2.parent).toStrictEqual(duplicatedPage1._id);
|
|
|
expect(duplicatedRevision1.body).toBe(_revision1.body);
|
|
|
@@ -1449,7 +1456,10 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
expect(revertedPage.parent).toStrictEqual(rootPage._id);
|
|
|
expect(revertedPage.status).toBe(Page.STATUS_PUBLISHED);
|
|
|
expect(revertedPage.grant).toBe(Page.GRANT_USER_GROUP);
|
|
|
- expect(normalizeGrantedGroups(revertedPage.grantedGroups)).toStrictEqual([{ item: groupIdA.toString(), type: 'UserGroup' }]);
|
|
|
+ expect(normalizeGrantedGroups(revertedPage.grantedGroups)).toStrictEqual([
|
|
|
+ { item: groupIdA.toString(), type: GroupType.userGroup },
|
|
|
+ { item: externalGroupIdA.toString(), type: GroupType.externalUserGroup },
|
|
|
+ ]);
|
|
|
expect(pageTagRelation.isPageTrashed).toBe(false);
|
|
|
});
|
|
|
test(`revert multiple pages: only target page should be reverted.
|
|
|
@@ -1531,8 +1541,14 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
expect(revertedPage1.status).toBe(Page.STATUS_PUBLISHED);
|
|
|
expect(revertedPage2.status).toBe(Page.STATUS_PUBLISHED);
|
|
|
expect(newlyCreatedPage.status).toBe(Page.STATUS_PUBLISHED);
|
|
|
- expect(normalizeGrantedGroups(revertedPage1.grantedGroups)).toStrictEqual([{ item: groupIdA.toString(), type: 'UserGroup' }]);
|
|
|
- expect(normalizeGrantedGroups(revertedPage2.grantedGroups)).toStrictEqual([{ item: groupIdB.toString(), type: 'UserGroup' }]);
|
|
|
+ expect(normalizeGrantedGroups(revertedPage1.grantedGroups)).toStrictEqual([
|
|
|
+ { item: groupIdA.toString(), type: GroupType.userGroup },
|
|
|
+ { item: externalGroupIdA.toString(), type: GroupType.externalUserGroup },
|
|
|
+ ]);
|
|
|
+ expect(normalizeGrantedGroups(revertedPage2.grantedGroups)).toStrictEqual([
|
|
|
+ { item: groupIdB.toString(), type: GroupType.userGroup },
|
|
|
+ { item: externalGroupIdB.toString(), type: GroupType.externalUserGroup },
|
|
|
+ ]);
|
|
|
expect(newlyCreatedPage.grant).toBe(Page.GRANT_PUBLIC);
|
|
|
|
|
|
});
|