@reltio/components 1.4.2184 → 1.4.2185
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/HierarchyNodeTitle/HierarchyNodeTitle.test.js +83 -1
- package/HierarchyNodeTitle/useEntityDetails.js +8 -4
- package/HierarchyNodeTitle/useEntityDetails.test.js +24 -9
- package/cjs/HierarchyNodeTitle/HierarchyNodeTitle.test.js +83 -1
- package/cjs/HierarchyNodeTitle/useEntityDetails.js +6 -2
- package/cjs/HierarchyNodeTitle/useEntityDetails.test.js +27 -9
- package/cjs/features/history/hooks/useHistorySlice.js +1 -1
- package/features/history/hooks/useHistorySlice.js +1 -1
- package/package.json +2 -2
|
@@ -63,7 +63,21 @@ var defaultProps = {
|
|
|
63
63
|
entityUri: 'entities/123',
|
|
64
64
|
anchorEl: document.createElement('div')
|
|
65
65
|
};
|
|
66
|
-
var
|
|
66
|
+
var getDefaultMetadata = function (masking) {
|
|
67
|
+
if (masking === void 0) { masking = false; }
|
|
68
|
+
return ({
|
|
69
|
+
entityTypes: [
|
|
70
|
+
{
|
|
71
|
+
uri: 'configuration/entityTypes/HCP',
|
|
72
|
+
attributes: [
|
|
73
|
+
__assign({ uri: 'configuration/entityTypes/HCP/attributes/FirstName', type: 'String', name: 'FirstName', label: 'First Name' }, (masking && { masking: { regexPattern: '.*' } }))
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
relationTypes: []
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
var defaultMdmValues = { uiPath: 'http://localhost:3000/ui/sokol/', metadata: getDefaultMetadata(), showMasking: true };
|
|
67
81
|
var defaultMdmActions = { openEntity: jest.fn() };
|
|
68
82
|
var setUp = function (_a) {
|
|
69
83
|
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.mdmActions, mdmActions = _e === void 0 ? defaultMdmActions : _e;
|
|
@@ -136,6 +150,9 @@ describe('Hierarchy node title tests', function () {
|
|
|
136
150
|
}); })];
|
|
137
151
|
case 2:
|
|
138
152
|
_a.sent();
|
|
153
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', {
|
|
154
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
155
|
+
});
|
|
139
156
|
within(tooltip).getByAltText('fallback entity avatar');
|
|
140
157
|
within(tooltip).getByText('perfect entity');
|
|
141
158
|
within(tooltip).getByText('ID:');
|
|
@@ -148,4 +165,69 @@ describe('Hierarchy node title tests', function () {
|
|
|
148
165
|
}
|
|
149
166
|
});
|
|
150
167
|
}); });
|
|
168
|
+
it('should pass sendMasked option to getEntity if metadata has masking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
+
var user, entityWithMasking;
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
switch (_a.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
user = setUp({ mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true) }) }).user;
|
|
174
|
+
return [4 /*yield*/, user.hover(screen.getByText('Title'))];
|
|
175
|
+
case 1:
|
|
176
|
+
_a.sent();
|
|
177
|
+
expect(screen.getByRole('tooltip')).toBeInTheDocument();
|
|
178
|
+
entityWithMasking = {
|
|
179
|
+
uri: 'entities/123',
|
|
180
|
+
label: '***t entity',
|
|
181
|
+
type: 'configuration/entityTypes/HCP'
|
|
182
|
+
};
|
|
183
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
184
|
+
return __generator(this, function (_a) {
|
|
185
|
+
switch (_a.label) {
|
|
186
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entityWithMasking)];
|
|
187
|
+
case 1:
|
|
188
|
+
_a.sent();
|
|
189
|
+
return [2 /*return*/];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); })];
|
|
193
|
+
case 2:
|
|
194
|
+
_a.sent();
|
|
195
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', {
|
|
196
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk,sendMasked'
|
|
197
|
+
});
|
|
198
|
+
return [2 /*return*/];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}); });
|
|
202
|
+
it('should not pass sendMasked option to getEntity if metadata has masking but showMasking is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
203
|
+
var user;
|
|
204
|
+
return __generator(this, function (_a) {
|
|
205
|
+
switch (_a.label) {
|
|
206
|
+
case 0:
|
|
207
|
+
user = setUp({
|
|
208
|
+
mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true), showMasking: false })
|
|
209
|
+
}).user;
|
|
210
|
+
return [4 /*yield*/, user.hover(screen.getByText('Title'))];
|
|
211
|
+
case 1:
|
|
212
|
+
_a.sent();
|
|
213
|
+
expect(screen.getByRole('tooltip')).toBeInTheDocument();
|
|
214
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
switch (_a.label) {
|
|
217
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entity)];
|
|
218
|
+
case 1:
|
|
219
|
+
_a.sent();
|
|
220
|
+
return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}); })];
|
|
224
|
+
case 2:
|
|
225
|
+
_a.sent();
|
|
226
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', {
|
|
227
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
228
|
+
});
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}); });
|
|
151
233
|
});
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { getEntity, debounce } from '@reltio/mdm-sdk';
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { getEntity, debounce, addGetEntityMaskingOptions } from '@reltio/mdm-sdk';
|
|
3
3
|
import { useSafePromise } from '../hooks/useSafePromise';
|
|
4
|
+
import { useMdmMetadata, useMdmShowMasking } from '../contexts/MdmModuleContext';
|
|
4
5
|
export var useEntityDetails = function (entityUri) {
|
|
5
6
|
var _a = useState(null), entityDetails = _a[0], setEntityDetails = _a[1];
|
|
6
7
|
var _b = useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
7
8
|
var safePromise = useSafePromise();
|
|
8
9
|
var cancelRequest = useCallback(function () { return safePromise(Promise.resolve()); }, [safePromise]);
|
|
10
|
+
var metadata = useMdmMetadata();
|
|
11
|
+
var showMasking = useMdmShowMasking();
|
|
12
|
+
var entityOptions = useMemo(function () { return addGetEntityMaskingOptions(metadata, { showMasking: showMasking, showAccess: false }); }, [metadata, showMasking]);
|
|
9
13
|
var showEntityDetails = useCallback(debounce(function () {
|
|
10
14
|
setIsLoading(true);
|
|
11
|
-
safePromise(getEntity(entityUri))
|
|
15
|
+
safePromise(getEntity(entityUri, entityOptions))
|
|
12
16
|
.then(setEntityDetails)
|
|
13
17
|
.catch(function (error) {
|
|
14
18
|
console.warn('Failed to load entity', error);
|
|
15
19
|
})
|
|
16
20
|
.finally(function () { return setIsLoading(false); });
|
|
17
|
-
}, 1000), [entityUri, safePromise]);
|
|
21
|
+
}, 1000), [entityUri, safePromise, entityOptions]);
|
|
18
22
|
var hideEntityDetails = useCallback(function () {
|
|
19
23
|
cancelRequest();
|
|
20
24
|
showEntityDetails.cancel();
|
|
@@ -45,12 +45,27 @@ 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
|
+
import React from 'react';
|
|
48
49
|
import { renderHook, act } from '@testing-library/react-hooks';
|
|
49
50
|
import { getEntity, debounce } from '@reltio/mdm-sdk';
|
|
51
|
+
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
50
52
|
import { useEntityDetails } from './useEntityDetails';
|
|
51
53
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getEntity: jest.fn(), debounce: jest.fn() })); });
|
|
54
|
+
var entity = { uri: 'entities/123', type: 'configuration/entityTypes/HCP' };
|
|
55
|
+
var defaultMdmValues = {
|
|
56
|
+
metadata: {
|
|
57
|
+
entityTypes: []
|
|
58
|
+
}
|
|
59
|
+
};
|
|
52
60
|
describe('useEntityDetails', function () {
|
|
53
|
-
var
|
|
61
|
+
var setUp = function (_a) {
|
|
62
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? entity.uri : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
|
|
63
|
+
var Providers = function (_a) {
|
|
64
|
+
var children = _a.children;
|
|
65
|
+
return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
|
|
66
|
+
};
|
|
67
|
+
return renderHook(useEntityDetails, { initialProps: props, wrapper: Providers });
|
|
68
|
+
};
|
|
54
69
|
beforeEach(function () {
|
|
55
70
|
getEntity.mockResolvedValue(entity);
|
|
56
71
|
debounce.mockImplementation(function (fn) { return jest.requireActual('@reltio/mdm-sdk').debounce(fn, 10); });
|
|
@@ -66,7 +81,7 @@ describe('useEntityDetails', function () {
|
|
|
66
81
|
return __generator(this, function (_a) {
|
|
67
82
|
switch (_a.label) {
|
|
68
83
|
case 0:
|
|
69
|
-
result =
|
|
84
|
+
result = setUp().result;
|
|
70
85
|
expect(result.current.isLoading).toBe(false);
|
|
71
86
|
act(function () {
|
|
72
87
|
result.current.showEntityDetails();
|
|
@@ -78,7 +93,7 @@ describe('useEntityDetails', function () {
|
|
|
78
93
|
});
|
|
79
94
|
expect(result.current.isLoading).toBe(true);
|
|
80
95
|
expect(result.current.entityDetails).toBe(null);
|
|
81
|
-
expect(getEntity).toHaveBeenCalledWith(entity.uri);
|
|
96
|
+
expect(getEntity).toHaveBeenCalledWith(entity.uri, { options: 'sendHidden,addRefAttrUriToCrosswalk' });
|
|
82
97
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
98
|
return __generator(this, function (_a) {
|
|
84
99
|
return [2 /*return*/, Promise.resolve()];
|
|
@@ -97,7 +112,7 @@ describe('useEntityDetails', function () {
|
|
|
97
112
|
return __generator(this, function (_a) {
|
|
98
113
|
switch (_a.label) {
|
|
99
114
|
case 0:
|
|
100
|
-
result =
|
|
115
|
+
result = setUp().result;
|
|
101
116
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
117
|
return __generator(this, function (_a) {
|
|
103
118
|
result.current.showEntityDetails();
|
|
@@ -121,7 +136,7 @@ describe('useEntityDetails', function () {
|
|
|
121
136
|
return __generator(this, function (_a) {
|
|
122
137
|
switch (_a.label) {
|
|
123
138
|
case 0:
|
|
124
|
-
result =
|
|
139
|
+
result = setUp().result;
|
|
125
140
|
act(function () {
|
|
126
141
|
result.current.showEntityDetails();
|
|
127
142
|
jest.runAllTimers();
|
|
@@ -144,7 +159,7 @@ describe('useEntityDetails', function () {
|
|
|
144
159
|
});
|
|
145
160
|
}); });
|
|
146
161
|
it('should clear timeout if hideEntityDetails has been called before request started', function () {
|
|
147
|
-
var result =
|
|
162
|
+
var result = setUp().result;
|
|
148
163
|
act(function () {
|
|
149
164
|
result.current.showEntityDetails();
|
|
150
165
|
});
|
|
@@ -167,12 +182,12 @@ describe('useEntityDetails', function () {
|
|
|
167
182
|
return __generator(this, function (_a) {
|
|
168
183
|
switch (_a.label) {
|
|
169
184
|
case 0:
|
|
170
|
-
result =
|
|
185
|
+
result = setUp().result;
|
|
171
186
|
act(function () {
|
|
172
187
|
result.current.showEntityDetails();
|
|
173
188
|
jest.runAllTimers();
|
|
174
189
|
});
|
|
175
|
-
expect(getEntity).toHaveBeenCalledWith('entities/123');
|
|
190
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', { options: 'sendHidden,addRefAttrUriToCrosswalk' });
|
|
176
191
|
expect(result.current.isLoading).toBe(true);
|
|
177
192
|
expect(result.current.entityDetails).toBe(null);
|
|
178
193
|
act(function () {
|
|
@@ -201,7 +216,7 @@ describe('useEntityDetails', function () {
|
|
|
201
216
|
case 0:
|
|
202
217
|
warnSpy = jest.spyOn(global.console, 'warn');
|
|
203
218
|
getEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
|
|
204
|
-
result =
|
|
219
|
+
result = setUp().result;
|
|
205
220
|
act(function () {
|
|
206
221
|
result.current.showEntityDetails();
|
|
207
222
|
jest.runAllTimers();
|
|
@@ -68,7 +68,21 @@ var defaultProps = {
|
|
|
68
68
|
entityUri: 'entities/123',
|
|
69
69
|
anchorEl: document.createElement('div')
|
|
70
70
|
};
|
|
71
|
-
var
|
|
71
|
+
var getDefaultMetadata = function (masking) {
|
|
72
|
+
if (masking === void 0) { masking = false; }
|
|
73
|
+
return ({
|
|
74
|
+
entityTypes: [
|
|
75
|
+
{
|
|
76
|
+
uri: 'configuration/entityTypes/HCP',
|
|
77
|
+
attributes: [
|
|
78
|
+
__assign({ uri: 'configuration/entityTypes/HCP/attributes/FirstName', type: 'String', name: 'FirstName', label: 'First Name' }, (masking && { masking: { regexPattern: '.*' } }))
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
relationTypes: []
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
var defaultMdmValues = { uiPath: 'http://localhost:3000/ui/sokol/', metadata: getDefaultMetadata(), showMasking: true };
|
|
72
86
|
var defaultMdmActions = { openEntity: jest.fn() };
|
|
73
87
|
var setUp = function (_a) {
|
|
74
88
|
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.mdmActions, mdmActions = _e === void 0 ? defaultMdmActions : _e;
|
|
@@ -141,6 +155,9 @@ describe('Hierarchy node title tests', function () {
|
|
|
141
155
|
}); })];
|
|
142
156
|
case 2:
|
|
143
157
|
_a.sent();
|
|
158
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
|
|
159
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
160
|
+
});
|
|
144
161
|
(0, react_2.within)(tooltip).getByAltText('fallback entity avatar');
|
|
145
162
|
(0, react_2.within)(tooltip).getByText('perfect entity');
|
|
146
163
|
(0, react_2.within)(tooltip).getByText('ID:');
|
|
@@ -153,4 +170,69 @@ describe('Hierarchy node title tests', function () {
|
|
|
153
170
|
}
|
|
154
171
|
});
|
|
155
172
|
}); });
|
|
173
|
+
it('should pass sendMasked option to getEntity if metadata has masking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var user, entityWithMasking;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
user = setUp({ mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true) }) }).user;
|
|
179
|
+
return [4 /*yield*/, user.hover(react_2.screen.getByText('Title'))];
|
|
180
|
+
case 1:
|
|
181
|
+
_a.sent();
|
|
182
|
+
expect(react_2.screen.getByRole('tooltip')).toBeInTheDocument();
|
|
183
|
+
entityWithMasking = {
|
|
184
|
+
uri: 'entities/123',
|
|
185
|
+
label: '***t entity',
|
|
186
|
+
type: 'configuration/entityTypes/HCP'
|
|
187
|
+
};
|
|
188
|
+
return [4 /*yield*/, (0, react_2.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
switch (_a.label) {
|
|
191
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entityWithMasking)];
|
|
192
|
+
case 1:
|
|
193
|
+
_a.sent();
|
|
194
|
+
return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); })];
|
|
198
|
+
case 2:
|
|
199
|
+
_a.sent();
|
|
200
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
|
|
201
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk,sendMasked'
|
|
202
|
+
});
|
|
203
|
+
return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}); });
|
|
207
|
+
it('should not pass sendMasked option to getEntity if metadata has masking but showMasking is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
+
var user;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
user = setUp({
|
|
213
|
+
mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true), showMasking: false })
|
|
214
|
+
}).user;
|
|
215
|
+
return [4 /*yield*/, user.hover(react_2.screen.getByText('Title'))];
|
|
216
|
+
case 1:
|
|
217
|
+
_a.sent();
|
|
218
|
+
expect(react_2.screen.getByRole('tooltip')).toBeInTheDocument();
|
|
219
|
+
return [4 /*yield*/, (0, react_2.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
switch (_a.label) {
|
|
222
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entity)];
|
|
223
|
+
case 1:
|
|
224
|
+
_a.sent();
|
|
225
|
+
return [2 /*return*/];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}); })];
|
|
229
|
+
case 2:
|
|
230
|
+
_a.sent();
|
|
231
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
|
|
232
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
233
|
+
});
|
|
234
|
+
return [2 /*return*/];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}); });
|
|
156
238
|
});
|
|
@@ -4,20 +4,24 @@ exports.useEntityDetails = void 0;
|
|
|
4
4
|
var react_1 = require("react");
|
|
5
5
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
6
6
|
var useSafePromise_1 = require("../hooks/useSafePromise");
|
|
7
|
+
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
7
8
|
var useEntityDetails = function (entityUri) {
|
|
8
9
|
var _a = (0, react_1.useState)(null), entityDetails = _a[0], setEntityDetails = _a[1];
|
|
9
10
|
var _b = (0, react_1.useState)(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
10
11
|
var safePromise = (0, useSafePromise_1.useSafePromise)();
|
|
11
12
|
var cancelRequest = (0, react_1.useCallback)(function () { return safePromise(Promise.resolve()); }, [safePromise]);
|
|
13
|
+
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
14
|
+
var showMasking = (0, MdmModuleContext_1.useMdmShowMasking)();
|
|
15
|
+
var entityOptions = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.addGetEntityMaskingOptions)(metadata, { showMasking: showMasking, showAccess: false }); }, [metadata, showMasking]);
|
|
12
16
|
var showEntityDetails = (0, react_1.useCallback)((0, mdm_sdk_1.debounce)(function () {
|
|
13
17
|
setIsLoading(true);
|
|
14
|
-
safePromise((0, mdm_sdk_1.getEntity)(entityUri))
|
|
18
|
+
safePromise((0, mdm_sdk_1.getEntity)(entityUri, entityOptions))
|
|
15
19
|
.then(setEntityDetails)
|
|
16
20
|
.catch(function (error) {
|
|
17
21
|
console.warn('Failed to load entity', error);
|
|
18
22
|
})
|
|
19
23
|
.finally(function () { return setIsLoading(false); });
|
|
20
|
-
}, 1000), [entityUri, safePromise]);
|
|
24
|
+
}, 1000), [entityUri, safePromise, entityOptions]);
|
|
21
25
|
var hideEntityDetails = (0, react_1.useCallback)(function () {
|
|
22
26
|
cancelRequest();
|
|
23
27
|
showEntityDetails.cancel();
|
|
@@ -46,13 +46,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
49
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = __importDefault(require("react"));
|
|
50
54
|
var react_hooks_1 = require("@testing-library/react-hooks");
|
|
51
55
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
56
|
+
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
52
57
|
var useEntityDetails_1 = require("./useEntityDetails");
|
|
53
58
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getEntity: jest.fn(), debounce: jest.fn() })); });
|
|
59
|
+
var entity = { uri: 'entities/123', type: 'configuration/entityTypes/HCP' };
|
|
60
|
+
var defaultMdmValues = {
|
|
61
|
+
metadata: {
|
|
62
|
+
entityTypes: []
|
|
63
|
+
}
|
|
64
|
+
};
|
|
54
65
|
describe('useEntityDetails', function () {
|
|
55
|
-
var
|
|
66
|
+
var setUp = function (_a) {
|
|
67
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? entity.uri : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
|
|
68
|
+
var Providers = function (_a) {
|
|
69
|
+
var children = _a.children;
|
|
70
|
+
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues }, children));
|
|
71
|
+
};
|
|
72
|
+
return (0, react_hooks_1.renderHook)(useEntityDetails_1.useEntityDetails, { initialProps: props, wrapper: Providers });
|
|
73
|
+
};
|
|
56
74
|
beforeEach(function () {
|
|
57
75
|
mdm_sdk_1.getEntity.mockResolvedValue(entity);
|
|
58
76
|
mdm_sdk_1.debounce.mockImplementation(function (fn) { return jest.requireActual('@reltio/mdm-sdk').debounce(fn, 10); });
|
|
@@ -68,7 +86,7 @@ describe('useEntityDetails', function () {
|
|
|
68
86
|
return __generator(this, function (_a) {
|
|
69
87
|
switch (_a.label) {
|
|
70
88
|
case 0:
|
|
71
|
-
result = (
|
|
89
|
+
result = setUp().result;
|
|
72
90
|
expect(result.current.isLoading).toBe(false);
|
|
73
91
|
(0, react_hooks_1.act)(function () {
|
|
74
92
|
result.current.showEntityDetails();
|
|
@@ -80,7 +98,7 @@ describe('useEntityDetails', function () {
|
|
|
80
98
|
});
|
|
81
99
|
expect(result.current.isLoading).toBe(true);
|
|
82
100
|
expect(result.current.entityDetails).toBe(null);
|
|
83
|
-
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith(entity.uri);
|
|
101
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith(entity.uri, { options: 'sendHidden,addRefAttrUriToCrosswalk' });
|
|
84
102
|
return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
103
|
return __generator(this, function (_a) {
|
|
86
104
|
return [2 /*return*/, Promise.resolve()];
|
|
@@ -99,7 +117,7 @@ describe('useEntityDetails', function () {
|
|
|
99
117
|
return __generator(this, function (_a) {
|
|
100
118
|
switch (_a.label) {
|
|
101
119
|
case 0:
|
|
102
|
-
result = (
|
|
120
|
+
result = setUp().result;
|
|
103
121
|
return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
122
|
return __generator(this, function (_a) {
|
|
105
123
|
result.current.showEntityDetails();
|
|
@@ -123,7 +141,7 @@ describe('useEntityDetails', function () {
|
|
|
123
141
|
return __generator(this, function (_a) {
|
|
124
142
|
switch (_a.label) {
|
|
125
143
|
case 0:
|
|
126
|
-
result = (
|
|
144
|
+
result = setUp().result;
|
|
127
145
|
(0, react_hooks_1.act)(function () {
|
|
128
146
|
result.current.showEntityDetails();
|
|
129
147
|
jest.runAllTimers();
|
|
@@ -146,7 +164,7 @@ describe('useEntityDetails', function () {
|
|
|
146
164
|
});
|
|
147
165
|
}); });
|
|
148
166
|
it('should clear timeout if hideEntityDetails has been called before request started', function () {
|
|
149
|
-
var result = (
|
|
167
|
+
var result = setUp().result;
|
|
150
168
|
(0, react_hooks_1.act)(function () {
|
|
151
169
|
result.current.showEntityDetails();
|
|
152
170
|
});
|
|
@@ -169,12 +187,12 @@ describe('useEntityDetails', function () {
|
|
|
169
187
|
return __generator(this, function (_a) {
|
|
170
188
|
switch (_a.label) {
|
|
171
189
|
case 0:
|
|
172
|
-
result = (
|
|
190
|
+
result = setUp().result;
|
|
173
191
|
(0, react_hooks_1.act)(function () {
|
|
174
192
|
result.current.showEntityDetails();
|
|
175
193
|
jest.runAllTimers();
|
|
176
194
|
});
|
|
177
|
-
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123');
|
|
195
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', { options: 'sendHidden,addRefAttrUriToCrosswalk' });
|
|
178
196
|
expect(result.current.isLoading).toBe(true);
|
|
179
197
|
expect(result.current.entityDetails).toBe(null);
|
|
180
198
|
(0, react_hooks_1.act)(function () {
|
|
@@ -203,7 +221,7 @@ describe('useEntityDetails', function () {
|
|
|
203
221
|
case 0:
|
|
204
222
|
warnSpy = jest.spyOn(global.console, 'warn');
|
|
205
223
|
mdm_sdk_1.getEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
|
|
206
|
-
result = (
|
|
224
|
+
result = setUp().result;
|
|
207
225
|
(0, react_hooks_1.act)(function () {
|
|
208
226
|
result.current.showEntityDetails();
|
|
209
227
|
jest.runAllTimers();
|
|
@@ -28,7 +28,7 @@ var useHistorySlice = function (_a) {
|
|
|
28
28
|
if (entityUri) {
|
|
29
29
|
if (historyEvent) {
|
|
30
30
|
setIsLoading(true);
|
|
31
|
-
var entityOptions = (0, mdm_sdk_1.addGetEntityMaskingOptions)(metadata, showMasking);
|
|
31
|
+
var entityOptions = (0, mdm_sdk_1.addGetEntityMaskingOptions)(metadata, { showMasking: showMasking });
|
|
32
32
|
safePromise(Promise.all([
|
|
33
33
|
(0, mdm_sdk_1.getEntityTimeSlice)(entityUri, aStamp, entityOptions),
|
|
34
34
|
bStamp && bStamp !== 1
|
|
@@ -25,7 +25,7 @@ export var useHistorySlice = function (_a) {
|
|
|
25
25
|
if (entityUri) {
|
|
26
26
|
if (historyEvent) {
|
|
27
27
|
setIsLoading(true);
|
|
28
|
-
var entityOptions = addGetEntityMaskingOptions(metadata, showMasking);
|
|
28
|
+
var entityOptions = addGetEntityMaskingOptions(metadata, { showMasking: showMasking });
|
|
29
29
|
safePromise(Promise.all([
|
|
30
30
|
getEntityTimeSlice(entityUri, aStamp, entityOptions),
|
|
31
31
|
bStamp && bStamp !== 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2185",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
12
12
|
"@googlemaps/markerclusterer": "^2.5.3",
|
|
13
13
|
"@react-sigma/core": "3.4.0",
|
|
14
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
14
|
+
"@reltio/mdm-sdk": "^1.4.1994",
|
|
15
15
|
"@vis.gl/react-google-maps": "^1.3.0",
|
|
16
16
|
"d3-cloud": "^1.2.5",
|
|
17
17
|
"d3-geo": "^2.0.1",
|