@truedat/df 6.6.5 → 6.7.0
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/package.json +5 -5
- package/src/components/DynamicFieldValue.js +7 -1
- package/src/components/DynamicForm.js +4 -1
- package/src/components/DynamicFormViewer.js +0 -1
- package/src/components/FieldGroupDetail.js +3 -3
- package/src/components/FieldGroupSegment.js +6 -2
- package/src/components/OriginLabel.js +34 -0
- package/src/components/__tests__/DynamicFieldValue.spec.js +2 -2
- package/src/components/__tests__/DynamicForm.spec.js +4 -1
- package/src/components/__tests__/FieldGroupDetail.spec.js +12 -12
- package/src/components/__tests__/SelectableDynamicForm.spec.js +1 -1
- package/src/components/__tests__/__snapshots__/EditableDynamicFieldValue.spec.js.snap +2 -2
- package/src/components/widgets/DynamicField.js +71 -62
- package/src/components/widgets/__tests__/DynamicField.spec.js +34 -14
- package/src/components/widgets/__tests__/HierarchyDropdown.spec.js +48 -0
- package/src/components/widgets/__tests__/HierarchyPreview.spec.js +1 -2
- package/src/components/widgets/__tests__/__snapshots__/HierarchyDropdown.spec.js.snap +6 -0
- package/src/templates/components/templateForm/ActiveGroupForm.js +4 -1
- package/src/templates/components/templateForm/DefaultValue.js +13 -10
- package/src/templates/components/templateForm/FieldForm.js +8 -2
- package/src/templates/components/templateForm/__tests__/DefaultValue.spec.js +2 -2
- package/src/templates/components/templateForm/__tests__/FieldForm.spec.js +2 -2
- package/src/templates/utils/__tests__/applyDefaults.spec.js +101 -51
- package/src/templates/utils/__tests__/applyTemplate.spec.js +81 -37
- package/src/templates/utils/__tests__/filterDepends.spec.js +9 -6
- package/src/templates/utils/__tests__/filterDomains.spec.js +76 -31
- package/src/templates/utils/__tests__/filterSwitches.spec.js +35 -6
- package/src/templates/utils/__tests__/filterValues.spec.js +19 -7
- package/src/templates/utils/__tests__/parseFieldOptions.spec.js +18 -12
- package/src/templates/utils/__tests__/parseGroups.spec.js +57 -18
- package/src/templates/utils/applyDefaults.js +62 -21
- package/src/templates/utils/filterDepends.js +4 -2
- package/src/templates/utils/filterDomains.js +1 -1
- package/src/templates/utils/filterSwitches.js +6 -6
- package/src/templates/utils/filterValues.js +7 -4
- package/src/templates/utils/parseFieldOptions.js +1 -1
- package/src/templates/utils/parseGroups.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/df",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"description": "Truedat Web Data Quality Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@testing-library/jest-dom": "^5.16.5",
|
|
35
35
|
"@testing-library/react": "^12.0.0",
|
|
36
36
|
"@testing-library/user-event": "^13.2.1",
|
|
37
|
-
"@truedat/test": "6.
|
|
37
|
+
"@truedat/test": "6.7.0",
|
|
38
38
|
"babel-jest": "^28.1.0",
|
|
39
39
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
40
40
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@apollo/client": "^3.7.1",
|
|
90
|
-
"@truedat/auth": "6.
|
|
91
|
-
"@truedat/core": "6.
|
|
90
|
+
"@truedat/auth": "6.7.0",
|
|
91
|
+
"@truedat/core": "6.7.0",
|
|
92
92
|
"decode-uri-component": "^0.2.2",
|
|
93
93
|
"path-to-regexp": "^1.7.0",
|
|
94
94
|
"prop-types": "^15.8.1",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"react-dom": ">= 16.8.6 < 17",
|
|
110
110
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "6a4284b126a917e396160f1b36c03ca0faf6bac5"
|
|
113
113
|
}
|
|
@@ -3,6 +3,7 @@ import React from "react";
|
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
5
5
|
import { Icon, List, Container } from "semantic-ui-react";
|
|
6
|
+
import OriginLabel from "./OriginLabel";
|
|
6
7
|
import DomainPreview from "./widgets/DomainPreview";
|
|
7
8
|
import HierarchyPreview from "./widgets/HierarchyPreview";
|
|
8
9
|
import SystemPreview from "./widgets/SystemPreview";
|
|
@@ -11,13 +12,17 @@ import "../styles/fieldGroupDetail.less";
|
|
|
11
12
|
|
|
12
13
|
export const DynamicFieldValue = ({
|
|
13
14
|
label,
|
|
14
|
-
value,
|
|
15
|
+
value: valueAndOrigin,
|
|
15
16
|
type,
|
|
16
17
|
values,
|
|
17
18
|
widget,
|
|
18
19
|
isSecret,
|
|
19
20
|
isChanged,
|
|
20
21
|
}) => {
|
|
22
|
+
const { value, origin } = valueAndOrigin || {
|
|
23
|
+
value: null,
|
|
24
|
+
origin: "default",
|
|
25
|
+
};
|
|
21
26
|
const { formatMessage } = useIntl();
|
|
22
27
|
return (
|
|
23
28
|
<List.Item>
|
|
@@ -36,6 +41,7 @@ export const DynamicFieldValue = ({
|
|
|
36
41
|
{label ? (
|
|
37
42
|
<FormattedMessage id={`fields.${label}`} defaultMessage={label} />
|
|
38
43
|
) : null}
|
|
44
|
+
<OriginLabel origin={origin} />
|
|
39
45
|
</List.Header>
|
|
40
46
|
<List.Description>
|
|
41
47
|
{_.isNil(value) || (!_.isNumber(value) && _.isEmpty(value)) ? (
|
|
@@ -38,7 +38,10 @@ export const DynamicForm = ({
|
|
|
38
38
|
|
|
39
39
|
const handleChange = (e, { name, value }) => {
|
|
40
40
|
e && e.preventDefault();
|
|
41
|
-
const newContent = applyTemplate(
|
|
41
|
+
const newContent = applyTemplate(
|
|
42
|
+
{ ...content, [name]: { value: value, origin: "user" } },
|
|
43
|
+
domainId
|
|
44
|
+
);
|
|
42
45
|
onChange(newContent);
|
|
43
46
|
};
|
|
44
47
|
|
|
@@ -18,9 +18,9 @@ const parseField = (field) => {
|
|
|
18
18
|
)(values);
|
|
19
19
|
return {
|
|
20
20
|
...field,
|
|
21
|
-
value: _.isArray(value)
|
|
22
|
-
? _.map(translateValue)(value)
|
|
23
|
-
: translateValue(value),
|
|
21
|
+
value: _.isArray(value.value)
|
|
22
|
+
? { ...value, value: _.map(translateValue)(value.value) }
|
|
23
|
+
: { ...value, value: translateValue(value.value) },
|
|
24
24
|
};
|
|
25
25
|
} else {
|
|
26
26
|
return field;
|
|
@@ -22,7 +22,7 @@ export const FieldGroupSegment = ({
|
|
|
22
22
|
key={i}
|
|
23
23
|
onFieldChange={onFieldChange}
|
|
24
24
|
name={field.name}
|
|
25
|
-
fields={field.value}
|
|
25
|
+
fields={field.value.value}
|
|
26
26
|
prevFields={fields}
|
|
27
27
|
/>
|
|
28
28
|
) : (
|
|
@@ -35,7 +35,11 @@ export const FieldGroupSegment = ({
|
|
|
35
35
|
fields={fields}
|
|
36
36
|
isModification={isModification}
|
|
37
37
|
key={i}
|
|
38
|
-
onChange={
|
|
38
|
+
onChange={
|
|
39
|
+
_.includes(field.name)(noTranslatableFields)
|
|
40
|
+
? () => false
|
|
41
|
+
: onFieldChange
|
|
42
|
+
}
|
|
39
43
|
/>
|
|
40
44
|
)
|
|
41
45
|
)}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
|
|
5
|
+
import { Icon } from "semantic-ui-react";
|
|
6
|
+
|
|
7
|
+
const OriginLabel = ({ origin }) => {
|
|
8
|
+
const { formatMessage } = useIntl();
|
|
9
|
+
|
|
10
|
+
const icon = formatMessage({
|
|
11
|
+
id: `template.field.origin.${origin}.icon`,
|
|
12
|
+
defaultMessage: "none",
|
|
13
|
+
}).replace("none", "");
|
|
14
|
+
const label = formatMessage({
|
|
15
|
+
id: `template.field.origin.${origin}.label`,
|
|
16
|
+
defaultMessage: "none",
|
|
17
|
+
}).replace("none", "");
|
|
18
|
+
|
|
19
|
+
return icon || label ? (
|
|
20
|
+
<span
|
|
21
|
+
title={`Generated by ${origin}`}
|
|
22
|
+
className={`originLabel ${origin}Label`}
|
|
23
|
+
>
|
|
24
|
+
{icon && <Icon name={icon} />}
|
|
25
|
+
{label && <span>{label}</span>}
|
|
26
|
+
</span>
|
|
27
|
+
) : null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
OriginLabel.propTypes = {
|
|
31
|
+
origin: PropTypes.string,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default OriginLabel;
|
|
@@ -6,7 +6,7 @@ describe("<DynamicFieldValue />", () => {
|
|
|
6
6
|
it("matches the latest snapshot", () => {
|
|
7
7
|
const props = {
|
|
8
8
|
label: "label",
|
|
9
|
-
value: "value",
|
|
9
|
+
value: { value: "value", origin: "user" },
|
|
10
10
|
type: "string",
|
|
11
11
|
values: null,
|
|
12
12
|
widget: "text",
|
|
@@ -19,7 +19,7 @@ describe("<DynamicFieldValue />", () => {
|
|
|
19
19
|
const props = {
|
|
20
20
|
isChanged: true,
|
|
21
21
|
label: "label",
|
|
22
|
-
value: "value",
|
|
22
|
+
value: { value: "value", origin: "user" },
|
|
23
23
|
type: "string",
|
|
24
24
|
values: null,
|
|
25
25
|
widget: "text",
|
|
@@ -114,7 +114,7 @@ describe("<DynamicForm />", () => {
|
|
|
114
114
|
fields: [
|
|
115
115
|
{
|
|
116
116
|
name: "test",
|
|
117
|
-
default: { 1: ["a"] },
|
|
117
|
+
default: { value: { 1: ["a"] }, origin: "user" },
|
|
118
118
|
values: {
|
|
119
119
|
domain: { 1: ["a", "b", "c"] },
|
|
120
120
|
},
|
|
@@ -123,6 +123,9 @@ describe("<DynamicForm />", () => {
|
|
|
123
123
|
},
|
|
124
124
|
],
|
|
125
125
|
};
|
|
126
|
+
const content = {
|
|
127
|
+
test: { value: "a", origin: "user" },
|
|
128
|
+
};
|
|
126
129
|
const props = {
|
|
127
130
|
applyTemplate,
|
|
128
131
|
onChange,
|
|
@@ -9,24 +9,24 @@ describe("<FieldGroupDetail />", () => {
|
|
|
9
9
|
fields: [
|
|
10
10
|
{
|
|
11
11
|
cardinality: "?",
|
|
12
|
-
default: "",
|
|
12
|
+
default: { value: "", origin: "default" },
|
|
13
13
|
label: "foo field",
|
|
14
14
|
name: "foo_field",
|
|
15
15
|
type: "string",
|
|
16
16
|
values: null,
|
|
17
17
|
widget: "text",
|
|
18
|
-
value: "foo value",
|
|
18
|
+
value: { value: "foo value", origin: "user" },
|
|
19
19
|
required: false,
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
cardinality: "?",
|
|
23
|
-
default: "",
|
|
23
|
+
default: { value: "", origin: "default" },
|
|
24
24
|
label: "bar field",
|
|
25
25
|
name: "bar_field",
|
|
26
26
|
type: "string",
|
|
27
27
|
values: null,
|
|
28
28
|
widget: "number",
|
|
29
|
-
value: 25,
|
|
29
|
+
value: { value: 25, origin: "user" },
|
|
30
30
|
required: false,
|
|
31
31
|
},
|
|
32
32
|
],
|
|
@@ -42,24 +42,24 @@ describe("<FieldGroupDetail />", () => {
|
|
|
42
42
|
fields: [
|
|
43
43
|
{
|
|
44
44
|
cardinality: "?",
|
|
45
|
-
default: "",
|
|
45
|
+
default: { value: "", origin: "default" },
|
|
46
46
|
label: "foo field",
|
|
47
47
|
name: "foo_field",
|
|
48
48
|
type: "string",
|
|
49
49
|
values: null,
|
|
50
50
|
widget: "text",
|
|
51
|
-
value: "foo value",
|
|
51
|
+
value: { value: "foo value", origin: "user" },
|
|
52
52
|
required: false,
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
cardinality: "?",
|
|
56
|
-
default: "",
|
|
56
|
+
default: { value: "", origin: "default" },
|
|
57
57
|
label: "bar field",
|
|
58
58
|
name: "bar_field",
|
|
59
59
|
type: "string",
|
|
60
60
|
values: null,
|
|
61
61
|
widget: "number",
|
|
62
|
-
value: 25,
|
|
62
|
+
value: { value: 25, origin: "user" },
|
|
63
63
|
required: false,
|
|
64
64
|
},
|
|
65
65
|
],
|
|
@@ -75,24 +75,24 @@ describe("<FieldGroupDetail />", () => {
|
|
|
75
75
|
fields: [
|
|
76
76
|
{
|
|
77
77
|
cardinality: "?",
|
|
78
|
-
default: "",
|
|
78
|
+
default: { value: "", origin: "default" },
|
|
79
79
|
label: "foo field",
|
|
80
80
|
name: "foo_field",
|
|
81
81
|
type: "string",
|
|
82
82
|
values: null,
|
|
83
83
|
widget: "text",
|
|
84
|
-
value: "foo value",
|
|
84
|
+
value: { value: "foo value", origin: "user" },
|
|
85
85
|
required: false,
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
cardinality: "?",
|
|
89
|
-
default: "",
|
|
89
|
+
default: { value: "", origin: "default" },
|
|
90
90
|
label: "bar field",
|
|
91
91
|
name: "bar_field",
|
|
92
92
|
type: "string",
|
|
93
93
|
values: null,
|
|
94
94
|
widget: "number",
|
|
95
|
-
value: 25,
|
|
95
|
+
value: { value: 25, origin: "user" },
|
|
96
96
|
required: false,
|
|
97
97
|
},
|
|
98
98
|
],
|
|
@@ -70,7 +70,7 @@ describe("<SelectableDynamicForm />", () => {
|
|
|
70
70
|
const input = container.querySelector('[name="field1"]');
|
|
71
71
|
userEvent.type(input, "A");
|
|
72
72
|
expect(onChange).toHaveBeenCalledWith({
|
|
73
|
-
content: { field1: "A" },
|
|
73
|
+
content: { field1: { value: "A", origin: "user" } },
|
|
74
74
|
valid: [],
|
|
75
75
|
});
|
|
76
76
|
});
|
|
@@ -33,7 +33,7 @@ exports[`<EditableDynamicFieldValue /> matches the latest snapshot 1`] = `
|
|
|
33
33
|
<input
|
|
34
34
|
name="name"
|
|
35
35
|
type="text"
|
|
36
|
-
value="
|
|
36
|
+
value=""
|
|
37
37
|
/>
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
@@ -85,7 +85,7 @@ exports[`<EditableDynamicFieldValue /> matches the latest snapshot 1`] = `
|
|
|
85
85
|
<input
|
|
86
86
|
name="name"
|
|
87
87
|
type="text"
|
|
88
|
-
value="
|
|
88
|
+
value=""
|
|
89
89
|
/>
|
|
90
90
|
</div>
|
|
91
91
|
</div>
|
|
@@ -3,6 +3,7 @@ import React from "react";
|
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { Form, Icon, Popup, Label } from "semantic-ui-react";
|
|
5
5
|
import { FormattedMessage } from "react-intl";
|
|
6
|
+
import OriginLabel from "../OriginLabel";
|
|
6
7
|
import DateTimeField from "./DateTimeField";
|
|
7
8
|
import CheckboxField from "./CheckboxField";
|
|
8
9
|
import ColorPickerField from "./ColorPickerField";
|
|
@@ -72,7 +73,7 @@ export const DynamicField = ({
|
|
|
72
73
|
label,
|
|
73
74
|
cardinality,
|
|
74
75
|
description,
|
|
75
|
-
value,
|
|
76
|
+
value: valueAndOrigin,
|
|
76
77
|
editable = true,
|
|
77
78
|
disabled = false,
|
|
78
79
|
...fieldProps
|
|
@@ -80,71 +81,79 @@ export const DynamicField = ({
|
|
|
80
81
|
isModification,
|
|
81
82
|
onChange,
|
|
82
83
|
scope,
|
|
83
|
-
}) =>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
}) => {
|
|
85
|
+
const { value, origin } = valueAndOrigin || {
|
|
86
|
+
value: null,
|
|
87
|
+
origin: "default",
|
|
88
|
+
};
|
|
89
|
+
return (
|
|
90
|
+
<Form.Field
|
|
91
|
+
disabled={(!editable && isModification) || disabled}
|
|
92
|
+
data-testid="form-field"
|
|
93
|
+
>
|
|
94
|
+
<label>
|
|
95
|
+
{(label && fieldProps.type != "hierarchy") ||
|
|
96
|
+
(fieldProps.type == "hierarchy" &&
|
|
97
|
+
(fieldProps.values.hierarchy.min_depth == 0 ||
|
|
98
|
+
!fieldProps.values.hierarchy.min_depth)) ? (
|
|
98
99
|
<FormattedMessage id={`fields.${label}`} defaultMessage={label} />
|
|
100
|
+
) : null}
|
|
101
|
+
{label &&
|
|
102
|
+
fieldProps.type == "hierarchy" &&
|
|
103
|
+
fieldProps.values.hierarchy.min_depth > 0 ? (
|
|
104
|
+
<>
|
|
105
|
+
<FormattedMessage id={`fields.${label}`} defaultMessage={label} />
|
|
106
|
+
<Label pointing="left">
|
|
107
|
+
<FormattedMessage
|
|
108
|
+
id="hierarchy.selectable.mindepth"
|
|
109
|
+
values={{ depth: fieldProps.values.hierarchy.min_depth }}
|
|
110
|
+
/>
|
|
111
|
+
</Label>
|
|
112
|
+
</>
|
|
113
|
+
) : null}
|
|
114
|
+
{fieldProps?.required && (
|
|
115
|
+
<span
|
|
116
|
+
style={{
|
|
117
|
+
color: "#D95C5C",
|
|
118
|
+
marginLeft: "3px",
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
*
|
|
122
|
+
</span>
|
|
123
|
+
)}
|
|
124
|
+
<OriginLabel origin={origin} />
|
|
125
|
+
{description && (
|
|
126
|
+
<Popup
|
|
127
|
+
trigger={
|
|
128
|
+
<Icon
|
|
129
|
+
style={{
|
|
130
|
+
cursor: "pointer",
|
|
131
|
+
marginLeft: "5px",
|
|
132
|
+
}}
|
|
133
|
+
name="question circle outline"
|
|
134
|
+
/>
|
|
135
|
+
}
|
|
136
|
+
content={description}
|
|
137
|
+
on="click"
|
|
138
|
+
hideOnScroll
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
141
|
+
{fieldProps?.required && isNullOrEmpty(value) ? (
|
|
99
142
|
<Label pointing="left">
|
|
100
|
-
<FormattedMessage
|
|
101
|
-
id="hierarchy.selectable.mindepth"
|
|
102
|
-
values={{ depth: fieldProps.values.hierarchy.min_depth }}
|
|
103
|
-
/>
|
|
143
|
+
<FormattedMessage id="template.form.validation.empty_required" />
|
|
104
144
|
</Label>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
{fieldProps?.required && (
|
|
108
|
-
<span
|
|
109
|
-
style={{
|
|
110
|
-
color: "#D95C5C",
|
|
111
|
-
marginLeft: "3px",
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
*
|
|
115
|
-
</span>
|
|
116
|
-
)}
|
|
117
|
-
{description && (
|
|
118
|
-
<Popup
|
|
119
|
-
trigger={
|
|
120
|
-
<Icon
|
|
121
|
-
style={{
|
|
122
|
-
cursor: "pointer",
|
|
123
|
-
marginLeft: "5px",
|
|
124
|
-
}}
|
|
125
|
-
name="question circle outline"
|
|
126
|
-
/>
|
|
127
|
-
}
|
|
128
|
-
content={description}
|
|
129
|
-
on="click"
|
|
130
|
-
hideOnScroll
|
|
131
|
-
/>
|
|
132
|
-
)}
|
|
133
|
-
{fieldProps?.required && isNullOrEmpty(value) ? (
|
|
134
|
-
<Label pointing="left">
|
|
135
|
-
<FormattedMessage id="template.form.validation.empty_required" />
|
|
136
|
-
</Label>
|
|
137
|
-
) : null}
|
|
138
|
-
</label>
|
|
145
|
+
) : null}
|
|
146
|
+
</label>
|
|
139
147
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
148
|
+
<FieldByWidget
|
|
149
|
+
field={{ ...fieldProps, value, cardinality }}
|
|
150
|
+
onChange={onChange}
|
|
151
|
+
scope={scope}
|
|
152
|
+
widget={_.prop("widget")(fieldProps)}
|
|
153
|
+
/>
|
|
154
|
+
</Form.Field>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
148
157
|
|
|
149
158
|
DynamicField.propTypes = {
|
|
150
159
|
field: PropTypes.object.isRequired,
|
|
@@ -6,6 +6,8 @@ import { DynamicField } from "../DynamicField";
|
|
|
6
6
|
const onChange = jest.fn();
|
|
7
7
|
|
|
8
8
|
describe("<DynamicField />", () => {
|
|
9
|
+
const defaultValue = { value: "", origin: "user" };
|
|
10
|
+
|
|
9
11
|
it("matches the latest snapshot (radio widget)", () => {
|
|
10
12
|
const parsedValues = [
|
|
11
13
|
{
|
|
@@ -21,74 +23,84 @@ describe("<DynamicField />", () => {
|
|
|
21
23
|
text: "c",
|
|
22
24
|
},
|
|
23
25
|
];
|
|
24
|
-
const props = {
|
|
26
|
+
const props = {
|
|
27
|
+
field: { widget: "radio", parsedValues, ...defaultValue },
|
|
28
|
+
onChange,
|
|
29
|
+
};
|
|
25
30
|
const { container } = render(<DynamicField {...props} />);
|
|
26
31
|
expect(container).toMatchSnapshot();
|
|
27
32
|
});
|
|
28
33
|
|
|
29
34
|
it("matches the latest snapshot (checkbox widget)", () => {
|
|
30
|
-
const props = { field: { widget: "checkbox" }, onChange };
|
|
35
|
+
const props = { field: { widget: "checkbox", ...defaultValue }, onChange };
|
|
31
36
|
const { container } = render(<DynamicField {...props} />);
|
|
32
37
|
expect(container).toMatchSnapshot();
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
it("matches the latest snapshot (dropdown widget)", () => {
|
|
36
|
-
const props = { field: { widget: "dropdown" }, onChange };
|
|
41
|
+
const props = { field: { widget: "dropdown", ...defaultValue }, onChange };
|
|
37
42
|
const { container } = render(<DynamicField {...props} />);
|
|
38
43
|
expect(container).toMatchSnapshot();
|
|
39
44
|
});
|
|
40
45
|
|
|
41
46
|
it("matches the latest snapshot (textarea widget)", () => {
|
|
42
|
-
const props = { field: { widget: "textarea" }, onChange };
|
|
47
|
+
const props = { field: { widget: "textarea", ...defaultValue }, onChange };
|
|
43
48
|
const { container } = render(<DynamicField {...props} />);
|
|
44
49
|
expect(container).toMatchSnapshot();
|
|
45
50
|
});
|
|
46
51
|
|
|
47
52
|
it("matches the latest snapshot (color_picker widget)", () => {
|
|
48
|
-
const props = {
|
|
53
|
+
const props = {
|
|
54
|
+
field: { widget: "color_picker", ...defaultValue },
|
|
55
|
+
onChange,
|
|
56
|
+
};
|
|
49
57
|
const { container } = render(<DynamicField {...props} />);
|
|
50
58
|
expect(container).toMatchSnapshot();
|
|
51
59
|
});
|
|
52
60
|
|
|
53
61
|
it("matches the latest snapshot (pair_list widget)", () => {
|
|
54
|
-
const props = { field: { widget: "pair_list" }, onChange };
|
|
62
|
+
const props = { field: { widget: "pair_list", ...defaultValue }, onChange };
|
|
55
63
|
const { container } = render(<DynamicField {...props} />);
|
|
56
64
|
expect(container).toMatchSnapshot();
|
|
57
65
|
});
|
|
58
66
|
|
|
59
67
|
it("matches the latest snapshot (image widget)", () => {
|
|
60
|
-
const props = { field: { widget: "image" }, onChange };
|
|
68
|
+
const props = { field: { widget: "image", ...defaultValue }, onChange };
|
|
61
69
|
const { container } = render(<DynamicField {...props} />);
|
|
62
70
|
expect(container).toMatchSnapshot();
|
|
63
71
|
});
|
|
64
72
|
|
|
65
73
|
it("matches the latest snapshot (number widget)", () => {
|
|
66
|
-
const props = { field: { widget: "number" }, onChange };
|
|
74
|
+
const props = { field: { widget: "number", ...defaultValue }, onChange };
|
|
67
75
|
const { container } = render(<DynamicField {...props} />);
|
|
68
76
|
expect(container).toMatchSnapshot();
|
|
69
77
|
});
|
|
70
78
|
|
|
71
79
|
it("matches the latest snapshot (date widget)", () => {
|
|
72
|
-
const props = { field: { widget: "date" }, onChange };
|
|
80
|
+
const props = { field: { widget: "date", ...defaultValue }, onChange };
|
|
73
81
|
const { container } = render(<DynamicField {...props} />);
|
|
74
82
|
expect(container).toMatchSnapshot();
|
|
75
83
|
});
|
|
76
84
|
|
|
77
85
|
it("matches the latest snapshot (datetime widget)", () => {
|
|
78
|
-
const props = { field: { widget: "datetime" }, onChange };
|
|
86
|
+
const props = { field: { widget: "datetime", ...defaultValue }, onChange };
|
|
79
87
|
const { container } = render(<DynamicField {...props} />);
|
|
80
88
|
expect(container).toMatchSnapshot();
|
|
81
89
|
});
|
|
82
90
|
|
|
83
91
|
it("matches the latest snapshot (default widget)", () => {
|
|
84
|
-
const props = { field: { widget: "foo" }, onChange };
|
|
92
|
+
const props = { field: { widget: "foo", ...defaultValue }, onChange };
|
|
85
93
|
const { container } = render(<DynamicField {...props} />);
|
|
86
94
|
expect(container).toMatchSnapshot();
|
|
87
95
|
});
|
|
88
96
|
|
|
89
97
|
it("editable: false enable the form field if is not modification", () => {
|
|
90
98
|
const props = {
|
|
91
|
-
field: {
|
|
99
|
+
field: {
|
|
100
|
+
widget: "string",
|
|
101
|
+
value: { value: "input_placeholder", origin: "ai" },
|
|
102
|
+
editable: false,
|
|
103
|
+
},
|
|
92
104
|
onChange,
|
|
93
105
|
isModification: false,
|
|
94
106
|
};
|
|
@@ -102,7 +114,11 @@ describe("<DynamicField />", () => {
|
|
|
102
114
|
|
|
103
115
|
it("editable: false disables the form field if is a modification", () => {
|
|
104
116
|
const props = {
|
|
105
|
-
field: {
|
|
117
|
+
field: {
|
|
118
|
+
widget: "string",
|
|
119
|
+
value: { value: "input_placeholder", origin: "user" },
|
|
120
|
+
editable: false,
|
|
121
|
+
},
|
|
106
122
|
onChange,
|
|
107
123
|
isModification: true,
|
|
108
124
|
};
|
|
@@ -116,7 +132,11 @@ describe("<DynamicField />", () => {
|
|
|
116
132
|
|
|
117
133
|
it("editable: true enables the form field if not a modification", () => {
|
|
118
134
|
const props = {
|
|
119
|
-
field: {
|
|
135
|
+
field: {
|
|
136
|
+
widget: "string",
|
|
137
|
+
value: { value: "input_placeholder", origin: "user" },
|
|
138
|
+
editable: true,
|
|
139
|
+
},
|
|
120
140
|
onChange,
|
|
121
141
|
isModification: false,
|
|
122
142
|
};
|
|
@@ -16,4 +16,52 @@ describe("<HierarchyDropdown />", () => {
|
|
|
16
16
|
const { container } = render(<HierarchyDropdown {...props} />);
|
|
17
17
|
expect(container).toMatchSnapshot();
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
it("matches the latest snapshot (min-depth 0)", async () => {
|
|
21
|
+
const missingMinDepthProps = {
|
|
22
|
+
field: {
|
|
23
|
+
name: "foo",
|
|
24
|
+
cardinality: "*",
|
|
25
|
+
value: "",
|
|
26
|
+
values: { hierarchy: { id: 50, min_depth: 0 } },
|
|
27
|
+
},
|
|
28
|
+
onChange: jest.fn(),
|
|
29
|
+
};
|
|
30
|
+
const { container } = render(
|
|
31
|
+
<HierarchyDropdown {...missingMinDepthProps} />
|
|
32
|
+
);
|
|
33
|
+
expect(container).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("matches the latest snapshot (min-depth 2)", async () => {
|
|
37
|
+
const missingMinDepthProps = {
|
|
38
|
+
field: {
|
|
39
|
+
name: "foo",
|
|
40
|
+
cardinality: "*",
|
|
41
|
+
value: "",
|
|
42
|
+
values: { hierarchy: { id: 50, min_depth: 2 } },
|
|
43
|
+
},
|
|
44
|
+
onChange: jest.fn(),
|
|
45
|
+
};
|
|
46
|
+
const { container } = render(
|
|
47
|
+
<HierarchyDropdown {...missingMinDepthProps} />
|
|
48
|
+
);
|
|
49
|
+
expect(container).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("matches the latest snapshot (missing min-depth)", async () => {
|
|
53
|
+
const missingMinDepthProps = {
|
|
54
|
+
field: {
|
|
55
|
+
name: "foo",
|
|
56
|
+
cardinality: "*",
|
|
57
|
+
value: "",
|
|
58
|
+
values: { hierarchy: { id: 50 } },
|
|
59
|
+
},
|
|
60
|
+
onChange: jest.fn(),
|
|
61
|
+
};
|
|
62
|
+
const { container } = render(
|
|
63
|
+
<HierarchyDropdown {...missingMinDepthProps} />
|
|
64
|
+
);
|
|
65
|
+
expect(container).toMatchSnapshot();
|
|
66
|
+
});
|
|
19
67
|
});
|
|
@@ -20,9 +20,8 @@ describe("<HierarchyPreview />", () => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it("show tooltip", async () => {
|
|
23
|
-
const { getByText
|
|
23
|
+
const { getByText } = render(<HierarchyPreview {...props} />);
|
|
24
24
|
userEvent.hover(await getByText("xyz"));
|
|
25
25
|
await waitFor(() => expect(getByText("baz")).toBeInTheDocument());
|
|
26
|
-
debug();
|
|
27
26
|
});
|
|
28
27
|
});
|