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