@reltio/components 1.4.1906 → 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.
Files changed (97) hide show
  1. package/cjs/ActionsPanel/ActionsPanel.test.js +133 -49
  2. package/cjs/AttributeListItem/AttributeListItem.spec.js +147 -118
  3. package/cjs/AttributeSelector/AttributeSelector.specs.js +125 -193
  4. package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
  5. package/cjs/AttributesErrorsPanel/components/Error/Error.specs.js +96 -90
  6. package/cjs/AttributesErrorsPanel/store.test-data.d.ts +22 -0
  7. package/cjs/AttributesErrorsPanel/store.test-data.js +29 -0
  8. package/cjs/AttributesFilterSelector/AttributesFilterSelector.test.js +127 -105
  9. package/cjs/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
  10. package/cjs/AttributesValuesEditor/AttributesValuesEditor.test.js +92 -88
  11. package/cjs/AttributesView/AttributesView.test.js +67 -34
  12. package/cjs/AutoSizeList/AutoSizeList.test.js +81 -59
  13. package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +15 -31
  14. package/cjs/BarChart/BarChart.test.js +128 -65
  15. package/cjs/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
  16. package/cjs/BasicViewContent/BasicViewContent.test.js +7 -9
  17. package/cjs/BlobRenderer/BlobRenderer.test.js +28 -9
  18. package/cjs/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
  19. package/cjs/BubbleChart/BubbleChart.test.js +111 -87
  20. package/cjs/CloudChart/CloudChart.test.js +95 -36
  21. package/cjs/CollaborationItem/CollaborationItem.test.js +67 -30
  22. package/cjs/CollaborationItem/components/Comment/Comment.test.js +221 -189
  23. package/cjs/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -81
  24. package/cjs/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
  25. package/cjs/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
  26. package/cjs/CollapseButton/CollapseButton.test.js +74 -15
  27. package/cjs/CollapseRowButton/CollapseRowButton.test.js +82 -24
  28. package/cjs/ColorBar/ColorBar.test.js +13 -15
  29. package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
  30. package/cjs/CommentsContainer/CommentsContainer.test.js +282 -211
  31. package/cjs/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +183 -122
  32. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
  33. package/cjs/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
  34. package/cjs/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
  35. package/cjs/ConnectionEditor/ConnectionEditor.test.js +299 -282
  36. package/esm/ActionsPanel/ActionsPanel.test.js +133 -49
  37. package/esm/AttributeListItem/AttributeListItem.spec.js +149 -97
  38. package/esm/AttributeSelector/AttributeSelector.specs.js +125 -193
  39. package/esm/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
  40. package/esm/AttributesErrorsPanel/components/Error/Error.specs.js +98 -72
  41. package/esm/AttributesErrorsPanel/store.test-data.d.ts +22 -0
  42. package/esm/AttributesErrorsPanel/store.test-data.js +26 -0
  43. package/esm/AttributesFilterSelector/AttributesFilterSelector.test.js +129 -84
  44. package/esm/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
  45. package/esm/AttributesValuesEditor/AttributesValuesEditor.test.js +94 -67
  46. package/esm/AttributesView/AttributesView.test.js +67 -34
  47. package/esm/AutoSizeList/AutoSizeList.test.js +81 -59
  48. package/esm/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +16 -32
  49. package/esm/BarChart/BarChart.test.js +128 -65
  50. package/esm/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
  51. package/esm/BasicViewContent/BasicViewContent.test.js +7 -9
  52. package/esm/BlobRenderer/BlobRenderer.test.js +28 -9
  53. package/esm/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
  54. package/esm/BubbleChart/BubbleChart.test.js +111 -87
  55. package/esm/CloudChart/CloudChart.test.js +95 -36
  56. package/esm/CollaborationItem/CollaborationItem.test.js +67 -30
  57. package/esm/CollaborationItem/components/Comment/Comment.test.js +221 -189
  58. package/esm/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -58
  59. package/esm/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
  60. package/esm/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
  61. package/esm/CollapseButton/CollapseButton.test.js +74 -15
  62. package/esm/CollapseRowButton/CollapseRowButton.test.js +82 -24
  63. package/esm/ColorBar/ColorBar.test.js +13 -15
  64. package/esm/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
  65. package/esm/CommentsContainer/CommentsContainer.test.js +282 -211
  66. package/esm/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +182 -101
  67. package/esm/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
  68. package/esm/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
  69. package/esm/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
  70. package/esm/ConnectionEditor/ConnectionEditor.test.js +300 -283
  71. package/package.json +1 -1
  72. package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -100
  73. package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
  74. package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -46
  75. package/cjs/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
  76. package/cjs/AvatarWithFallback/AvatarWithFallback.specs.js +0 -27
  77. package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
  78. package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -27
  79. package/cjs/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
  80. package/cjs/CollaborationItem/components/Avatar/Avatar.test.js +0 -15
  81. package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
  82. package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -80
  83. package/esm/ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts +0 -1
  84. package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts +0 -1
  85. package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -95
  86. package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
  87. package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -41
  88. package/esm/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
  89. package/esm/AvatarWithFallback/AvatarWithFallback.specs.js +0 -22
  90. package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
  91. package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -22
  92. package/esm/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
  93. package/esm/CollaborationItem/components/Avatar/Avatar.test.js +0 -10
  94. package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
  95. package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -55
  96. /package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts → AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
  97. /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 defaultCollaborationContextValue = {
41
- createComment: jest.fn().mockResolvedValue(undefined),
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 component = setUpWithoutContext();
97
- expect(component.isEmptyRender()).toBe(true);
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 component = setUp({ collaborationContextValue: collaborationContextValue });
102
- expect(component.isEmptyRender()).toBe(true);
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
- var component = setUp();
106
- expect(component.isEmptyRender()).toBe(false);
107
- expect(component.find(AddCommentButton_1.AddCommentButton)).toHaveLength(1);
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
- var component = setUp({ props: props });
113
- expect(component.find(AddCommentButton_1.AddCommentButton).prop('className')).toBe('addButton showAlways');
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
- var component = setUp({ props: props });
118
- expect(component.find(AddCommentButton_1.AddCommentButton).prop('className')).toBe('addButton');
119
- });
120
- it('should render AddCommentButton with correctly className if open popup with new comment', function () {
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
- var component = setUp({ props: props, collaborationContextValue: collaborationContextValue });
133
- expect(component.find(AddCommentButton_1.AddCommentButton)).toHaveLength(0);
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
- var component = setUp({ collaborationContextValue: collaborationContextValue });
147
- expect(component.isEmptyRender()).toBe(false);
148
- expect(component.find(AddCommentButton_1.AddCommentButton)).toHaveLength(1);
149
- expect(component.find(CommentButton_1.CommentButton)).toHaveLength(2);
150
- expect(component.find(CommentButton_1.CommentButton).at(0).text()).toBe('3');
151
- expect(component.find(CommentButton_1.CommentButton).at(1).text()).toBe('2');
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
- var component = setUp({ collaborationContextValue: collaborationContextValue });
162
- expect(component.isEmptyRender()).toBe(false);
163
- expect(component.find(AddCommentButton_1.AddCommentButton)).toHaveLength(1);
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
- var currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
179
- var commentsMap = (_a = {},
180
- _a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
181
- _a);
182
- var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment });
183
- var component = setUp({ collaborationContextValue: collaborationContextValue });
184
- var onClick = component.find(CommentButton_1.CommentButton).prop('onClick');
185
- (0, test_utils_1.act)(function () {
186
- onClick(currentComment.commentId);
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
- component.update();
189
- expect(component.find(CommentButton_1.CommentButton).html()).toBe(component.find(CollaborationPopup_1.CollaborationPopup).prop('anchorEl').outerHTML);
190
- expect(component.find(CollaborationPopup_1.CollaborationPopup).props()).toMatchObject({
191
- open: true,
192
- uri: defaultProps.uri,
193
- objectType: defaultProps.objectType,
194
- comment: currentComment
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('handleClickAddCommentButton handler should work correctly', function () {
198
- var component = setUp();
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
- var currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
207
- var commentsMap = (_a = {},
208
- _a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
209
- _a);
210
- var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment });
211
- var component = setUp({ collaborationContextValue: collaborationContextValue });
212
- var onClick = component.find(CommentButton_1.CommentButton).prop('onClick');
213
- (0, test_utils_1.act)(function () {
214
- onClick(currentComment.commentId);
215
- });
216
- component.update();
217
- expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('open')).toBe(true);
218
- expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('anchorEl')).not.toBe(null);
219
- (0, test_utils_1.act)(function () {
220
- component.find(CollaborationPopup_1.CollaborationPopup).prop('onClose')();
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
- component.update();
223
- expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('open')).toBe(false);
224
- expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('anchorEl')).toBe(null);
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
- var currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
230
- var commentsMap = (_a = {},
231
- _a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
232
- _a);
233
- var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment });
234
- var component = setUp({ collaborationContextValue: collaborationContextValue });
235
- component.find(CommentButton_1.CommentButton).simulate('click', null);
236
- expect(collaborationContextValue.getComment).toBeCalledWith(currentComment.commentId);
237
- });
238
- it('should call onChangePopupVisibility handler when anchorEl changed', function () {
239
- var onChangePopupVisibility = jest.fn();
240
- var props = __assign(__assign({}, defaultProps), { onChangePopupVisibility: onChangePopupVisibility });
241
- var component = setUp({ props: props });
242
- expect(onChangePopupVisibility).not.toHaveBeenCalled();
243
- component.find(AddCommentButton_1.AddCommentButton).simulate('click', { currentTarget: 'Element' });
244
- expect(onChangePopupVisibility).toHaveBeenCalledWith(true);
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
- expect(onChangePopupVisibility).toHaveBeenCalledWith(false);
249
- });
250
- it('should not close popup if click menu item in kebab', function () {
251
- var _a;
252
- var currentComment = (0, CommentsContainer_test_data_1.createDefaultComment)();
253
- var commentsMap = (_a = {},
254
- _a[defaultProps.uri] = [{ commentId: currentComment.commentId, status: 'open', replies: 0 }],
255
- _a);
256
- var collaborationContextValue = __assign(__assign({}, defaultCollaborationContextValue), { commentsMap: commentsMap, currentComment: currentComment });
257
- var component = setUp({ collaborationContextValue: collaborationContextValue });
258
- var onClick = component.find(CommentButton_1.CommentButton).prop('onClick');
259
- (0, test_utils_1.act)(function () {
260
- onClick(currentComment.commentId);
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
- component.update();
263
- expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('open')).toBe(true);
264
- component.find(DropDownMenuButton_1.DropDownMenuButton).at(0).find('button').simulate('click', { currentTarget: 'Element' });
265
- component.update();
266
- (0, test_utils_1.act)(function () {
267
- component
268
- .find(DefaultMenuItemRenderer_1.DefaultMenuItemRenderer)
269
- .at(0)
270
- .find('li')
271
- .at(0)
272
- .simulate('click', { currentTarget: 'Element' });
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
- component.update();
275
- expect(component.find(CollaborationPopup_1.CollaborationPopup).prop('anchorEl')).not.toBe(null);
276
- (0, test_utils_1.act)(function () {
277
- component.find(CollaborationPopup_1.CollaborationPopup).prop('onClose')();
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
- component.update();
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
  });