@reltio/components 1.4.1939 → 1.4.1941

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 (39) hide show
  1. package/cjs/AttributesFiltersButton/AttributesFiltersButton.d.ts +4 -1
  2. package/cjs/AttributesFiltersButton/AttributesFiltersButton.js +9 -8
  3. package/cjs/AttributesFiltersButton/AttributesFiltersButton.test.js +15 -0
  4. package/cjs/EditModeAttributesList/EditModeAttributesList.js +1 -1
  5. package/cjs/EditModeAttributesPager/components/AttributeRenderer/IntegrationAttributeRenderer.test.js +27 -0
  6. package/cjs/EditModeComplexAttribute/EditModeComplexAttribute.js +8 -2
  7. package/cjs/EntitySelector/EntitySelector.d.ts +2 -1
  8. package/cjs/EntitySelector/EntitySelector.js +3 -3
  9. package/cjs/EntitySelector/EntitySelector.test.js +3 -2
  10. package/cjs/ReferenceAttributeEditor/ReferenceAttributeEditor.js +1 -1
  11. package/cjs/RelationEditor/IntegrationRelationEditor.test.js +60 -1
  12. package/cjs/RelationEditor/RelationEditor.js +7 -5
  13. package/cjs/SearchInput/SearchInput.d.ts +2 -1
  14. package/cjs/SearchInput/SearchInput.js +4 -2
  15. package/cjs/SearchInput/SearchInput.spec.js +115 -35
  16. package/cjs/SimpleAttribute/IntegrationSimpleAttribute.test.js +9 -3
  17. package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.js +3 -3
  18. package/cjs/hooks/useMaskedAttribute/useMaskedAttribute.js +3 -1
  19. package/cjs/types/index.d.ts +1 -0
  20. package/esm/AttributesFiltersButton/AttributesFiltersButton.d.ts +4 -1
  21. package/esm/AttributesFiltersButton/AttributesFiltersButton.js +9 -8
  22. package/esm/AttributesFiltersButton/AttributesFiltersButton.test.js +15 -0
  23. package/esm/EditModeAttributesList/EditModeAttributesList.js +2 -2
  24. package/esm/EditModeAttributesPager/components/AttributeRenderer/IntegrationAttributeRenderer.test.js +27 -0
  25. package/esm/EditModeComplexAttribute/EditModeComplexAttribute.js +9 -3
  26. package/esm/EntitySelector/EntitySelector.d.ts +2 -1
  27. package/esm/EntitySelector/EntitySelector.js +3 -3
  28. package/esm/EntitySelector/EntitySelector.test.js +3 -2
  29. package/esm/ReferenceAttributeEditor/ReferenceAttributeEditor.js +2 -2
  30. package/esm/RelationEditor/IntegrationRelationEditor.test.js +60 -1
  31. package/esm/RelationEditor/RelationEditor.js +9 -7
  32. package/esm/SearchInput/SearchInput.d.ts +2 -1
  33. package/esm/SearchInput/SearchInput.js +4 -2
  34. package/esm/SearchInput/SearchInput.spec.js +115 -35
  35. package/esm/SimpleAttribute/IntegrationSimpleAttribute.test.js +9 -3
  36. package/esm/SimpleAttributeEditor/SimpleAttributeEditor.js +4 -4
  37. package/esm/hooks/useMaskedAttribute/useMaskedAttribute.js +3 -1
  38. package/esm/types/index.d.ts +1 -0
  39. package/package.json +2 -2
@@ -135,6 +135,7 @@ export type AttributesFilterComponentsClasses = {
135
135
  filterSelectorContainer?: string;
136
136
  actionsContainer?: string;
137
137
  filterPopup?: string;
138
+ triggerButton?: string;
138
139
  };
139
140
  export declare enum ActionButtonMode {
140
141
  iconButton = "iconButton",
@@ -16,10 +16,13 @@ type Props = {
16
16
  onTogglePopup?: (open: boolean) => void;
17
17
  isFiltersApplied?: boolean;
18
18
  dataReltioId?: string;
19
+ ButtonIcon?: React.ElementType;
19
20
  onFilterAttributeChange?: (attrSelectInfo: AttributeSelectionInfo) => void;
20
21
  onClear?: () => void;
21
22
  onCancel?: () => void;
22
23
  onApply?: () => void;
24
+ popoverAnchorRef?: React.MutableRefObject<HTMLDivElement>;
25
+ title?: string;
23
26
  };
24
- declare const _default: React.MemoExoticComponent<({ filters: filtersProp, classes, attributesTypesGroups, attributesTypesGroupFilter, onChange, components, children, onTogglePopup, isFiltersApplied: isFiltersAppliedProp, dataReltioId, onFilterAttributeChange, onCancel, onClear, onApply }: Props) => JSX.Element>;
27
+ declare const _default: React.MemoExoticComponent<({ filters: filtersProp, classes, attributesTypesGroups, attributesTypesGroupFilter, onChange, components, children, onTogglePopup, isFiltersApplied: isFiltersAppliedProp, dataReltioId, onFilterAttributeChange, onCancel, onClear, onApply, ButtonIcon, popoverAnchorRef, title }: Props) => JSX.Element>;
25
28
  export default _default;
@@ -11,11 +11,12 @@ import { AttributesFiltersBuilder } from '../AttributesFiltersBuilder';
11
11
  import { ActionButtons } from './components/ActionButtons/';
12
12
  import { useStyles } from './styles';
13
13
  var AttributesFiltersButton = function (_a) {
14
- var filtersProp = _a.filters, classes = _a.classes, attributesTypesGroups = _a.attributesTypesGroups, attributesTypesGroupFilter = _a.attributesTypesGroupFilter, onChange = _a.onChange, components = _a.components, children = _a.children, onTogglePopup = _a.onTogglePopup, isFiltersAppliedProp = _a.isFiltersApplied, dataReltioId = _a.dataReltioId, onFilterAttributeChange = _a.onFilterAttributeChange, onCancel = _a.onCancel, onClear = _a.onClear, onApply = _a.onApply;
14
+ var _b;
15
+ var filtersProp = _a.filters, classes = _a.classes, attributesTypesGroups = _a.attributesTypesGroups, attributesTypesGroupFilter = _a.attributesTypesGroupFilter, onChange = _a.onChange, components = _a.components, children = _a.children, onTogglePopup = _a.onTogglePopup, isFiltersAppliedProp = _a.isFiltersApplied, dataReltioId = _a.dataReltioId, onFilterAttributeChange = _a.onFilterAttributeChange, onCancel = _a.onCancel, onClear = _a.onClear, onApply = _a.onApply, _c = _a.ButtonIcon, ButtonIcon = _c === void 0 ? FilterIcon : _c, popoverAnchorRef = _a.popoverAnchorRef, title = _a.title;
15
16
  var styles = useStyles();
16
17
  var buttonRef = useRef();
17
- var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
18
- var _c = useState([]), filters = _c[0], setFilters = _c[1];
18
+ var _d = useState(false), isOpen = _d[0], setIsOpen = _d[1];
19
+ var _e = useState([]), filters = _e[0], setFilters = _e[1];
19
20
  var isFiltersApplied = isFiltersAppliedProp !== null && isFiltersAppliedProp !== void 0 ? isFiltersAppliedProp : !!buildFilterQueryString()(filtersProp);
20
21
  var buttonColor = isFiltersApplied ? 'primary' : 'inherit';
21
22
  var togglePopup = function () {
@@ -44,19 +45,19 @@ var AttributesFiltersButton = function (_a) {
44
45
  }, [onClear]);
45
46
  return (React.createElement(React.Fragment, null,
46
47
  React.createElement(Button, { "data-reltio-id": dataReltioId, ref: buttonRef, color: buttonColor, classes: {
47
- root: styles.triggerButton,
48
+ root: classNames(styles.triggerButton, classes === null || classes === void 0 ? void 0 : classes.triggerButton),
48
49
  textPrimary: styles.changedFiltersIndicator
49
50
  }, onClick: togglePopup },
50
- React.createElement(FilterIcon, { color: buttonColor })),
51
- React.createElement(Popover, { open: isOpen, classes: { paper: classNames(styles.popupContent, classes === null || classes === void 0 ? void 0 : classes.filterPopup) }, anchorEl: buttonRef.current, onClose: togglePopup, anchorOrigin: {
51
+ React.createElement(ButtonIcon, { color: buttonColor })),
52
+ React.createElement(Popover, { open: isOpen, classes: { paper: classNames(styles.popupContent, classes === null || classes === void 0 ? void 0 : classes.filterPopup) }, anchorEl: (_b = popoverAnchorRef === null || popoverAnchorRef === void 0 ? void 0 : popoverAnchorRef.current) !== null && _b !== void 0 ? _b : buttonRef.current, onClose: togglePopup, anchorOrigin: {
52
53
  vertical: 'bottom',
53
- horizontal: 'right'
54
+ horizontal: (popoverAnchorRef === null || popoverAnchorRef === void 0 ? void 0 : popoverAnchorRef.current) ? 'left' : 'right'
54
55
  }, transformOrigin: {
55
56
  vertical: 'top',
56
57
  horizontal: 'left'
57
58
  } },
58
59
  React.createElement(React.Fragment, null,
59
- React.createElement(Typography, { variant: "h6" }, i18n.text('Filter')),
60
+ React.createElement(Typography, { variant: "h6" }, title !== null && title !== void 0 ? title : i18n.text('Filter')),
60
61
  React.createElement("div", { className: styles.filtersBuilderWrapper },
61
62
  children,
62
63
  React.createElement(AttributesFiltersBuilder, { attributesTypesGroups: attributesTypesGroups, attributesTypesGroupFilter: attributesTypesGroupFilter, filters: filters, onChange: setFilters, components: components, onFilterAttributeChange: onFilterAttributeChange, classes: classes })),
@@ -242,4 +242,19 @@ describe('AttributesFiltersButton tests', function () {
242
242
  }
243
243
  });
244
244
  }); });
245
+ it('should use title if defined', function () { return __awaiter(void 0, void 0, void 0, function () {
246
+ var title, user;
247
+ return __generator(this, function (_a) {
248
+ switch (_a.label) {
249
+ case 0:
250
+ title = 'TestTitle';
251
+ user = setUp(__assign(__assign({}, defaultProps), { title: title })).user;
252
+ return [4 /*yield*/, user.click(screen.getByRole('button'))];
253
+ case 1:
254
+ _a.sent();
255
+ expect(screen.getByText(title)).toBeInTheDocument();
256
+ return [2 /*return*/];
257
+ }
258
+ });
259
+ }); });
245
260
  });
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import React, { useCallback, useContext, useMemo, useState, useEffect } from 'react';
13
13
  import i18n from 'ui-i18n';
14
- import { getCreatableAttributeTypes, getAttributesListForEditMode, getParentUri, checkCanCreateAttribute, getBaseUri } from '@reltio/mdm-sdk';
14
+ import { getCreatableAttributeTypes, getAttributesListForEditMode, getParentUri, checkCanCreateAttribute, getBaseUri, Mode } from '@reltio/mdm-sdk';
15
15
  import { last, path } from 'ramda';
16
16
  import { EditModeAttributesPager } from '../EditModeAttributesPager';
17
17
  import { BranchDecorator } from '../BranchDecorator';
@@ -67,7 +67,7 @@ var EditModeAttributesList = function (_a) {
67
67
  }); }, [hasDeletionsMap, setHasDeletions]);
68
68
  return (React.createElement("div", { className: className },
69
69
  children && React.createElement(BranchDecorator, __assign({}, decoratorProps), children),
70
- React.createElement(BranchDecorator, __assign({}, decoratorProps, { plain: true }), moreAttrTypes.length > 0 && (React.createElement(MoreAttributesButton, { label: i18n.text('More attributes'), onApply: onAddMoreAttributes, dense: drawLines, data: moreAttrTypes, parent: canCreateParentAttrType && parentAttributeType }))),
70
+ React.createElement(BranchDecorator, __assign({}, decoratorProps, { plain: true }), moreAttrTypes.length > 0 && mode !== Mode.Viewing && (React.createElement(MoreAttributesButton, { label: i18n.text('More attributes'), onApply: onAddMoreAttributes, dense: drawLines, data: moreAttrTypes, parent: canCreateParentAttrType && parentAttributeType }))),
71
71
  React.createElement(HasDeletionsContext.Provider, { value: hasDeletionsContextValue }, regularPagersData.concat(alwaysVisiblePagersData).map(function (_a) {
72
72
  var attrType = _a.attrType, values = _a.values;
73
73
  return (React.createElement(EditModeAttributesPager, { key: "".concat(attrType.uri, "_").concat(parentUri), attributeType: attrType, drawLines: drawLines, values: values, paging: path(['paging', attrType.uri], attributes), parentUri: parentUri, showEmptyEditors: showEmptyEditors, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }));
@@ -185,4 +185,31 @@ describe('Attribute renderer tests', function () {
185
185
  }
186
186
  });
187
187
  }); });
188
+ it('should render correct if one of the values is masked', function () {
189
+ var values = [
190
+ {
191
+ ov: true,
192
+ type: 'configuration/entityTypes/HCP/attributes/PrescriberIndicator',
193
+ uri: 'entities/0XAnnkw/attributes/PrescriberIndicator/ESG66YW',
194
+ value: false
195
+ },
196
+ {
197
+ ov: true,
198
+ type: 'configuration/entityTypes/HCP/attributes/PrescriberIndicator',
199
+ uri: 'entities/0XAnnkw/attributes/PrescriberIndicator/ESG66YW',
200
+ value: true,
201
+ masked: true
202
+ }
203
+ ];
204
+ var props = __assign(__assign({}, defaultProps), { values: values });
205
+ setUp({ props: props });
206
+ var attributeValues = screen.getAllByTestId('reltio-attribute-value');
207
+ expect(attributeValues).toHaveLength(2);
208
+ expect(within(attributeValues[0]).getAllByRole('checkbox')).toHaveLength(2);
209
+ expect(within(attributeValues[0]).getByText('Yes')).toBeInTheDocument();
210
+ expect(within(attributeValues[0]).getByText('No')).toBeInTheDocument();
211
+ expect(within(attributeValues[1]).queryAllByRole('checkbox')).toHaveLength(0);
212
+ expect(within(attributeValues[1]).getByText('Yes')).toBeInTheDocument();
213
+ expect(within(attributeValues[1]).queryByText('No')).not.toBeInTheDocument();
214
+ });
188
215
  });
@@ -2,7 +2,7 @@ import React, { useMemo, useState, useEffect } from 'react';
2
2
  import { pipe, propOr, pathEq, any } from 'ramda';
3
3
  import classnames from 'classnames';
4
4
  import i18n from 'ui-i18n';
5
- import { checkCanDeleteAttribute, isReltioCrosswalk, isTempUri, getErrorMessage, hasAttributeDescendantsWithErrors, isAnalyticAttribute } from '@reltio/mdm-sdk';
5
+ import { checkCanDeleteAttribute, isReltioCrosswalk, isTempUri, getErrorMessage, hasAttributeDescendantsWithErrors, isAnalyticAttribute, Mode } from '@reltio/mdm-sdk';
6
6
  import Button from '@mui/material/Button';
7
7
  import DeleteIcon from '@mui/icons-material/Delete';
8
8
  import Typography from '@mui/material/Typography';
@@ -17,7 +17,7 @@ import { useScrollToAttributeError } from '../hooks/useScrollToAttributeError';
17
17
  import { useStyles } from './styles';
18
18
  var EditModeComplexAttribute = function (_a) {
19
19
  var _b;
20
- var label = _a.label, attributeTypesList = _a.attributeTypesList, attributeType = _a.attributeType, attributeValue = _a.attributeValue, children = _a.children, errors = _a.errors, ownError = _a.ownError, mode = _a.mode, metadata = _a.metadata, crosswalks = _a.crosswalks, lazy = _a.lazy, showEmptyEditors = _a.showEmptyEditors, onAddOneMore = _a.onAddOneMore, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, hideDeleteButton = _a.hideDeleteButton, state = _a.state, showNonOv = _a.showNonOv, isHighlightedPath = _a.isHighlightedPath, highlightedError = _a.highlightedError, _c = _a.expanded, expandedProp = _c === void 0 ? false : _c;
20
+ var label = _a.label, attributeTypesList = _a.attributeTypesList, attributeType = _a.attributeType, attributeValue = _a.attributeValue, children = _a.children, errors = _a.errors, ownError = _a.ownError, modeProp = _a.mode, metadata = _a.metadata, crosswalks = _a.crosswalks, lazy = _a.lazy, showEmptyEditors = _a.showEmptyEditors, onAddOneMore = _a.onAddOneMore, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, hideDeleteButton = _a.hideDeleteButton, state = _a.state, showNonOv = _a.showNonOv, isHighlightedPath = _a.isHighlightedPath, highlightedError = _a.highlightedError, _c = _a.expanded, expandedProp = _c === void 0 ? false : _c;
21
21
  var styles = useStyles();
22
22
  var deleted = state === 'deleted';
23
23
  var edited = state === 'edited';
@@ -26,6 +26,7 @@ var EditModeComplexAttribute = function (_a) {
26
26
  var defaultExpand = isNew || expandedProp;
27
27
  var _d = useState(defaultExpand), expanded = _d[0], setExpanded = _d[1];
28
28
  var _e = useScrollToAttributeError({ highlightedError: highlightedError }), ref = _e.ref, errorClassName = _e.errorClassName;
29
+ var mode = attributeValue.masked ? Mode.Viewing : modeProp;
29
30
  useEffect(function () {
30
31
  if (isHighlightedPath) {
31
32
  setExpanded(true);
@@ -45,7 +46,12 @@ var EditModeComplexAttribute = function (_a) {
45
46
  isReltioCrosswalk: isReltioCrosswalk(crosswalks, attributeValue)
46
47
  });
47
48
  }, [attributeType, attributeValue, mode, metadata, crosswalks, configCanDelete]);
48
- var showDeleteButton = !deleted && !hideDeleteButton && !!onDeleteAttribute && canDelete;
49
+ var showDeleteButton = !deleted &&
50
+ !hideDeleteButton &&
51
+ !!onDeleteAttribute &&
52
+ canDelete &&
53
+ !attributeValue.masked &&
54
+ mode !== Mode.Viewing;
49
55
  var onDeleteThis = function () { return onDeleteAttribute({ uri: uri, attributeType: attributeType, attributeValue: attributeValue }); };
50
56
  var hasDescendantsWithErrors = useMemo(function () { return hasAttributeDescendantsWithErrors(attributeValue, errors); }, [errors, attributeValue]);
51
57
  useEffect(function () {
@@ -17,6 +17,7 @@ type Props = {
17
17
  className?: string;
18
18
  height?: number;
19
19
  isDisabled?: boolean;
20
+ isMasked?: boolean;
20
21
  };
21
- export declare const EntitySelector: ({ entity, entityTypesUris, mode, max, onChange, onCreate, metadata, globalSearchRequestOptions, attributeTypesSelectionStrategy, disableLinkClick, ...otherProps }: Props) => JSX.Element;
22
+ export declare const EntitySelector: ({ entity, entityTypesUris, mode, max, onChange, onCreate, metadata, globalSearchRequestOptions, attributeTypesSelectionStrategy, disableLinkClick, isMasked, ...otherProps }: Props) => JSX.Element;
22
23
  export {};
@@ -35,11 +35,11 @@ import { buildEntityOptions } from './helpers';
35
35
  import { useStyles } from './styles';
36
36
  var DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION = 20;
37
37
  export var EntitySelector = function (_a) {
38
- var _b = _a.entity, entity = _b === void 0 ? {} : _b, _c = _a.entityTypesUris, entityTypesUris = _c === void 0 ? [] : _c, mode = _a.mode, _d = _a.max, max = _d === void 0 ? DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION : _d, onChange = _a.onChange, onCreate = _a.onCreate, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, attributeTypesSelectionStrategy = _a.attributeTypesSelectionStrategy, _e = _a.disableLinkClick, disableLinkClick = _e === void 0 ? false : _e, otherProps = __rest(_a, ["entity", "entityTypesUris", "mode", "max", "onChange", "onCreate", "metadata", "globalSearchRequestOptions", "attributeTypesSelectionStrategy", "disableLinkClick"]);
38
+ var _b = _a.entity, entity = _b === void 0 ? {} : _b, _c = _a.entityTypesUris, entityTypesUris = _c === void 0 ? [] : _c, mode = _a.mode, _d = _a.max, max = _d === void 0 ? DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION : _d, onChange = _a.onChange, onCreate = _a.onCreate, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, attributeTypesSelectionStrategy = _a.attributeTypesSelectionStrategy, _e = _a.disableLinkClick, disableLinkClick = _e === void 0 ? false : _e, _f = _a.isMasked, isMasked = _f === void 0 ? false : _f, otherProps = __rest(_a, ["entity", "entityTypesUris", "mode", "max", "onChange", "onCreate", "metadata", "globalSearchRequestOptions", "attributeTypesSelectionStrategy", "disableLinkClick", "isMasked"]);
39
39
  var styles = useStyles();
40
- var _f = useState(''), inputValue = _f[0], setInputValue = _f[1];
40
+ var _g = useState(''), inputValue = _g[0], setInputValue = _g[1];
41
41
  var entityTypes = useMemo(function () { return entityTypesUris.map(function (type) { return getEntityType(metadata, type); }).filter(isAvailableEntityType); }, [entityTypesUris, metadata]);
42
- var options = __assign(__assign({}, globalSearchRequestOptions), { max: max });
42
+ var options = __assign(__assign({}, globalSearchRequestOptions), { max: max, sendMasked: isMasked });
43
43
  var handleCreate = onCreate
44
44
  ? function (value, entityTypeUri) {
45
45
  onCreate(entityTypeUri || entityTypesUris[0], value);
@@ -133,7 +133,7 @@ describe('EntitySelector', function () {
133
133
  .prop('getOptions')()
134
134
  .then(function () {
135
135
  var entityTypes = [metadata.entityTypes[0]];
136
- var options = __assign(__assign({}, globalSearchRequestOptions), { max: 5 });
136
+ var options = __assign(__assign({}, globalSearchRequestOptions), { max: 5, sendMasked: false });
137
137
  expect(typeAheadSearchSpy).toHaveBeenCalledWith(entityTypes, undefined, options);
138
138
  done();
139
139
  });
@@ -151,7 +151,8 @@ describe('EntitySelector', function () {
151
151
  .then(function () {
152
152
  var entityTypes = [metadata.entityTypes[0]];
153
153
  var options = {
154
- max: 20
154
+ max: 20,
155
+ sendMasked: false
155
156
  };
156
157
  expect(typeAheadSearchSpy).toHaveBeenCalledWith(entityTypes, undefined, options);
157
158
  done();
@@ -23,7 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import React, { useMemo, useCallback, useRef } from 'react';
24
24
  import classnames from 'classnames';
25
25
  import { identity, pipe, isEmpty } from 'ramda';
26
- import { evaluateDeepEntityLabel, referencedEntityAttributeTypesSelectionStrategy, getEntityType, getReferencedEntityFromAttrValue, getReferencedRelationFromAttrValue, getReferencedEntityUri, getReferencedEntityTypeUri, getReferencedEntityTypeUriFromAttrType, getReferencedRelationAttrTypesUris, findAttributeTypeByUri, getCreatableAttributeTypes, createTemporaryEntity, convertReferencedEntityForAttrValue, createReferencedRelationForAttrValue, addReferencedRelationCrosswalks, getReferencedEntityUriFromAttrValue, checkCanEditAttribute, checkMetadataForCreate, isReltioCrosswalk, getErrorMessage, getErrorId, getReferencedEntityActiveError, isTempUri, getLabel, isAttributeTypeError } from '@reltio/mdm-sdk';
26
+ import { evaluateDeepEntityLabel, referencedEntityAttributeTypesSelectionStrategy, getEntityType, getReferencedEntityFromAttrValue, getReferencedRelationFromAttrValue, getReferencedEntityUri, getReferencedEntityTypeUri, getReferencedEntityTypeUriFromAttrType, getReferencedRelationAttrTypesUris, findAttributeTypeByUri, getCreatableAttributeTypes, createTemporaryEntity, convertReferencedEntityForAttrValue, createReferencedRelationForAttrValue, addReferencedRelationCrosswalks, getReferencedEntityUriFromAttrValue, checkCanEditAttribute, checkMetadataForCreate, isReltioCrosswalk, getErrorMessage, getErrorId, getReferencedEntityActiveError, isTempUri, getLabel, isAttributeTypeError, isAttributeHasMaskedValue } from '@reltio/mdm-sdk';
27
27
  import { EditModeComplexAttribute } from '../EditModeComplexAttribute';
28
28
  import { EntitySelector } from '../EntitySelector';
29
29
  import { ErrorWrapper } from '../ErrorWrapper';
@@ -122,7 +122,7 @@ var ReferenceAttributeEditor = function (props) {
122
122
  React.createElement(ErrorWrapper, { errorMessage: errorMessage },
123
123
  React.createElement(EntitySelector, { className: classnames(styles.item, (_a = {},
124
124
  _a[styles.dense] = errorMessage || (selectedEntity && isTempUri(selectedEntity.entityUri)),
125
- _a)), entity: selectedEntity || {}, entityTypesUris: entityTypesUris, globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, isDisabled: !canChangeReferencedEntity, onChange: onChangeEntity, onCreate: canCreateReferencedEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: newEntityAttrTypesSelectionStrategy })))));
125
+ _a)), entity: selectedEntity || {}, entityTypesUris: entityTypesUris, globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, isDisabled: !canChangeReferencedEntity || !!attributeValue.masked, onChange: onChangeEntity, onCreate: canCreateReferencedEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: newEntityAttrTypesSelectionStrategy, isMasked: isAttributeHasMaskedValue(attributeValue) })))));
126
126
  };
127
127
  export default withContext(ScrollToElementContext, function (contextValue, _a) {
128
128
  var attributeValue = _a.attributeValue, attributeType = _a.attributeType;
@@ -179,7 +179,8 @@ describe('RelationEditor behaviour', function () {
179
179
  expect(typeAheadSearch).toBeCalledWith([{ label: 'Address', uri: 'configuration/entityTypes/Location' }], '', {
180
180
  globalFilter: '',
181
181
  max: 20,
182
- searchOptions: ''
182
+ searchOptions: '',
183
+ sendMasked: false
183
184
  });
184
185
  screen.getByText('Create new Address');
185
186
  return [2 /*return*/];
@@ -275,4 +276,62 @@ describe('RelationEditor behaviour', function () {
275
276
  }
276
277
  });
277
278
  }); });
279
+ it('should add sendMasked option if connection entity has attribute with masked value', function () { return __awaiter(void 0, void 0, void 0, function () {
280
+ var props, user, inputs;
281
+ return __generator(this, function (_a) {
282
+ switch (_a.label) {
283
+ case 0:
284
+ props = __assign(__assign({}, defaultProps), { connection: {
285
+ relation: defaultRelation,
286
+ entity: {
287
+ uri: 'entities/uri$$123',
288
+ type: 'configuration/entityTypes/HCP',
289
+ object: {
290
+ uri: 'entities/04B1CqH',
291
+ type: 'configuration/entityTypes/Location',
292
+ attributes: {
293
+ Address: [
294
+ {
295
+ label: 'AcOEvPaVqTfzZCE Josogaf VA',
296
+ relationshipLabel: '',
297
+ value: {
298
+ AddressLine1: [
299
+ {
300
+ type: 'configuration/entityTypes/Location/attributes/AddressLine1',
301
+ ov: true,
302
+ value: 'AcOEvPaVqTfzZCE',
303
+ uri: 'entities/04B1CqH/attributes/Address/03R51aT/AddressLine1/1XFBcmPYm'
304
+ }
305
+ ],
306
+ AddressLine2: [
307
+ {
308
+ type: 'configuration/entityTypes/Location/attributes/AddressLine2',
309
+ ov: true,
310
+ masked: true,
311
+ value: 'KBmiSMlqhElLHMH',
312
+ uri: 'entities/04B1CqH/attributes/Address/03R51aT/AddressLine2/1XFBcmTp2'
313
+ }
314
+ ]
315
+ }
316
+ }
317
+ ]
318
+ }
319
+ }
320
+ }
321
+ } });
322
+ user = setUp({ props: props }).user;
323
+ inputs = screen.getAllByRole('textbox');
324
+ return [4 /*yield*/, user.click(inputs[0])];
325
+ case 1:
326
+ _a.sent();
327
+ expect(typeAheadSearch).toBeCalledWith([{ label: 'Address', uri: 'configuration/entityTypes/Location' }], '', {
328
+ globalFilter: '',
329
+ max: 20,
330
+ searchOptions: '',
331
+ sendMasked: true
332
+ });
333
+ return [2 /*return*/];
334
+ }
335
+ });
336
+ }); });
278
337
  });
@@ -12,10 +12,10 @@ var __assign = (this && this.__assign) || function () {
12
12
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
13
13
  import i18n from 'ui-i18n';
14
14
  import classnames from 'classnames';
15
- import { always, assoc, concat, differenceWith, equals, forEach, map, path, pick, pipe, prop, propEq, when, uniq, curry } from 'ramda';
15
+ import { always, assoc, concat, differenceWith, equals, forEach, map, path, pick, pipe, prop, propEq, when, uniq, curry, values, flatten, any } from 'ramda';
16
16
  import Button from '@mui/material/Button';
17
17
  import Typography from '@mui/material/Typography';
18
- import { createTemporaryEntity, findRelatedTemporaryEntities, getActivenessAttributes, getCreatableAttributeTypes, getEntityType, getErrorMessage, getErrorId, omitMarks, relationEditorAttributeTypesSelectionStrategy, validateConnection, updateConnectionEntityLabel, isTempUri, isEmptyValue, getRelationAttributesList, getDefaultRelationTypeObject, getInOutRelations, isSuggestMode, isAttributeTypeError, getRelationUriFromConnection, getRelationEditorActiveError, getRelationAttributesFromConnection, getEntityUriFromConnection, evaluateErrorPath, AttributeValuePathItemType, getAllRelationEditorActiveErrors } from '@reltio/mdm-sdk';
18
+ import { createTemporaryEntity, findRelatedTemporaryEntities, getActivenessAttributes, getCreatableAttributeTypes, getEntityType, getErrorMessage, getErrorId, omitMarks, relationEditorAttributeTypesSelectionStrategy, validateConnection, updateConnectionEntityLabel, isTempUri, isEmptyValue, getRelationAttributesList, getDefaultRelationTypeObject, getInOutRelations, isSuggestMode, isAttributeTypeError, getRelationUriFromConnection, getRelationEditorActiveError, getRelationAttributesFromConnection, getEntityUriFromConnection, evaluateErrorPath, AttributeValuePathItemType, getAllRelationEditorActiveErrors, isAttributeHasMaskedValue } from '@reltio/mdm-sdk';
19
19
  import { ConnectionRelationTypeSelector } from '../ConnectionRelationTypeSelector';
20
20
  import { ErrorWrapper } from '../ErrorWrapper';
21
21
  import { EntitySelector } from '../EntitySelector';
@@ -33,9 +33,10 @@ var areRelatedEntitiesChanged = function (initial, actual) {
33
33
  var emptyHiddenAttributes = {};
34
34
  var RelationEditor = function (_a) {
35
35
  var _b;
36
+ var _c, _d;
36
37
  var connection = _a.connection, config = _a.config, mode = _a.mode, metadata = _a.metadata, highlightedError = _a.highlightedError;
37
38
  var styles = useStyles();
38
- var _c = connection.relation, relationType = _c.relationType, direction = _c.direction;
39
+ var _e = connection.relation, relationType = _e.relationType, direction = _e.direction;
39
40
  var isNew = connection.isNew;
40
41
  var entityUri = getEntityUriFromConnection(connection);
41
42
  var relationUri = getRelationUriFromConnection(connection);
@@ -66,8 +67,8 @@ var RelationEditor = function (_a) {
66
67
  var allRelationEditorErrors = getAllRelationEditorActiveErrors(connection, profileErrors);
67
68
  var modifiedEntity = isTempEntity ? mdmModifiedEntity : null;
68
69
  var allModifiedEntities = isTempEntity ? mdmAllModifiedEntities : null;
69
- var _d = useScrollToAttributeError({ highlightedError: highlightedError, isSimple: true }), ref = _d.ref, errorClassName = _d.errorClassName;
70
- var _e = useMemo(function () {
70
+ var _f = useScrollToAttributeError({ highlightedError: highlightedError, isSimple: true }), ref = _f.ref, errorClassName = _f.errorClassName;
71
+ var _g = useMemo(function () {
71
72
  return getInOutRelations({
72
73
  content: connection.parentEntityUri
73
74
  ? config.contentSecondLevel
@@ -77,7 +78,7 @@ var RelationEditor = function (_a) {
77
78
  mode: mode,
78
79
  metadata: metadata
79
80
  });
80
- }, [config, direction, relationType, mode, metadata, connection.parentEntityUri]), _f = _e.inRelations, inRelationTypes = _f === void 0 ? [] : _f, _g = _e.outRelations, outRelationTypes = _g === void 0 ? [] : _g;
81
+ }, [config, direction, relationType, mode, metadata, connection.parentEntityUri]), _h = _g.inRelations, inRelationTypes = _h === void 0 ? [] : _h, _j = _g.outRelations, outRelationTypes = _j === void 0 ? [] : _j;
81
82
  var firstLevelRelationAttrTypes = useMemo(function () { return getRelationAttributesList(metadata, relationType); }, [relationType, metadata]);
82
83
  var attributeListEntity = useMemo(function () { return (__assign({ attributes: __assign({}, getRelationAttributesFromConnection(connection)) }, getActivenessAttributes(connection.relation))); }, [connection]);
83
84
  var relatedTempEntities = useMemo(function () { return findRelatedTemporaryEntities(allModifiedEntities, modifiedEntity); }, [allModifiedEntities, modifiedEntity]);
@@ -187,6 +188,7 @@ var RelationEditor = function (_a) {
187
188
  }
188
189
  return content.entityTypes;
189
190
  }, [config, connection.parentEntityUri]);
191
+ var isEntityHasMaskedAttrValue = pipe(values, flatten, any(isAttributeHasMaskedValue))(((_d = (_c = connection.entity) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.attributes) || {});
190
192
  return (React.createElement(React.Fragment, null,
191
193
  React.createElement("div", { className: styles.editor },
192
194
  React.createElement(Typography, { className: styles.title }, isNew ? i18n.text('Add new item') : i18n.text('Edit item')),
@@ -197,7 +199,7 @@ var RelationEditor = function (_a) {
197
199
  React.createElement(EntitySelector, { className: classnames(styles.item, (_b = {},
198
200
  _b[styles.dense] = errorMessage ||
199
201
  (connection.entity && isTempUri(connection.entity.entityUri)),
200
- _b)), entity: connection.entity || {}, entityTypesUris: getEntityTypesUris() || [], globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: canCreateNewEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: relationEditorAttributeTypesSelectionStrategy }))),
202
+ _b)), entity: connection.entity || {}, entityTypesUris: getEntityTypesUris() || [], globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: canCreateNewEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: relationEditorAttributeTypesSelectionStrategy, isMasked: isEntityHasMaskedAttrValue }))),
201
203
  React.createElement(HiddenAttributesContext.Provider, { value: emptyHiddenAttributes },
202
204
  React.createElement(EditModeAttributesList, { className: styles.item, attrTypes: firstLevelRelationAttrTypes, entity: attributeListEntity, showEmptyEditors: true, mode: mode, parentUri: relationUri, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute }))))),
203
205
  React.createElement("div", { className: styles.actionButtons },
@@ -7,6 +7,7 @@ type Props = InputProps & {
7
7
  rootRef?: React.MutableRefObject<HTMLInputElement>;
8
8
  height: number;
9
9
  placeholder?: string;
10
+ endAdornmentContent?: React.ReactNode;
10
11
  };
11
- declare const _default: React.MemoExoticComponent<({ value, autofocus, onSearch, rootRef, classes, height, placeholder, ...otherProps }: Props) => JSX.Element>;
12
+ declare const _default: React.MemoExoticComponent<({ value, autofocus, onSearch, rootRef, classes, height, placeholder, endAdornmentContent, ...otherProps }: Props) => JSX.Element>;
12
13
  export default _default;
@@ -32,13 +32,15 @@ import { getValue } from '../helpers/events';
32
32
  import { SmallIconButton } from '../SmallIconButton';
33
33
  import { useStyles } from './styles';
34
34
  var SearchInput = function (_a) {
35
- var value = _a.value, autofocus = _a.autofocus, _b = _a.onSearch, onSearch = _b === void 0 ? identity : _b, rootRef = _a.rootRef, _c = _a.classes, classes = _c === void 0 ? {} : _c, height = _a.height, _d = _a.placeholder, placeholder = _d === void 0 ? i18n.text('Search') : _d, otherProps = __rest(_a, ["value", "autofocus", "onSearch", "rootRef", "classes", "height", "placeholder"]);
35
+ var value = _a.value, autofocus = _a.autofocus, _b = _a.onSearch, onSearch = _b === void 0 ? identity : _b, rootRef = _a.rootRef, _c = _a.classes, classes = _c === void 0 ? {} : _c, height = _a.height, _d = _a.placeholder, placeholder = _d === void 0 ? i18n.text('Search') : _d, endAdornmentContent = _a.endAdornmentContent, otherProps = __rest(_a, ["value", "autofocus", "onSearch", "rootRef", "classes", "height", "placeholder", "endAdornmentContent"]);
36
36
  var styles = useStyles({ height: height });
37
37
  var _e = useState(''), localValue = _e[0], setLocalValue = _e[1];
38
38
  var updateValue = pipe(tap(onSearch), setLocalValue);
39
39
  var clearValue = function () { return updateValue(''); };
40
40
  var inputValue = isNil(value) ? localValue : value;
41
41
  return (React.createElement(Input, __assign({ startAdornment: React.createElement(InputAdornment, { position: "start" },
42
- React.createElement(SearchIcon, { className: styles.icon })), endAdornment: React.createElement(InputAdornment, { position: "end" }, inputValue.length > 0 && (React.createElement(SmallIconButton, { icon: CloseIcon, className: styles.clearButton, onClick: clearValue }))), autoFocus: autofocus, classes: __assign(__assign({}, classes), { input: classNames(styles.input, classes.input), root: classNames(styles.container, classes.root) }), placeholder: placeholder, value: inputValue, onChange: pipe(getValue, updateValue), disableUnderline: true, ref: rootRef }, otherProps)));
42
+ React.createElement(SearchIcon, { className: styles.icon })), endAdornment: React.createElement(InputAdornment, { position: "end" },
43
+ inputValue.length > 0 && (React.createElement(SmallIconButton, { icon: CloseIcon, className: styles.clearButton, onClick: clearValue })),
44
+ endAdornmentContent), autoFocus: autofocus, classes: __assign(__assign({}, classes), { input: classNames(styles.input, classes.input), root: classNames(styles.container, classes.root) }), placeholder: placeholder, value: inputValue, onChange: pipe(getValue, updateValue), disableUnderline: true, ref: rootRef }, otherProps)));
43
45
  };
44
46
  export default memo(SearchInput);
@@ -9,51 +9,131 @@ 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
  import React from 'react';
13
- import { shallow, mount } from 'enzyme';
14
- import Input from '@mui/material/Input';
15
- import { SmallIconButton } from '../SmallIconButton';
49
+ import { render, screen } from '@testing-library/react';
50
+ import userEvent from '@testing-library/user-event';
16
51
  import SearchInput from './SearchInput';
52
+ import { getMuiIconByName } from '../test-utils';
17
53
  describe('SearchInput tests', function () {
54
+ var onSearch = jest.fn();
18
55
  var defaultProps = {
19
56
  value: '',
20
57
  autofocus: true,
21
- onSearch: function () { },
58
+ onSearch: onSearch,
22
59
  height: 40
23
60
  };
24
- it('should render all components', function () {
25
- var component = mount(React.createElement(SearchInput, __assign({}, defaultProps)));
26
- expect(component.find(Input)).toHaveLength(1);
27
- expect(component.find('svg')).toHaveLength(1);
28
- expect(component.find(Input).prop('placeholder')).toEqual('Search');
29
- });
30
- it('should call onSearch prop on change', function () {
31
- var onSearch = jest.fn();
32
- var component = shallow(React.createElement(SearchInput, __assign({}, defaultProps, { onSearch: onSearch })));
33
- var input = component.find(Input);
34
- input.simulate('change', { target: { value: 'test' } });
35
- expect(onSearch).toBeCalledWith('test');
36
- });
37
- it('should call onSearch prop on clear input', function () {
38
- var onSearch = jest.fn();
39
- var component = mount(React.createElement(SearchInput, __assign({}, defaultProps, { onSearch: onSearch, value: 'test' })));
40
- component.find(SmallIconButton).find('button').simulate('click');
41
- expect(onSearch).toBeCalledWith('');
61
+ var setUp = function (props) {
62
+ if (props === void 0) { props = defaultProps; }
63
+ var user = userEvent.setup();
64
+ return __assign({ user: user }, render(React.createElement(SearchInput, __assign({}, props))));
65
+ };
66
+ afterEach(function () {
67
+ jest.clearAllMocks();
42
68
  });
43
- it('should not fail when onSearch prop is undefined', function () {
44
- var component = shallow(React.createElement(SearchInput, __assign({}, defaultProps)));
45
- var input = component.find(Input);
46
- input.simulate('change', { target: { value: 'test' } });
69
+ it('should render all components', function () {
70
+ setUp();
71
+ expect(screen.getByRole('textbox')).toBeInTheDocument();
72
+ expect(screen.getByPlaceholderText('Search')).toBeInTheDocument();
73
+ expect(getMuiIconByName('Search')).toBeInTheDocument();
47
74
  });
48
- it('should forward props to Input', function () {
49
- var onKeyDown = jest.fn();
50
- var onFocus = jest.fn();
51
- var component = shallow(React.createElement(SearchInput, __assign({}, defaultProps, { fullWidth: true, onFocus: onFocus, onKeyDown: onKeyDown })));
52
- var input = component.find(Input);
53
- expect(input.props()).toMatchObject({
54
- fullWidth: true,
55
- onKeyDown: onKeyDown,
56
- onFocus: onFocus
75
+ it('should call onSearch prop on change', function () { return __awaiter(void 0, void 0, void 0, function () {
76
+ var user, searchValue;
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
79
+ case 0:
80
+ user = setUp(__assign(__assign({}, defaultProps), { value: null })).user;
81
+ searchValue = 'searchValue';
82
+ return [4 /*yield*/, user.type(screen.getByRole('textbox'), searchValue)];
83
+ case 1:
84
+ _a.sent();
85
+ expect(onSearch).toHaveBeenLastCalledWith(searchValue);
86
+ return [2 /*return*/];
87
+ }
88
+ });
89
+ }); });
90
+ it('should call onSearch prop on clear input', function () { return __awaiter(void 0, void 0, void 0, function () {
91
+ var user;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0:
95
+ user = setUp(__assign(__assign({}, defaultProps), { value: 'test' })).user;
96
+ return [4 /*yield*/, user.click(screen.getByRole('button'))];
97
+ case 1:
98
+ _a.sent();
99
+ expect(onSearch).toBeCalledWith('');
100
+ return [2 /*return*/];
101
+ }
102
+ });
103
+ }); });
104
+ it('should not fail when onSearch prop is undefined', function () { return __awaiter(void 0, void 0, void 0, function () {
105
+ var user;
106
+ return __generator(this, function (_a) {
107
+ switch (_a.label) {
108
+ case 0:
109
+ user = setUp().user;
110
+ return [4 /*yield*/, user.type(screen.getByRole('textbox'), 'q')];
111
+ case 1:
112
+ _a.sent();
113
+ return [2 /*return*/];
114
+ }
115
+ });
116
+ }); });
117
+ it('should forward props to Input', function () { return __awaiter(void 0, void 0, void 0, function () {
118
+ var onKeyDown, onFocus, user;
119
+ return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0:
122
+ onKeyDown = jest.fn();
123
+ onFocus = jest.fn();
124
+ user = setUp(__assign(__assign({}, defaultProps), { fullWidth: true, onKeyDown: onKeyDown, onFocus: onFocus })).user;
125
+ return [4 /*yield*/, user.type(screen.getByRole('textbox'), 'q')];
126
+ case 1:
127
+ _a.sent();
128
+ expect(onKeyDown).toHaveBeenCalled();
129
+ expect(onFocus).toHaveBeenCalled();
130
+ return [2 /*return*/];
131
+ }
57
132
  });
133
+ }); });
134
+ it('should use provided endAdornmentContent', function () {
135
+ var endAdornmentContent = React.createElement("div", null, "testContent");
136
+ setUp(__assign(__assign({}, defaultProps), { endAdornmentContent: endAdornmentContent }));
137
+ expect(screen.getByText('testContent')).toBeInTheDocument();
58
138
  });
59
139
  });
@@ -51,6 +51,7 @@ import { render, screen } from '@testing-library/react';
51
51
  import userEvent from '@testing-library/user-event';
52
52
  import * as mdmSdk from '@reltio/mdm-sdk';
53
53
  import { MaskedAttributesProvider } from '../contexts/MaskedAttributesContext';
54
+ import { MdmModuleProvider } from '../contexts/MdmModuleContext';
54
55
  import { SimpleAttribute } from './SimpleAttribute';
55
56
  jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getUnmaskedAttributeValue: jest.fn() })); });
56
57
  describe('masking/unmasking behaviour', function () {
@@ -66,10 +67,15 @@ describe('masking/unmasking behaviour', function () {
66
67
  var setUp = function (isMaskingNeeded) {
67
68
  if (isMaskingNeeded === void 0) { isMaskingNeeded = true; }
68
69
  var attributeType = isMaskingNeeded ? defaultAttributeType : dissoc('masking', defaultAttributeType);
69
- var container = render(React.createElement(MaskedAttributesProvider, null,
70
- React.createElement(SimpleAttribute, { attributeType: attributeType, attributeValue: defaultAttributeValue }))).container;
70
+ var Providers = function (_a) {
71
+ var children = _a.children;
72
+ return (React.createElement(MdmModuleProvider, { values: { mode: mdmSdk.Mode.Viewing } },
73
+ React.createElement(MaskedAttributesProvider, null, children)));
74
+ };
71
75
  var user = userEvent.setup();
72
- return { container: container, user: user };
76
+ return __assign({ user: user }, render(React.createElement(SimpleAttribute, { attributeType: attributeType, attributeValue: defaultAttributeValue }), {
77
+ wrapper: Providers
78
+ }));
73
79
  };
74
80
  it('should not render MaskingSwitcher if attribute should not be masked', function () {
75
81
  var container = setUp(false).container;