@reltio/components 1.4.2238 → 1.4.2240
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/DataTenantBadge/DataTenantBadge.js +3 -3
- package/DataTenantBadge/DataTenantBadge.test.js +3 -3
- package/DropDownSelector/DropDownSelector.d.ts +2 -1
- package/DropDownSelector/DropDownSelector.js +2 -2
- package/EntitySelector/EntitySelector.d.ts +2 -1
- package/EntitySelector/EntitySelector.js +2 -2
- package/EntityUriLink/EntityUriLink.d.ts +1 -0
- package/EntityUriLink/EntityUriLink.js +2 -2
- package/ProfileCard/ProfileCard.d.ts +2 -1
- package/ProfileCard/ProfileCard.js +2 -2
- package/ProfileCard/ProfileCard.test.js +19 -0
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.d.ts +2 -1
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.js +2 -2
- package/TenantsDropDownSelector/TenantsDropDownSelector.d.ts +2 -1
- package/TenantsDropDownSelector/TenantsDropDownSelector.js +2 -3
- package/TenantsDropDownSelector/TenantsDropDownSelector.spec.js +34 -3
- package/cjs/DataTenantBadge/DataTenantBadge.js +2 -2
- package/cjs/DataTenantBadge/DataTenantBadge.test.js +3 -3
- package/cjs/DropDownSelector/DropDownSelector.d.ts +2 -1
- package/cjs/DropDownSelector/DropDownSelector.js +2 -2
- package/cjs/EntitySelector/EntitySelector.d.ts +2 -1
- package/cjs/EntitySelector/EntitySelector.js +2 -2
- package/cjs/EntityUriLink/EntityUriLink.d.ts +1 -0
- package/cjs/EntityUriLink/EntityUriLink.js +2 -2
- package/cjs/ProfileCard/ProfileCard.d.ts +2 -1
- package/cjs/ProfileCard/ProfileCard.js +2 -2
- package/cjs/ProfileCard/ProfileCard.test.js +19 -0
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.d.ts +2 -1
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.js +2 -2
- package/cjs/TenantsDropDownSelector/TenantsDropDownSelector.d.ts +2 -1
- package/cjs/TenantsDropDownSelector/TenantsDropDownSelector.js +1 -2
- package/cjs/TenantsDropDownSelector/TenantsDropDownSelector.spec.js +34 -3
- package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/cjs/contexts/MdmModuleContext/hooks.js +6 -2
- package/cjs/contexts/MdmModuleContext/index.d.ts +1 -1
- package/cjs/contexts/MdmModuleContext/index.js +3 -2
- package/cjs/hooks/useMatchesLoader/useMatchesLoader.js +3 -1
- package/cjs/hooks/useMatchesLoader/useMatchesLoader.test.js +124 -22
- package/contexts/MdmModuleContext/context.d.ts +2 -0
- package/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/contexts/MdmModuleContext/hooks.js +3 -0
- package/contexts/MdmModuleContext/index.d.ts +1 -1
- package/contexts/MdmModuleContext/index.js +1 -1
- package/hooks/useMatchesLoader/useMatchesLoader.js +4 -2
- package/hooks/useMatchesLoader/useMatchesLoader.test.js +125 -23
- package/package.json +2 -2
|
@@ -9,12 +9,55 @@ 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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["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 { getTransitiveMatches } from '@reltio/mdm-sdk';
|
|
49
|
+
import { getTransitiveMatches, getMatchesForDataTenantEntity } from '@reltio/mdm-sdk';
|
|
14
50
|
import { renderHook } from '@testing-library/react-hooks';
|
|
15
51
|
import { MdmModuleProvider } from '../../contexts/MdmModuleContext';
|
|
16
52
|
import { useMatchesLoader } from './useMatchesLoader';
|
|
17
|
-
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getTransitiveMatches: jest.fn() })); });
|
|
53
|
+
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getTransitiveMatches: jest.fn(), getMatchesForDataTenantEntity: jest.fn(), isDataTenantEntity: jest.fn().mockImplementation(function (entity) { return !!entity.dataTenant; }) })); });
|
|
54
|
+
/**
|
|
55
|
+
* useMatchesLoader runs a useEffect that calls getMatches() on mount. getMatches() is async:
|
|
56
|
+
* it calls the SDK (getTransitiveMatches / getMatchesForDataTenantEntity), and when the
|
|
57
|
+
* promise resolves, it updates the state (setTotal, setMatches, setEntitiesMap), which triggers
|
|
58
|
+
* a re-render. waitForNextUpdate() waits for that next render, so assertions run after
|
|
59
|
+
* the async load has completed and we avoid races.
|
|
60
|
+
*/
|
|
18
61
|
describe('Test useMatchesLoader hook', function () {
|
|
19
62
|
var defaultProps = {
|
|
20
63
|
enabled: true,
|
|
@@ -44,37 +87,96 @@ describe('Test useMatchesLoader hook', function () {
|
|
|
44
87
|
}
|
|
45
88
|
]
|
|
46
89
|
}); };
|
|
47
|
-
var
|
|
90
|
+
var defaultDataTenantsWithIdBuilder = [{ id: 'tenantId4', name: 'idBuilderTenant', idBuilderSubscription: false }];
|
|
91
|
+
var defaultMdmValues = {
|
|
92
|
+
metadata: getMetadata(),
|
|
93
|
+
dataTenantsWithIdBuilder: defaultDataTenantsWithIdBuilder
|
|
94
|
+
};
|
|
48
95
|
var setUp = function (_a) {
|
|
49
96
|
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
|
|
50
97
|
var Providers = function (_a) {
|
|
51
98
|
var children = _a.children;
|
|
52
99
|
return React.createElement(MdmModuleProvider, { values: mdmValues }, children);
|
|
53
100
|
};
|
|
54
|
-
return
|
|
101
|
+
return renderHook(useMatchesLoader, { initialProps: props, wrapper: Providers });
|
|
55
102
|
};
|
|
56
103
|
afterEach(function () {
|
|
57
104
|
jest.clearAllMocks();
|
|
58
105
|
});
|
|
59
106
|
describe('Data masking behaviour', function () {
|
|
60
|
-
it('should call transitive endpoint without options if metadata doesnt have masked attribute', function () {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
107
|
+
it('should call transitive endpoint without options if metadata doesnt have masked attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
+
var waitForNextUpdate;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0:
|
|
112
|
+
waitForNextUpdate = setUp().waitForNextUpdate;
|
|
113
|
+
return [4 /*yield*/, waitForNextUpdate()];
|
|
114
|
+
case 1:
|
|
115
|
+
_a.sent();
|
|
116
|
+
expect(getTransitiveMatches).toHaveBeenCalledTimes(1);
|
|
117
|
+
expect(getTransitiveMatches).not.toHaveBeenCalledWith(expect.objectContaining({ options: expect.anything() }));
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}); });
|
|
122
|
+
it('should call transitive endpoint with sendMasked option if metadata has masked attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var metadata, waitForNextUpdate;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
metadata = getMetadata();
|
|
128
|
+
metadata.entityTypes[0].attributes[0].masking = { regexPattern: '.{4}$' };
|
|
129
|
+
waitForNextUpdate = setUp({ mdmValues: { metadata: metadata } }).waitForNextUpdate;
|
|
130
|
+
return [4 /*yield*/, waitForNextUpdate()];
|
|
131
|
+
case 1:
|
|
132
|
+
_a.sent();
|
|
133
|
+
expect(getTransitiveMatches).toHaveBeenCalledTimes(1);
|
|
134
|
+
expect(getTransitiveMatches).toHaveBeenCalledWith(expect.objectContaining({ options: 'sendMasked,showAccess' }));
|
|
135
|
+
return [2 /*return*/];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}); });
|
|
139
|
+
it('should not add sendMasked or showAccess option if showMasking configuration property is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
var metadata, waitForNextUpdate;
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
metadata = getMetadata();
|
|
145
|
+
metadata.entityTypes[0].attributes[0].masking = { regexPattern: '.{4}$' };
|
|
146
|
+
waitForNextUpdate = setUp({ mdmValues: { metadata: metadata, showMasking: false } }).waitForNextUpdate;
|
|
147
|
+
return [4 /*yield*/, waitForNextUpdate()];
|
|
148
|
+
case 1:
|
|
149
|
+
_a.sent();
|
|
150
|
+
expect(getTransitiveMatches).toHaveBeenCalledTimes(1);
|
|
151
|
+
expect(getTransitiveMatches).not.toHaveBeenCalledWith(expect.objectContaining({ options: expect.anything() }));
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}); });
|
|
79
156
|
});
|
|
157
|
+
it('should pass dataTenants to getMatchesForDataTenantEntity when entity has dataTenant', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
+
var dataTenantEntity, dataTenants, waitForNextUpdate;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
switch (_a.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
dataTenantEntity = {
|
|
163
|
+
uri: 'entities/dataTenantEntity',
|
|
164
|
+
type: 'configuration/entityTypes/HCP',
|
|
165
|
+
dataTenant: 'tenantId4',
|
|
166
|
+
attributes: {}
|
|
167
|
+
};
|
|
168
|
+
dataTenants = [{ id: 'tenantId4', name: 'tenant', idBuilderSubscription: false }];
|
|
169
|
+
waitForNextUpdate = setUp({
|
|
170
|
+
props: __assign(__assign({}, defaultProps), { entity: dataTenantEntity }),
|
|
171
|
+
mdmValues: __assign(__assign({}, defaultMdmValues), { dataTenantsWithIdBuilder: dataTenants })
|
|
172
|
+
}).waitForNextUpdate;
|
|
173
|
+
return [4 /*yield*/, waitForNextUpdate()];
|
|
174
|
+
case 1:
|
|
175
|
+
_a.sent();
|
|
176
|
+
expect(getMatchesForDataTenantEntity).toHaveBeenCalledTimes(1);
|
|
177
|
+
expect(getMatchesForDataTenantEntity).toHaveBeenCalledWith(expect.objectContaining({ dataTenants: dataTenants }));
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}); });
|
|
80
182
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2240",
|
|
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.2029",
|
|
15
15
|
"@vis.gl/react-google-maps": "^1.3.0",
|
|
16
16
|
"d3-cloud": "^1.2.5",
|
|
17
17
|
"d3-geo": "^2.0.1",
|