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