|
|
@@ -55,18 +55,18 @@ describe('UserGroupService', () => {
|
|
|
]);
|
|
|
|
|
|
// Create UserGroupRelations
|
|
|
- await UserGroupRelation.insertMany([
|
|
|
- {
|
|
|
- _id: userGroupRelationId1,
|
|
|
- relatedGroup: groupId1,
|
|
|
- relatedUser: userId1,
|
|
|
- },
|
|
|
- {
|
|
|
- _id: userGroupRelationId4,
|
|
|
- relatedGroup: groupId4,
|
|
|
- relatedUser: userId4,
|
|
|
- },
|
|
|
- ]);
|
|
|
+ // await UserGroupRelation.insertMany([
|
|
|
+ // {
|
|
|
+ // _id: userGroupRelationId1,
|
|
|
+ // relatedGroup: groupId1,
|
|
|
+ // relatedUser: userId1,
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // _id: userGroupRelationId4,
|
|
|
+ // relatedGroup: groupId4,
|
|
|
+ // relatedUser: userId4,
|
|
|
+ // },
|
|
|
+ // ]);
|
|
|
|
|
|
|
|
|
});
|
|
|
@@ -78,11 +78,11 @@ describe('UserGroupService', () => {
|
|
|
const userGroup1 = await UserGroup.findOne({ _id: groupId1 });
|
|
|
const userGroup2 = await UserGroup.findOne({ _id: groupId2 });
|
|
|
|
|
|
- const newGroupName = 'v5_group2_new';
|
|
|
- const newGroupDescription = 'description2_new';
|
|
|
- const newParentId = userGroup1._id;
|
|
|
+ const newGroupName = 'v5_group1_new';
|
|
|
+ const newGroupDescription = 'description1_new';
|
|
|
+ const newParentId = userGroup2._id;
|
|
|
|
|
|
- const updatedUserGroup = await crowi.userGroupService.updateGroup(userGroup2._id, newGroupName, newGroupDescription, newParentId);
|
|
|
+ const updatedUserGroup = await crowi.userGroupService.updateGroup(userGroup1._id, newGroupName, newGroupDescription, newParentId);
|
|
|
|
|
|
expect(updatedUserGroup.name).toBe(newGroupName);
|
|
|
expect(updatedUserGroup.description).toBe(newGroupDescription);
|
|
|
@@ -93,13 +93,15 @@ describe('UserGroupService', () => {
|
|
|
const userGroup1 = await UserGroup.findOne({ _id: groupId1 });
|
|
|
const userGroup2 = await UserGroup.findOne({ _id: groupId2 });
|
|
|
|
|
|
- const result = await crowi.userGroupService.updateGroup(userGroup1._id, userGroup2.name);
|
|
|
+ // const result = await crowi.userGroupService.updateGroup(userGroup1._id, userGroup2.name);
|
|
|
+
|
|
|
+ // console.log('result_hoge', result);
|
|
|
|
|
|
- await expect(result).rejects.toThrow('The group name is already taken');
|
|
|
+ await expect(crowi.userGroupService.updateGroup(userGroup1._id, userGroup2.name)).rejects.toThrow('The group name is already taken');
|
|
|
});
|
|
|
|
|
|
- // forceUpdateParents is false
|
|
|
- test('Should throw an error when users in clild group do not include in users in parent group', async() => {
|
|
|
+ // In case that forceUpdateParents is false
|
|
|
+ test('Should throw an error when users in clild group do not include in parent group', async() => {
|
|
|
const userGroup1 = await UserGroup.findOne({ _id: groupId1 });
|
|
|
const userGroup4 = await UserGroup.findOne({ _id: groupId4 });
|
|
|
|
|
|
@@ -108,7 +110,7 @@ describe('UserGroupService', () => {
|
|
|
await expect(result).rejects.toThrow('The parent group does not contain the users in this group.');
|
|
|
});
|
|
|
|
|
|
- // force update
|
|
|
+ // In case that force update is true
|
|
|
test('Should be included user forcibly to parent group', async() => {
|
|
|
const userGroup1 = await UserGroup.findOne({ _id: groupId1 });
|
|
|
const userGroup4 = await UserGroup.findOne({ _id: groupId4 });
|
|
|
@@ -116,7 +118,7 @@ describe('UserGroupService', () => {
|
|
|
const forceUpdateParents = true;
|
|
|
|
|
|
await crowi.userGroupService.updateGroup(userGroup1._id, userGroup1.name, userGroup1.description, userGroup4._id, forceUpdateParents);
|
|
|
- const relatedGroup = await UserGroupRelation.findOne({ relatedGroup: userGroup4._id, relatedUser: userId1 });
|
|
|
+ const relatedGroup = UserGroupRelation.findOne({ relatedGroup: userGroup4._id, relatedUser: userId1 });
|
|
|
|
|
|
expect(relatedGroup).toBeTruthy();
|
|
|
}, 80000);
|