@reltio/components 1.4.1905 → 1.4.1907
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/ActionsPanel/ActionsPanel.test.js +133 -49
- package/cjs/AttributeListItem/AttributeListItem.spec.js +147 -118
- package/cjs/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/cjs/AttributesErrorsPanel/components/Error/Error.specs.js +96 -90
- package/cjs/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/cjs/AttributesErrorsPanel/store.test-data.js +29 -0
- package/cjs/AttributesFilterSelector/AttributesFilterSelector.test.js +127 -105
- package/cjs/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/cjs/AttributesValuesEditor/AttributesValuesEditor.test.js +92 -88
- package/cjs/AttributesView/AttributesView.test.js +67 -34
- package/cjs/AutoSizeList/AutoSizeList.test.js +81 -59
- package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +15 -31
- package/cjs/BarChart/BarChart.test.js +128 -65
- package/cjs/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/cjs/BasicViewContent/BasicViewContent.test.js +7 -9
- package/cjs/BlobRenderer/BlobRenderer.test.js +28 -9
- package/cjs/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/cjs/BubbleChart/BubbleChart.test.js +111 -87
- package/cjs/CloudChart/CloudChart.test.js +95 -36
- package/cjs/CollaborationItem/CollaborationItem.test.js +67 -30
- package/cjs/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/cjs/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -81
- package/cjs/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/cjs/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/cjs/CollapseButton/CollapseButton.test.js +74 -15
- package/cjs/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/cjs/ColorBar/ColorBar.test.js +13 -15
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/cjs/CommentsContainer/CommentsContainer.test.js +282 -211
- package/cjs/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +183 -122
- package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/cjs/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/cjs/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/cjs/ConnectionEditor/ConnectionEditor.test.js +299 -282
- package/cjs/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.d.ts +3 -1
- package/cjs/ReactSortableTree/ReactSortableTree.js +2 -7
- package/cjs/RelationTypeSelector/RelationTypeSelector.d.ts +3 -1
- package/cjs/types/index.d.ts +1 -1
- package/esm/ActionsPanel/ActionsPanel.test.js +133 -49
- package/esm/AttributeListItem/AttributeListItem.spec.js +149 -97
- package/esm/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/esm/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/esm/AttributesErrorsPanel/components/Error/Error.specs.js +98 -72
- package/esm/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/esm/AttributesErrorsPanel/store.test-data.js +26 -0
- package/esm/AttributesFilterSelector/AttributesFilterSelector.test.js +129 -84
- package/esm/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/esm/AttributesValuesEditor/AttributesValuesEditor.test.js +94 -67
- package/esm/AttributesView/AttributesView.test.js +67 -34
- package/esm/AutoSizeList/AutoSizeList.test.js +81 -59
- package/esm/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +16 -32
- package/esm/BarChart/BarChart.test.js +128 -65
- package/esm/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/esm/BasicViewContent/BasicViewContent.test.js +7 -9
- package/esm/BlobRenderer/BlobRenderer.test.js +28 -9
- package/esm/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/esm/BubbleChart/BubbleChart.test.js +111 -87
- package/esm/CloudChart/CloudChart.test.js +95 -36
- package/esm/CollaborationItem/CollaborationItem.test.js +67 -30
- package/esm/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/esm/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -58
- package/esm/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/esm/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/esm/CollapseButton/CollapseButton.test.js +74 -15
- package/esm/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/esm/ColorBar/ColorBar.test.js +13 -15
- package/esm/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/esm/CommentsContainer/CommentsContainer.test.js +282 -211
- package/esm/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +182 -101
- package/esm/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/esm/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/esm/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/esm/ConnectionEditor/ConnectionEditor.test.js +300 -283
- package/esm/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.d.ts +3 -1
- package/esm/ReactSortableTree/ReactSortableTree.js +2 -7
- package/esm/RelationTypeSelector/RelationTypeSelector.d.ts +3 -1
- package/esm/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -100
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -46
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.js +0 -27
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -27
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.js +0 -15
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -80
- package/esm/ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -95
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -41
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.js +0 -22
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -22
- package/esm/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/esm/CollaborationItem/components/Avatar/Avatar.test.js +0 -10
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -55
- /package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts → AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
- /package/{cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts → esm/AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
|
@@ -10,12 +10,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { shallow } from 'enzyme';
|
|
14
13
|
import { CollaborationObjectTypes } from '@reltio/mdm-sdk';
|
|
15
|
-
import { Comment } from './components/Comment';
|
|
16
|
-
import { RepliedComment } from './components/RepliedComment';
|
|
17
|
-
import { SendMessageArea } from './components/SendMessageArea';
|
|
18
14
|
import CollaborationItem from './CollaborationItem';
|
|
15
|
+
import { render, screen } from '@testing-library/react';
|
|
16
|
+
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
19
17
|
var createComment = function (hasReplies) {
|
|
20
18
|
if (hasReplies === void 0) { hasReplies = false; }
|
|
21
19
|
var comment = {
|
|
@@ -39,12 +37,12 @@ var createComment = function (hasReplies) {
|
|
|
39
37
|
comment.replies.push({
|
|
40
38
|
selfLink: 'https://cservice-dev.reltio.com/tst-01/sokol/comments/00001lo/replies/000007s',
|
|
41
39
|
replyId: '000007s',
|
|
42
|
-
createdBy: '
|
|
40
|
+
createdBy: 'other.user',
|
|
43
41
|
createdTime: 1620280061505,
|
|
44
42
|
modifiedTime: 1620280061505,
|
|
45
43
|
deleted: false,
|
|
46
44
|
action: 'none',
|
|
47
|
-
content: '
|
|
45
|
+
content: 'other comment',
|
|
48
46
|
namedUsers: []
|
|
49
47
|
});
|
|
50
48
|
}
|
|
@@ -58,37 +56,76 @@ var createProps = function (comment) {
|
|
|
58
56
|
objectType: CollaborationObjectTypes.ENTITY_ATTRIBUTE
|
|
59
57
|
};
|
|
60
58
|
};
|
|
61
|
-
var setUp = function (props) { return shallow(React.createElement(CollaborationItem, __assign({}, props))); };
|
|
62
59
|
describe('CollaborationItem tests', function () {
|
|
60
|
+
var entity = {
|
|
61
|
+
type: 'configuration/entityTypes/HCP',
|
|
62
|
+
uri: 'entities/02ZRRE9',
|
|
63
|
+
attributes: {
|
|
64
|
+
FirstName: [
|
|
65
|
+
{
|
|
66
|
+
type: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
67
|
+
ov: true,
|
|
68
|
+
value: 'nameValue',
|
|
69
|
+
uri: 'entities/02ZRRE9/attributes/FirstName/15p60Tel'
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var metadata = {
|
|
75
|
+
entityTypes: [
|
|
76
|
+
{
|
|
77
|
+
uri: 'configuration/entityTypes/HCP',
|
|
78
|
+
attributes: [
|
|
79
|
+
{
|
|
80
|
+
uri: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
81
|
+
type: 'String',
|
|
82
|
+
name: 'FirstName',
|
|
83
|
+
label: 'First Name',
|
|
84
|
+
access: ['READ', 'CREATE', 'UPDATE', 'INITIATE_CHANGE_REQUEST']
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
};
|
|
90
|
+
var actions = {
|
|
91
|
+
removeAttribute: function () { }
|
|
92
|
+
};
|
|
93
|
+
var mdmDefaultValues = {
|
|
94
|
+
user: {
|
|
95
|
+
username: 'test.testmail'
|
|
96
|
+
},
|
|
97
|
+
entity: entity,
|
|
98
|
+
metadata: metadata,
|
|
99
|
+
modifiedEntities: { 'entities/02ZRRE9': entity },
|
|
100
|
+
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
|
|
101
|
+
};
|
|
102
|
+
var setUp = function (props) {
|
|
103
|
+
var Providers = function (_a) {
|
|
104
|
+
var children = _a.children;
|
|
105
|
+
return (React.createElement(MdmModuleProvider, { values: mdmDefaultValues, actions: actions }, children));
|
|
106
|
+
};
|
|
107
|
+
return render(React.createElement(CollaborationItem, __assign({}, props)), { wrapper: Providers });
|
|
108
|
+
};
|
|
63
109
|
it('should render Comment correctly if comment exist', function () {
|
|
64
|
-
|
|
65
|
-
expect(
|
|
66
|
-
expect(
|
|
110
|
+
setUp(createProps(createComment()));
|
|
111
|
+
expect(screen.queryByText('VK')).toBeInTheDocument();
|
|
112
|
+
expect(screen.queryByText('vyacheslav.kovyazin')).toBeInTheDocument();
|
|
113
|
+
expect(screen.queryByText('comment')).toBeInTheDocument();
|
|
67
114
|
});
|
|
68
115
|
it('should not render Comment and RepliedComment if comment do not exist', function () {
|
|
69
|
-
var
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
116
|
+
var container = setUp(createProps()).container;
|
|
117
|
+
expect(container.querySelector('.comment')).not.toBeInTheDocument();
|
|
118
|
+
expect(container.querySelector('.replies')).not.toBeInTheDocument();
|
|
72
119
|
});
|
|
73
120
|
it('should render SendMessageArea correctly', function () {
|
|
74
|
-
var
|
|
75
|
-
expect(
|
|
76
|
-
expect(
|
|
77
|
-
expect(component.find(SendMessageArea).prop('relatedObjectUris')).toEqual(['entities/13JKIKAz']);
|
|
78
|
-
});
|
|
79
|
-
it('should not render replied comments correctly if they do not exist', function () {
|
|
80
|
-
var component = setUp(createProps(createComment(false)));
|
|
81
|
-
expect(component.find(RepliedComment)).toHaveLength(0);
|
|
121
|
+
var container = setUp(createProps(createComment())).container;
|
|
122
|
+
expect(screen.queryByText('TT')).toBeInTheDocument();
|
|
123
|
+
expect(container.querySelector('.sendMessageArea')).toBeInTheDocument();
|
|
82
124
|
});
|
|
83
125
|
it('should render replied comments correctly if they do exist', function () {
|
|
84
|
-
|
|
85
|
-
expect(
|
|
86
|
-
expect(
|
|
87
|
-
|
|
88
|
-
content: 'abc',
|
|
89
|
-
createdBy: 'vyacheslav.kovyazin',
|
|
90
|
-
action: 'none',
|
|
91
|
-
namedUsers: []
|
|
92
|
-
});
|
|
126
|
+
setUp(createProps(createComment(true)));
|
|
127
|
+
expect(screen.queryByText('OU')).toBeInTheDocument();
|
|
128
|
+
expect(screen.queryByText('other.user')).toBeInTheDocument();
|
|
129
|
+
expect(screen.queryByText('other comment')).toBeInTheDocument();
|
|
93
130
|
});
|
|
94
131
|
});
|
|
@@ -46,234 +46,268 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import React from 'react';
|
|
49
|
-
import { mount } from 'enzyme';
|
|
50
49
|
import { render, screen } from '@testing-library/react';
|
|
51
50
|
import userEvent from '@testing-library/user-event';
|
|
52
|
-
import { act } from 'react-dom/test-utils';
|
|
53
51
|
import { CollaborationObjectTypes } from '@reltio/mdm-sdk';
|
|
54
|
-
import Link from '@mui/material/Link';
|
|
55
|
-
import { DropDownMenuButton } from '../../../DropDownMenuButton';
|
|
56
52
|
import { CollaborationContext } from '../../../contexts/CollaborationContext';
|
|
57
53
|
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
|
|
58
54
|
import { formatDate } from '../../helpers';
|
|
59
|
-
import { Avatar } from '../Avatar';
|
|
60
|
-
import { SendMessageArea } from '../SendMessageArea';
|
|
61
|
-
import { CommentContent } from '../CommentContent';
|
|
62
55
|
import { Comment } from './Comment';
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
permanentLink: ''
|
|
56
|
+
describe('Comment tests', function () {
|
|
57
|
+
var TIME = 1620280049022;
|
|
58
|
+
var createComment = function (status, createdBy) {
|
|
59
|
+
if (status === void 0) { status = 'open'; }
|
|
60
|
+
if (createdBy === void 0) { createdBy = 'vyacheslav.kovyazin'; }
|
|
61
|
+
return {
|
|
62
|
+
createdBy: createdBy,
|
|
63
|
+
createdTime: TIME,
|
|
64
|
+
status: status,
|
|
65
|
+
objectId: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5',
|
|
66
|
+
objectType: CollaborationObjectTypes.ENTITY_ATTRIBUTE,
|
|
67
|
+
content: 'comment',
|
|
68
|
+
relatedObjectUris: ['entities/13JKIKAz'],
|
|
69
|
+
commentId: 'commentId',
|
|
70
|
+
namedUsers: [],
|
|
71
|
+
replies: [],
|
|
72
|
+
modifiedTime: 0,
|
|
73
|
+
deleted: false,
|
|
74
|
+
visibility: '',
|
|
75
|
+
selfLink: '',
|
|
76
|
+
permanentLink: ''
|
|
77
|
+
};
|
|
86
78
|
};
|
|
87
|
-
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
79
|
+
var defaultCurrentComment = createComment();
|
|
80
|
+
var defaultCommentsMap = {
|
|
81
|
+
uri1: [
|
|
82
|
+
{
|
|
83
|
+
commentId: defaultCurrentComment.commentId,
|
|
84
|
+
status: 'open',
|
|
85
|
+
replies: 0
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
var defaultUsername = 'vyacheslav.kovyazin';
|
|
90
|
+
var entity = {
|
|
91
|
+
type: 'configuration/entityTypes/HCP',
|
|
92
|
+
uri: 'entities/02ZRRE9',
|
|
93
|
+
attributes: {
|
|
94
|
+
FirstName: [
|
|
95
|
+
{
|
|
96
|
+
type: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
97
|
+
ov: true,
|
|
98
|
+
value: 'nameValue',
|
|
99
|
+
uri: 'entities/02ZRRE9/attributes/FirstName/15p60Tel'
|
|
100
|
+
}
|
|
101
|
+
]
|
|
95
102
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
103
|
+
};
|
|
104
|
+
var metadata = {
|
|
105
|
+
entityTypes: [
|
|
106
|
+
{
|
|
107
|
+
uri: 'configuration/entityTypes/HCP',
|
|
108
|
+
attributes: [
|
|
109
|
+
{
|
|
110
|
+
uri: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
111
|
+
type: 'String',
|
|
112
|
+
name: 'FirstName',
|
|
113
|
+
label: 'First Name',
|
|
114
|
+
access: ['READ', 'CREATE', 'UPDATE', 'INITIATE_CHANGE_REQUEST']
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
var defaultMdmValues = {
|
|
121
|
+
user: {
|
|
122
|
+
username: defaultUsername
|
|
123
|
+
},
|
|
124
|
+
entity: entity,
|
|
125
|
+
metadata: metadata
|
|
126
|
+
};
|
|
127
|
+
var defaultCollaborationContextValue = {
|
|
128
|
+
commentsMap: defaultCommentsMap,
|
|
129
|
+
currentComment: defaultCurrentComment,
|
|
130
|
+
createComment: function () { return Promise.resolve(); },
|
|
131
|
+
editComment: function () { return Promise.resolve(); },
|
|
132
|
+
editReply: function () { return Promise.resolve(); },
|
|
133
|
+
deleteComment: jest.fn(),
|
|
134
|
+
deleteReply: function () { },
|
|
135
|
+
createReply: function () { return Promise.resolve(); },
|
|
136
|
+
reOpenThread: jest.fn(),
|
|
137
|
+
resolveThread: jest.fn(),
|
|
138
|
+
getComment: jest.fn(),
|
|
139
|
+
clearCurrentComment: jest.fn(),
|
|
140
|
+
sending: false,
|
|
141
|
+
loading: false,
|
|
142
|
+
pageToken: '',
|
|
143
|
+
getComments: function () { return Promise.resolve(); },
|
|
144
|
+
comments: [],
|
|
145
|
+
getCommentsCount: function () { return Promise.resolve(); },
|
|
146
|
+
getCommentState: function () { return ({}); },
|
|
147
|
+
updateCommentState: jest.fn(),
|
|
148
|
+
clearCommentState: function () { }
|
|
149
|
+
};
|
|
150
|
+
var defaultProps = {
|
|
151
|
+
comment: defaultCurrentComment,
|
|
152
|
+
onReply: jest.fn(),
|
|
153
|
+
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5',
|
|
154
|
+
relatedObjectUris: ['entities/13JKIKAz'],
|
|
155
|
+
objectType: CollaborationObjectTypes.ENTITY_ATTRIBUTE
|
|
156
|
+
};
|
|
157
|
+
var setUp = function (_a) {
|
|
158
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d, _e = _b.collaborationContextValue, collaborationContextValue = _e === void 0 ? defaultCollaborationContextValue : _e;
|
|
159
|
+
var Providers = function (_a) {
|
|
160
|
+
var children = _a.children;
|
|
161
|
+
return (React.createElement(MdmModuleProvider, { values: mdmValues },
|
|
162
|
+
React.createElement(CollaborationContext.Provider, { value: collaborationContextValue }, children)));
|
|
163
|
+
};
|
|
164
|
+
var user = userEvent.setup();
|
|
165
|
+
return __assign({ user: user }, render(React.createElement(Comment, __assign({}, props)), { wrapper: Providers }));
|
|
166
|
+
};
|
|
148
167
|
it('should render avatar correctly', function () {
|
|
149
|
-
|
|
150
|
-
expect(
|
|
151
|
-
expect(component.find(Avatar).prop('children')).toBe('vyacheslav.kovyazin');
|
|
168
|
+
setUp();
|
|
169
|
+
expect(screen.queryByText('VK')).toBeInTheDocument();
|
|
152
170
|
});
|
|
153
171
|
it('should render username correctly', function () {
|
|
154
|
-
|
|
155
|
-
expect(
|
|
156
|
-
expect(component.find('.username').at(0).text()).toBe('vyacheslav.kovyazin');
|
|
172
|
+
setUp();
|
|
173
|
+
expect(screen.queryByText('vyacheslav.kovyazin')).toBeInTheDocument();
|
|
157
174
|
});
|
|
158
175
|
it('should render time correctly', function () {
|
|
159
|
-
|
|
160
|
-
expect(
|
|
161
|
-
expect(component.find('.createdAt').at(0).text()).toBe(formatDate(TIME));
|
|
176
|
+
setUp();
|
|
177
|
+
expect(screen.queryByText(formatDate(TIME))).toBeInTheDocument();
|
|
162
178
|
});
|
|
163
179
|
it('should render CommentContent correctly', function () {
|
|
164
|
-
|
|
165
|
-
expect(
|
|
166
|
-
expect(component.find('.message').at(0).props()).toMatchObject({
|
|
167
|
-
comment: {
|
|
168
|
-
content: 'comment',
|
|
169
|
-
namedUsers: []
|
|
170
|
-
}
|
|
171
|
-
});
|
|
180
|
+
setUp();
|
|
181
|
+
expect(screen.queryByText('comment')).toBeInTheDocument();
|
|
172
182
|
});
|
|
173
183
|
it('should render buttons correctly if status is "open"', function () {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
expect(
|
|
177
|
-
expect(
|
|
178
|
-
expect(buttons.childAt(1).text()).toBe('Resolve');
|
|
184
|
+
setUp();
|
|
185
|
+
expect(screen.queryByText('Reply')).toBeInTheDocument();
|
|
186
|
+
expect(screen.queryByText('Resolve')).toBeInTheDocument();
|
|
187
|
+
expect(screen.queryByText('Re-open')).not.toBeInTheDocument();
|
|
179
188
|
});
|
|
180
189
|
it('should render buttons correctly if status is "resolved"', function () {
|
|
181
190
|
var props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
expect(
|
|
185
|
-
expect(
|
|
186
|
-
expect(buttons.childAt(1).text()).toBe('Re-open');
|
|
191
|
+
setUp({ props: props });
|
|
192
|
+
expect(screen.queryByText('Reply')).toBeInTheDocument();
|
|
193
|
+
expect(screen.queryByText('Re-open')).toBeInTheDocument();
|
|
194
|
+
expect(screen.queryByText('Resolve')).not.toBeInTheDocument();
|
|
187
195
|
});
|
|
188
|
-
it('onReply handler should work correctly', function () {
|
|
189
|
-
var onReply
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
it('onReply handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
var onReply, user;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
onReply = defaultProps.onReply;
|
|
202
|
+
user = setUp().user;
|
|
203
|
+
expect(onReply).toHaveBeenCalledTimes(0);
|
|
204
|
+
return [4 /*yield*/, user.click(screen.getByText('Reply'))];
|
|
205
|
+
case 1:
|
|
206
|
+
_a.sent();
|
|
207
|
+
expect(onReply).toHaveBeenCalledTimes(1);
|
|
208
|
+
return [2 /*return*/];
|
|
209
|
+
}
|
|
196
210
|
});
|
|
197
|
-
|
|
198
|
-
});
|
|
211
|
+
}); });
|
|
199
212
|
it('should disable "Resolve" button if sending is "true"', function () {
|
|
200
213
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { sending: true });
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
expect(resolveBtn.prop('disabled')).toBe(true);
|
|
214
|
+
setUp({ collaborationContextValue: collaborationContextValue });
|
|
215
|
+
expect(screen.getByText('Resolve')).toBeDisabled();
|
|
204
216
|
});
|
|
205
217
|
it('should disable "Re-Open" button if sending is "true"', function () {
|
|
206
218
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { sending: true });
|
|
207
219
|
var props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
expect(resolveBtn.prop('disabled')).toBe(true);
|
|
211
|
-
});
|
|
212
|
-
it('handleResolve handler should work correctly', function () {
|
|
213
|
-
var resolveThread = defaultCollaborationContextValue.resolveThread;
|
|
214
|
-
var component = setUp();
|
|
215
|
-
var resolvedBtn = component.find(Link).filterWhere(function (button) { return button.text() === 'Resolve'; });
|
|
216
|
-
resolvedBtn.find('button').simulate('click');
|
|
217
|
-
expect(resolveThread).toHaveBeenCalledWith({
|
|
218
|
-
commentId: 'commentId',
|
|
219
|
-
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5'
|
|
220
|
-
});
|
|
220
|
+
setUp({ props: props, collaborationContextValue: collaborationContextValue });
|
|
221
|
+
expect(screen.getByText('Re-open')).toBeDisabled();
|
|
221
222
|
});
|
|
222
|
-
it('
|
|
223
|
-
var
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
223
|
+
it('handleResolve handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
+
var resolveThread, user;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0:
|
|
228
|
+
resolveThread = defaultCollaborationContextValue.resolveThread;
|
|
229
|
+
user = setUp().user;
|
|
230
|
+
return [4 /*yield*/, user.click(screen.getByText('Resolve'))];
|
|
231
|
+
case 1:
|
|
232
|
+
_a.sent();
|
|
233
|
+
expect(resolveThread).toHaveBeenCalledWith({
|
|
234
|
+
commentId: 'commentId',
|
|
235
|
+
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5'
|
|
236
|
+
});
|
|
237
|
+
return [2 /*return*/];
|
|
238
|
+
}
|
|
231
239
|
});
|
|
232
|
-
});
|
|
233
|
-
it('should
|
|
234
|
-
var
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
240
|
+
}); });
|
|
241
|
+
it('handleReOpen handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
242
|
+
var reOpenThread, props, user;
|
|
243
|
+
return __generator(this, function (_a) {
|
|
244
|
+
switch (_a.label) {
|
|
245
|
+
case 0:
|
|
246
|
+
reOpenThread = defaultCollaborationContextValue.reOpenThread;
|
|
247
|
+
props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
248
|
+
user = setUp({ props: props }).user;
|
|
249
|
+
return [4 /*yield*/, user.click(screen.getByText('Re-open'))];
|
|
250
|
+
case 1:
|
|
251
|
+
_a.sent();
|
|
252
|
+
expect(reOpenThread).toHaveBeenCalledWith({
|
|
253
|
+
commentId: 'commentId',
|
|
254
|
+
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5'
|
|
255
|
+
});
|
|
256
|
+
return [2 /*return*/];
|
|
257
|
+
}
|
|
241
258
|
});
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
259
|
+
}); });
|
|
260
|
+
it('should call updateCommentState with right params when onCancel called', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
261
|
+
var updateCommentState, getCommentState, collaborationContextValue, user;
|
|
262
|
+
return __generator(this, function (_a) {
|
|
263
|
+
switch (_a.label) {
|
|
264
|
+
case 0:
|
|
265
|
+
updateCommentState = defaultCollaborationContextValue.updateCommentState;
|
|
266
|
+
getCommentState = function () { return ({ isEditing: true }); };
|
|
267
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { getCommentState: getCommentState });
|
|
268
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
269
|
+
return [4 /*yield*/, user.click(screen.getByText('Cancel'))];
|
|
270
|
+
case 1:
|
|
271
|
+
_a.sent();
|
|
272
|
+
expect(updateCommentState).toHaveBeenCalledWith(defaultProps.uri, 'comment/commentId', { isEditing: false });
|
|
273
|
+
return [2 /*return*/];
|
|
274
|
+
}
|
|
253
275
|
});
|
|
254
|
-
|
|
255
|
-
|
|
276
|
+
}); });
|
|
277
|
+
it('should call updateCommentState with right params when updateIsEditingComment called', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
278
|
+
var updateCommentState, getCommentState, collaborationContextValue, user;
|
|
279
|
+
return __generator(this, function (_a) {
|
|
280
|
+
switch (_a.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
updateCommentState = defaultCollaborationContextValue.updateCommentState;
|
|
283
|
+
getCommentState = function () { return ({ isEditing: false }); };
|
|
284
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { getCommentState: getCommentState });
|
|
285
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
286
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('Open menu'))];
|
|
287
|
+
case 1:
|
|
288
|
+
_a.sent();
|
|
289
|
+
return [4 /*yield*/, user.click(screen.getByText('Edit'))];
|
|
290
|
+
case 2:
|
|
291
|
+
_a.sent();
|
|
292
|
+
expect(updateCommentState).toHaveBeenCalledWith(defaultProps.uri, 'comment/commentId', { isEditing: true });
|
|
293
|
+
return [2 /*return*/];
|
|
294
|
+
}
|
|
256
295
|
});
|
|
257
|
-
|
|
258
|
-
});
|
|
296
|
+
}); });
|
|
259
297
|
it('should render sendMessageArea insead of comment if isEditing equals true', function () {
|
|
260
298
|
var getCommentState = function () { return ({ isEditing: true }); };
|
|
261
299
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { getCommentState: getCommentState });
|
|
262
|
-
|
|
263
|
-
expect(
|
|
264
|
-
var sendMessageArea = component.find(SendMessageArea);
|
|
265
|
-
expect(sendMessageArea).toHaveLength(1);
|
|
266
|
-
var inputRef = sendMessageArea.prop('inputRef');
|
|
267
|
-
expect(inputRef.current.value).toEqual('comment');
|
|
300
|
+
setUp({ collaborationContextValue: collaborationContextValue });
|
|
301
|
+
expect(screen.getByRole('textbox')).toHaveValue('comment');
|
|
268
302
|
});
|
|
269
303
|
it('should render DropDownMenuButton if comment created by current user', function () {
|
|
270
|
-
|
|
271
|
-
expect(
|
|
304
|
+
setUp();
|
|
305
|
+
expect(screen.queryByLabelText('Open menu')).toBeInTheDocument();
|
|
272
306
|
});
|
|
273
307
|
it('should not render DropDownMenuButton if comment created by another user', function () {
|
|
274
308
|
var props = __assign(__assign({}, defaultProps), { comment: createComment('open', 'alexey.smirnov') });
|
|
275
|
-
|
|
276
|
-
expect(
|
|
309
|
+
setUp({ props: props });
|
|
310
|
+
expect(screen.queryByLabelText('Open menu')).not.toBeInTheDocument();
|
|
277
311
|
});
|
|
278
312
|
it('should hide Edit button in DropDownMenuButton if comment is resolved', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
279
313
|
var props, user;
|
|
@@ -281,9 +315,7 @@ describe('Comment tests', function () {
|
|
|
281
315
|
switch (_a.label) {
|
|
282
316
|
case 0:
|
|
283
317
|
props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
284
|
-
user =
|
|
285
|
-
render(React.createElement(MdmModuleProvider, { values: defaultMdmValues },
|
|
286
|
-
React.createElement(Comment, __assign({}, props))));
|
|
318
|
+
user = setUp({ props: props }).user;
|
|
287
319
|
return [4 /*yield*/, user.click(screen.getByLabelText('Open menu'))];
|
|
288
320
|
case 1:
|
|
289
321
|
_a.sent();
|