|
@@ -316,17 +316,19 @@ describe('PageService', () => {
|
|
|
const dummyId = '600d395667536503354c9999';
|
|
const dummyId = '600d395667536503354c9999';
|
|
|
crowi.models.Page.findRelatedTagsById = jest.fn().mockImplementation(() => { return parentTag });
|
|
crowi.models.Page.findRelatedTagsById = jest.fn().mockImplementation(() => { return parentTag });
|
|
|
const originTagsMock = jest.spyOn(Page, 'findRelatedTagsById').mockImplementation(() => { return parentTag });
|
|
const originTagsMock = jest.spyOn(Page, 'findRelatedTagsById').mockImplementation(() => { return parentTag });
|
|
|
- jest.spyOn(PageTagRelation, 'updatePageTags').mockImplementation(() => { return [dummyId, originTagsMock().name] });
|
|
|
|
|
- jest.spyOn(PageTagRelation, 'listTagNamesByPage').mockImplementation(() => { return [parentTag].map((tag) => { return tag.name }) });
|
|
|
|
|
|
|
+ jest.spyOn(PageTagRelation, 'updatePageTags').mockImplementation(() => { return [dummyId, parentTag.name] });
|
|
|
|
|
+ jest.spyOn(PageTagRelation, 'listTagNamesByPage').mockImplementation(() => { return [parentTag.name] });
|
|
|
|
|
+
|
|
|
|
|
+ const resultPageRecursivly = await crowi.pageService.duplicate(parentForDuplicate, '/newParentDuplicateRecursively', testUser2, true);
|
|
|
|
|
+ const duplicatedRecursivelyToPageRevision = await Revision.findOne({ path: '/newParentDuplicateRecursively' });
|
|
|
|
|
|
|
|
- const resultPageRecursivly = await crowi.pageService.duplicate(parentForDuplicate, '/newParent', testUser1, true);
|
|
|
|
|
|
|
|
|
|
expect(xssSpy).toHaveBeenCalled();
|
|
expect(xssSpy).toHaveBeenCalled();
|
|
|
expect(duplicateDescendantsWithStreamSpy).toHaveBeenCalled();
|
|
expect(duplicateDescendantsWithStreamSpy).toHaveBeenCalled();
|
|
|
expect(serializePageSecurely).toHaveBeenCalled();
|
|
expect(serializePageSecurely).toHaveBeenCalled();
|
|
|
- expect(resultPageRecursivly.path).toBe('/newParent');
|
|
|
|
|
- expect(resultPageRecursivly.lastUpdateUser._id).toEqual(testUser1._id);
|
|
|
|
|
- expect(resultPageRecursivly.revision).not.toEqual(parentForDuplicate.revision);
|
|
|
|
|
|
|
+ expect(resultPageRecursivly.path).toBe('/newParentDuplicateRecursively');
|
|
|
|
|
+ expect(resultPageRecursivly.lastUpdateUser._id).toEqual(testUser2._id);
|
|
|
|
|
+ expect(duplicatedRecursivelyToPageRevision._id).not.toEqual(parentForDuplicate.revision._id);
|
|
|
expect(resultPageRecursivly.grant).toEqual(parentForDuplicate.grant);
|
|
expect(resultPageRecursivly.grant).toEqual(parentForDuplicate.grant);
|
|
|
expect(resultPageRecursivly.tags).toEqual([originTagsMock().name]);
|
|
expect(resultPageRecursivly.tags).toEqual([originTagsMock().name]);
|
|
|
});
|
|
});
|