@reltio/components 1.4.1905 → 1.4.1907
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/cjs/ActionsPanel/ActionsPanel.test.js +133 -49
- package/cjs/AttributeListItem/AttributeListItem.spec.js +147 -118
- package/cjs/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/cjs/AttributesErrorsPanel/components/Error/Error.specs.js +96 -90
- package/cjs/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/cjs/AttributesErrorsPanel/store.test-data.js +29 -0
- package/cjs/AttributesFilterSelector/AttributesFilterSelector.test.js +127 -105
- package/cjs/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/cjs/AttributesValuesEditor/AttributesValuesEditor.test.js +92 -88
- package/cjs/AttributesView/AttributesView.test.js +67 -34
- package/cjs/AutoSizeList/AutoSizeList.test.js +81 -59
- package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +15 -31
- package/cjs/BarChart/BarChart.test.js +128 -65
- package/cjs/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/cjs/BasicViewContent/BasicViewContent.test.js +7 -9
- package/cjs/BlobRenderer/BlobRenderer.test.js +28 -9
- package/cjs/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/cjs/BubbleChart/BubbleChart.test.js +111 -87
- package/cjs/CloudChart/CloudChart.test.js +95 -36
- package/cjs/CollaborationItem/CollaborationItem.test.js +67 -30
- package/cjs/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/cjs/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -81
- package/cjs/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/cjs/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/cjs/CollapseButton/CollapseButton.test.js +74 -15
- package/cjs/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/cjs/ColorBar/ColorBar.test.js +13 -15
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/cjs/CommentsContainer/CommentsContainer.test.js +282 -211
- package/cjs/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +183 -122
- package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/cjs/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/cjs/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/cjs/ConnectionEditor/ConnectionEditor.test.js +299 -282
- package/cjs/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.d.ts +3 -1
- package/cjs/ReactSortableTree/ReactSortableTree.js +2 -7
- package/cjs/RelationTypeSelector/RelationTypeSelector.d.ts +3 -1
- package/cjs/types/index.d.ts +1 -1
- package/esm/ActionsPanel/ActionsPanel.test.js +133 -49
- package/esm/AttributeListItem/AttributeListItem.spec.js +149 -97
- package/esm/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/esm/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/esm/AttributesErrorsPanel/components/Error/Error.specs.js +98 -72
- package/esm/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/esm/AttributesErrorsPanel/store.test-data.js +26 -0
- package/esm/AttributesFilterSelector/AttributesFilterSelector.test.js +129 -84
- package/esm/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/esm/AttributesValuesEditor/AttributesValuesEditor.test.js +94 -67
- package/esm/AttributesView/AttributesView.test.js +67 -34
- package/esm/AutoSizeList/AutoSizeList.test.js +81 -59
- package/esm/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +16 -32
- package/esm/BarChart/BarChart.test.js +128 -65
- package/esm/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/esm/BasicViewContent/BasicViewContent.test.js +7 -9
- package/esm/BlobRenderer/BlobRenderer.test.js +28 -9
- package/esm/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/esm/BubbleChart/BubbleChart.test.js +111 -87
- package/esm/CloudChart/CloudChart.test.js +95 -36
- package/esm/CollaborationItem/CollaborationItem.test.js +67 -30
- package/esm/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/esm/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -58
- package/esm/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/esm/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/esm/CollapseButton/CollapseButton.test.js +74 -15
- package/esm/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/esm/ColorBar/ColorBar.test.js +13 -15
- package/esm/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/esm/CommentsContainer/CommentsContainer.test.js +282 -211
- package/esm/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +182 -101
- package/esm/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/esm/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/esm/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/esm/ConnectionEditor/ConnectionEditor.test.js +300 -283
- package/esm/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.d.ts +3 -1
- package/esm/ReactSortableTree/ReactSortableTree.js +2 -7
- package/esm/RelationTypeSelector/RelationTypeSelector.d.ts +3 -1
- package/esm/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -100
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -46
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.js +0 -27
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -27
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.js +0 -15
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -80
- package/esm/ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -95
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -41
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.js +0 -22
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -22
- package/esm/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/esm/CollaborationItem/components/Avatar/Avatar.test.js +0 -10
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -55
- /package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts → AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
- /package/{cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts → esm/AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
|
@@ -9,155 +9,237 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import Typography from '@mui/material/Typography';
|
|
21
|
-
import AttributesFiltersButton from './AttributesFiltersButton';
|
|
22
|
-
import { AttributesFiltersBuilder } from '../AttributesFiltersBuilder';
|
|
23
|
-
import { ActionButtons } from './components/ActionButtons';
|
|
24
|
-
import { rerenderWrapper } from '../test-utils';
|
|
25
|
-
import { EmptyStub } from '../EmptyStub';
|
|
26
|
-
jest.mock('../AttributesFiltersBuilder', function () { return ({
|
|
27
|
-
AttributesFiltersBuilder: jest.fn(function () { return null; })
|
|
28
|
-
}); });
|
|
29
|
-
var defaultProps = {
|
|
30
|
-
filters: [],
|
|
31
|
-
attributesTypesGroups: [],
|
|
32
|
-
onChange: jest.fn()
|
|
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
|
+
});
|
|
33
20
|
};
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
return
|
|
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;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
}
|
|
37
47
|
};
|
|
48
|
+
import React from 'react';
|
|
49
|
+
import AttributesFiltersButton from './AttributesFiltersButton';
|
|
50
|
+
import { getMuiIconByName } from '../test-utils';
|
|
51
|
+
import { render, screen, within } from '@testing-library/react';
|
|
52
|
+
import userEvent from '@testing-library/user-event';
|
|
53
|
+
import { metadata } from '../AttributesFiltersBuilder/metadata.test-data';
|
|
54
|
+
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
55
|
+
import { attributesTypesGroups } from '../AttributesFiltersBuilder/attributes.test-data';
|
|
38
56
|
describe('AttributesFiltersButton tests', function () {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
var mdmValues = {
|
|
58
|
+
metadata: metadata,
|
|
59
|
+
tenant: {
|
|
60
|
+
id: 't1',
|
|
61
|
+
name: 't1'
|
|
62
|
+
},
|
|
63
|
+
lookups: {},
|
|
64
|
+
globalSearchRequestOptions: {}
|
|
65
|
+
};
|
|
66
|
+
var defaultProps = {
|
|
67
|
+
filters: [],
|
|
68
|
+
attributesTypesGroups: attributesTypesGroups,
|
|
69
|
+
onChange: jest.fn()
|
|
70
|
+
};
|
|
71
|
+
var setUp = function (props) {
|
|
72
|
+
if (props === void 0) { props = defaultProps; }
|
|
73
|
+
var user = userEvent.setup();
|
|
74
|
+
var Providers = function (_a) {
|
|
75
|
+
var children = _a.children;
|
|
76
|
+
return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
|
|
77
|
+
};
|
|
78
|
+
return __assign({ user: user }, render(React.createElement(AttributesFiltersButton, __assign({}, props)), { wrapper: Providers }));
|
|
79
|
+
};
|
|
80
|
+
it('should render main components', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
+
var user, button;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
switch (_a.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
user = setUp().user;
|
|
86
|
+
button = screen.getByRole('button');
|
|
87
|
+
expect(button).toHaveClass('MuiButton-colorInherit');
|
|
88
|
+
expect(getMuiIconByName('FilterList')).not.toHaveClass('MuiSvgIcon-colorPrimary');
|
|
89
|
+
return [4 /*yield*/, user.click(button)];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.sent();
|
|
92
|
+
expect(screen.getByRole('presentation')).toBeInTheDocument();
|
|
93
|
+
expect(screen.getByText('Filter')).toBeInTheDocument();
|
|
94
|
+
expect(screen.getByText('Clear all')).toBeInTheDocument();
|
|
95
|
+
expect(screen.getByText('Apply')).toBeInTheDocument();
|
|
96
|
+
return [2 /*return*/];
|
|
97
|
+
}
|
|
63
98
|
});
|
|
64
|
-
|
|
65
|
-
});
|
|
99
|
+
}); });
|
|
66
100
|
it('should set color prop to button and FilterIcon as "primary" if some not empty filter is applied', function () {
|
|
67
|
-
|
|
68
|
-
expect(
|
|
69
|
-
expect(
|
|
70
|
-
expect(component.find(FilterIcon)).toHaveLength(1);
|
|
71
|
-
expect(component.find(FilterIcon).prop('color')).toBe('primary');
|
|
101
|
+
setUp(__assign(__assign({}, defaultProps), { filters: [{ fieldName: 'fieldName', filter: 'exists' }] }));
|
|
102
|
+
expect(screen.getByRole('button')).toHaveClass('MuiButton-textPrimary');
|
|
103
|
+
expect(getMuiIconByName('FilterList')).toHaveClass('MuiSvgIcon-colorPrimary');
|
|
72
104
|
});
|
|
73
105
|
it('should set color prop to button and FilterIcon as "primary" if prop isFiltersApplied = true', function () {
|
|
74
|
-
|
|
75
|
-
expect(
|
|
76
|
-
expect(
|
|
77
|
-
expect(component.find(FilterIcon)).toHaveLength(1);
|
|
78
|
-
expect(component.find(FilterIcon).prop('color')).toBe('primary');
|
|
106
|
+
setUp(__assign(__assign({}, defaultProps), { filters: [], isFiltersApplied: true }));
|
|
107
|
+
expect(screen.getByRole('button')).toHaveClass('MuiButton-textPrimary');
|
|
108
|
+
expect(getMuiIconByName('FilterList')).toHaveClass('MuiSvgIcon-colorPrimary');
|
|
79
109
|
});
|
|
80
110
|
it('should set color prop to button and FilterIcon as "inherit" if some empty filter is applied', function () {
|
|
81
|
-
|
|
82
|
-
expect(
|
|
83
|
-
expect(
|
|
84
|
-
expect(component.find(FilterIcon)).toHaveLength(1);
|
|
85
|
-
expect(component.find(FilterIcon).prop('color')).toBe('inherit');
|
|
111
|
+
setUp(__assign(__assign({}, defaultProps), { filters: [{ fieldName: 'fieldName', filter: 'equals', values: [] }] }));
|
|
112
|
+
expect(screen.getByRole('button')).toHaveClass('MuiButton-colorInherit');
|
|
113
|
+
expect(getMuiIconByName('FilterList')).not.toHaveClass('MuiSvgIcon-colorPrimary');
|
|
86
114
|
});
|
|
87
115
|
it('should set color prop to button and FilterIcon as "inherit" if prop isFiltersApplied = false', function () {
|
|
88
|
-
|
|
89
|
-
expect(
|
|
90
|
-
expect(
|
|
91
|
-
expect(component.find(FilterIcon)).toHaveLength(1);
|
|
92
|
-
expect(component.find(FilterIcon).prop('color')).toBe('inherit');
|
|
93
|
-
});
|
|
94
|
-
it('should open Popover after filter button clicking', function () {
|
|
95
|
-
var event = {};
|
|
96
|
-
var component = setUp();
|
|
97
|
-
component.find(Button).prop('onClick')(event);
|
|
98
|
-
rerenderWrapper(component);
|
|
99
|
-
expect(component.find(Popover).prop('open')).toBe(true);
|
|
100
|
-
});
|
|
101
|
-
it('should close Popover after cancel button clicking', function () {
|
|
102
|
-
var event = {};
|
|
103
|
-
var component = setUp();
|
|
104
|
-
component.find(Button).prop('onClick')(event);
|
|
105
|
-
rerenderWrapper(component);
|
|
106
|
-
expect(component.find(Popover).prop('open')).toBe(true);
|
|
107
|
-
component.find(ActionButtons).prop('onCancel')();
|
|
108
|
-
rerenderWrapper(component);
|
|
109
|
-
expect(component.find(Popover).prop('open')).toBe(false);
|
|
116
|
+
setUp(__assign(__assign({}, defaultProps), { filters: [], isFiltersApplied: false }));
|
|
117
|
+
expect(screen.getByRole('button')).toHaveClass('MuiButton-colorInherit');
|
|
118
|
+
expect(getMuiIconByName('FilterList')).not.toHaveClass('MuiSvgIcon-colorPrimary');
|
|
110
119
|
});
|
|
111
|
-
it('should
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
attributesTypesGroups: [],
|
|
129
|
-
onChange: jest.fn()
|
|
120
|
+
it('should close Popover after cancel button clicking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
121
|
+
var user, button;
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
switch (_a.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
user = setUp().user;
|
|
126
|
+
button = screen.getByRole('button');
|
|
127
|
+
return [4 /*yield*/, user.click(button)];
|
|
128
|
+
case 1:
|
|
129
|
+
_a.sent();
|
|
130
|
+
expect(screen.getByRole('presentation')).toBeInTheDocument();
|
|
131
|
+
return [4 /*yield*/, user.click(button)];
|
|
132
|
+
case 2:
|
|
133
|
+
_a.sent();
|
|
134
|
+
expect(screen.queryByRole('presentation')).not.toBeInTheDocument();
|
|
135
|
+
return [2 /*return*/];
|
|
136
|
+
}
|
|
130
137
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
}); });
|
|
139
|
+
it('should close Popover after cancel button clicking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
var onCancelSpy, user;
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
onCancelSpy = jest.fn();
|
|
145
|
+
user = setUp(__assign(__assign({}, defaultProps), { onCancel: onCancelSpy })).user;
|
|
146
|
+
return [4 /*yield*/, user.click(screen.getByRole('button'))];
|
|
147
|
+
case 1:
|
|
148
|
+
_a.sent();
|
|
149
|
+
return [4 /*yield*/, user.click(screen.getByText('Cancel'))];
|
|
150
|
+
case 2:
|
|
151
|
+
_a.sent();
|
|
152
|
+
expect(onCancelSpy).toHaveBeenCalled();
|
|
153
|
+
expect(screen.queryByRole('presentation')).not.toBeInTheDocument();
|
|
154
|
+
return [2 /*return*/];
|
|
155
|
+
}
|
|
140
156
|
});
|
|
141
|
-
});
|
|
142
|
-
it('should
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
157
|
+
}); });
|
|
158
|
+
it('should call onChange prop after apply button clicking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
159
|
+
var onApplySpy, onChangeSpy, user, rows, editor, input;
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
switch (_a.label) {
|
|
162
|
+
case 0:
|
|
163
|
+
onApplySpy = jest.fn();
|
|
164
|
+
onChangeSpy = jest.fn();
|
|
165
|
+
user = setUp(__assign(__assign({}, defaultProps), { onApply: onApplySpy, onChange: onChangeSpy, filters: [{ fieldName: 'attributes.Int', filter: 'equals', values: [['TestValue']] }] })).user;
|
|
166
|
+
return [4 /*yield*/, user.click(screen.getByRole('button'))];
|
|
167
|
+
case 1:
|
|
168
|
+
_a.sent();
|
|
169
|
+
rows = screen.getAllByTestId('query-builder-row');
|
|
170
|
+
editor = within(rows[0]).getByTestId('filter-value-editor');
|
|
171
|
+
input = within(editor).getByRole('textbox');
|
|
172
|
+
return [4 /*yield*/, user.type(input, '12{Enter}')];
|
|
173
|
+
case 2:
|
|
174
|
+
_a.sent();
|
|
175
|
+
return [4 /*yield*/, user.click(screen.getByText('Apply'))];
|
|
176
|
+
case 3:
|
|
177
|
+
_a.sent();
|
|
178
|
+
expect(onChangeSpy).toBeCalledWith([
|
|
179
|
+
{
|
|
180
|
+
fieldName: 'attributes.Int',
|
|
181
|
+
filter: 'equals',
|
|
182
|
+
values: [['TestValue', '12']]
|
|
183
|
+
}
|
|
184
|
+
]);
|
|
185
|
+
expect(onApplySpy).toHaveBeenCalled();
|
|
186
|
+
expect(screen.queryByRole('presentation')).not.toBeInTheDocument();
|
|
187
|
+
return [2 /*return*/];
|
|
188
|
+
}
|
|
149
189
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
190
|
+
}); });
|
|
191
|
+
it('should clear filters after clear all button clicking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
192
|
+
var onClearSpy, user;
|
|
193
|
+
return __generator(this, function (_a) {
|
|
194
|
+
switch (_a.label) {
|
|
195
|
+
case 0:
|
|
196
|
+
onClearSpy = jest.fn();
|
|
197
|
+
user = setUp(__assign(__assign({}, defaultProps), { onClear: onClearSpy, filters: [{ fieldName: 'attributes.Int', filter: 'equals', values: [['TestValue']] }] })).user;
|
|
198
|
+
return [4 /*yield*/, user.click(screen.getByRole('button'))];
|
|
199
|
+
case 1:
|
|
200
|
+
_a.sent();
|
|
201
|
+
expect(screen.getByText('TestValue')).toBeInTheDocument();
|
|
202
|
+
return [4 /*yield*/, user.click(screen.getByText('Clear all'))];
|
|
203
|
+
case 2:
|
|
204
|
+
_a.sent();
|
|
205
|
+
expect(screen.queryByText('TestValue')).not.toBeInTheDocument();
|
|
206
|
+
expect(onClearSpy).toHaveBeenCalled();
|
|
207
|
+
return [2 /*return*/];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}); });
|
|
211
|
+
it('should render children ', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
212
|
+
var user;
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
switch (_a.label) {
|
|
215
|
+
case 0:
|
|
216
|
+
user = setUp(__assign(__assign({}, defaultProps), { children: React.createElement("div", null, "children") })).user;
|
|
217
|
+
return [4 /*yield*/, user.click(screen.getByRole('button'))];
|
|
218
|
+
case 1:
|
|
219
|
+
_a.sent();
|
|
220
|
+
expect(screen.getByText('children')).toBeInTheDocument();
|
|
221
|
+
return [2 /*return*/];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}); });
|
|
225
|
+
it('should call onTogglePopup prop when open Popover', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
|
+
var onTogglePopup, user, popupButton;
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
switch (_a.label) {
|
|
229
|
+
case 0:
|
|
230
|
+
onTogglePopup = jest.fn();
|
|
231
|
+
user = setUp(__assign(__assign({}, defaultProps), { onTogglePopup: onTogglePopup })).user;
|
|
232
|
+
popupButton = screen.getByRole('button');
|
|
233
|
+
return [4 /*yield*/, user.click(popupButton)];
|
|
234
|
+
case 1:
|
|
235
|
+
_a.sent();
|
|
236
|
+
expect(onTogglePopup).toHaveBeenLastCalledWith(true);
|
|
237
|
+
return [4 /*yield*/, user.click(popupButton)];
|
|
238
|
+
case 2:
|
|
239
|
+
_a.sent();
|
|
240
|
+
expect(onTogglePopup).toHaveBeenLastCalledWith(false);
|
|
241
|
+
return [2 /*return*/];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}); });
|
|
163
245
|
});
|
|
@@ -9,80 +9,107 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
attribute: {
|
|
21
|
-
attrType: {},
|
|
22
|
-
entityTypeUri: '',
|
|
23
|
-
fieldName: 'attribute',
|
|
24
|
-
groupName: '',
|
|
25
|
-
title: '',
|
|
26
|
-
uri: ''
|
|
27
|
-
},
|
|
28
|
-
filter: 'filter',
|
|
29
|
-
id: 0,
|
|
30
|
-
values: []
|
|
31
|
-
},
|
|
32
|
-
rowContext: {
|
|
33
|
-
attributesGroup: [],
|
|
34
|
-
entityType: {
|
|
35
|
-
uri: 'configuration/entityTypes/HCA',
|
|
36
|
-
label: 'HCA',
|
|
37
|
-
attributes: []
|
|
38
|
-
},
|
|
39
|
-
addNewFilter: jest.fn(),
|
|
40
|
-
addRowAfterIndex: jest.fn(),
|
|
41
|
-
changeFilter: jest.fn(),
|
|
42
|
-
duplicateRow: jest.fn(),
|
|
43
|
-
removeRow: jest.fn(),
|
|
44
|
-
attributeSelectorItemsGroups: []
|
|
45
|
-
}
|
|
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
|
+
});
|
|
46
20
|
};
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
return
|
|
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;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
}
|
|
50
47
|
};
|
|
48
|
+
import React from 'react';
|
|
49
|
+
import AttributesValuesEditor from './AttributesValuesEditor';
|
|
50
|
+
import { render, screen } from '@testing-library/react';
|
|
51
|
+
import userEvent from '@testing-library/user-event';
|
|
51
52
|
describe('AttributesValuesEditor tests', function () {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
var defaultProps = {
|
|
54
|
+
rowData: {
|
|
55
|
+
attribute: {
|
|
56
|
+
attrType: {
|
|
57
|
+
name: 'attribute1',
|
|
58
|
+
uri: 'etityTypes/uri1',
|
|
59
|
+
type: 'string'
|
|
60
|
+
},
|
|
61
|
+
entityTypeUri: '',
|
|
62
|
+
fieldName: 'attribute',
|
|
63
|
+
groupName: '',
|
|
64
|
+
title: '',
|
|
65
|
+
uri: ''
|
|
66
|
+
},
|
|
67
|
+
filter: 'equals',
|
|
68
|
+
id: 0,
|
|
57
69
|
values: []
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
},
|
|
71
|
+
rowContext: {
|
|
72
|
+
attributesGroup: [],
|
|
73
|
+
entityType: {
|
|
74
|
+
uri: 'configuration/entityTypes/HCA',
|
|
75
|
+
label: 'HCA',
|
|
76
|
+
attributes: []
|
|
77
|
+
},
|
|
78
|
+
addNewFilter: jest.fn(),
|
|
79
|
+
addRowAfterIndex: jest.fn(),
|
|
80
|
+
changeFilter: jest.fn(),
|
|
81
|
+
duplicateRow: jest.fn(),
|
|
82
|
+
removeRow: jest.fn(),
|
|
83
|
+
attributeSelectorItemsGroups: []
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var setUp = function (props) {
|
|
87
|
+
if (props === void 0) { props = defaultProps; }
|
|
88
|
+
var user = userEvent.setup();
|
|
89
|
+
return __assign({ user: user }, render(React.createElement(AttributesValuesEditor, __assign({}, props))));
|
|
90
|
+
};
|
|
91
|
+
it('should call changeFilter prop after values changing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
92
|
+
var _a, fieldName, filter, id, changeFilterSpy, user;
|
|
93
|
+
return __generator(this, function (_b) {
|
|
94
|
+
switch (_b.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
_a = defaultProps.rowData, fieldName = _a.attribute.fieldName, filter = _a.filter, id = _a.id;
|
|
97
|
+
changeFilterSpy = jest.fn();
|
|
98
|
+
user = setUp(__assign(__assign({}, defaultProps), { rowContext: __assign(__assign({}, defaultProps.rowContext), { changeFilter: changeFilterSpy }) })).user;
|
|
99
|
+
return [4 /*yield*/, user.type(screen.getByRole('textbox'), 'NewValue{Enter}')];
|
|
100
|
+
case 1:
|
|
101
|
+
_b.sent();
|
|
102
|
+
expect(changeFilterSpy).toHaveBeenCalledWith({ fieldName: fieldName, filter: filter, values: [['NewValue']] }, id);
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
64
105
|
});
|
|
65
|
-
});
|
|
66
|
-
it('should call changeFilter prop after values changing', function () {
|
|
67
|
-
var rowContext = defaultProps.rowContext, rowData = defaultProps.rowData;
|
|
68
|
-
var newValues = ['1', '2'];
|
|
69
|
-
var newFilter = {
|
|
70
|
-
fieldName: rowData.attribute.fieldName,
|
|
71
|
-
filter: rowData.filter,
|
|
72
|
-
values: newValues
|
|
73
|
-
};
|
|
74
|
-
var component = setUp();
|
|
75
|
-
component.find(FilterValueEditor).prop('onChange')(newValues);
|
|
76
|
-
expect(rowContext.changeFilter).toBeCalledWith(newFilter, rowData.id);
|
|
77
|
-
});
|
|
106
|
+
}); });
|
|
78
107
|
it('should not render AttributesValuesEditor if there is not rowData.attribute', function () {
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
expect(component.find(FilterValueEditor)).toHaveLength(0);
|
|
108
|
+
var container = setUp(__assign(__assign({}, defaultProps), { rowData: null })).container;
|
|
109
|
+
expect(container.firstChild).toBeEmptyDOMElement();
|
|
82
110
|
});
|
|
83
111
|
it('should not render AttributesValuesEditor if checkIfOptionHasValues return false', function () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
expect(component.find(FilterValueEditor)).toHaveLength(0);
|
|
112
|
+
var container = setUp(__assign(__assign({}, defaultProps), { rowData: __assign(__assign({}, defaultProps.rowData), { filter: 'missing' }) })).container;
|
|
113
|
+
expect(container.firstChild).toBeEmptyDOMElement();
|
|
87
114
|
});
|
|
88
115
|
});
|