@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,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
50
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
51
|
if (ar || !(i in from)) {
|
|
@@ -24,104 +60,106 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
60
|
};
|
|
25
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
62
|
var react_1 = __importDefault(require("react"));
|
|
27
|
-
var test_utils_1 = require("react-dom/test-utils");
|
|
28
|
-
var enzyme_1 = require("enzyme");
|
|
29
63
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
30
64
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
31
65
|
var CollaborationContext_1 = require("../contexts/CollaborationContext");
|
|
32
66
|
var RelatedObjectUrisContext_1 = require("../contexts/RelatedObjectUrisContext");
|
|
33
|
-
var DropDownMenuButton_1 = require("../DropDownMenuButton");
|
|
34
|
-
var DefaultMenuItemRenderer_1 = require("../DropDownMenuButton/components/DefaultMenuItemRenderer");
|
|
35
|
-
var CollaborationPopup_1 = require("./components/CollaborationPopup");
|
|
36
|
-
var AddCommentButton_1 = require("./components/AddCommentButton");
|
|
37
|
-
var CommentButton_1 = require("./components/CommentButton");
|
|
38
67
|
var CommentsContainer_test_data_1 = require("./CommentsContainer.test-data");
|
|
39
68
|
var CommentsContainer_1 = require("./CommentsContainer");
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
editComment: jest.fn().mockResolvedValue(undefined),
|
|
43
|
-
createReply: jest.fn().mockResolvedValue(undefined),
|
|
44
|
-
editReply: jest.fn().mockResolvedValue(undefined),
|
|
45
|
-
getCommentsCount: jest.fn().mockResolvedValue(undefined),
|
|
46
|
-
getCommentState: jest.fn().mockReturnValue({}),
|
|
47
|
-
deleteComment: jest.fn(),
|
|
48
|
-
deleteReply: jest.fn(),
|
|
49
|
-
reOpenThread: jest.fn(),
|
|
50
|
-
resolveThread: jest.fn(),
|
|
51
|
-
updateCommentState: jest.fn(),
|
|
52
|
-
clearCommentState: jest.fn(),
|
|
53
|
-
getComment: jest.fn(),
|
|
54
|
-
clearCurrentComment: jest.fn(),
|
|
55
|
-
getComments: jest.fn(),
|
|
56
|
-
sending: false,
|
|
57
|
-
loading: false,
|
|
58
|
-
commentsMap: {},
|
|
59
|
-
currentComment: null,
|
|
60
|
-
comments: [],
|
|
61
|
-
pageToken: null
|
|
62
|
-
};
|
|
63
|
-
var defaultMdmValues = {
|
|
64
|
-
metadata: (0, CommentsContainer_test_data_1.createDefaultMetadata)(),
|
|
65
|
-
entity: (0, CommentsContainer_test_data_1.createDefaultEntity)(),
|
|
66
|
-
tenant: { id: 'alenat', name: 'alenat' },
|
|
67
|
-
user: { username: 'vyacheslav.kovyazin' },
|
|
68
|
-
collaborationPath: 'https://cservice-dev.reltio.com/reltio-collaboration/tst-01',
|
|
69
|
-
uiPath: 'http://localhost:3000/ui/alenat/'
|
|
70
|
-
};
|
|
71
|
-
var defaultProps = {
|
|
72
|
-
relatedObjectUris: ['relatedEntityUri'],
|
|
73
|
-
uri: 'uri1',
|
|
74
|
-
objectType: mdm_sdk_1.CollaborationObjectTypes.ENTITY,
|
|
75
|
-
showAlways: false,
|
|
76
|
-
allowOnlyOneComment: false,
|
|
77
|
-
onChangePopupVisibility: jest.fn()
|
|
78
|
-
};
|
|
79
|
-
var setUpWithoutContext = function (_a) {
|
|
80
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.providers, CustomProviders = _d === void 0 ? react_1.default.Fragment : _d;
|
|
81
|
-
return (0, enzyme_1.mount)(react_1.default.createElement(CustomProviders, null,
|
|
82
|
-
react_1.default.createElement(CommentsContainer_1.CommentsContainer, __assign({}, props))));
|
|
83
|
-
};
|
|
84
|
-
var setUp = function (_a) {
|
|
85
|
-
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, _f = _b.providers, CustomProviders = _f === void 0 ? react_1.default.Fragment : _f;
|
|
86
|
-
var Providers = function (_a) {
|
|
87
|
-
var children = _a.children;
|
|
88
|
-
return (react_1.default.createElement(CustomProviders, null,
|
|
89
|
-
react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues },
|
|
90
|
-
react_1.default.createElement(CollaborationContext_1.CollaborationContext.Provider, { value: collaborationContextValue }, children))));
|
|
91
|
-
};
|
|
92
|
-
return setUpWithoutContext({ props: props, providers: Providers });
|
|
93
|
-
};
|
|
69
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
70
|
+
var react_2 = require("@testing-library/react");
|
|
94
71
|
describe('CommentsContainer tests', function () {
|
|
72
|
+
var defaultCollaborationContextValue = {
|
|
73
|
+
createComment: jest.fn().mockResolvedValue(undefined),
|
|
74
|
+
editComment: jest.fn().mockResolvedValue(undefined),
|
|
75
|
+
createReply: jest.fn().mockResolvedValue(undefined),
|
|
76
|
+
editReply: jest.fn().mockResolvedValue(undefined),
|
|
77
|
+
getCommentsCount: jest.fn().mockResolvedValue(undefined),
|
|
78
|
+
getCommentState: jest.fn().mockReturnValue({}),
|
|
79
|
+
deleteComment: jest.fn(),
|
|
80
|
+
deleteReply: jest.fn(),
|
|
81
|
+
reOpenThread: jest.fn(),
|
|
82
|
+
resolveThread: jest.fn(),
|
|
83
|
+
updateCommentState: jest.fn(),
|
|
84
|
+
clearCommentState: jest.fn(),
|
|
85
|
+
getComment: jest.fn(),
|
|
86
|
+
clearCurrentComment: jest.fn(),
|
|
87
|
+
getComments: jest.fn(),
|
|
88
|
+
sending: false,
|
|
89
|
+
loading: false,
|
|
90
|
+
commentsMap: {},
|
|
91
|
+
currentComment: null,
|
|
92
|
+
comments: [],
|
|
93
|
+
pageToken: null
|
|
94
|
+
};
|
|
95
|
+
var defaultMdmValues = {
|
|
96
|
+
metadata: (0, CommentsContainer_test_data_1.createDefaultMetadata)(),
|
|
97
|
+
entity: (0, CommentsContainer_test_data_1.createDefaultEntity)(),
|
|
98
|
+
tenant: { id: 'alenat', name: 'alenat' },
|
|
99
|
+
user: { username: 'vyacheslav.kovyazin' },
|
|
100
|
+
collaborationPath: 'https://cservice-dev.reltio.com/reltio-collaboration/tst-01',
|
|
101
|
+
uiPath: 'http://localhost:3000/ui/alenat/'
|
|
102
|
+
};
|
|
103
|
+
var defaultProps = {
|
|
104
|
+
relatedObjectUris: ['relatedEntityUri'],
|
|
105
|
+
uri: 'uri1',
|
|
106
|
+
objectType: mdm_sdk_1.CollaborationObjectTypes.ENTITY,
|
|
107
|
+
showAlways: false,
|
|
108
|
+
allowOnlyOneComment: false,
|
|
109
|
+
onChangePopupVisibility: jest.fn()
|
|
110
|
+
};
|
|
111
|
+
var setUp = function (_a) {
|
|
112
|
+
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, _f = _b.providers, CustomProviders = _f === void 0 ? react_1.default.Fragment : _f, _g = _b.withoutProviders, withoutProviders = _g === void 0 ? false : _g;
|
|
113
|
+
var Providers = function (_a) {
|
|
114
|
+
var children = _a.children;
|
|
115
|
+
return (react_1.default.createElement(CustomProviders, null,
|
|
116
|
+
react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues },
|
|
117
|
+
react_1.default.createElement(CollaborationContext_1.CollaborationContext.Provider, { value: collaborationContextValue }, children))));
|
|
118
|
+
};
|
|
119
|
+
var user = user_event_1.default.setup();
|
|
120
|
+
return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(CommentsContainer_1.CommentsContainer, __assign({}, props)), { wrapper: withoutProviders ? undefined : Providers }));
|
|
121
|
+
};
|
|
95
122
|
it('should render nothing if CollaborationContext is not set', function () {
|
|
96
|
-
var
|
|
97
|
-
expect(
|
|
123
|
+
var container = setUp({ withoutProviders: true }).container;
|
|
124
|
+
expect(container).toBeEmptyDOMElement();
|
|
98
125
|
});
|
|
99
126
|
it('should render nothing if objectType is not specified in CollaborationContext', function () {
|
|
100
127
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { objectTypes: [mdm_sdk_1.CollaborationObjectTypes.RELATION] });
|
|
101
|
-
var
|
|
102
|
-
expect(
|
|
128
|
+
var container = setUp({ collaborationContextValue: collaborationContextValue }).container;
|
|
129
|
+
expect(container).toBeEmptyDOMElement();
|
|
103
130
|
});
|
|
104
131
|
it('should render AddCommentButton if CollaborationContext is defined', function () {
|
|
105
|
-
|
|
106
|
-
expect(
|
|
107
|
-
expect(
|
|
108
|
-
expect(component.find(CommentButton_1.CommentButton)).toHaveLength(0);
|
|
132
|
+
setUp();
|
|
133
|
+
expect(react_2.screen.queryByLabelText('Add comment')).toBeInTheDocument();
|
|
134
|
+
expect(react_2.screen.queryByLabelText('Show comment')).not.toBeInTheDocument();
|
|
109
135
|
});
|
|
110
136
|
it('should render AddCommentButton with correctly className if showAlways prop is "true"', function () {
|
|
111
137
|
var props = __assign(__assign({}, defaultProps), { showAlways: true });
|
|
112
|
-
|
|
113
|
-
expect(
|
|
138
|
+
setUp({ props: props });
|
|
139
|
+
expect(react_2.screen.getByLabelText('Add comment')).toHaveClass('addButton', 'showAlways');
|
|
114
140
|
});
|
|
115
141
|
it('should render AddCommentButton with correctly className if showAlways prop is "false"', function () {
|
|
116
142
|
var props = __assign(__assign({}, defaultProps), { showAlways: false });
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var component = setUp();
|
|
122
|
-
component.find(AddCommentButton_1.AddCommentButton).simulate('click', { currentTarget: 'Element' });
|
|
123
|
-
expect(component.find(AddCommentButton_1.AddCommentButton).prop('className')).toBe('addButton showAlways');
|
|
143
|
+
setUp({ props: props });
|
|
144
|
+
var addCommentButton = react_2.screen.getByLabelText('Add comment');
|
|
145
|
+
expect(addCommentButton).toHaveClass('addButton');
|
|
146
|
+
expect(addCommentButton).not.toHaveClass('showAlways');
|
|
124
147
|
});
|
|
148
|
+
it('should render AddCommentButton with correctly className if open popup with new comment', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
+
var user, addCommentButton;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
switch (_a.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
user = setUp().user;
|
|
154
|
+
addCommentButton = react_2.screen.getByLabelText('Add comment');
|
|
155
|
+
return [4 /*yield*/, user.click(addCommentButton)];
|
|
156
|
+
case 1:
|
|
157
|
+
_a.sent();
|
|
158
|
+
expect(react_2.screen.getByLabelText('Add comment')).toHaveClass('addButton', 'showAlways');
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}); });
|
|
125
163
|
it('should not render AddCommentButton if allowOnlyOneComment prop is "true" and commentsMap has open comments', function () {
|
|
126
164
|
var _a;
|
|
127
165
|
var commentsMap = (_a = {},
|
|
@@ -129,8 +167,8 @@ describe('CommentsContainer tests', function () {
|
|
|
129
167
|
_a);
|
|
130
168
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap });
|
|
131
169
|
var props = __assign(__assign({}, defaultProps), { allowOnlyOneComment: true });
|
|
132
|
-
|
|
133
|
-
expect(
|
|
170
|
+
setUp({ props: props, collaborationContextValue: collaborationContextValue });
|
|
171
|
+
expect(react_2.screen.queryByLabelText('Add comment')).not.toBeInTheDocument();
|
|
134
172
|
});
|
|
135
173
|
it('should render CommentButton for correct uri in commentsMap', function () {
|
|
136
174
|
var _a;
|
|
@@ -143,12 +181,12 @@ describe('CommentsContainer tests', function () {
|
|
|
143
181
|
_a.uri2 = [{ commentId: 'id4', status: 'open', replies: 1 }],
|
|
144
182
|
_a);
|
|
145
183
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap });
|
|
146
|
-
|
|
147
|
-
expect(
|
|
148
|
-
|
|
149
|
-
expect(
|
|
150
|
-
expect(
|
|
151
|
-
expect(
|
|
184
|
+
setUp({ collaborationContextValue: collaborationContextValue });
|
|
185
|
+
expect(react_2.screen.queryByLabelText('Add comment')).toBeInTheDocument();
|
|
186
|
+
var showCommentButtons = react_2.screen.getAllByLabelText('Show comment');
|
|
187
|
+
expect(showCommentButtons).toHaveLength(2);
|
|
188
|
+
expect(showCommentButtons[0]).toHaveTextContent('3');
|
|
189
|
+
expect(showCommentButtons[1]).toHaveTextContent('2');
|
|
152
190
|
});
|
|
153
191
|
it('should not render CommentButtons if there is no needed uri in commentsMap', function () {
|
|
154
192
|
var commentsMap = {
|
|
@@ -158,140 +196,173 @@ describe('CommentsContainer tests', function () {
|
|
|
158
196
|
]
|
|
159
197
|
};
|
|
160
198
|
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap });
|
|
161
|
-
|
|
162
|
-
expect(
|
|
163
|
-
expect(
|
|
164
|
-
expect(component.find(CommentButton_1.CommentButton)).toHaveLength(0);
|
|
165
|
-
});
|
|
166
|
-
it('should render CollaborationPopup if currentComment does not exist', function () {
|
|
167
|
-
var component = setUp();
|
|
168
|
-
expect(component.find(CollaborationPopup_1.CollaborationPopup).props()).toMatchObject({
|
|
169
|
-
anchorEl: null,
|
|
170
|
-
open: false,
|
|
171
|
-
uri: defaultProps.uri,
|
|
172
|
-
objectType: defaultProps.objectType,
|
|
173
|
-
comment: null
|
|
174
|
-
});
|
|
199
|
+
setUp({ collaborationContextValue: collaborationContextValue });
|
|
200
|
+
expect(react_2.screen.queryByLabelText('Add comment')).toBeInTheDocument();
|
|
201
|
+
expect(react_2.screen.queryByLabelText('Show comment')).not.toBeInTheDocument();
|
|
175
202
|
});
|
|
176
|
-
it('should render CollaborationPopup if currentComment exists and commentsButton is clicked', function () {
|
|
203
|
+
it('should render CollaborationPopup if currentComment exists and commentsButton is clicked', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
204
|
+
var currentComment, commentsMap, collaborationContextValue, user;
|
|
177
205
|
var _a;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
206
|
+
return __generator(this, function (_b) {
|
|
207
|
+
switch (_b.label) {
|
|
208
|
+
case 0:
|
|
209
|
+
currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
|
|
210
|
+
commentsMap = (_a = {},
|
|
211
|
+
_a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
|
|
212
|
+
_a);
|
|
213
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment });
|
|
214
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
215
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Show comment'))];
|
|
216
|
+
case 1:
|
|
217
|
+
_b.sent();
|
|
218
|
+
expect(react_2.screen.queryByText(currentComment.content)).toBeInTheDocument();
|
|
219
|
+
expect(react_2.screen.queryByText(defaultMdmValues.entity.label)).toBeInTheDocument();
|
|
220
|
+
return [2 /*return*/];
|
|
221
|
+
}
|
|
187
222
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
223
|
+
}); });
|
|
224
|
+
it('handleClickAddCommentButton handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
+
var user;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0:
|
|
229
|
+
user = setUp().user;
|
|
230
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Add comment'))];
|
|
231
|
+
case 1:
|
|
232
|
+
_a.sent();
|
|
233
|
+
expect(react_2.screen.queryByText('Comments')).toBeInTheDocument();
|
|
234
|
+
return [2 /*return*/];
|
|
235
|
+
}
|
|
195
236
|
});
|
|
196
|
-
});
|
|
197
|
-
it('
|
|
198
|
-
var
|
|
199
|
-
expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('anchorEl')).toBe(null);
|
|
200
|
-
component.find(AddCommentButton_1.AddCommentButton).simulate('click', { currentTarget: 'Element' });
|
|
201
|
-
expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('anchorEl')).not.toBe(null);
|
|
202
|
-
expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('open')).toBe(true);
|
|
203
|
-
});
|
|
204
|
-
it('handleClose handler should work correctly', function () {
|
|
237
|
+
}); });
|
|
238
|
+
it('handleClose handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
239
|
+
var currentComment, commentsMap, clearCurrentComment, collaborationContextValue, user;
|
|
205
240
|
var _a;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
241
|
+
return __generator(this, function (_b) {
|
|
242
|
+
switch (_b.label) {
|
|
243
|
+
case 0:
|
|
244
|
+
currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
|
|
245
|
+
commentsMap = (_a = {},
|
|
246
|
+
_a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
|
|
247
|
+
_a);
|
|
248
|
+
clearCurrentComment = jest.fn();
|
|
249
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment, clearCurrentComment: clearCurrentComment });
|
|
250
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
251
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Show comment'))];
|
|
252
|
+
case 1:
|
|
253
|
+
_b.sent();
|
|
254
|
+
expect(react_2.screen.queryByText('Comments')).toBeInTheDocument();
|
|
255
|
+
return [4 /*yield*/, user.click(document.querySelector('.backdrop'))];
|
|
256
|
+
case 2:
|
|
257
|
+
_b.sent();
|
|
258
|
+
expect(react_2.screen.queryByText('Comments')).not.toBeInTheDocument();
|
|
259
|
+
expect(clearCurrentComment).toBeCalled();
|
|
260
|
+
return [2 /*return*/];
|
|
261
|
+
}
|
|
221
262
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
expect(collaborationContextValue.clearCurrentComment).toBeCalled();
|
|
226
|
-
});
|
|
227
|
-
it('handleClickCommentButton should work correctly', function () {
|
|
263
|
+
}); });
|
|
264
|
+
it('handleClickCommentButton should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
265
|
+
var currentComment, commentsMap, getComment, collaborationContextValue, user;
|
|
228
266
|
var _a;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(0, test_utils_1.act)(function () {
|
|
246
|
-
component.find(CollaborationPopup_1.CollaborationPopup).prop('onClose')();
|
|
267
|
+
return __generator(this, function (_b) {
|
|
268
|
+
switch (_b.label) {
|
|
269
|
+
case 0:
|
|
270
|
+
currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
|
|
271
|
+
commentsMap = (_a = {},
|
|
272
|
+
_a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
|
|
273
|
+
_a);
|
|
274
|
+
getComment = jest.fn();
|
|
275
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, getComment: getComment });
|
|
276
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
277
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Show comment'))];
|
|
278
|
+
case 1:
|
|
279
|
+
_b.sent();
|
|
280
|
+
expect(getComment).toBeCalledWith(currentComment.commentId);
|
|
281
|
+
return [2 /*return*/];
|
|
282
|
+
}
|
|
247
283
|
});
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
284
|
+
}); });
|
|
285
|
+
it('should call onChangePopupVisibility handler when anchorEl changed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
286
|
+
var onChangePopupVisibility, props, user;
|
|
287
|
+
return __generator(this, function (_a) {
|
|
288
|
+
switch (_a.label) {
|
|
289
|
+
case 0:
|
|
290
|
+
onChangePopupVisibility = jest.fn();
|
|
291
|
+
props = __assign(__assign({}, defaultProps), { onChangePopupVisibility: onChangePopupVisibility });
|
|
292
|
+
user = setUp({ props: props }).user;
|
|
293
|
+
expect(onChangePopupVisibility).not.toHaveBeenCalled();
|
|
294
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Add comment'))];
|
|
295
|
+
case 1:
|
|
296
|
+
_a.sent();
|
|
297
|
+
expect(onChangePopupVisibility).toHaveBeenCalledWith(true);
|
|
298
|
+
return [4 /*yield*/, user.click(document.querySelector('.backdrop'))];
|
|
299
|
+
case 2:
|
|
300
|
+
_a.sent();
|
|
301
|
+
expect(onChangePopupVisibility).toHaveBeenCalledWith(false);
|
|
302
|
+
return [2 /*return*/];
|
|
303
|
+
}
|
|
261
304
|
});
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
305
|
+
}); });
|
|
306
|
+
it('should not close popup if click menu item in kebab', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
307
|
+
var currentComment, commentsMap, collaborationContextValue, user;
|
|
308
|
+
var _a;
|
|
309
|
+
return __generator(this, function (_b) {
|
|
310
|
+
switch (_b.label) {
|
|
311
|
+
case 0:
|
|
312
|
+
currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
|
|
313
|
+
commentsMap = (_a = {},
|
|
314
|
+
_a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
|
|
315
|
+
_a);
|
|
316
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment });
|
|
317
|
+
user = setUp({ collaborationContextValue: collaborationContextValue }).user;
|
|
318
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Show comment'))];
|
|
319
|
+
case 1:
|
|
320
|
+
_b.sent();
|
|
321
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Open menu' }))];
|
|
322
|
+
case 2:
|
|
323
|
+
_b.sent();
|
|
324
|
+
expect(react_2.screen.queryByText('Comments')).toBeInTheDocument();
|
|
325
|
+
return [4 /*yield*/, user.click(document.querySelector('.backdrop'))];
|
|
326
|
+
case 3:
|
|
327
|
+
_b.sent();
|
|
328
|
+
expect(react_2.screen.queryByText('Comments')).not.toBeInTheDocument();
|
|
329
|
+
return [2 /*return*/];
|
|
330
|
+
}
|
|
273
331
|
});
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
332
|
+
}); });
|
|
333
|
+
it('should use RelatedObjectUrisContext for collect relatedObjectUris', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
334
|
+
var additionalRelatedObjectUris, createComment, getCommentState, collaborationContextValue, Providers, user;
|
|
335
|
+
return __generator(this, function (_a) {
|
|
336
|
+
switch (_a.label) {
|
|
337
|
+
case 0:
|
|
338
|
+
additionalRelatedObjectUris = ['additionalUri1', 'additionalUri2'];
|
|
339
|
+
createComment = jest.fn().mockReturnValue(new Promise(function (res) { return res(); }));
|
|
340
|
+
getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
341
|
+
value: 'Hello @[vyacheslav](vyacheslav)',
|
|
342
|
+
plainTextValue: 'Hello +vyacheslav',
|
|
343
|
+
mentions: ['vyacheslav']
|
|
344
|
+
}); });
|
|
345
|
+
collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { createComment: createComment, currentComment: null, getCommentState: getCommentState });
|
|
346
|
+
Providers = function (_a) {
|
|
347
|
+
var children = _a.children;
|
|
348
|
+
return (react_1.default.createElement(RelatedObjectUrisContext_1.RelatedObjectUrisContext.Provider, { value: additionalRelatedObjectUris }, children));
|
|
349
|
+
};
|
|
350
|
+
user = setUp({ collaborationContextValue: collaborationContextValue, providers: Providers }).user;
|
|
351
|
+
return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Add comment'))];
|
|
352
|
+
case 1:
|
|
353
|
+
_a.sent();
|
|
354
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Comment' }))];
|
|
355
|
+
case 2:
|
|
356
|
+
_a.sent();
|
|
357
|
+
expect(createComment).toHaveBeenCalledWith({
|
|
358
|
+
content: 'Hello +vyacheslav',
|
|
359
|
+
namedUsers: ['vyacheslav'],
|
|
360
|
+
objectType: 'entity',
|
|
361
|
+
relatedObjectUris: __spreadArray(['relatedEntityUri'], additionalRelatedObjectUris, true),
|
|
362
|
+
uri: 'uri1'
|
|
363
|
+
});
|
|
364
|
+
return [2 /*return*/];
|
|
365
|
+
}
|
|
278
366
|
});
|
|
279
|
-
|
|
280
|
-
expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('anchorEl')).toBe(null);
|
|
281
|
-
});
|
|
282
|
-
it('should use RelatedObjectUrisContext for collect relatedObjectUris', function () {
|
|
283
|
-
var _a;
|
|
284
|
-
var additionalRelatedObjectUris = ['additionalUri1', 'additionalUri2'];
|
|
285
|
-
var currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
|
|
286
|
-
var commentsMap = (_a = {},
|
|
287
|
-
_a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
|
|
288
|
-
_a);
|
|
289
|
-
var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment });
|
|
290
|
-
var Providers = function (_a) {
|
|
291
|
-
var children = _a.children;
|
|
292
|
-
return (react_1.default.createElement(RelatedObjectUrisContext_1.RelatedObjectUrisContext.Provider, { value: additionalRelatedObjectUris }, children));
|
|
293
|
-
};
|
|
294
|
-
var component = setUp({ collaborationContextValue: collaborationContextValue, providers: Providers });
|
|
295
|
-
expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('relatedObjectUris')).toEqual(__spreadArray(__spreadArray([], defaultProps.relatedObjectUris, true), additionalRelatedObjectUris, true));
|
|
296
|
-
});
|
|
367
|
+
}); });
|
|
297
368
|
});
|