@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
|
@@ -15,12 +15,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var react_1 = __importDefault(require("react"));
|
|
18
|
-
var enzyme_1 = require("enzyme");
|
|
19
18
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
20
|
-
var Comment_1 = require("./components/Comment");
|
|
21
|
-
var RepliedComment_1 = require("./components/RepliedComment");
|
|
22
|
-
var SendMessageArea_1 = require("./components/SendMessageArea");
|
|
23
19
|
var CollaborationItem_1 = __importDefault(require("./CollaborationItem"));
|
|
20
|
+
var react_2 = require("@testing-library/react");
|
|
21
|
+
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
24
22
|
var createComment = function (hasReplies) {
|
|
25
23
|
if (hasReplies === void 0) { hasReplies = false; }
|
|
26
24
|
var comment = {
|
|
@@ -44,12 +42,12 @@ var createComment = function (hasReplies) {
|
|
|
44
42
|
comment.replies.push({
|
|
45
43
|
selfLink: 'https://cservice-dev.reltio.com/tst-01/sokol/comments/00001lo/replies/000007s',
|
|
46
44
|
replyId: '000007s',
|
|
47
|
-
createdBy: '
|
|
45
|
+
createdBy: 'other.user',
|
|
48
46
|
createdTime: 1620280061505,
|
|
49
47
|
modifiedTime: 1620280061505,
|
|
50
48
|
deleted: false,
|
|
51
49
|
action: 'none',
|
|
52
|
-
content: '
|
|
50
|
+
content: 'other comment',
|
|
53
51
|
namedUsers: []
|
|
54
52
|
});
|
|
55
53
|
}
|
|
@@ -63,37 +61,76 @@ var createProps = function (comment) {
|
|
|
63
61
|
objectType: mdm_sdk_1.CollaborationObjectTypes.ENTITY_ATTRIBUTE
|
|
64
62
|
};
|
|
65
63
|
};
|
|
66
|
-
var setUp = function (props) { return (0, enzyme_1.shallow)(react_1.default.createElement(CollaborationItem_1.default, __assign({}, props))); };
|
|
67
64
|
describe('CollaborationItem tests', function () {
|
|
65
|
+
var entity = {
|
|
66
|
+
type: 'configuration/entityTypes/HCP',
|
|
67
|
+
uri: 'entities/02ZRRE9',
|
|
68
|
+
attributes: {
|
|
69
|
+
FirstName: [
|
|
70
|
+
{
|
|
71
|
+
type: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
72
|
+
ov: true,
|
|
73
|
+
value: 'nameValue',
|
|
74
|
+
uri: 'entities/02ZRRE9/attributes/FirstName/15p60Tel'
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var metadata = {
|
|
80
|
+
entityTypes: [
|
|
81
|
+
{
|
|
82
|
+
uri: 'configuration/entityTypes/HCP',
|
|
83
|
+
attributes: [
|
|
84
|
+
{
|
|
85
|
+
uri: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
86
|
+
type: 'String',
|
|
87
|
+
name: 'FirstName',
|
|
88
|
+
label: 'First Name',
|
|
89
|
+
access: ['READ', 'CREATE', 'UPDATE', 'INITIATE_CHANGE_REQUEST']
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
};
|
|
95
|
+
var actions = {
|
|
96
|
+
removeAttribute: function () { }
|
|
97
|
+
};
|
|
98
|
+
var mdmDefaultValues = {
|
|
99
|
+
user: {
|
|
100
|
+
username: 'test.testmail'
|
|
101
|
+
},
|
|
102
|
+
entity: entity,
|
|
103
|
+
metadata: metadata,
|
|
104
|
+
modifiedEntities: { 'entities/02ZRRE9': entity },
|
|
105
|
+
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
|
|
106
|
+
};
|
|
107
|
+
var setUp = function (props) {
|
|
108
|
+
var Providers = function (_a) {
|
|
109
|
+
var children = _a.children;
|
|
110
|
+
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmDefaultValues, actions: actions }, children));
|
|
111
|
+
};
|
|
112
|
+
return (0, react_2.render)(react_1.default.createElement(CollaborationItem_1.default, __assign({}, props)), { wrapper: Providers });
|
|
113
|
+
};
|
|
68
114
|
it('should render Comment correctly if comment exist', function () {
|
|
69
|
-
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
115
|
+
setUp(createProps(createComment()));
|
|
116
|
+
expect(react_2.screen.queryByText('VK')).toBeInTheDocument();
|
|
117
|
+
expect(react_2.screen.queryByText('vyacheslav.kovyazin')).toBeInTheDocument();
|
|
118
|
+
expect(react_2.screen.queryByText('comment')).toBeInTheDocument();
|
|
72
119
|
});
|
|
73
120
|
it('should not render Comment and RepliedComment if comment do not exist', function () {
|
|
74
|
-
var
|
|
75
|
-
expect(
|
|
76
|
-
expect(
|
|
121
|
+
var container = setUp(createProps()).container;
|
|
122
|
+
expect(container.querySelector('.comment')).not.toBeInTheDocument();
|
|
123
|
+
expect(container.querySelector('.replies')).not.toBeInTheDocument();
|
|
77
124
|
});
|
|
78
125
|
it('should render SendMessageArea correctly', function () {
|
|
79
|
-
var
|
|
80
|
-
expect(
|
|
81
|
-
expect(
|
|
82
|
-
expect(component.find(SendMessageArea_1.SendMessageArea).prop('relatedObjectUris')).toEqual(['entities/13JKIKAz']);
|
|
83
|
-
});
|
|
84
|
-
it('should not render replied comments correctly if they do not exist', function () {
|
|
85
|
-
var component = setUp(createProps(createComment(false)));
|
|
86
|
-
expect(component.find(RepliedComment_1.RepliedComment)).toHaveLength(0);
|
|
126
|
+
var container = setUp(createProps(createComment())).container;
|
|
127
|
+
expect(react_2.screen.queryByText('TT')).toBeInTheDocument();
|
|
128
|
+
expect(container.querySelector('.sendMessageArea')).toBeInTheDocument();
|
|
87
129
|
});
|
|
88
130
|
it('should render replied comments correctly if they do exist', function () {
|
|
89
|
-
|
|
90
|
-
expect(
|
|
91
|
-
expect(
|
|
92
|
-
|
|
93
|
-
content: 'abc',
|
|
94
|
-
createdBy: 'vyacheslav.kovyazin',
|
|
95
|
-
action: 'none',
|
|
96
|
-
namedUsers: []
|
|
97
|
-
});
|
|
131
|
+
setUp(createProps(createComment(true)));
|
|
132
|
+
expect(react_2.screen.queryByText('OU')).toBeInTheDocument();
|
|
133
|
+
expect(react_2.screen.queryByText('other.user')).toBeInTheDocument();
|
|
134
|
+
expect(react_2.screen.queryByText('other comment')).toBeInTheDocument();
|
|
98
135
|
});
|
|
99
136
|
});
|
|
@@ -51,234 +51,268 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
var react_1 = __importDefault(require("react"));
|
|
54
|
-
var enzyme_1 = require("enzyme");
|
|
55
54
|
var react_2 = require("@testing-library/react");
|
|
56
55
|
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
57
|
-
var test_utils_1 = require("react-dom/test-utils");
|
|
58
56
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
59
|
-
var Link_1 = __importDefault(require("@mui/material/Link"));
|
|
60
|
-
var DropDownMenuButton_1 = require("../../../DropDownMenuButton");
|
|
61
57
|
var CollaborationContext_1 = require("../../../contexts/CollaborationContext");
|
|
62
58
|
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
63
59
|
var helpers_1 = require("../../helpers");
|
|
64
|
-
var Avatar_1 = require("../Avatar");
|
|
65
|
-
var SendMessageArea_1 = require("../SendMessageArea");
|
|
66
|
-
var CommentContent_1 = require("../CommentContent");
|
|
67
60
|
var Comment_1 = require("./Comment");
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
permanentLink: ''
|
|
61
|
+
describe('Comment tests', function () {
|
|
62
|
+
var TIME = 1620280049022;
|
|
63
|
+
var createComment = function (status, createdBy) {
|
|
64
|
+
if (status === void 0) { status = 'open'; }
|
|
65
|
+
if (createdBy === void 0) { createdBy = 'vyacheslav.kovyazin'; }
|
|
66
|
+
return {
|
|
67
|
+
createdBy: createdBy,
|
|
68
|
+
createdTime: TIME,
|
|
69
|
+
status: status,
|
|
70
|
+
objectId: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5',
|
|
71
|
+
objectType: mdm_sdk_1.CollaborationObjectTypes.ENTITY_ATTRIBUTE,
|
|
72
|
+
content: 'comment',
|
|
73
|
+
relatedObjectUris: ['entities/13JKIKAz'],
|
|
74
|
+
commentId: 'commentId',
|
|
75
|
+
namedUsers: [],
|
|
76
|
+
replies: [],
|
|
77
|
+
modifiedTime: 0,
|
|
78
|
+
deleted: false,
|
|
79
|
+
visibility: '',
|
|
80
|
+
selfLink: '',
|
|
81
|
+
permanentLink: ''
|
|
82
|
+
};
|
|
91
83
|
};
|
|
92
|
-
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
84
|
+
var defaultCurrentComment = createComment();
|
|
85
|
+
var defaultCommentsMap = {
|
|
86
|
+
uri1: [
|
|
87
|
+
{
|
|
88
|
+
commentId: defaultCurrentComment.commentId,
|
|
89
|
+
status: 'open',
|
|
90
|
+
replies: 0
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
var defaultUsername = 'vyacheslav.kovyazin';
|
|
95
|
+
var entity = {
|
|
96
|
+
type: 'configuration/entityTypes/HCP',
|
|
97
|
+
uri: 'entities/02ZRRE9',
|
|
98
|
+
attributes: {
|
|
99
|
+
FirstName: [
|
|
100
|
+
{
|
|
101
|
+
type: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
102
|
+
ov: true,
|
|
103
|
+
value: 'nameValue',
|
|
104
|
+
uri: 'entities/02ZRRE9/attributes/FirstName/15p60Tel'
|
|
105
|
+
}
|
|
106
|
+
]
|
|
100
107
|
}
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
108
|
+
};
|
|
109
|
+
var metadata = {
|
|
110
|
+
entityTypes: [
|
|
111
|
+
{
|
|
112
|
+
uri: 'configuration/entityTypes/HCP',
|
|
113
|
+
attributes: [
|
|
114
|
+
{
|
|
115
|
+
uri: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
116
|
+
type: 'String',
|
|
117
|
+
name: 'FirstName',
|
|
118
|
+
label: 'First Name',
|
|
119
|
+
access: ['READ', 'CREATE', 'UPDATE', 'INITIATE_CHANGE_REQUEST']
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
};
|
|
125
|
+
var defaultMdmValues = {
|
|
126
|
+
user: {
|
|
127
|
+
username: defaultUsername
|
|
128
|
+
},
|
|
129
|
+
entity: entity,
|
|
130
|
+
metadata: metadata
|
|
131
|
+
};
|
|
132
|
+
var defaultCollaborationContextValue = {
|
|
133
|
+
commentsMap: defaultCommentsMap,
|
|
134
|
+
currentComment: defaultCurrentComment,
|
|
135
|
+
createComment: function () { return Promise.resolve(); },
|
|
136
|
+
editComment: function () { return Promise.resolve(); },
|
|
137
|
+
editReply: function () { return Promise.resolve(); },
|
|
138
|
+
deleteComment: jest.fn(),
|
|
139
|
+
deleteReply: function () { },
|
|
140
|
+
createReply: function () { return Promise.resolve(); },
|
|
141
|
+
reOpenThread: jest.fn(),
|
|
142
|
+
resolveThread: jest.fn(),
|
|
143
|
+
getComment: jest.fn(),
|
|
144
|
+
clearCurrentComment: jest.fn(),
|
|
145
|
+
sending: false,
|
|
146
|
+
loading: false,
|
|
147
|
+
pageToken: '',
|
|
148
|
+
getComments: function () { return Promise.resolve(); },
|
|
149
|
+
comments: [],
|
|
150
|
+
getCommentsCount: function () { return Promise.resolve(); },
|
|
151
|
+
getCommentState: function () { return ({}); },
|
|
152
|
+
updateCommentState: jest.fn(),
|
|
153
|
+
clearCommentState: function () { }
|
|
154
|
+
};
|
|
155
|
+
var defaultProps = {
|
|
156
|
+
comment: defaultCurrentComment,
|
|
157
|
+
onReply: jest.fn(),
|
|
158
|
+
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5',
|
|
159
|
+
relatedObjectUris: ['entities/13JKIKAz'],
|
|
160
|
+
objectType: mdm_sdk_1.CollaborationObjectTypes.ENTITY_ATTRIBUTE
|
|
161
|
+
};
|
|
162
|
+
var setUp = function (_a) {
|
|
163
|
+
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;
|
|
164
|
+
var Providers = function (_a) {
|
|
165
|
+
var children = _a.children;
|
|
166
|
+
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues },
|
|
167
|
+
react_1.default.createElement(CollaborationContext_1.CollaborationContext.Provider, { value: collaborationContextValue }, children)));
|
|
168
|
+
};
|
|
169
|
+
var user = user_event_1.default.setup();
|
|
170
|
+
return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(Comment_1.Comment, __assign({}, props)), { wrapper: Providers }));
|
|
171
|
+
};
|
|
153
172
|
it('should render avatar correctly', function () {
|
|
154
|
-
|
|
155
|
-
expect(
|
|
156
|
-
expect(component.find(Avatar_1.Avatar).prop('children')).toBe('vyacheslav.kovyazin');
|
|
173
|
+
setUp();
|
|
174
|
+
expect(react_2.screen.queryByText('VK')).toBeInTheDocument();
|
|
157
175
|
});
|
|
158
176
|
it('should render username correctly', function () {
|
|
159
|
-
|
|
160
|
-
expect(
|
|
161
|
-
expect(component.find('.username').at(0).text()).toBe('vyacheslav.kovyazin');
|
|
177
|
+
setUp();
|
|
178
|
+
expect(react_2.screen.queryByText('vyacheslav.kovyazin')).toBeInTheDocument();
|
|
162
179
|
});
|
|
163
180
|
it('should render time correctly', function () {
|
|
164
|
-
|
|
165
|
-
expect(
|
|
166
|
-
expect(component.find('.createdAt').at(0).text()).toBe((0, helpers_1.formatDate)(TIME));
|
|
181
|
+
setUp();
|
|
182
|
+
expect(react_2.screen.queryByText((0, helpers_1.formatDate)(TIME))).toBeInTheDocument();
|
|
167
183
|
});
|
|
168
184
|
it('should render CommentContent correctly', function () {
|
|
169
|
-
|
|
170
|
-
expect(
|
|
171
|
-
expect(component.find('.message').at(0).props()).toMatchObject({
|
|
172
|
-
comment: {
|
|
173
|
-
content: 'comment',
|
|
174
|
-
namedUsers: []
|
|
175
|
-
}
|
|
176
|
-
});
|
|
185
|
+
setUp();
|
|
186
|
+
expect(react_2.screen.queryByText('comment')).toBeInTheDocument();
|
|
177
187
|
});
|
|
178
188
|
it('should render buttons correctly if status is "open"', function () {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
expect(
|
|
182
|
-
expect(
|
|
183
|
-
expect(buttons.childAt(1).text()).toBe('Resolve');
|
|
189
|
+
setUp();
|
|
190
|
+
expect(react_2.screen.queryByText('Reply')).toBeInTheDocument();
|
|
191
|
+
expect(react_2.screen.queryByText('Resolve')).toBeInTheDocument();
|
|
192
|
+
expect(react_2.screen.queryByText('Re-open')).not.toBeInTheDocument();
|
|
184
193
|
});
|
|
185
194
|
it('should render buttons correctly if status is "resolved"', function () {
|
|
186
195
|
var props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
expect(
|
|
190
|
-
expect(
|
|
191
|
-
expect(buttons.childAt(1).text()).toBe('Re-open');
|
|
196
|
+
setUp({ props: props });
|
|
197
|
+
expect(react_2.screen.queryByText('Reply')).toBeInTheDocument();
|
|
198
|
+
expect(react_2.screen.queryByText('Re-open')).toBeInTheDocument();
|
|
199
|
+
expect(react_2.screen.queryByText('Resolve')).not.toBeInTheDocument();
|
|
192
200
|
});
|
|
193
|
-
it('onReply handler should work correctly', function () {
|
|
194
|
-
var onReply
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
+
it('onReply handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
202
|
+
var onReply, user;
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0:
|
|
206
|
+
onReply = defaultProps.onReply;
|
|
207
|
+
user = setUp().user;
|
|
208
|
+
expect(onReply).toHaveBeenCalledTimes(0);
|
|
209
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Reply'))];
|
|
210
|
+
case 1:
|
|
211
|
+
_a.sent();
|
|
212
|
+
expect(onReply).toHaveBeenCalledTimes(1);
|
|
213
|
+
return [2 /*return*/];
|
|
214
|
+
}
|
|
201
215
|
});
|
|
202
|
-
|
|
203
|
-
});
|
|
216
|
+
}); });
|
|
204
217
|
it('should disable "Resolve" button if sending is "true"', function () {
|
|
205
218
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { sending: true });
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
expect(resolveBtn.prop('disabled')).toBe(true);
|
|
219
|
+
setUp({ collaborationContextValue: collaborationContextValue });
|
|
220
|
+
expect(react_2.screen.getByText('Resolve')).toBeDisabled();
|
|
209
221
|
});
|
|
210
222
|
it('should disable "Re-Open" button if sending is "true"', function () {
|
|
211
223
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { sending: true });
|
|
212
224
|
var props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
expect(resolveBtn.prop('disabled')).toBe(true);
|
|
216
|
-
});
|
|
217
|
-
it('handleResolve handler should work correctly', function () {
|
|
218
|
-
var resolveThread = defaultCollaborationContextValue.resolveThread;
|
|
219
|
-
var component = setUp();
|
|
220
|
-
var resolvedBtn = component.find(Link_1.default).filterWhere(function (button) { return button.text() === 'Resolve'; });
|
|
221
|
-
resolvedBtn.find('button').simulate('click');
|
|
222
|
-
expect(resolveThread).toHaveBeenCalledWith({
|
|
223
|
-
commentId: 'commentId',
|
|
224
|
-
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5'
|
|
225
|
-
});
|
|
225
|
+
setUp({ props: props, collaborationContextValue: collaborationContextValue });
|
|
226
|
+
expect(react_2.screen.getByText('Re-open')).toBeDisabled();
|
|
226
227
|
});
|
|
227
|
-
it('
|
|
228
|
-
var
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
228
|
+
it('handleResolve handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
229
|
+
var resolveThread, user;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
resolveThread = defaultCollaborationContextValue.resolveThread;
|
|
234
|
+
user = setUp().user;
|
|
235
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Resolve'))];
|
|
236
|
+
case 1:
|
|
237
|
+
_a.sent();
|
|
238
|
+
expect(resolveThread).toHaveBeenCalledWith({
|
|
239
|
+
commentId: 'commentId',
|
|
240
|
+
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5'
|
|
241
|
+
});
|
|
242
|
+
return [2 /*return*/];
|
|
243
|
+
}
|
|
236
244
|
});
|
|
237
|
-
});
|
|
238
|
-
it('should
|
|
239
|
-
var
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
}); });
|
|
246
|
+
it('handleReOpen handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
247
|
+
var reOpenThread, props, user;
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
reOpenThread = defaultCollaborationContextValue.reOpenThread;
|
|
252
|
+
props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
253
|
+
user = setUp({ props: props }).user;
|
|
254
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Re-open'))];
|
|
255
|
+
case 1:
|
|
256
|
+
_a.sent();
|
|
257
|
+
expect(reOpenThread).toHaveBeenCalledWith({
|
|
258
|
+
commentId: 'commentId',
|
|
259
|
+
uri: 'entities/13JKIKAz/attributes/Name/2mlWuqDq5'
|
|
260
|
+
});
|
|
261
|
+
return [2 /*return*/];
|
|
262
|
+
}
|
|
246
263
|
});
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
264
|
+
}); });
|
|
265
|
+
it('should call updateCommentState with right params when onCancel called', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
266
|
+
var updateCommentState, getCommentState, collaborationContextValue, user;
|
|
267
|
+
return __generator(this, function (_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0:
|
|
270
|
+
updateCommentState = defaultCollaborationContextValue.updateCommentState;
|
|
271
|
+
getCommentState = function () { return ({ isEditing: true }); };
|
|
272
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { getCommentState: getCommentState });
|
|
273
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
274
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
|
|
275
|
+
case 1:
|
|
276
|
+
_a.sent();
|
|
277
|
+
expect(updateCommentState).toHaveBeenCalledWith(defaultProps.uri, 'comment/commentId', { isEditing: false });
|
|
278
|
+
return [2 /*return*/];
|
|
279
|
+
}
|
|
258
280
|
});
|
|
259
|
-
|
|
260
|
-
|
|
281
|
+
}); });
|
|
282
|
+
it('should call updateCommentState with right params when updateIsEditingComment called', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
283
|
+
var updateCommentState, getCommentState, collaborationContextValue, user;
|
|
284
|
+
return __generator(this, function (_a) {
|
|
285
|
+
switch (_a.label) {
|
|
286
|
+
case 0:
|
|
287
|
+
updateCommentState = defaultCollaborationContextValue.updateCommentState;
|
|
288
|
+
getCommentState = function () { return ({ isEditing: false }); };
|
|
289
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { getCommentState: getCommentState });
|
|
290
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
291
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Open menu'))];
|
|
292
|
+
case 1:
|
|
293
|
+
_a.sent();
|
|
294
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Edit'))];
|
|
295
|
+
case 2:
|
|
296
|
+
_a.sent();
|
|
297
|
+
expect(updateCommentState).toHaveBeenCalledWith(defaultProps.uri, 'comment/commentId', { isEditing: true });
|
|
298
|
+
return [2 /*return*/];
|
|
299
|
+
}
|
|
261
300
|
});
|
|
262
|
-
|
|
263
|
-
});
|
|
301
|
+
}); });
|
|
264
302
|
it('should render sendMessageArea insead of comment if isEditing equals true', function () {
|
|
265
303
|
var getCommentState = function () { return ({ isEditing: true }); };
|
|
266
304
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { getCommentState: getCommentState });
|
|
267
|
-
|
|
268
|
-
expect(
|
|
269
|
-
var sendMessageArea = component.find(SendMessageArea_1.SendMessageArea);
|
|
270
|
-
expect(sendMessageArea).toHaveLength(1);
|
|
271
|
-
var inputRef = sendMessageArea.prop('inputRef');
|
|
272
|
-
expect(inputRef.current.value).toEqual('comment');
|
|
305
|
+
setUp({ collaborationContextValue: collaborationContextValue });
|
|
306
|
+
expect(react_2.screen.getByRole('textbox')).toHaveValue('comment');
|
|
273
307
|
});
|
|
274
308
|
it('should render DropDownMenuButton if comment created by current user', function () {
|
|
275
|
-
|
|
276
|
-
expect(
|
|
309
|
+
setUp();
|
|
310
|
+
expect(react_2.screen.queryByLabelText('Open menu')).toBeInTheDocument();
|
|
277
311
|
});
|
|
278
312
|
it('should not render DropDownMenuButton if comment created by another user', function () {
|
|
279
313
|
var props = __assign(__assign({}, defaultProps), { comment: createComment('open', 'alexey.smirnov') });
|
|
280
|
-
|
|
281
|
-
expect(
|
|
314
|
+
setUp({ props: props });
|
|
315
|
+
expect(react_2.screen.queryByLabelText('Open menu')).not.toBeInTheDocument();
|
|
282
316
|
});
|
|
283
317
|
it('should hide Edit button in DropDownMenuButton if comment is resolved', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
284
318
|
var props, user;
|
|
@@ -286,9 +320,7 @@ describe('Comment tests', function () {
|
|
|
286
320
|
switch (_a.label) {
|
|
287
321
|
case 0:
|
|
288
322
|
props = __assign(__assign({}, defaultProps), { comment: createComment('resolved') });
|
|
289
|
-
user =
|
|
290
|
-
(0, react_2.render)(react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: defaultMdmValues },
|
|
291
|
-
react_1.default.createElement(Comment_1.Comment, __assign({}, props))));
|
|
323
|
+
user = setUp({ props: props }).user;
|
|
292
324
|
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Open menu'))];
|
|
293
325
|
case 1:
|
|
294
326
|
_a.sent();
|