orc-shared 5.10.0-dev.1 → 5.10.0-dev.3

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.
@@ -116,6 +116,16 @@ var useStyles = exports.useStyles = (0, _styles.makeStyles)(function (theme) {
116
116
  "& + $track": {
117
117
  backgroundColor: "".concat(theme.palette.grey.borders, " !important")
118
118
  }
119
+ },
120
+ container: {
121
+ display: "flex",
122
+ flexDirection: "column"
123
+ },
124
+ errorText: {
125
+ marginTop: theme.spacing(0.5),
126
+ color: theme.palette.error.main,
127
+ fontSize: theme.typography.fieldLabelSize,
128
+ float: "left"
119
129
  }
120
130
  };
121
131
  });
@@ -130,6 +140,7 @@ var Switch = function Switch(_ref) {
130
140
  var value = (switchProps == null ? void 0 : switchProps.get(_SwitchProps.default.propNames.value)) || false;
131
141
  var onCaption = switchProps == null ? void 0 : switchProps.get(_SwitchProps.default.propNames.onCaption);
132
142
  var offCaption = switchProps == null ? void 0 : switchProps.get(_SwitchProps.default.propNames.offCaption);
143
+ var error = switchProps == null ? void 0 : switchProps.get(_SwitchProps.default.propNames.error);
133
144
  var disabled = (switchProps == null ? void 0 : switchProps.get(_SwitchProps.default.propNames.disabled)) || false;
134
145
  var readOnly = switchProps == null ? void 0 : switchProps.get(_SwitchProps.default.propNames.readOnly);
135
146
  var className = (switchProps == null ? void 0 : switchProps.get(_SwitchProps.default.propNames.className)) || "";
@@ -149,7 +160,7 @@ var Switch = function Switch(_ref) {
149
160
  checked: classes.checked,
150
161
  disabled: classes.disabled
151
162
  }, className);
152
- return /*#__PURE__*/_react.default.createElement(_Switch.default, {
163
+ var switchComponent = /*#__PURE__*/_react.default.createElement(_Switch.default, {
153
164
  disabled: disabled,
154
165
  classes: switchClasses,
155
166
  checked: value,
@@ -158,6 +169,11 @@ var Switch = function Switch(_ref) {
158
169
  },
159
170
  color: "primary"
160
171
  });
172
+ return error && /*#__PURE__*/_react.default.createElement("div", {
173
+ className: classes.container
174
+ }, switchComponent, /*#__PURE__*/_react.default.createElement("div", {
175
+ className: (0, _classnames.default)(classes.errorText)
176
+ }, error)) || switchComponent;
161
177
  };
162
178
  __signature__(Switch, "useIntl{{ formatMessage }}\nuseStyles{classes}", function () {
163
179
  return [_reactIntl.useIntl, useStyles];
@@ -35,6 +35,7 @@ var SwitchProps = /*#__PURE__*/function (_ComponentProps) {
35
35
  _this.componentProps.set(_this.constructor.propNames.readOnly, null);
36
36
  _this.componentProps.set(_this.constructor.propNames.className, null);
37
37
  _this.componentProps.set(_this.constructor.propNames.id, null);
38
+ _this.componentProps.set(_this.constructor.propNames.error, null);
38
39
  _this.componentProps.set(_this.constructor.propNames.metadata, null);
39
40
  _this._isSwitchProps = true;
40
41
  return _this;
@@ -57,6 +58,7 @@ _defineProperty(SwitchProps, "propNames", {
57
58
  readOnly: "readOnly",
58
59
  className: "className",
59
60
  id: "id",
61
+ error: "error",
60
62
  metadata: "metadata"
61
63
  });
62
64
  var isSwitchProps = exports.isSwitchProps = function isSwitchProps(value) {
@@ -49,11 +49,14 @@ var useMultipleFieldEditState = function useMultipleFieldEditState(entityId, sec
49
49
  var dispatch = (0, _useDispatchWithModulesData.useDispatchWithModulesData)();
50
50
  var mergedValidationRules = _objectSpread(_objectSpread({}, _modelValidationHelper.validationRules), extendedValidationRules);
51
51
  var modifiedStates = (0, _reactRedux.useSelector)((0, _view.getModifiedModels)(entityId))[sectionName] || {};
52
- var useDynamicFieldState = function useDynamicFieldState(id, fieldName, errorTypes) {
52
+ var useDynamicFieldState = function useDynamicFieldState(id, fieldName, errorTypes, fieldDependencies) {
53
53
  var _initialValues$id$fie, _initialValues$id, _modifiedStates$id$fi, _modifiedStates$id, _editState$value;
54
54
  if (errorTypes === void 0) {
55
55
  errorTypes = [];
56
56
  }
57
+ if (fieldDependencies === void 0) {
58
+ fieldDependencies = {};
59
+ }
57
60
  var keys = [id, fieldName];
58
61
  var initialValue = (_initialValues$id$fie = (_initialValues$id = initialValues[id]) == null ? void 0 : _initialValues$id[fieldName]) != null ? _initialValues$id$fie : "";
59
62
  var editState = (_modifiedStates$id$fi = (_modifiedStates$id = modifiedStates[id]) == null ? void 0 : _modifiedStates$id[fieldName]) != null ? _modifiedStates$id$fi : {};
@@ -65,17 +68,23 @@ var useMultipleFieldEditState = function useMultipleFieldEditState(entityId, sec
65
68
  var resetEditState = function resetEditState() {
66
69
  dispatch(_view2.setEditModelField, [keys, initialValue, initialValue, entityId, sectionName]);
67
70
  };
68
- var isEditStateValid = function isEditStateValid(value) {
71
+ var isEditStateValid = function isEditStateValid(value, dependencies) {
72
+ if (dependencies === void 0) {
73
+ dependencies = {};
74
+ }
69
75
  var valueToValidate = value != null ? value : editState.value;
70
76
  var hasAnyValidationErrors = false;
71
77
  errorTypes.forEach(function (errorType) {
72
- var isValid = mergedValidationRules[errorType](valueToValidate, id, fieldName);
78
+ var isValid = mergedValidationRules[errorType](valueToValidate, id, fieldName, _objectSpread(_objectSpread({}, fieldDependencies), dependencies));
73
79
  if (isValid === false) {
74
80
  dispatch(_view2.setEditModelFieldError, [keys, errorType, entityId, sectionName]);
75
81
  hasAnyValidationErrors = true;
76
82
  return;
77
83
  }
78
84
  });
85
+ if (!hasAnyValidationErrors) {
86
+ dispatch(_view2.removeEditModelFieldError, [keys, entityId, sectionName]);
87
+ }
79
88
  return !hasAnyValidationErrors;
80
89
  };
81
90
  return {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.variantPropertyMapKvaSelector = exports.variantPropertyKeyValuesSelector = exports.selectCurrentLookupDetails = exports.profileAttributeGroupsSelector = exports.productPropertyValuesSelector = exports.productPropertyValueSelector = exports.productPropertyMapSelector = exports.orderLookupsNextPageToLoad = exports.orderLookupsListCurrentInfo = exports.newProfileDefinitionNameSelector = exports.newProfileDefinitionInstanceSelector = exports.namedLookupValuesSelector = exports.namedLookupSelector = exports.namedLookupLocalizedValuesSelector = exports.namedLookupLocalizedSelector = exports.mappedOrderLookupsListSelector = exports.mappedLookupsListSelector = exports.mappedLookupListSelector = exports.mappedDefinitionsListSelector = exports.mappedDefinitionEntity = exports.mappedDefinitionAttributesSelector = exports.mappedCustomDefinitionsListSelector = exports.mappedBaseDefinitionsListSelector = exports.lookupsNextPageToLoad = exports.lookupsListSelector = exports.lookupsListCurrentInfo = exports.lookupSelector = exports.lookupExistAndIsActiveSelector = exports.lookupByNameSelector = exports.groupedCustomAttributesDefinitionSelector = exports.definitionEntityCustomAttributesSelector = exports.definitionEntityBaseAttributesSelector = exports.definitionEntity = exports.customProfileTypesSelector = exports.customAttributesSelector = exports.customAttributesDefinitionSelector = exports.baseAttributesSelector = void 0;
4
+ exports.variantPropertyMapKvaSelector = exports.variantPropertyKeyValuesSelector = exports.selectCurrentLookupDetails = exports.profileAttributeGroupsSelector = exports.productPropertyValuesSelector = exports.productPropertyValueSelector = exports.productPropertyMapSelector = exports.orderLookupsNextPageToLoad = exports.orderLookupsListCurrentInfo = exports.newProfileDefinitionNameSelector = exports.newProfileDefinitionInstanceSelector = exports.namedLookupsValuesSelector = exports.namedLookupValuesSelector = exports.namedLookupSelector = exports.namedLookupLocalizedValuesSelector = exports.namedLookupLocalizedSelector = exports.mappedOrderLookupsListSelector = exports.mappedLookupsListSelector = exports.mappedLookupListSelector = exports.mappedDefinitionsListSelector = exports.mappedDefinitionEntity = exports.mappedDefinitionAttributesSelector = exports.mappedCustomDefinitionsListSelector = exports.mappedBaseDefinitionsListSelector = exports.lookupsNextPageToLoad = exports.lookupsListSelector = exports.lookupsListCurrentInfo = exports.lookupSelector = exports.lookupExistAndIsActiveSelector = exports.lookupByNameSelector = exports.groupedCustomAttributesDefinitionSelector = exports.definitionEntityCustomAttributesSelector = exports.definitionEntityBaseAttributesSelector = exports.definitionEntity = exports.customProfileTypesSelector = exports.customAttributesSelector = exports.customAttributesDefinitionSelector = exports.baseAttributesSelector = void 0;
5
5
  var _reselect = require("reselect");
6
6
  var _immutable = _interopRequireDefault(require("immutable"));
7
7
  var _utils = require("../utils");
@@ -77,6 +77,19 @@ var namedLookupValuesSelector = exports.namedLookupValuesSelector = (0, _utils.m
77
77
  });
78
78
  });
79
79
  });
80
+ var namedLookupsValuesSelector = exports.namedLookupsValuesSelector = (0, _utils.memoize)(function (moduleName, lookupNames) {
81
+ return (0, _reselect.createSelector)(lookupSelector(moduleName), _locale.currentLocaleOrDefault, function (lookups, locale) {
82
+ var lookupsValues = {};
83
+ (0, _lodash.each)(lookupNames, function (name) {
84
+ var lookup = lookups.get(name);
85
+ if (!lookup) return;
86
+ lookupsValues[name] = lookup.get("values", _immutable.default.Map()).map(function (lookupValue) {
87
+ return (0, _setTranslationWithFallback.setTranslationWithFallbackField)(locale, lookupValue, "name", "displayName");
88
+ });
89
+ });
90
+ return _immutable.default.fromJS(lookupsValues);
91
+ });
92
+ });
80
93
  var selectCurrentLookupDetails = exports.selectCurrentLookupDetails = (0, _utils.memoize)(function (moduleName, lookupName) {
81
94
  return namedLookupSelector(moduleName, lookupName);
82
95
  });
@@ -364,6 +377,7 @@ var resolveProductPropertyValue = function resolveProductPropertyValue(property,
364
377
  reactHotLoader.register(lookupByNameSelector, "lookupByNameSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
365
378
  reactHotLoader.register(namedLookupSelector, "namedLookupSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
366
379
  reactHotLoader.register(namedLookupValuesSelector, "namedLookupValuesSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
380
+ reactHotLoader.register(namedLookupsValuesSelector, "namedLookupsValuesSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
367
381
  reactHotLoader.register(selectCurrentLookupDetails, "selectCurrentLookupDetails", "/home/vsts/work/1/s/src/selectors/metadata.js");
368
382
  reactHotLoader.register(namedLookupLocalizedSelector, "namedLookupLocalizedSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
369
383
  reactHotLoader.register(lookupExistAndIsActiveSelector, "lookupExistAndIsActiveSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
@@ -422,6 +436,7 @@ var resolveProductPropertyValue = function resolveProductPropertyValue(property,
422
436
  reactHotLoader.register(lookupByNameSelector, "lookupByNameSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
423
437
  reactHotLoader.register(namedLookupSelector, "namedLookupSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
424
438
  reactHotLoader.register(namedLookupValuesSelector, "namedLookupValuesSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
439
+ reactHotLoader.register(namedLookupsValuesSelector, "namedLookupsValuesSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
425
440
  reactHotLoader.register(selectCurrentLookupDetails, "selectCurrentLookupDetails", "/home/vsts/work/1/s/src/selectors/metadata.js");
426
441
  reactHotLoader.register(namedLookupLocalizedSelector, "namedLookupLocalizedSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
427
442
  reactHotLoader.register(lookupExistAndIsActiveSelector, "lookupExistAndIsActiveSelector", "/home/vsts/work/1/s/src/selectors/metadata.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.10.0-dev.1",
3
+ "version": "5.10.0-dev.3",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -87,6 +87,16 @@ export const useStyles = makeStyles(theme => ({
87
87
  backgroundColor: `${theme.palette.grey.borders} !important`,
88
88
  },
89
89
  },
90
+ container: {
91
+ display: "flex",
92
+ flexDirection: "column",
93
+ },
94
+ errorText: {
95
+ marginTop: theme.spacing(0.5),
96
+ color: theme.palette.error.main,
97
+ fontSize: theme.typography.fieldLabelSize,
98
+ float: "left",
99
+ },
90
100
  }));
91
101
 
92
102
  const Switch = ({ switchProps }) => {
@@ -100,6 +110,7 @@ const Switch = ({ switchProps }) => {
100
110
  const value = switchProps?.get(SwitchProps.propNames.value) || false;
101
111
  const onCaption = switchProps?.get(SwitchProps.propNames.onCaption);
102
112
  const offCaption = switchProps?.get(SwitchProps.propNames.offCaption);
113
+ const error = switchProps?.get(SwitchProps.propNames.error);
103
114
  const disabled = switchProps?.get(SwitchProps.propNames.disabled) || false;
104
115
  const readOnly = switchProps?.get(SwitchProps.propNames.readOnly);
105
116
  const className = switchProps?.get(SwitchProps.propNames.className) || "";
@@ -120,7 +131,7 @@ const Switch = ({ switchProps }) => {
120
131
  ...className,
121
132
  };
122
133
 
123
- return (
134
+ const switchComponent = (
124
135
  <SwitchMui
125
136
  disabled={disabled}
126
137
  classes={switchClasses}
@@ -129,6 +140,16 @@ const Switch = ({ switchProps }) => {
129
140
  color={"primary"}
130
141
  />
131
142
  );
143
+
144
+ return (
145
+ (error && (
146
+ <div className={classes.container}>
147
+ {switchComponent}
148
+ <div className={classNames(classes.errorText)}>{error}</div>
149
+ </div>
150
+ )) ||
151
+ switchComponent
152
+ );
132
153
  };
133
154
 
134
155
  export default Switch;
@@ -60,6 +60,29 @@ describe("Switch Component", () => {
60
60
  expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
61
61
  });
62
62
 
63
+ it("Renders Switch component with an error", () => {
64
+ const switchProps = new SwitchProps();
65
+
66
+ switchProps.set(SwitchProps.propNames.update, update);
67
+ switchProps.set(SwitchProps.propNames.value, true);
68
+ switchProps.set(SwitchProps.propNames.error, "an error");
69
+ switchProps.set(SwitchProps.propNames.onCaption, { id: "captionOn" });
70
+ switchProps.set(SwitchProps.propNames.offCaption, { id: "captionOff" });
71
+
72
+ const component = (
73
+ <IntlProvider messages={messages} locale="en-US">
74
+ <Switch switchProps={switchProps} />
75
+ </IntlProvider>
76
+ );
77
+
78
+ const mountedComponent = mount(component);
79
+ const expectedSwitch = <SwitchMUI checked={true} />;
80
+ const expectedError = <div>an error</div>;
81
+
82
+ expect(mountedComponent.containsMatchingElement(expectedSwitch), "to be truthy");
83
+ expect(mountedComponent.containsMatchingElement(expectedError), "to be truthy");
84
+ });
85
+
63
86
  it("Checkbox component handles check", () => {
64
87
  const switchProps = new SwitchProps();
65
88
 
@@ -10,6 +10,7 @@ class SwitchProps extends ComponentProps {
10
10
  readOnly: "readOnly",
11
11
  className: "className",
12
12
  id: "id",
13
+ error: "error",
13
14
  metadata: "metadata",
14
15
  };
15
16
 
@@ -23,6 +24,7 @@ class SwitchProps extends ComponentProps {
23
24
  this.componentProps.set(this.constructor.propNames.readOnly, null);
24
25
  this.componentProps.set(this.constructor.propNames.className, null);
25
26
  this.componentProps.set(this.constructor.propNames.id, null);
27
+ this.componentProps.set(this.constructor.propNames.error, null);
26
28
  this.componentProps.set(this.constructor.propNames.metadata, null);
27
29
 
28
30
  this._isSwitchProps = true;
@@ -11,6 +11,7 @@ describe("Switch Props", () => {
11
11
  "readOnly",
12
12
  "className",
13
13
  "id",
14
+ "error",
14
15
  "metadata",
15
16
  ];
16
17
 
@@ -27,6 +28,7 @@ describe("Switch Props", () => {
27
28
  "readOnly",
28
29
  "className",
29
30
  "id",
31
+ "error",
30
32
  "metadata",
31
33
  ];
32
34
 
@@ -1,7 +1,7 @@
1
1
  import { useSelector } from "react-redux";
2
2
  import { validationRules } from "../utils/modelValidationHelper";
3
3
  import { getModifiedModels } from "../selectors/view";
4
- import { setEditModelField, setEditModelFieldError } from "../actions/view";
4
+ import { setEditModelField, setEditModelFieldError, removeEditModelFieldError } from "../actions/view";
5
5
  import { useDispatchWithModulesData } from "./../hooks/useDispatchWithModulesData";
6
6
 
7
7
  /* This hook is used when a component has a dynamic number of fields that can be edited (e.g.: Orders' Custom Configuration Parameters).
@@ -25,7 +25,7 @@ const useMultipleFieldEditState = (entityId, sectionName, initialValues, extende
25
25
  const mergedValidationRules = { ...validationRules, ...extendedValidationRules };
26
26
  const modifiedStates = useSelector(getModifiedModels(entityId))[sectionName] || {};
27
27
 
28
- const useDynamicFieldState = (id, fieldName, errorTypes = []) => {
28
+ const useDynamicFieldState = (id, fieldName, errorTypes = [], fieldDependencies = {}) => {
29
29
  const keys = [id, fieldName];
30
30
 
31
31
  const initialValue = initialValues[id]?.[fieldName] ?? "";
@@ -42,12 +42,15 @@ const useMultipleFieldEditState = (entityId, sectionName, initialValues, extende
42
42
  dispatch(setEditModelField, [keys, initialValue, initialValue, entityId, sectionName]);
43
43
  };
44
44
 
45
- const isEditStateValid = value => {
45
+ const isEditStateValid = (value, dependencies = {}) => {
46
46
  const valueToValidate = value ?? editState.value;
47
47
 
48
48
  let hasAnyValidationErrors = false;
49
49
  errorTypes.forEach(errorType => {
50
- const isValid = mergedValidationRules[errorType](valueToValidate, id, fieldName);
50
+ const isValid = mergedValidationRules[errorType](valueToValidate, id, fieldName, {
51
+ ...fieldDependencies,
52
+ ...dependencies,
53
+ });
51
54
 
52
55
  if (isValid === false) {
53
56
  dispatch(setEditModelFieldError, [keys, errorType, entityId, sectionName]);
@@ -57,6 +60,10 @@ const useMultipleFieldEditState = (entityId, sectionName, initialValues, extende
57
60
  }
58
61
  });
59
62
 
63
+ if (!hasAnyValidationErrors) {
64
+ dispatch(removeEditModelFieldError, [keys, entityId, sectionName]);
65
+ }
66
+
60
67
  return !hasAnyValidationErrors;
61
68
  };
62
69
 
@@ -5,7 +5,7 @@ import Immutable from "immutable";
5
5
  import sinon from "sinon";
6
6
  import { mount } from "enzyme";
7
7
  import * as useDispatchWithModulesDataMock from "./useDispatchWithModulesData";
8
- import { setEditModelField, setEditModelFieldError } from "./../actions/view";
8
+ import { removeEditModelFieldError, setEditModelField, setEditModelFieldError } from "./../actions/view";
9
9
  import { validationErrorTypes } from "./../constants";
10
10
  import _ from "lodash";
11
11
 
@@ -404,6 +404,54 @@ describe("useMultipleFieldEditState", () => {
404
404
  }
405
405
  });
406
406
 
407
+ it("Updates edit view value and reset error correctly with custom validation rules when validation was passed", () => {
408
+ const useDispatchWithModulesDataSpy = sinon.spy();
409
+ const useDispatchWithModulesDataStub = sinon
410
+ .stub(useDispatchWithModulesDataMock, "useDispatchWithModulesData")
411
+ .returns(useDispatchWithModulesDataSpy);
412
+
413
+ try {
414
+ // TODOJOC
415
+ const mountedComponent = mountComponent();
416
+
417
+ const fieldComponent = mountedComponent.find(`#id1-prop1-update`);
418
+
419
+ const event = {
420
+ target: {
421
+ value: "anotherValue",
422
+ },
423
+ };
424
+
425
+ fieldComponent.invoke("onClick")(event);
426
+
427
+ const resetEvent = {
428
+ target: {
429
+ value: "custom",
430
+ },
431
+ };
432
+
433
+ fieldComponent.invoke("onClick")(resetEvent);
434
+
435
+ const id = "id1";
436
+ const fieldName = "prop1";
437
+ const initialFieldValue = fieldInitialValues[id][fieldName];
438
+
439
+ expect(useDispatchWithModulesDataSpy, "to have a call satisfying", {
440
+ args: [setEditModelField, [[id, fieldName], "anotherValue", initialFieldValue, entityId, sectionName]],
441
+ });
442
+
443
+ expect(useDispatchWithModulesDataSpy, "to have a call satisfying", {
444
+ args: [setEditModelFieldError, [[id, fieldName], "customRule", entityId, sectionName]],
445
+ });
446
+
447
+ expect(useDispatchWithModulesDataSpy, "to have a call satisfying", {
448
+ args: [removeEditModelFieldError, [[id, fieldName], entityId, sectionName]],
449
+ });
450
+ } finally {
451
+ useDispatchWithModulesDataStub.restore();
452
+ }
453
+ });
454
+
407
455
  it.each([
408
456
  ["id1", "prop1"],
409
457
  ["id1", "prop2"],
@@ -53,6 +53,23 @@ export const namedLookupValuesSelector = memoize((moduleName, lookupName) =>
53
53
  ),
54
54
  );
55
55
 
56
+ export const namedLookupsValuesSelector = memoize((moduleName, lookupNames) =>
57
+ createSelector(lookupSelector(moduleName), currentLocaleOrDefault, (lookups, locale) => {
58
+ const lookupsValues = {};
59
+
60
+ each(lookupNames, name => {
61
+ const lookup = lookups.get(name);
62
+ if (!lookup) return;
63
+
64
+ lookupsValues[name] = lookup
65
+ .get("values", Immutable.Map())
66
+ .map(lookupValue => setTranslationWithFallbackField(locale, lookupValue, "name", "displayName"));
67
+ });
68
+
69
+ return Immutable.fromJS(lookupsValues);
70
+ }),
71
+ );
72
+
56
73
  export const selectCurrentLookupDetails = memoize((moduleName, lookupName) =>
57
74
  namedLookupSelector(moduleName, lookupName),
58
75
  );
@@ -340,7 +357,7 @@ export const variantPropertyKeyValuesSelector = memoize(({ definitionName }, pro
340
357
  ? {
341
358
  ...acc,
342
359
  [rec]: resolveProductPropertyValue(propertyMap[camelCase(rec)], propertyBag[rec], locale, lookups),
343
- }
360
+ }
344
361
  : acc,
345
362
  {},
346
363
  );
@@ -31,6 +31,7 @@ import {
31
31
  lookupByNameSelector,
32
32
  mappedLookupsListSelector,
33
33
  lookupExistAndIsActiveSelector,
34
+ namedLookupsValuesSelector,
34
35
  } from "./metadata";
35
36
 
36
37
  const lookups = {
@@ -409,6 +410,109 @@ describe("namedLookupValuesSelector", () => {
409
410
  });
410
411
  });
411
412
 
413
+ describe("namedLookupsValuesSelector", () => {
414
+ let state;
415
+ beforeEach(() => {
416
+ state = Immutable.fromJS({
417
+ locale: { locale: "it-IT" },
418
+ metadata: {
419
+ lookups: {
420
+ order: {
421
+ index: {
422
+ CanceledStatusReasons: {
423
+ lookupName: "CanceledStatusReasons",
424
+ values: {
425
+ CanceledReason1: {
426
+ id: "e16d07f847284775b77cfb985724cf58",
427
+ value: "CanceledReason1",
428
+ lookupId: "CanceledStatusReasons",
429
+ sortOrder: 0,
430
+ isActive: true,
431
+ isSystem: true,
432
+ displayName: {
433
+ "en-CA": "Cancel for reason 1",
434
+ "en-US": "Cancel for reason 1",
435
+ "fr-CA": "Annulé pour raison 1",
436
+ "it-IT": "Annulla per motivo 1",
437
+ },
438
+ },
439
+ CanceledReason2: {
440
+ id: "6bbfe77703c745d68b8eaceb9cd484b1",
441
+ value: "CanceledReason2",
442
+ lookupId: "CanceledStatusReasons",
443
+ sortOrder: 0,
444
+ isActive: true,
445
+ isSystem: true,
446
+ displayName: {
447
+ "en-CA": "Cancel for reason 2",
448
+ "en-US": "Cancel for reason 2",
449
+ "fr-CA": "Annulé pour raison 2",
450
+ "it-IT": "Annulla per motivo 2",
451
+ },
452
+ },
453
+ },
454
+ isActive: true,
455
+ isSystem: true,
456
+ },
457
+ CartStatus: {
458
+ lookupName: "CartStatus",
459
+ values: {},
460
+ isActive: true,
461
+ isSystem: true,
462
+ },
463
+ },
464
+ list: [],
465
+ },
466
+ },
467
+ },
468
+ });
469
+ });
470
+
471
+ it("gets the value list for multiple named lookups", () =>
472
+ expect(
473
+ namedLookupsValuesSelector,
474
+ "when called with",
475
+ ["order", ["CanceledStatusReasons", "CartStatus"]],
476
+ "when called with",
477
+ [state],
478
+ "to satisfy",
479
+ Immutable.fromJS({
480
+ CanceledStatusReasons: {
481
+ CanceledReason1: {
482
+ id: "e16d07f847284775b77cfb985724cf58",
483
+ value: "CanceledReason1",
484
+ lookupId: "CanceledStatusReasons",
485
+ sortOrder: 0,
486
+ isActive: true,
487
+ isSystem: true,
488
+ displayName: "Annulla per motivo 1",
489
+ },
490
+ CanceledReason2: {
491
+ id: "6bbfe77703c745d68b8eaceb9cd484b1",
492
+ value: "CanceledReason2",
493
+ lookupId: "CanceledStatusReasons",
494
+ sortOrder: 0,
495
+ isActive: true,
496
+ isSystem: true,
497
+ displayName: "Annulla per motivo 2",
498
+ },
499
+ },
500
+ CartStatus: {},
501
+ }),
502
+ ));
503
+
504
+ it("will get an empty Map if lookup does not exist", () =>
505
+ expect(
506
+ namedLookupsValuesSelector,
507
+ "when called with",
508
+ ["order", ["NotALookup"]],
509
+ "when called with",
510
+ [state],
511
+ "to equal",
512
+ Immutable.fromJS({}),
513
+ ));
514
+ });
515
+
412
516
  describe("selectCurrentLookupDetails", () => {
413
517
  let state;
414
518
  beforeEach(() => {