@reltio/components 1.4.1512 → 1.4.1516

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.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var react_1 = __importDefault(require("react"));
7
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
7
8
  var contexts_1 = require("../../../../contexts");
8
9
  var SourceItem_1 = __importDefault(require("./SourceItem"));
9
10
  var LightArrowTooltip_1 = __importDefault(require("../../../LightArrowTooltip/LightArrowTooltip"));
@@ -12,9 +13,10 @@ var styles_1 = require("./styles");
12
13
  var CrosswalkIcon = function (_a) {
13
14
  var crosswalk = _a.crosswalk, className = _a.className;
14
15
  var color = (0, contexts_1.useCrosswalkColor)(crosswalk);
16
+ var isDisabled = (0, mdm_sdk_1.isCrosswalkDisabled)(crosswalk);
15
17
  var _b = (0, contexts_1.useCrosswalkHighlight)(crosswalk), isDimmed = _b.isDimmed, highlightCrosswalk = _b.highlightCrosswalk, removeHighlight = _b.removeHighlight;
16
- var styles = (0, styles_1.useStyles)({ isOpaque: !isDimmed, color: color });
18
+ var styles = (0, styles_1.useStyles)({ isOpaque: !isDimmed, color: color, isDisabled: isDisabled });
17
19
  return (react_1.default.createElement(LightArrowTooltip_1.default, { title: react_1.default.createElement(SourceItem_1.default, { crosswalk: crosswalk, color: color }), placement: 'top' },
18
- react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.crosswalkIcon, className), onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } })));
20
+ react_1.default.createElement("div", { "data-reltio-id": "crosswalk-icon", className: (0, classnames_1.default)(styles.crosswalkIcon, className), onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } })));
19
21
  };
20
22
  exports.default = CrosswalkIcon;
@@ -1,79 +1,129 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
12
10
  };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
18
36
  }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
37
  };
36
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
40
  };
39
41
  Object.defineProperty(exports, "__esModule", { value: true });
40
42
  var react_1 = __importDefault(require("react"));
41
- var enzyme_1 = require("enzyme");
43
+ var react_2 = require("@testing-library/react");
44
+ var user_event_1 = __importDefault(require("@testing-library/user-event"));
45
+ var react_redux_1 = require("react-redux");
42
46
  var CrosswalkIcon_1 = __importDefault(require("../CrosswalkIcon"));
43
- var crosswalksDisplay = __importStar(require("../../../../../contexts/CrosswalksDisplayContext"));
44
- var LightArrowTooltip_1 = __importDefault(require("../../../../LightArrowTooltip/LightArrowTooltip"));
47
+ var CrosswalksDisplayContext_1 = require("../../../../../contexts/CrosswalksDisplayContext");
48
+ var store_utils_1 = require("../../../../../test-utils/store-utils");
49
+ jest.unmock('@material-ui/core/styles');
45
50
  describe('CrosswalkIcon tests', function () {
46
- var highlightCrosswalk = jest.fn();
47
- var removeHighlight = jest.fn();
48
- var color = '#FF0000';
49
- beforeAll(function () {
50
- jest.spyOn(crosswalksDisplay, 'useCrosswalkColor').mockReturnValue(color);
51
- jest.spyOn(crosswalksDisplay, 'useCrosswalkHighlight').mockReturnValue({
52
- isHighlighted: true,
53
- isDimmed: false,
54
- highlightCrosswalk: highlightCrosswalk,
55
- removeHighlight: removeHighlight
51
+ var setCrosswalkHighlighted = jest.fn();
52
+ var crosswalk = { type: 'Reltio', uri: 'crosswalkUri', value: '20' };
53
+ var disabledCrosswalk = { type: 'Reltio', uri: 'crosswalkUri', value: '20', deleteDate: 1000000 };
54
+ var setUp = function (crosswalk, className, color) {
55
+ if (className === void 0) { className = ''; }
56
+ if (color === void 0) { color = '#F0F'; }
57
+ var store = (0, store_utils_1.createTestStore)({
58
+ metadata: {
59
+ tenant: {
60
+ sources: [{ uri: 'configuration/sources/Reltio', label: 'Reltio' }]
61
+ }
62
+ },
63
+ tenant: {
64
+ id: 'tenant'
65
+ }
56
66
  });
57
- });
58
- var props = {
59
- crosswalk: { type: 'testType', uri: 'crosswalkUri', value: '20' },
60
- className: 'testClassName'
67
+ var Providers = function (_a) {
68
+ var children = _a.children;
69
+ return (react_1.default.createElement(react_redux_1.Provider, { store: store },
70
+ react_1.default.createElement(CrosswalksDisplayContext_1.CrosswalksDisplayProvider, { setCrosswalkHighlighted: setCrosswalkHighlighted, getCrosswalkColor: function () { return color; } }, children)));
71
+ };
72
+ return (0, react_2.render)(react_1.default.createElement(CrosswalkIcon_1.default, { crosswalk: crosswalk, className: className }), { wrapper: Providers });
61
73
  };
62
- it('should render CrosswalkIcon correctly', function () {
63
- var wrapper = (0, enzyme_1.shallow)(react_1.default.createElement(CrosswalkIcon_1.default, __assign({}, props)));
64
- var tooltip = wrapper.find(LightArrowTooltip_1.default);
65
- var title = tooltip.prop('title');
66
- expect(title.props.crosswalk).toEqual(props.crosswalk);
67
- expect(title.props.color).toEqual(color);
68
- expect(wrapper.find('div').length).toBe(1);
69
- });
70
- it('should support highlighting', function () {
71
- var wrapper = (0, enzyme_1.shallow)(react_1.default.createElement(CrosswalkIcon_1.default, __assign({}, props)));
72
- var div = wrapper.find('div');
73
- expect(div.prop('className')).toBe('crosswalkIcon testClassName');
74
- div.simulate('mouseenter');
75
- expect(highlightCrosswalk).toBeCalledTimes(1);
76
- div.simulate('mouseleave');
77
- expect(removeHighlight).toBeCalledTimes(1);
74
+ it('should render CrosswalkIcon correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
75
+ var user, icon;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ user = user_event_1.default.setup();
80
+ setUp(crosswalk);
81
+ icon = react_2.screen.getByTestId('crosswalk-icon');
82
+ return [4 /*yield*/, user.hover(icon)];
83
+ case 1:
84
+ _a.sent();
85
+ return [4 /*yield*/, react_2.screen.findByRole('tooltip')];
86
+ case 2:
87
+ _a.sent();
88
+ expect(react_2.screen.getByText('R')).toBeInTheDocument();
89
+ return [2 /*return*/];
90
+ }
91
+ });
92
+ }); });
93
+ it('should support highlighting', function () { return __awaiter(void 0, void 0, void 0, function () {
94
+ var user, icon, hoverArgs, unhoverArgs;
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ setCrosswalkHighlighted.mockReset();
99
+ user = user_event_1.default.setup();
100
+ setUp(crosswalk);
101
+ icon = react_2.screen.getByTestId('crosswalk-icon');
102
+ return [4 /*yield*/, user.hover(icon)];
103
+ case 1:
104
+ _a.sent();
105
+ expect(setCrosswalkHighlighted).toHaveBeenCalledTimes(1);
106
+ hoverArgs = setCrosswalkHighlighted.mock.calls[0];
107
+ expect(hoverArgs[0]).toBe(crosswalk);
108
+ expect(hoverArgs[1]).toBeTruthy();
109
+ return [4 /*yield*/, user.unhover(icon)];
110
+ case 2:
111
+ _a.sent();
112
+ expect(setCrosswalkHighlighted).toHaveBeenCalledTimes(2);
113
+ unhoverArgs = setCrosswalkHighlighted.mock.calls[1];
114
+ expect(unhoverArgs[0]).toBe(crosswalk);
115
+ expect(unhoverArgs[1]).toBeFalsy();
116
+ return [2 /*return*/];
117
+ }
118
+ });
119
+ }); });
120
+ it('should render correct icon for disabled crosswalk', function () {
121
+ setUp(disabledCrosswalk);
122
+ var element = react_2.screen.getByTestId('crosswalk-icon');
123
+ var style = getComputedStyle(element);
124
+ expect(style).toMatchObject({
125
+ border: '2px solid #f0f',
126
+ 'box-sizing': 'border-box'
127
+ });
78
128
  });
79
129
  });
@@ -2,6 +2,7 @@ declare type StylesProps = {
2
2
  color: string;
3
3
  isOpaque?: boolean;
4
4
  isFocused?: boolean;
5
+ isDisabled?: boolean;
5
6
  };
6
7
  export declare const useStyles: (props: StylesProps) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "crosswalkValue" | "sourceItem" | "eyeIcon" | "sourceInfo" | "sourceIcon" | "crosswalkIcon">;
7
8
  export declare const useComplexAttributeLabelStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label">;
@@ -41,11 +41,13 @@ exports.useStyles = (0, styles_1.makeStyles)({
41
41
  });
42
42
  },
43
43
  crosswalkIcon: function (_a) {
44
- var color = _a.color, isOpaque = _a.isOpaque;
44
+ var color = _a.color, isOpaque = _a.isOpaque, isDisabled = _a.isDisabled;
45
45
  return ({
46
- backgroundColor: color,
46
+ backgroundColor: isDisabled ? '#fff' : color,
47
+ border: isDisabled ? "2px solid ".concat(color) : null,
47
48
  height: '12px',
48
49
  width: '12px',
50
+ boxSizing: 'border-box',
49
51
  borderRadius: '30px',
50
52
  opacity: isOpaque ? 1 : 0.38,
51
53
  transition: 'opacity 0.3s'
@@ -0,0 +1,78 @@
1
+ export declare const createTestStore: (initialState: any) => import("redux-dynamic-modules").IModuleStore<{
2
+ dataTenants: any;
3
+ tenants: any;
4
+ metadata: any;
5
+ profile: import("redux").CombinedState<{
6
+ dependentLookups: import("@reltio/mdm-module/src/profile/dependentLookups/constants").DependentLookupsState;
7
+ entity: import("@reltio/mdm-sdk").Entity;
8
+ errors: import("@reltio/mdm-sdk").AttributeError[];
9
+ history: import("@reltio/mdm-module").History;
10
+ lastLoadedTime: any;
11
+ lookups: any;
12
+ mode: import("@reltio/mdm-sdk").Mode;
13
+ modifiedEntities: import("@reltio/mdm-module/src/profile/modifiedEntities/constants").ModifiedEntitiesState;
14
+ relations: any;
15
+ trees: import("@reltio/mdm-sdk").TreesState;
16
+ operation: import("@reltio/mdm-sdk").Operation;
17
+ views: import("@reltio/mdm-module/src/profile/views/constants").ProfileViewsState;
18
+ sidePanelViews: string[] | import("@reltio/mdm-sdk").SidePanelViewConfig[];
19
+ }>;
20
+ tenant: any;
21
+ environment: any;
22
+ user: any;
23
+ ui: any;
24
+ search: {
25
+ searchResults: any;
26
+ keyword: any;
27
+ searchOptions: {
28
+ searchByOv: boolean;
29
+ ovOnly: boolean;
30
+ };
31
+ activityFilter: string;
32
+ globalFilter: {
33
+ query: any;
34
+ savedSearchesUris: any[];
35
+ isMuted: boolean;
36
+ };
37
+ searchProviderData: any;
38
+ searchNavigationData: any;
39
+ } | {
40
+ keyword: any;
41
+ searchOptions: any;
42
+ activityFilter: string;
43
+ globalFilter: {
44
+ query: any;
45
+ savedSearchesUris: any[];
46
+ isMuted: boolean;
47
+ };
48
+ searchNavigationData: any;
49
+ searchProviderData: any;
50
+ searchResults: any[];
51
+ } | {
52
+ activityFilter: any;
53
+ searchResults: any[];
54
+ keyword: any;
55
+ searchOptions: {
56
+ searchByOv: boolean;
57
+ ovOnly: boolean;
58
+ };
59
+ globalFilter: {
60
+ query: any;
61
+ savedSearchesUris: any[];
62
+ isMuted: boolean;
63
+ };
64
+ searchProviderData: any;
65
+ searchNavigationData: any;
66
+ } | {
67
+ globalFilter: any;
68
+ searchResults: any[];
69
+ keyword: any;
70
+ searchOptions: {
71
+ searchByOv: boolean;
72
+ ovOnly: boolean;
73
+ };
74
+ activityFilter: string;
75
+ searchProviderData: any;
76
+ searchNavigationData: any;
77
+ };
78
+ }>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createTestStore = void 0;
7
+ /// we do it temporary because of rootDir
8
+ var redux_dynamic_modules_saga_1 = require("redux-dynamic-modules-saga");
9
+ var redux_dynamic_modules_thunk_1 = require("redux-dynamic-modules-thunk");
10
+ var redux_dynamic_modules_1 = require("redux-dynamic-modules");
11
+ var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
12
+ var createTestStore = function (initialState) {
13
+ return (0, redux_dynamic_modules_1.createStore)({
14
+ initialState: initialState,
15
+ enhancers: [],
16
+ extensions: [(0, redux_dynamic_modules_thunk_1.getThunkExtension)(), (0, redux_dynamic_modules_saga_1.getSagaExtension)()]
17
+ }, mdm_module_1.default.getModule());
18
+ };
19
+ exports.createTestStore = createTestStore;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { isCrosswalkDisabled } from '@reltio/mdm-sdk';
2
3
  import { useCrosswalkColor, useCrosswalkHighlight } from '../../../../contexts';
3
4
  import SourceItem from './SourceItem';
4
5
  import LightArrowTooltip from '../../../LightArrowTooltip/LightArrowTooltip';
@@ -7,9 +8,10 @@ import { useStyles } from './styles';
7
8
  var CrosswalkIcon = function (_a) {
8
9
  var crosswalk = _a.crosswalk, className = _a.className;
9
10
  var color = useCrosswalkColor(crosswalk);
11
+ var isDisabled = isCrosswalkDisabled(crosswalk);
10
12
  var _b = useCrosswalkHighlight(crosswalk), isDimmed = _b.isDimmed, highlightCrosswalk = _b.highlightCrosswalk, removeHighlight = _b.removeHighlight;
11
- var styles = useStyles({ isOpaque: !isDimmed, color: color });
13
+ var styles = useStyles({ isOpaque: !isDimmed, color: color, isDisabled: isDisabled });
12
14
  return (React.createElement(LightArrowTooltip, { title: React.createElement(SourceItem, { crosswalk: crosswalk, color: color }), placement: 'top' },
13
- React.createElement("div", { className: classnames(styles.crosswalkIcon, className), onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } })));
15
+ React.createElement("div", { "data-reltio-id": "crosswalk-icon", className: classnames(styles.crosswalkIcon, className), onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } })));
14
16
  };
15
17
  export default CrosswalkIcon;
@@ -1,51 +1,124 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
11
36
  };
12
37
  import React from 'react';
13
- import { shallow } from 'enzyme';
38
+ import { render, screen } from '@testing-library/react';
39
+ import userEvent from '@testing-library/user-event';
40
+ import { Provider } from 'react-redux';
14
41
  import CrosswalkIcon from '../CrosswalkIcon';
15
- import * as crosswalksDisplay from '../../../../../contexts/CrosswalksDisplayContext';
16
- import LightArrowTooltip from '../../../../LightArrowTooltip/LightArrowTooltip';
42
+ import { CrosswalksDisplayProvider } from '../../../../../contexts/CrosswalksDisplayContext';
43
+ import { createTestStore } from '../../../../../test-utils/store-utils';
44
+ jest.unmock('@material-ui/core/styles');
17
45
  describe('CrosswalkIcon tests', function () {
18
- var highlightCrosswalk = jest.fn();
19
- var removeHighlight = jest.fn();
20
- var color = '#FF0000';
21
- beforeAll(function () {
22
- jest.spyOn(crosswalksDisplay, 'useCrosswalkColor').mockReturnValue(color);
23
- jest.spyOn(crosswalksDisplay, 'useCrosswalkHighlight').mockReturnValue({
24
- isHighlighted: true,
25
- isDimmed: false,
26
- highlightCrosswalk: highlightCrosswalk,
27
- removeHighlight: removeHighlight
46
+ var setCrosswalkHighlighted = jest.fn();
47
+ var crosswalk = { type: 'Reltio', uri: 'crosswalkUri', value: '20' };
48
+ var disabledCrosswalk = { type: 'Reltio', uri: 'crosswalkUri', value: '20', deleteDate: 1000000 };
49
+ var setUp = function (crosswalk, className, color) {
50
+ if (className === void 0) { className = ''; }
51
+ if (color === void 0) { color = '#F0F'; }
52
+ var store = createTestStore({
53
+ metadata: {
54
+ tenant: {
55
+ sources: [{ uri: 'configuration/sources/Reltio', label: 'Reltio' }]
56
+ }
57
+ },
58
+ tenant: {
59
+ id: 'tenant'
60
+ }
28
61
  });
29
- });
30
- var props = {
31
- crosswalk: { type: 'testType', uri: 'crosswalkUri', value: '20' },
32
- className: 'testClassName'
62
+ var Providers = function (_a) {
63
+ var children = _a.children;
64
+ return (React.createElement(Provider, { store: store },
65
+ React.createElement(CrosswalksDisplayProvider, { setCrosswalkHighlighted: setCrosswalkHighlighted, getCrosswalkColor: function () { return color; } }, children)));
66
+ };
67
+ return render(React.createElement(CrosswalkIcon, { crosswalk: crosswalk, className: className }), { wrapper: Providers });
33
68
  };
34
- it('should render CrosswalkIcon correctly', function () {
35
- var wrapper = shallow(React.createElement(CrosswalkIcon, __assign({}, props)));
36
- var tooltip = wrapper.find(LightArrowTooltip);
37
- var title = tooltip.prop('title');
38
- expect(title.props.crosswalk).toEqual(props.crosswalk);
39
- expect(title.props.color).toEqual(color);
40
- expect(wrapper.find('div').length).toBe(1);
41
- });
42
- it('should support highlighting', function () {
43
- var wrapper = shallow(React.createElement(CrosswalkIcon, __assign({}, props)));
44
- var div = wrapper.find('div');
45
- expect(div.prop('className')).toBe('crosswalkIcon testClassName');
46
- div.simulate('mouseenter');
47
- expect(highlightCrosswalk).toBeCalledTimes(1);
48
- div.simulate('mouseleave');
49
- expect(removeHighlight).toBeCalledTimes(1);
69
+ it('should render CrosswalkIcon correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
70
+ var user, icon;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ user = userEvent.setup();
75
+ setUp(crosswalk);
76
+ icon = screen.getByTestId('crosswalk-icon');
77
+ return [4 /*yield*/, user.hover(icon)];
78
+ case 1:
79
+ _a.sent();
80
+ return [4 /*yield*/, screen.findByRole('tooltip')];
81
+ case 2:
82
+ _a.sent();
83
+ expect(screen.getByText('R')).toBeInTheDocument();
84
+ return [2 /*return*/];
85
+ }
86
+ });
87
+ }); });
88
+ it('should support highlighting', function () { return __awaiter(void 0, void 0, void 0, function () {
89
+ var user, icon, hoverArgs, unhoverArgs;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ setCrosswalkHighlighted.mockReset();
94
+ user = userEvent.setup();
95
+ setUp(crosswalk);
96
+ icon = screen.getByTestId('crosswalk-icon');
97
+ return [4 /*yield*/, user.hover(icon)];
98
+ case 1:
99
+ _a.sent();
100
+ expect(setCrosswalkHighlighted).toHaveBeenCalledTimes(1);
101
+ hoverArgs = setCrosswalkHighlighted.mock.calls[0];
102
+ expect(hoverArgs[0]).toBe(crosswalk);
103
+ expect(hoverArgs[1]).toBeTruthy();
104
+ return [4 /*yield*/, user.unhover(icon)];
105
+ case 2:
106
+ _a.sent();
107
+ expect(setCrosswalkHighlighted).toHaveBeenCalledTimes(2);
108
+ unhoverArgs = setCrosswalkHighlighted.mock.calls[1];
109
+ expect(unhoverArgs[0]).toBe(crosswalk);
110
+ expect(unhoverArgs[1]).toBeFalsy();
111
+ return [2 /*return*/];
112
+ }
113
+ });
114
+ }); });
115
+ it('should render correct icon for disabled crosswalk', function () {
116
+ setUp(disabledCrosswalk);
117
+ var element = screen.getByTestId('crosswalk-icon');
118
+ var style = getComputedStyle(element);
119
+ expect(style).toMatchObject({
120
+ border: '2px solid #f0f',
121
+ 'box-sizing': 'border-box'
122
+ });
50
123
  });
51
124
  });
@@ -2,6 +2,7 @@ declare type StylesProps = {
2
2
  color: string;
3
3
  isOpaque?: boolean;
4
4
  isFocused?: boolean;
5
+ isDisabled?: boolean;
5
6
  };
6
7
  export declare const useStyles: (props: StylesProps) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "crosswalkValue" | "sourceItem" | "eyeIcon" | "sourceInfo" | "sourceIcon" | "crosswalkIcon">;
7
8
  export declare const useComplexAttributeLabelStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label">;
@@ -38,11 +38,13 @@ export var useStyles = makeStyles({
38
38
  });
39
39
  },
40
40
  crosswalkIcon: function (_a) {
41
- var color = _a.color, isOpaque = _a.isOpaque;
41
+ var color = _a.color, isOpaque = _a.isOpaque, isDisabled = _a.isDisabled;
42
42
  return ({
43
- backgroundColor: color,
43
+ backgroundColor: isDisabled ? '#fff' : color,
44
+ border: isDisabled ? "2px solid ".concat(color) : null,
44
45
  height: '12px',
45
46
  width: '12px',
47
+ boxSizing: 'border-box',
46
48
  borderRadius: '30px',
47
49
  opacity: isOpaque ? 1 : 0.38,
48
50
  transition: 'opacity 0.3s'
@@ -0,0 +1,78 @@
1
+ export declare const createTestStore: (initialState: any) => import("redux-dynamic-modules").IModuleStore<{
2
+ dataTenants: any;
3
+ tenants: any;
4
+ metadata: any;
5
+ profile: import("redux").CombinedState<{
6
+ dependentLookups: import("@reltio/mdm-module/src/profile/dependentLookups/constants").DependentLookupsState;
7
+ entity: import("@reltio/mdm-sdk").Entity;
8
+ errors: import("@reltio/mdm-sdk").AttributeError[];
9
+ history: import("@reltio/mdm-module").History;
10
+ lastLoadedTime: any;
11
+ lookups: any;
12
+ mode: import("@reltio/mdm-sdk").Mode;
13
+ modifiedEntities: import("@reltio/mdm-module/src/profile/modifiedEntities/constants").ModifiedEntitiesState;
14
+ relations: any;
15
+ trees: import("@reltio/mdm-sdk").TreesState;
16
+ operation: import("@reltio/mdm-sdk").Operation;
17
+ views: import("@reltio/mdm-module/src/profile/views/constants").ProfileViewsState;
18
+ sidePanelViews: string[] | import("@reltio/mdm-sdk").SidePanelViewConfig[];
19
+ }>;
20
+ tenant: any;
21
+ environment: any;
22
+ user: any;
23
+ ui: any;
24
+ search: {
25
+ searchResults: any;
26
+ keyword: any;
27
+ searchOptions: {
28
+ searchByOv: boolean;
29
+ ovOnly: boolean;
30
+ };
31
+ activityFilter: string;
32
+ globalFilter: {
33
+ query: any;
34
+ savedSearchesUris: any[];
35
+ isMuted: boolean;
36
+ };
37
+ searchProviderData: any;
38
+ searchNavigationData: any;
39
+ } | {
40
+ keyword: any;
41
+ searchOptions: any;
42
+ activityFilter: string;
43
+ globalFilter: {
44
+ query: any;
45
+ savedSearchesUris: any[];
46
+ isMuted: boolean;
47
+ };
48
+ searchNavigationData: any;
49
+ searchProviderData: any;
50
+ searchResults: any[];
51
+ } | {
52
+ activityFilter: any;
53
+ searchResults: any[];
54
+ keyword: any;
55
+ searchOptions: {
56
+ searchByOv: boolean;
57
+ ovOnly: boolean;
58
+ };
59
+ globalFilter: {
60
+ query: any;
61
+ savedSearchesUris: any[];
62
+ isMuted: boolean;
63
+ };
64
+ searchProviderData: any;
65
+ searchNavigationData: any;
66
+ } | {
67
+ globalFilter: any;
68
+ searchResults: any[];
69
+ keyword: any;
70
+ searchOptions: {
71
+ searchByOv: boolean;
72
+ ovOnly: boolean;
73
+ };
74
+ activityFilter: string;
75
+ searchProviderData: any;
76
+ searchNavigationData: any;
77
+ };
78
+ }>;
@@ -0,0 +1,12 @@
1
+ /// we do it temporary because of rootDir
2
+ import { getSagaExtension } from 'redux-dynamic-modules-saga';
3
+ import { getThunkExtension } from 'redux-dynamic-modules-thunk';
4
+ import { createStore } from 'redux-dynamic-modules';
5
+ import mdmModule from '@reltio/mdm-module';
6
+ export var createTestStore = function (initialState) {
7
+ return createStore({
8
+ initialState: initialState,
9
+ enhancers: [],
10
+ extensions: [getThunkExtension(), getSagaExtension()]
11
+ }, mdmModule.getModule());
12
+ };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1512",
3
+ "version": "1.4.1516",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1512",
11
- "@reltio/mdm-sdk": "^1.4.1512",
10
+ "@reltio/mdm-module": "^1.4.1516",
11
+ "@reltio/mdm-sdk": "^1.4.1516",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",