@reltio/components 1.4.2050 → 1.4.2052
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AttributeListItem/AttributeListItem.d.ts +1 -1
- package/ChartTooltip/ChartTooltip.js +3 -3
- package/ColumnsSettings/ColumnsSettings.d.ts +2 -1
- package/ColumnsSettings/ColumnsSettings.js +2 -2
- package/ColumnsSettings/ColumnsSettings.test.js +14 -0
- package/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
- package/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
- package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
- package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
- package/DropDownMenuButton/DropDownMenuButton.js +1 -1
- package/HOCs/withAsyncMount/withAsyncMount.test.js +52 -52
- package/IgnoreButton/IgnoreButton.spec.js +109 -20
- package/Image/Image.d.ts +1 -1
- package/Image/Image.js +8 -8
- package/Image/Image.test.js +46 -51
- package/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
- package/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
- package/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
- package/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
- package/ImageAttributesLine/ImageAttributesLine.js +1 -1
- package/ImageAttributesLine/ImageAttributesLine.test.js +187 -193
- package/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
- package/ImageAttributesLine/imageAttributeValues.test-data.js +22 -0
- package/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +315 -298
- package/ImageDetailsView/ImageDetailsView.test.js +529 -55
- package/ImageDetailsView/attributes.test-data.d.ts +4 -1
- package/ImageDetailsView/attributes.test-data.js +98 -1
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
- package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
- package/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
- package/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
- package/ImageDetailsView/helpers.test.js +4 -4
- package/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
- package/ImportButton/ImportButton.test.js +94 -24
- package/InlineAttributesList/InlineAttributesList.test.js +22 -62
- package/InlineAttributesList/attributes.test-data.d.ts +4 -2
- package/InlineAttributesList/attributes.test-data.js +40 -1
- package/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
- package/InlineAttributesPager/InlineAttributesPager.js +1 -4
- package/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
- package/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
- package/InlineComplexAttribute/InlineComplexAttribute.test.js +396 -182
- package/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
- package/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
- package/InlineReferenceAttribute/InlineReferenceAttribute.test.js +165 -107
- package/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +352 -346
- package/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +285 -194
- package/InternalLink/InternalLink.test.js +41 -11
- package/LookupEditor/LookupEditor.test.js +180 -44
- package/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
- package/MapChart/MapChart.js +3 -8
- package/MapChart/MapChart.test.js +152 -188
- package/MapChart/components/Legend/Legend.js +3 -3
- package/MaskingSwitcher/MaskingSwitcher.js +1 -1
- package/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
- package/SelectEditor/SelectEditor.d.ts +4 -10
- package/SelectEditor/SelectEditor.js +0 -4
- package/SelectEditor/SelectEditor.test.js +79 -9
- package/SelectionPopup/SelectionPopup.d.ts +2 -1
- package/SelectionPopup/SelectionPopup.js +3 -3
- package/SelectionPopup/SelectionPopup.spec.js +90 -30
- package/cjs/AttributeListItem/AttributeListItem.d.ts +1 -1
- package/cjs/ChartTooltip/ChartTooltip.js +3 -3
- package/cjs/ColumnsSettings/ColumnsSettings.d.ts +2 -1
- package/cjs/ColumnsSettings/ColumnsSettings.js +2 -2
- package/cjs/ColumnsSettings/ColumnsSettings.test.js +14 -0
- package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
- package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
- package/cjs/DropDownMenuButton/DropDownMenuButton.js +1 -1
- package/cjs/HOCs/withAsyncMount/withAsyncMount.test.js +56 -56
- package/cjs/IgnoreButton/IgnoreButton.spec.js +109 -20
- package/cjs/Image/Image.d.ts +1 -1
- package/cjs/Image/Image.js +8 -8
- package/cjs/Image/Image.test.js +46 -51
- package/cjs/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
- package/cjs/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
- package/cjs/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
- package/cjs/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
- package/cjs/ImageAttributesLine/ImageAttributesLine.js +1 -1
- package/cjs/ImageAttributesLine/ImageAttributesLine.test.js +195 -224
- package/cjs/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
- package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +23 -1
- package/cjs/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +316 -299
- package/cjs/ImageDetailsView/ImageDetailsView.test.js +529 -55
- package/cjs/ImageDetailsView/attributes.test-data.d.ts +4 -1
- package/cjs/ImageDetailsView/attributes.test-data.js +99 -2
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
- package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
- package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
- package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
- package/cjs/ImageDetailsView/helpers.test.js +3 -3
- package/cjs/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
- package/cjs/ImportButton/ImportButton.test.js +94 -24
- package/cjs/InlineAttributesList/InlineAttributesList.test.js +22 -62
- package/cjs/InlineAttributesList/attributes.test-data.d.ts +4 -2
- package/cjs/InlineAttributesList/attributes.test-data.js +41 -2
- package/cjs/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
- package/cjs/InlineAttributesPager/InlineAttributesPager.js +1 -4
- package/cjs/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
- package/cjs/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
- package/cjs/InlineComplexAttribute/InlineComplexAttribute.test.js +395 -204
- package/cjs/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
- package/cjs/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
- package/cjs/InlineReferenceAttribute/InlineReferenceAttribute.test.js +164 -106
- package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +351 -345
- package/cjs/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +307 -193
- package/cjs/InternalLink/InternalLink.test.js +40 -10
- package/cjs/LookupEditor/LookupEditor.test.js +178 -65
- package/cjs/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
- package/cjs/MapChart/MapChart.js +3 -8
- package/cjs/MapChart/MapChart.test.js +152 -188
- package/cjs/MapChart/components/Legend/Legend.js +3 -3
- package/cjs/MaskingSwitcher/MaskingSwitcher.js +1 -1
- package/cjs/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
- package/cjs/SelectEditor/SelectEditor.d.ts +4 -10
- package/cjs/SelectEditor/SelectEditor.js +0 -4
- package/cjs/SelectEditor/SelectEditor.test.js +79 -9
- package/cjs/SelectionPopup/SelectionPopup.d.ts +2 -1
- package/cjs/SelectionPopup/SelectionPopup.js +3 -3
- package/cjs/SelectionPopup/SelectionPopup.spec.js +90 -30
- package/cjs/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
- package/cjs/hooks/useAsyncMount/useAsyncMount.js +1 -1
- package/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
- package/hooks/useAsyncMount/useAsyncMount.js +1 -1
- package/package.json +1 -1
- package/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
- package/HOCs/withTableContext/withTableContext.test.js +0 -41
- package/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
- package/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -98
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -99
- package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
- package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -65
- package/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -306
- package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -134
- package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -99
- package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -36
- package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -161
- package/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
- package/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -76
- package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
- package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -104
- package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
- package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -114
- package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
- package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -177
- package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
- package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -52
- package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
- package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -37
- package/cjs/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
- package/cjs/HOCs/withTableContext/withTableContext.test.js +0 -46
- package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
- package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -103
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -104
- package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -70
- package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -311
- package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -139
- package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -104
- package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -41
- package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -166
- package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -81
- package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
- package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -109
- package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
- package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -119
- package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
- package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -182
- package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
- package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -57
- package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
- package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -42
|
@@ -107,6 +107,6 @@ export var ImageAttributesLine = function (_a) {
|
|
|
107
107
|
children,
|
|
108
108
|
attributeValues.slice(0, maxItems).map(renderImage(renderImageProps)),
|
|
109
109
|
hiddenItemsLength > 0 && (React.createElement("div", { className: styles.moreButtonContainer },
|
|
110
|
-
React.createElement("div", { className: styles.moreButton, onClick: function () { return handleOpenImageGalleryDialog(); } },
|
|
110
|
+
React.createElement("div", { "data-reltio-id": "more-image-button", className: styles.moreButton, onClick: function () { return handleOpenImageGalleryDialog(); } },
|
|
111
111
|
React.createElement(Typography, { className: styles.number }, "+".concat(hiddenItemsLength))))))));
|
|
112
112
|
};
|
|
@@ -45,36 +45,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
48
|
import React from 'react';
|
|
58
|
-
import {
|
|
59
|
-
import { act } from '
|
|
60
|
-
import
|
|
61
|
-
import {
|
|
62
|
-
import
|
|
63
|
-
import { ImageAttributesLine } from './ImageAttributesLine';
|
|
64
|
-
import { ImageAttributesGallery } from '../ImageAttributesGallery';
|
|
65
|
-
import { imageAttributeValues } from './imageAttributeValues.test-data';
|
|
49
|
+
import { mockResizeObserver } from 'jsdom-testing-mocks';
|
|
50
|
+
import { act, render, screen, waitForElementToBeRemoved } from '@testing-library/react';
|
|
51
|
+
import userEvent from '@testing-library/user-event';
|
|
52
|
+
import { insertDefaultImageByAttrUri, Mode } from '@reltio/mdm-sdk';
|
|
53
|
+
import { imageAttributeValues, attributeType } from './imageAttributeValues.test-data';
|
|
66
54
|
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
67
55
|
import { BlockImageGalleryDialogContext } from '../contexts/BlockImageGalleryDialogContext';
|
|
56
|
+
import { downloadImagesByURLs } from './helpers';
|
|
57
|
+
import { ImageAttributesLine } from './ImageAttributesLine';
|
|
68
58
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { insertDefaultImageByAttrUri: jest.fn() })); });
|
|
59
|
+
jest.mock('./helpers', function () { return (__assign(__assign({}, jest.requireActual('./helpers')), { downloadImagesByURLs: jest.fn() })); });
|
|
69
60
|
describe('ImageAttributesLine tests', function () {
|
|
70
|
-
var
|
|
61
|
+
var resizeObserver = mockResizeObserver();
|
|
62
|
+
var renderImage = function (_a) {
|
|
63
|
+
var onOpenImageGalleryDialog = _a.onOpenImageGalleryDialog, onDownload = _a.onDownload, onShareLink = _a.onShareLink, onSetAsDefault = _a.onSetAsDefault;
|
|
64
|
+
var renderImage = function (attributeValue) { return (React.createElement("div", { key: attributeValue.uri, "data-reltio-id": "image" },
|
|
65
|
+
React.createElement("div", { "data-reltio-id": "image-content", onClick: function () { return onOpenImageGalleryDialog(attributeValue.uri); } }),
|
|
66
|
+
onDownload && React.createElement("div", { "data-reltio-id": "download", onClick: function () { return onDownload([attributeValue.uri]); } }),
|
|
67
|
+
onShareLink && React.createElement("div", { "data-reltio-id": "share", onClick: function () { return onShareLink(attributeValue.uri); } }),
|
|
68
|
+
onSetAsDefault && (React.createElement("div", { "data-reltio-id": "set-as-default", onClick: function () { return onSetAsDefault(attributeValue); } })))); };
|
|
69
|
+
return renderImage;
|
|
70
|
+
};
|
|
71
71
|
var defaultProps = {
|
|
72
72
|
attributeValues: [],
|
|
73
|
-
attributeType:
|
|
73
|
+
attributeType: attributeType,
|
|
74
74
|
renderImage: renderImage
|
|
75
75
|
};
|
|
76
76
|
var defaultMdmValues = {
|
|
77
|
-
entity: { uri: '
|
|
77
|
+
entity: { uri: 'entities/123', type: 'configuration/entityTypes/HCP' },
|
|
78
|
+
modifiedEntities: {
|
|
79
|
+
'entities/123': { uri: 'entities/123', type: 'configuration/entityTypes/HCP', attributes: {} }
|
|
80
|
+
},
|
|
78
81
|
mode: Mode.Viewing
|
|
79
82
|
};
|
|
80
83
|
var defaultMdmActions = {
|
|
@@ -82,192 +85,186 @@ describe('ImageAttributesLine tests', function () {
|
|
|
82
85
|
setDefaultProfilePicForEntity: jest.fn()
|
|
83
86
|
};
|
|
84
87
|
var setUp = function (_a) {
|
|
85
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ?
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? {} : _d, _e = _b.mdmActions, mdmActions = _e === void 0 ? {} : _e, _f = _b.blockDialogContextValue, blockDialogContextValue = _f === void 0 ? false : _f;
|
|
89
|
+
var user = userEvent.setup();
|
|
90
|
+
var Providers = function (_a) {
|
|
91
|
+
var children = _a.children;
|
|
92
|
+
return (React.createElement(MdmModuleProvider, { values: __assign(__assign({}, defaultMdmValues), mdmValues), actions: __assign(__assign({}, defaultMdmActions), mdmActions) },
|
|
93
|
+
React.createElement(BlockImageGalleryDialogContext.Provider, { value: blockDialogContextValue }, children)));
|
|
90
94
|
};
|
|
91
|
-
return
|
|
95
|
+
return __assign({ user: user }, render(React.createElement(ImageAttributesLine, __assign({}, defaultProps, props)), { wrapper: Providers }));
|
|
92
96
|
};
|
|
93
|
-
beforeAll(function () {
|
|
94
|
-
jest.spyOn(imageAttributesHelpers, 'downloadImagesByURLs').mockImplementation(function () { });
|
|
95
|
-
insertDefaultImageByAttrUri.mockResolvedValue({ status: 'success' });
|
|
96
|
-
renderImage.mockReturnValue(function (_, i) { return React.createElement("div", { key: i, className: "Image" }); });
|
|
97
|
-
Object.assign(navigator, {
|
|
98
|
-
clipboard: {
|
|
99
|
-
writeText: jest.fn()
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
97
|
beforeEach(function () {
|
|
104
98
|
jest.clearAllMocks();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var component = setUp();
|
|
108
|
-
expect(component.find('.imageBox')).toHaveLength(1);
|
|
109
|
-
expect(component.find('.moreButton')).toHaveLength(0);
|
|
110
|
-
expect(component.find('.Image')).toHaveLength(0);
|
|
111
|
-
expect(component.find(ImageAttributesGallery)).toHaveLength(1);
|
|
99
|
+
downloadImagesByURLs.mockReturnValue(undefined);
|
|
100
|
+
insertDefaultImageByAttrUri.mockResolvedValue({ status: 'success' });
|
|
112
101
|
});
|
|
113
102
|
it('should resize component', function () {
|
|
114
|
-
var
|
|
115
|
-
|
|
103
|
+
var container = setUp({ props: { attributeValues: imageAttributeValues } }).container;
|
|
104
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
|
|
116
105
|
act(function () {
|
|
117
|
-
|
|
106
|
+
resizeObserver.resize();
|
|
118
107
|
});
|
|
119
|
-
|
|
120
|
-
expect(
|
|
121
|
-
|
|
108
|
+
expect(screen.getAllByTestId('image')).toHaveLength(3);
|
|
109
|
+
expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
|
|
110
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
|
|
122
111
|
act(function () {
|
|
123
|
-
|
|
112
|
+
resizeObserver.resize(container);
|
|
124
113
|
});
|
|
125
|
-
|
|
126
|
-
expect(
|
|
127
|
-
|
|
128
|
-
expect(component.find('.moreButton').text()).toBe('+1');
|
|
114
|
+
expect(screen.getAllByTestId('image')).toHaveLength(2);
|
|
115
|
+
expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1');
|
|
116
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
|
|
129
117
|
act(function () {
|
|
130
|
-
|
|
118
|
+
resizeObserver.resize(container);
|
|
131
119
|
});
|
|
132
|
-
|
|
133
|
-
expect(
|
|
134
|
-
|
|
135
|
-
expect(component.find('.moreButton').text()).toBe('+2');
|
|
120
|
+
expect(screen.getAllByTestId('image')).toHaveLength(2);
|
|
121
|
+
expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2');
|
|
122
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
|
|
136
123
|
act(function () {
|
|
137
|
-
|
|
124
|
+
resizeObserver.resize(container);
|
|
138
125
|
});
|
|
139
|
-
|
|
140
|
-
expect(
|
|
141
|
-
expect(component.find('.moreButton')).toHaveLength(1);
|
|
142
|
-
expect(component.find('.moreButton').text()).toBe('+1');
|
|
126
|
+
expect(screen.getAllByTestId('image')).toHaveLength(2);
|
|
127
|
+
expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1');
|
|
143
128
|
});
|
|
144
129
|
it('should recalculate max items to screen width after attributeValues.length changing', function () {
|
|
145
|
-
var
|
|
146
|
-
|
|
130
|
+
var _a = setUp({ props: { attributeValues: imageAttributeValues } }), container = _a.container, rerender = _a.rerender;
|
|
131
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
|
|
147
132
|
act(function () {
|
|
148
|
-
|
|
133
|
+
resizeObserver.resize();
|
|
149
134
|
});
|
|
150
|
-
|
|
151
|
-
expect(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
expect(
|
|
158
|
-
|
|
159
|
-
attributeValues: __spreadArray(__spreadArray([], imageAttributeValues, true), imageAttributeValues, true)
|
|
160
|
-
});
|
|
161
|
-
component.update();
|
|
162
|
-
expect(component.find('.Image')).toHaveLength(5);
|
|
163
|
-
expect(component.find('.moreButton')).toHaveLength(1);
|
|
164
|
-
expect(component.find('.moreButton').text()).toBe('+1');
|
|
135
|
+
expect(screen.getAllByTestId('image')).toHaveLength(3);
|
|
136
|
+
expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
|
|
137
|
+
rerender(React.createElement(ImageAttributesLine, __assign({}, defaultProps, { attributeValues: [imageAttributeValues[0]] })));
|
|
138
|
+
expect(screen.getAllByTestId('image')).toHaveLength(1);
|
|
139
|
+
expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
|
|
140
|
+
var newAttributeValues = Array.from({ length: 6 }, function (_, i) { return (__assign(__assign({}, imageAttributeValues[0]), { uri: imageAttributeValues[0].uri + i })); });
|
|
141
|
+
rerender(React.createElement(ImageAttributesLine, __assign({}, defaultProps, { attributeValues: newAttributeValues })));
|
|
142
|
+
expect(screen.getAllByTestId('image')).toHaveLength(5);
|
|
143
|
+
expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1');
|
|
165
144
|
});
|
|
166
|
-
it('should open ImageAttributesGallery when click to image or button if BlockImageGalleryDialogContext context has value
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
145
|
+
it('should open ImageAttributesGallery when click to image or button if BlockImageGalleryDialogContext context has falsy value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var _a, container, user;
|
|
147
|
+
return __generator(this, function (_b) {
|
|
148
|
+
switch (_b.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
_a = setUp({
|
|
151
|
+
props: { attributeValues: imageAttributeValues },
|
|
152
|
+
blockDialogContextValue: false
|
|
153
|
+
}), container = _a.container, user = _a.user;
|
|
154
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
155
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
|
|
156
|
+
act(function () {
|
|
157
|
+
resizeObserver.resize();
|
|
158
|
+
});
|
|
159
|
+
return [4 /*yield*/, user.click(screen.getAllByTestId('image-content')[0])];
|
|
160
|
+
case 1:
|
|
161
|
+
_b.sent();
|
|
162
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
163
|
+
expect(screen.getByTestId('thumbnails-container').childNodes).toHaveLength(3);
|
|
164
|
+
expect(screen.getByText('Gallery')).toBeInTheDocument();
|
|
165
|
+
expect(screen.getByText('Meta info')).toBeInTheDocument();
|
|
166
|
+
expect(screen.getAllByTestId('image-meta-info-item')[0].querySelector('.link')).toHaveAttribute('href', '/test.jpg');
|
|
167
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('Close'))];
|
|
168
|
+
case 2:
|
|
169
|
+
_b.sent();
|
|
170
|
+
return [4 /*yield*/, waitForElementToBeRemoved(screen.queryByRole('dialog'))];
|
|
171
|
+
case 3:
|
|
172
|
+
_b.sent();
|
|
173
|
+
return [2 /*return*/];
|
|
174
|
+
}
|
|
181
175
|
});
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
176
|
+
}); });
|
|
177
|
+
it('should not open ImageAttributesGallery when click to image if BlockImageGalleryDialogContext context has value is "true"', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
var _a, container, user;
|
|
179
|
+
return __generator(this, function (_b) {
|
|
180
|
+
switch (_b.label) {
|
|
181
|
+
case 0:
|
|
182
|
+
_a = setUp({
|
|
183
|
+
props: { attributeValues: imageAttributeValues },
|
|
184
|
+
blockDialogContextValue: true
|
|
185
|
+
}), container = _a.container, user = _a.user;
|
|
186
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
187
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
|
|
188
|
+
act(function () {
|
|
189
|
+
resizeObserver.resize();
|
|
190
|
+
});
|
|
191
|
+
return [4 /*yield*/, user.click(screen.getAllByTestId('image-content')[0])];
|
|
192
|
+
case 1:
|
|
193
|
+
_b.sent();
|
|
194
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
}
|
|
192
197
|
});
|
|
193
|
-
|
|
194
|
-
expect(component.find(ImageAttributesGallery).prop('open')).toBe(false);
|
|
195
|
-
renderImage.mock.calls[0][0].onOpenImageGalleryDialog();
|
|
196
|
-
expect(component.find(ImageAttributesGallery).prop('open')).toBe(false);
|
|
197
|
-
component.find('.moreButton').simulate('click');
|
|
198
|
-
expect(component.find(ImageAttributesGallery).prop('open')).toBe(false);
|
|
199
|
-
});
|
|
198
|
+
}); });
|
|
200
199
|
describe('actions', function () {
|
|
201
200
|
it('should call actions from Image component props', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
202
|
-
var
|
|
203
|
-
return __generator(this, function (
|
|
204
|
-
switch (
|
|
201
|
+
var _a, container, user, clipboardText;
|
|
202
|
+
return __generator(this, function (_b) {
|
|
203
|
+
switch (_b.label) {
|
|
205
204
|
case 0:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
component = setUp({ props: props });
|
|
205
|
+
_a = setUp({ props: { attributeValues: imageAttributeValues, overlay: true } }), container = _a.container, user = _a.user;
|
|
206
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
|
|
209
207
|
act(function () {
|
|
210
|
-
|
|
208
|
+
resizeObserver.resize();
|
|
211
209
|
});
|
|
212
|
-
|
|
213
|
-
firstImageProps = renderImage.mock.calls[0][0];
|
|
214
|
-
image = './image1.jpg';
|
|
215
|
-
images = [image];
|
|
216
|
-
firstImageProps.onDownload(images);
|
|
217
|
-
expect(imageAttributesHelpers.downloadImagesByURLs).toHaveBeenCalledWith(images);
|
|
218
|
-
firstImageProps.onShareLink(image);
|
|
219
|
-
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(image);
|
|
220
|
-
return [4 /*yield*/, firstImageProps.onSetAsDefault(imageAttributeValues[0])];
|
|
210
|
+
return [4 /*yield*/, user.click(screen.getAllByTestId('download')[0])];
|
|
221
211
|
case 1:
|
|
222
|
-
|
|
223
|
-
expect(
|
|
224
|
-
|
|
212
|
+
_b.sent();
|
|
213
|
+
expect(downloadImagesByURLs).toHaveBeenCalledWith([imageAttributeValues[0].uri]);
|
|
214
|
+
return [4 /*yield*/, user.click(screen.getAllByTestId('share')[0])];
|
|
215
|
+
case 2:
|
|
216
|
+
_b.sent();
|
|
217
|
+
return [4 /*yield*/, navigator.clipboard.readText()];
|
|
218
|
+
case 3:
|
|
219
|
+
clipboardText = _b.sent();
|
|
220
|
+
expect(clipboardText).toBe(imageAttributeValues[0].uri);
|
|
221
|
+
return [4 /*yield*/, user.click(screen.getAllByTestId('set-as-default')[0])];
|
|
222
|
+
case 4:
|
|
223
|
+
_b.sent();
|
|
224
|
+
expect(insertDefaultImageByAttrUri).toHaveBeenCalledWith('entities/123', imageAttributeValues[0].uri);
|
|
225
|
+
expect(defaultMdmActions.setDefaultProfilePicForEntity).toHaveBeenCalledWith(imageAttributeValues[0]);
|
|
225
226
|
return [2 /*return*/];
|
|
226
227
|
}
|
|
227
228
|
});
|
|
228
229
|
}); });
|
|
229
230
|
it('should call actions from ImageAttributesGallery props', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
230
|
-
var
|
|
231
|
-
return __generator(this, function (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
value: imageAttributeValues[0]
|
|
262
|
-
});
|
|
263
|
-
return [2 /*return*/];
|
|
231
|
+
var _a, container, user, clipboardText;
|
|
232
|
+
return __generator(this, function (_b) {
|
|
233
|
+
switch (_b.label) {
|
|
234
|
+
case 0:
|
|
235
|
+
_a = setUp({ props: { attributeValues: imageAttributeValues } }), container = _a.container, user = _a.user;
|
|
236
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
|
|
237
|
+
act(function () {
|
|
238
|
+
resizeObserver.resize();
|
|
239
|
+
});
|
|
240
|
+
return [4 /*yield*/, user.click(screen.getAllByTestId('image-content')[0])];
|
|
241
|
+
case 1:
|
|
242
|
+
_b.sent();
|
|
243
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
244
|
+
return [4 /*yield*/, user.click(screen.getByText('Set as default'))];
|
|
245
|
+
case 2:
|
|
246
|
+
_b.sent();
|
|
247
|
+
expect(insertDefaultImageByAttrUri).toHaveBeenCalledWith('entities/123', imageAttributeValues[0].uri);
|
|
248
|
+
expect(defaultMdmActions.setDefaultProfilePicForEntity).toHaveBeenCalledWith(imageAttributeValues[0]);
|
|
249
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('Copy link'))];
|
|
250
|
+
case 3:
|
|
251
|
+
_b.sent();
|
|
252
|
+
return [4 /*yield*/, navigator.clipboard.readText()];
|
|
253
|
+
case 4:
|
|
254
|
+
clipboardText = _b.sent();
|
|
255
|
+
expect(clipboardText).toBe('/test.jpg');
|
|
256
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('Download selected items'))];
|
|
257
|
+
case 5:
|
|
258
|
+
_b.sent();
|
|
259
|
+
expect(downloadImagesByURLs).toHaveBeenCalledWith(['/test.jpg']);
|
|
260
|
+
return [2 /*return*/];
|
|
261
|
+
}
|
|
264
262
|
});
|
|
265
263
|
}); });
|
|
266
264
|
it('should call "requestNextPageOfAttributeValues" prop if "paging" prop is defined', function () {
|
|
267
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { mode: Mode.Editing });
|
|
268
265
|
var requestNextPageOfAttributeValues = jest.fn();
|
|
269
266
|
var props = __assign(__assign({}, defaultProps), { attributeValues: imageAttributeValues, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, paging: { totalValues: 10, totalOvValues: 10 }, parentUri: 'entity/1' });
|
|
270
|
-
setUp({ props: props
|
|
267
|
+
setUp({ props: props });
|
|
271
268
|
expect(requestNextPageOfAttributeValues).toHaveBeenCalledWith({
|
|
272
269
|
parentUri: 'entity/1',
|
|
273
270
|
attributeTypeUri: defaultProps.attributeType.uri,
|
|
@@ -277,10 +274,9 @@ describe('ImageAttributesLine tests', function () {
|
|
|
277
274
|
});
|
|
278
275
|
});
|
|
279
276
|
it('should use showNonOv for determining defaultMaxValues param of requestNextPageOfAttributeValues', function () {
|
|
280
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { mode: Mode.Editing });
|
|
281
277
|
var requestNextPageOfAttributeValues = jest.fn();
|
|
282
278
|
var props = __assign(__assign({}, defaultProps), { attributeValues: imageAttributeValues, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, paging: { totalValues: 10, totalOvValues: 8 }, parentUri: 'entity/1', showNonOv: true });
|
|
283
|
-
setUp({ props: props
|
|
279
|
+
setUp({ props: props });
|
|
284
280
|
expect(requestNextPageOfAttributeValues).toHaveBeenCalledWith({
|
|
285
281
|
parentUri: 'entity/1',
|
|
286
282
|
attributeTypeUri: defaultProps.attributeType.uri,
|
|
@@ -291,35 +287,33 @@ describe('ImageAttributesLine tests', function () {
|
|
|
291
287
|
});
|
|
292
288
|
});
|
|
293
289
|
it('should calculate max items if countFixedItems more than 0', function () {
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
|
|
290
|
+
var container = setUp({
|
|
291
|
+
props: { attributeValues: imageAttributeValues, countFixedItems: 1 },
|
|
292
|
+
mdmValues: { mode: Mode.Editing }
|
|
293
|
+
}).container;
|
|
294
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
|
|
297
295
|
act(function () {
|
|
298
|
-
|
|
296
|
+
resizeObserver.resize();
|
|
299
297
|
});
|
|
300
|
-
|
|
301
|
-
expect(
|
|
302
|
-
|
|
298
|
+
expect(screen.getAllByTestId('image')).toHaveLength(3);
|
|
299
|
+
expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
|
|
300
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
|
|
303
301
|
act(function () {
|
|
304
|
-
|
|
302
|
+
resizeObserver.resize(container);
|
|
305
303
|
});
|
|
306
|
-
|
|
307
|
-
expect(
|
|
308
|
-
|
|
309
|
-
expect(component.find('.moreButton').text()).toBe('+2');
|
|
304
|
+
expect(screen.getAllByTestId('image')).toHaveLength(1);
|
|
305
|
+
expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2');
|
|
306
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
|
|
310
307
|
act(function () {
|
|
311
|
-
|
|
308
|
+
resizeObserver.resize(container);
|
|
312
309
|
});
|
|
313
|
-
|
|
314
|
-
expect(
|
|
315
|
-
|
|
316
|
-
expect(component.find('.moreButton').text()).toBe('+3');
|
|
310
|
+
expect(screen.getAllByTestId('image')).toHaveLength(1);
|
|
311
|
+
expect(screen.getByTestId('more-image-button')).toHaveTextContent('+3');
|
|
312
|
+
resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
|
|
317
313
|
act(function () {
|
|
318
|
-
|
|
314
|
+
resizeObserver.resize(container);
|
|
319
315
|
});
|
|
320
|
-
|
|
321
|
-
expect(
|
|
322
|
-
expect(component.find('.moreButton')).toHaveLength(1);
|
|
323
|
-
expect(component.find('.moreButton').text()).toBe('+2');
|
|
316
|
+
expect(screen.getAllByTestId('image')).toHaveLength(1);
|
|
317
|
+
expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2');
|
|
324
318
|
});
|
|
325
319
|
});
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import { ImageAttributeValue } from '@reltio/mdm-sdk';
|
|
2
|
+
export declare const attributeType: {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
uri: string;
|
|
6
|
+
attributes: {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
uri: string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
2
12
|
export declare const imageAttributeValues: ImageAttributeValue[];
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
export var attributeType = {
|
|
2
|
+
name: 'ImageGallery',
|
|
3
|
+
type: '',
|
|
4
|
+
uri: 'uri',
|
|
5
|
+
attributes: [
|
|
6
|
+
{
|
|
7
|
+
name: 'Url',
|
|
8
|
+
type: 'String',
|
|
9
|
+
uri: 'configuration/entityTypes/Series/attributes/ImageGallery/attributes/Url'
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'UrlThumbnail',
|
|
13
|
+
type: 'String',
|
|
14
|
+
uri: 'configuration/entityTypes/Series/attributes/ImageGallery/attributes/UrlThumbnail'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'CdnUrlThumbnail',
|
|
18
|
+
type: 'String',
|
|
19
|
+
uri: 'configuration/entityTypes/Series/attributes/ImageGallery/attributes/CdnUrlThumbnail'
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
1
23
|
export var imageAttributeValues = [
|
|
2
24
|
{
|
|
3
25
|
value: {
|