@truedat/dq 4.33.10 → 4.34.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +5 -5
  3. package/src/components/ConditionSummary.js +23 -21
  4. package/src/components/ExecutionDetails.js +11 -14
  5. package/src/components/ExecutionGroup.js +24 -15
  6. package/src/components/ImplementationResultBar.js +80 -0
  7. package/src/components/ImplementationSummary.js +33 -72
  8. package/src/components/InformationSummary.js +68 -0
  9. package/src/components/NewRuleImplementation.js +12 -0
  10. package/src/components/RuleForm.js +0 -178
  11. package/src/components/RuleImplementation.js +10 -6
  12. package/src/components/RuleImplementationProperties.js +31 -64
  13. package/src/components/RuleImplementationResults.js +87 -53
  14. package/src/components/RuleProperties.js +1 -10
  15. package/src/components/RuleResultDecorator.js +43 -26
  16. package/src/components/RuleResultRow.js +4 -1
  17. package/src/components/RuleRoutes.js +0 -13
  18. package/src/components/RuleSummary.js +15 -2
  19. package/src/components/__tests__/ExecutionGroup.spec.js +11 -7
  20. package/src/components/__tests__/ImplementationResultBar.spec.js +98 -0
  21. package/src/components/__tests__/ImplementationSummary.spec.js +9 -26
  22. package/src/components/__tests__/InformationSummary.spec.js +35 -0
  23. package/src/components/__tests__/NewRuleImplementation.spec.js +1 -1
  24. package/src/components/__tests__/RuleForm.spec.js +0 -191
  25. package/src/components/__tests__/RuleImplementation.spec.js +1 -0
  26. package/src/components/__tests__/RuleImplementationProperties.spec.js +23 -33
  27. package/src/components/__tests__/RuleProperties.spec.js +7 -9
  28. package/src/components/__tests__/RuleResultDecorator.spec.js +17 -11
  29. package/src/components/__tests__/RuleResultRow.spec.js +25 -46
  30. package/src/components/__tests__/RuleRow.spec.js +0 -4
  31. package/src/components/__tests__/RuleSummary.spec.js +6 -6
  32. package/src/components/__tests__/Rules.spec.js +15 -39
  33. package/src/components/__tests__/__snapshots__/ConditionSummary.spec.js.snap +55 -51
  34. package/src/components/__tests__/__snapshots__/ExecutionGroup.spec.js.snap +5 -4
  35. package/src/components/__tests__/__snapshots__/ImplementationResultBar.spec.js.snap +141 -0
  36. package/src/components/__tests__/__snapshots__/ImplementationSummary.spec.js.snap +194 -457
  37. package/src/components/__tests__/__snapshots__/InformationSummary.spec.js.snap +185 -0
  38. package/src/components/__tests__/__snapshots__/NewRuleImplementation.spec.js.snap +6 -0
  39. package/src/components/__tests__/__snapshots__/RuleForm.spec.js.snap +0 -148
  40. package/src/components/__tests__/__snapshots__/RuleImplementation.spec.js.snap +20 -0
  41. package/src/components/__tests__/__snapshots__/RuleImplementationProperties.spec.js.snap +43 -49
  42. package/src/components/__tests__/__snapshots__/RuleImplementationResults.spec.js.snap +63 -61
  43. package/src/components/__tests__/__snapshots__/RuleProperties.spec.js.snap +0 -1
  44. package/src/components/__tests__/__snapshots__/RuleRow.spec.js.snap +0 -28
  45. package/src/components/__tests__/__snapshots__/Rules.spec.js.snap +0 -101
  46. package/src/components/ruleImplementationForm/InformationForm.js +5 -5
  47. package/src/components/ruleImplementationForm/LimitsForm.js +142 -0
  48. package/src/components/ruleImplementationForm/RuleImplementationForm.js +14 -4
  49. package/src/components/ruleImplementationForm/RuleImplementationRawForm.js +16 -6
  50. package/src/components/ruleImplementationForm/__tests__/LimitsForm.spec.js +186 -0
  51. package/src/components/ruleImplementationForm/__tests__/RuleImplementationRawForm.spec.js +42 -35
  52. package/src/components/ruleImplementationForm/__tests__/__snapshots__/LimitsForm.spec.js.snap +1104 -0
  53. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationForm.spec.js.snap +4 -1
  54. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationRawForm.spec.js.snap +12 -1
  55. package/src/components/ruleImplementationForm/limitsValidation.js +72 -0
  56. package/src/messages/en.js +130 -71
  57. package/src/messages/es.js +253 -180
  58. package/src/reducers/__tests__/rule.spec.js +2 -4
  59. package/src/reducers/__tests__/ruleImplementation.spec.js +2 -0
  60. package/src/reducers/__tests__/ruleImplementations.spec.js +12 -8
  61. package/src/reducers/rule.js +0 -3
  62. package/src/reducers/ruleImplementation.js +3 -0
  63. package/src/reducers/ruleImplementations.js +3 -0
  64. package/src/selectors/getRuleImplementationColumns.js +38 -3
  65. package/src/selectors/ruleColumnsSelector.js +0 -31
  66. package/src/styles/ruleSummary.less +17 -10
@@ -10,31 +10,30 @@ const nilResult = (ruleResult) =>
10
10
  isNil(ruleResult) ||
11
11
  (has("result_text")(ruleResult) && isNil(ruleResult?.result_text));
12
12
 
13
- export const RuleResultDecorator = ({ ruleResult, rule, date }) => {
14
- const { formatMessage, formatNumber: _formatNumber } = useIntl();
13
+ export const calculateResultDecoration = ({
14
+ ruleResult,
15
+ ruleImplementation,
16
+ date,
17
+ intl: { formatMessage, formatNumber: _formatNumber },
18
+ }) => {
15
19
  const formatNumber = (num) => (isNil(num) ? num : _formatNumber(num));
16
- if (nilResult(ruleResult) && isNil(date)) {
17
- return null;
18
- }
20
+
19
21
  if (ruleResult?.result_text === "quality_result.failed") {
20
- return (
21
- <>
22
- <Icon
23
- name="warning circle"
24
- color="red"
25
- title={formatMessage({ id: "quality_result.failed" })}
26
- />
27
- {formatMessage({ id: "quality_result.failed" })}
28
- </>
29
- );
22
+ const resultText = formatMessage({ id: "quality_result.failed" });
23
+ return {
24
+ iconName: "warning circle",
25
+ resultText: resultText,
26
+ color: "red",
27
+ resultText,
28
+ };
30
29
  }
31
- const resultText = ruleResult?.result_text;
32
- const resultType = rule?.result_type;
30
+
31
+ const resultType = ruleImplementation?.result_type;
33
32
  const result =
34
33
  resultType === "errors_number"
35
34
  ? formatNumber(ruleResult?.errors)
36
35
  : ruleResult?.result;
37
- const resultTitle = isNil(result)
36
+ const resultText = isNil(result)
38
37
  ? formatMessage({ id: "quality.result.no.data" })
39
38
  : date
40
39
  ? formatMessage(
@@ -45,23 +44,41 @@ export const RuleResultDecorator = ({ ruleResult, rule, date }) => {
45
44
  { id: `quality.result.${resultType}.description` },
46
45
  { result }
47
46
  );
48
- const color = selectColor({ ...rule, ...ruleResult });
47
+ const color = selectColor({ ...ruleImplementation, ...ruleResult });
48
+ const iconTitle = ruleResult?.result_text
49
+ ? formatMessage({ id: ruleResult?.result_text })
50
+ : null;
51
+
52
+ return { iconName: "circle", color, resultText, iconTitle };
53
+ };
54
+
55
+ export const RuleResultDecorator = ({
56
+ ruleResult,
57
+ ruleImplementation,
58
+ date,
59
+ }) => {
60
+ const intl = useIntl();
61
+ if (nilResult(ruleResult) && isNil(date)) {
62
+ return null;
63
+ }
64
+ const { iconName, color, resultText, iconTitle } = calculateResultDecoration({
65
+ ruleResult,
66
+ ruleImplementation,
67
+ date,
68
+ intl,
69
+ });
49
70
 
50
71
  return (
51
72
  <>
52
- <Icon
53
- name="circle"
54
- title={resultText ? formatMessage({ id: resultText }) : null}
55
- color={color}
56
- />
57
- {resultTitle}
73
+ <Icon name={iconName} title={iconTitle} color={color} />
74
+ {resultText}
58
75
  </>
59
76
  );
60
77
  };
61
78
 
62
79
  RuleResultDecorator.propTypes = {
63
80
  ruleResult: PropTypes.object,
64
- rule: PropTypes.object,
81
+ ruleImplementation: PropTypes.object,
65
82
  date: PropTypes.string,
66
83
  };
67
84
 
@@ -41,7 +41,10 @@ export const RuleResultRow = ({
41
41
  }
42
42
  >
43
43
  <Table.Cell>
44
- <Icon name="circle" color={selectColor({ ...rule, ...ruleResult })} />
44
+ <Icon
45
+ name="circle"
46
+ color={selectColor({ ...ruleImplementation, ...ruleResult })}
47
+ />
45
48
  {`${parseFloat(ruleResult.result)} %`}
46
49
  </Table.Cell>
47
50
  <Table.Cell>
@@ -66,7 +66,6 @@ const RuleRoutes = ({
66
66
  templatesLoaded,
67
67
  template,
68
68
  structuresAliasesLoading,
69
- templateImpl,
70
69
  ruleImplementation,
71
70
  }) => {
72
71
  const latest = _.head(ruleImplementation.results);
@@ -227,14 +226,6 @@ const RuleRoutes = ({
227
226
  <RuleImplementationProperties />
228
227
  </RuleImplementation>
229
228
  )}
230
- {!_.isEmpty(templateImpl) && ruleImplementationLoaded && (
231
- <Segment attached="bottom">
232
- <DynamicFormViewer
233
- template={templateImpl}
234
- content={ruleImplementation.df_content}
235
- />
236
- </Segment>
237
- )}
238
229
  </Segment>
239
230
  </>
240
231
  )}
@@ -305,7 +296,6 @@ RuleRoutes.propTypes = {
305
296
  implementationStructures: PropTypes.array,
306
297
  ruleLoaded: PropTypes.bool,
307
298
  template: PropTypes.object,
308
- templateImpl: PropTypes.object,
309
299
  ruleImplementation: PropTypes.object,
310
300
  ruleImplementationLoaded: PropTypes.bool,
311
301
  implementationStructuresLoaded: PropTypes.bool,
@@ -325,9 +315,6 @@ const mapStateToProps = (state) => ({
325
315
  templatesLoaded: !state.templatesLoading && !_.isEmpty(state.templates),
326
316
  template: _.find(_.propEq("name", state.rule.df_name))(state.templates),
327
317
  structuresAliasesLoading: state.structuresAliasesLoading,
328
- templateImpl: _.find(_.propEq("name", state.ruleImplementation.df_name))(
329
- state.templates
330
- ),
331
318
  ruleImplementation: state.ruleImplementation,
332
319
  });
333
320
 
@@ -22,8 +22,12 @@ const mapSummary = (implementations) => {
22
22
  const failed = _.size(failedImplementations);
23
23
  const quality = _.reduce(
24
24
  (summary, implementation) => {
25
- const { errors, result } = implementation.execution_result_info;
26
- const { goal, minimum, result_type } = implementation.rule;
25
+ const {
26
+ goal,
27
+ minimum,
28
+ result_type,
29
+ execution_result_info: { errors, result },
30
+ } = implementation;
27
31
  const color = selectColor({ errors, result, minimum, goal, result_type });
28
32
  return _.set(color, summary[color] + 1)(summary);
29
33
  },
@@ -71,6 +75,15 @@ const SummaryBar = ({
71
75
  </>
72
76
  );
73
77
 
78
+ SummaryBar.propTypes = {
79
+ key: PropTypes.string,
80
+ className: PropTypes.string,
81
+ summary: PropTypes.object,
82
+ percentages: PropTypes.array,
83
+ showPercentages: PropTypes.bool,
84
+ tooltip: PropTypes.string,
85
+ };
86
+
74
87
  const SummaryBars = (props) => {
75
88
  return (
76
89
  <div className="rule-summary">
@@ -11,11 +11,15 @@ describe("<ExecutionGroup />", () => {
11
11
  const rule = {
12
12
  id: 1,
13
13
  name: "rule_name",
14
+ };
15
+ const implementation = {
16
+ id: 1,
17
+ implementation_key: "foo",
18
+ rule_id: 1,
14
19
  result_type: "percentage",
15
20
  minimum: 10,
16
- goal: 20
21
+ goal: 20,
17
22
  };
18
- const implementation = { id: 1, implementation_key: "foo", rule_id: 1 };
19
23
  const result = {
20
24
  id: 1,
21
25
  implementation_key: "foo",
@@ -25,7 +29,7 @@ describe("<ExecutionGroup />", () => {
25
29
  errors: 30,
26
30
  result_type: "percentage",
27
31
  minimum: 10,
28
- goal: 20
32
+ goal: 20,
29
33
  };
30
34
  const quality_events = [
31
35
  {
@@ -33,14 +37,14 @@ describe("<ExecutionGroup />", () => {
33
37
  execution_id: 1,
34
38
  id: 1,
35
39
  type: "SUCCESS",
36
- message: ""
37
- }
40
+ message: "",
41
+ },
38
42
  ];
39
43
  const executions = [
40
- { id: 1, _embedded: { rule, implementation, result, quality_events } }
44
+ { id: 1, _embedded: { rule, implementation, result, quality_events } },
41
45
  ];
42
46
  const props = {
43
- executionGroup: { id: 1, _embedded: { executions } }
47
+ executionGroup: { id: 1, _embedded: { executions } },
44
48
  };
45
49
 
46
50
  it("matches the latest snapshot", () => {
@@ -0,0 +1,98 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import ImplementationResultBar from "../ImplementationResultBar";
4
+ import messages from "../../messages/en";
5
+
6
+ describe("<ImplementationResultBar />", () => {
7
+ const renderOpts = {
8
+ messages: { en: messages },
9
+ };
10
+ const base = {
11
+ id: 1,
12
+ rule_id: 8,
13
+ goal: 80,
14
+ minimum: 50,
15
+ result_type: "percentage",
16
+ };
17
+ const overGoalProps = {
18
+ implementation: {
19
+ ...base,
20
+ results: [{ date: "2021-07-19T00:01:20Z", result: "99.99" }],
21
+ },
22
+ };
23
+ const underGoalProps = {
24
+ implementation: {
25
+ ...base,
26
+ results: [{ date: "2021-07-19T00:01:20Z", result: "70" }],
27
+ },
28
+ };
29
+ const underMinimumProps = {
30
+ implementation: {
31
+ ...base,
32
+ results: [{ date: "2021-07-19T00:01:20Z", result: "40" }],
33
+ },
34
+ };
35
+ const notExecutedProps = {
36
+ implementation: {
37
+ ...base,
38
+ results: [],
39
+ },
40
+ };
41
+ const failedProps = {
42
+ implementation: {
43
+ ...base,
44
+ results: [],
45
+ event_type: "FAILED",
46
+ },
47
+ };
48
+
49
+ it("render overGoal implementation", () => {
50
+ const { container } = render(
51
+ <ImplementationResultBar {...overGoalProps} />,
52
+ renderOpts
53
+ );
54
+ expect(container).toMatchSnapshot();
55
+ expect(container.querySelector(".over-goal-color")).not.toBeNull();
56
+ expect(container).toHaveTextContent("99.99% at 2021-07-19 00:01");
57
+ });
58
+
59
+ it("render underGoal implementation", () => {
60
+ const { container } = render(
61
+ <ImplementationResultBar {...underGoalProps} />,
62
+ renderOpts
63
+ );
64
+ expect(container).toMatchSnapshot();
65
+ expect(container.querySelector(".under-goal-color")).not.toBeNull();
66
+ expect(container).toHaveTextContent("70% at 2021-07-19 00:01");
67
+ });
68
+
69
+ it("render underMinimum implementation", () => {
70
+ const { container } = render(
71
+ <ImplementationResultBar {...underMinimumProps} />,
72
+ renderOpts
73
+ );
74
+ expect(container).toMatchSnapshot();
75
+ expect(container.querySelector(".under-minimum-color")).not.toBeNull();
76
+ expect(container).toHaveTextContent("40% at 2021-07-19 00:01");
77
+ });
78
+
79
+ it("render not executed implementation", () => {
80
+ const { container } = render(
81
+ <ImplementationResultBar {...notExecutedProps} />,
82
+ renderOpts
83
+ );
84
+ expect(container).toMatchSnapshot();
85
+ expect(container.querySelector(".not-executed-color")).not.toBeNull();
86
+ expect(container).toHaveTextContent("No information about quality");
87
+ });
88
+
89
+ it("render failed implementation", () => {
90
+ const { container } = render(
91
+ <ImplementationResultBar {...failedProps} />,
92
+ renderOpts
93
+ );
94
+ expect(container).toMatchSnapshot();
95
+ expect(container.querySelector(".failed-color")).not.toBeNull();
96
+ expect(container).toHaveTextContent("Latest execution failed");
97
+ });
98
+ });
@@ -7,6 +7,12 @@ import { ImplementationSummary } from "../ImplementationSummary";
7
7
  const renderOpts = {
8
8
  messages: {
9
9
  en: {
10
+ "ruleImplementationForm.step.information": "information",
11
+ "quality.thresholds": "thresholds",
12
+ "quality.threshold": "threshold",
13
+ "quality.goal": "goal",
14
+ "ruleImplementations.props.result_type.percentage": "percentage",
15
+
10
16
  "ruleImplementation.summary.field": "Field",
11
17
  "ruleImplementation.summary.operator": "Operator",
12
18
  "ruleImplementation.summary.structure": "Structure",
@@ -47,6 +53,9 @@ const ruleImplementation = {
47
53
  value: [{ raw: ["4", "5", "6"] }],
48
54
  },
49
55
  ],
56
+ goal: 50,
57
+ minimum: 10,
58
+ result_type: "percentage",
50
59
  implementationType: "",
51
60
  rawContent: { system: "", dataset: "", population: "", validations: "" },
52
61
  };
@@ -82,32 +91,6 @@ describe("<ImplementationSummary />", () => {
82
91
  expect(queryByText('"4, 5, 6"')).not.toBeNull();
83
92
  });
84
93
 
85
- it("displays correctly general summary", () => {
86
- const props = {
87
- ruleImplementation,
88
- };
89
- const { container, queryByText } = render(
90
- <ImplementationSummary {...props} />,
91
- renderOpts
92
- );
93
- expect(container).toMatchSnapshot();
94
- expect(queryByText("Executable")).not.toBeNull();
95
- expect(queryByText('"ImplKey"')).not.toBeNull();
96
- });
97
-
98
- it("renders executable as internal when it is false", () => {
99
- const props = {
100
- ruleImplementation: { ...ruleImplementation, executable: false },
101
- };
102
- const { container, queryByText } = render(
103
- <ImplementationSummary {...props} />,
104
- renderOpts
105
- );
106
- expect(container).toMatchSnapshot();
107
- expect(queryByText("Internal")).not.toBeNull();
108
- expect(queryByText('"ImplKey"')).not.toBeNull();
109
- });
110
-
111
94
  it("getValues returns array of values that contain required keys and adds optional keys for operator with field value_type", () => {
112
95
  expect(
113
96
  getValues({
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import InformationSummary from "../InformationSummary";
4
+ import messages from "../../messages/en";
5
+
6
+ describe("<InformationSummary />", () => {
7
+ const renderOpts = {
8
+ messages: { en: messages },
9
+ };
10
+ const ruleImplementation = {
11
+ id: 1,
12
+ rule_id: 8,
13
+ goal: 80,
14
+ minimum: 50,
15
+ };
16
+
17
+ it("renders percentage result_type", () => {
18
+ const props = {
19
+ ruleImplementation: { ...ruleImplementation, result_type: "percentage" },
20
+ };
21
+ const { container } = render(<InformationSummary {...props} />, renderOpts);
22
+ expect(container).toMatchSnapshot();
23
+ });
24
+
25
+ it("renders errors_number result_type", () => {
26
+ const props = {
27
+ ruleImplementation: {
28
+ ...ruleImplementation,
29
+ result_type: "errors_number",
30
+ },
31
+ };
32
+ const { container } = render(<InformationSummary {...props} />, renderOpts);
33
+ expect(container).toMatchSnapshot();
34
+ });
35
+ });
@@ -11,7 +11,7 @@ describe("<NewRuleImplementation />", () => {
11
11
  ruleImplementationProps,
12
12
  createRuleImplementation,
13
13
  updateRuleImplementation,
14
- sources
14
+ sources,
15
15
  };
16
16
 
17
17
  it("matches the latest snapshot", () => {
@@ -23,8 +23,6 @@ describe("<RuleForm />", () => {
23
23
  },
24
24
  },
25
25
  current_business_concept_version: { name: "My Concept" },
26
- goal: 10,
27
- minimum: 1,
28
26
  };
29
27
  const handleSubmit = jest.fn();
30
28
  const selectDomain = jest.fn();
@@ -52,9 +50,6 @@ describe("<RuleForm />", () => {
52
50
  const eventMock = {
53
51
  preventDefault: jest.fn(),
54
52
  };
55
-
56
- const findLabel = (wrapper, field) =>
57
- wrapper.find("FieldLabelWrapping").find({ label: `rule.props.${field}` });
58
53
  const findField = (wrapper, name) => wrapper.find({ name });
59
54
 
60
55
  it("matches the latest snapshot for editMode", () => {
@@ -112,192 +107,6 @@ describe("<RuleForm />", () => {
112
107
  expect(handleSubmit.mock.calls.length).toBe(1);
113
108
  });
114
109
 
115
- it("shows and hides required label", () => {
116
- const wrapper = shallowWithIntl(<RuleForm {...defaultProps} />);
117
-
118
- const requiredValidation = "rule.form.validation.empty_required";
119
-
120
- const testLabelOnChange = (name, value) => {
121
- expect(findLabel(wrapper, name).props().messages).toEqual([
122
- requiredValidation,
123
- ]);
124
- findField(wrapper, name).simulate("change", eventMock, { name, value });
125
- expect(findLabel(wrapper, name).props().messages).toEqual(undefined);
126
- };
127
-
128
- testLabelOnChange("name", "value");
129
- testLabelOnChange("minimum", "2");
130
- testLabelOnChange("goal", "3");
131
- });
132
-
133
- it("doesnt change goal and minimum fields values when not valid number", () => {
134
- const wrapper = shallowWithIntl(<RuleForm {...defaultProps} />);
135
-
136
- const testValueOnChange = (name, beforeValue, value, expectedValue) => {
137
- expect(findField(wrapper, name).props().value).toEqual(beforeValue);
138
- findField(wrapper, name).simulate("change", eventMock, { name, value });
139
- expect(findField(wrapper, name).props().value).toEqual(expectedValue);
140
- };
141
-
142
- testValueOnChange("minimum", "", "invalid", "");
143
- testValueOnChange("minimum", "", "4", 4);
144
- testValueOnChange("minimum", 4, "invalid", 4);
145
- testValueOnChange("minimum", 4, "", "");
146
- testValueOnChange("goal", "", "invalid", "");
147
- testValueOnChange("goal", "", "5", 5);
148
- testValueOnChange("goal", 5, "invalid", 5);
149
- testValueOnChange("goal", 5, "", "");
150
- });
151
-
152
- it("shows correct messages for minimum and goal number ranges", () => {
153
- const wrapper = shallowWithIntl(<RuleForm {...defaultProps} />);
154
-
155
- findField(wrapper, "goal").simulate("change", eventMock, {
156
- name: "goal",
157
- value: "4",
158
- });
159
- expect(findLabel(wrapper, "goal").props().messages).toEqual(undefined);
160
- findField(wrapper, "goal").simulate("change", eventMock, {
161
- name: "goal",
162
- value: "101",
163
- });
164
- expect(findLabel(wrapper, "goal").props().messages).toEqual([
165
- "rule.form.validation.max_goal",
166
- ]);
167
-
168
- findField(wrapper, "minimum").simulate("change", eventMock, {
169
- name: "minimum",
170
- value: "5",
171
- });
172
- findField(wrapper, "goal").simulate("change", eventMock, {
173
- name: "goal",
174
- value: "10",
175
- });
176
- expect(findLabel(wrapper, "minimum").props().messages).toEqual(undefined);
177
- expect(findLabel(wrapper, "goal").props().messages).toEqual(undefined);
178
-
179
- findField(wrapper, "minimum").simulate("change", eventMock, {
180
- name: "minimum",
181
- value: "15",
182
- });
183
-
184
- expect(findLabel(wrapper, "minimum").props().messages).toEqual([
185
- "rule.form.validation.minimum_greater",
186
- ]);
187
- expect(findLabel(wrapper, "goal").props().messages).toEqual([
188
- "rule.form.validation.goal_less",
189
- ]);
190
- });
191
-
192
- it("shows correct messages for minimum and goal number ranges in a Rule with result_type deviation", () => {
193
- const props = {
194
- rule: { ...rule, result_type: "deviation" },
195
- handleSubmit,
196
- templatesLoaded,
197
- isSubmitting,
198
- template,
199
- business_concept_id,
200
- applyTemplate: applyTemplate(template),
201
- };
202
-
203
- const wrapper = shallowWithIntl(<RuleForm {...props} />);
204
-
205
- findField(wrapper, "goal").simulate("change", eventMock, {
206
- name: "goal",
207
- value: "11",
208
- });
209
- expect(findLabel(wrapper, "goal").props().messages).toEqual([
210
- "rule.form.validation.goal.less_eq.minimum",
211
- ]);
212
- findField(wrapper, "goal").simulate("change", eventMock, {
213
- name: "goal",
214
- value: "0",
215
- });
216
- expect(findLabel(wrapper, "goal").props().messages).toEqual(undefined);
217
-
218
- findField(wrapper, "minimum").simulate("change", eventMock, {
219
- name: "minimum",
220
- value: "70",
221
- });
222
- findField(wrapper, "goal").simulate("change", eventMock, {
223
- name: "goal",
224
- value: "80",
225
- });
226
- expect(findLabel(wrapper, "minimum").props().messages).toEqual([
227
- "rule.form.validation.minimum.greater_eq.goal",
228
- ]);
229
- expect(findLabel(wrapper, "goal").props().messages).toEqual([
230
- "rule.form.validation.goal.less_eq.minimum",
231
- ]);
232
-
233
- findField(wrapper, "minimum").simulate("change", eventMock, {
234
- name: "minimum",
235
- value: "90",
236
- });
237
-
238
- expect(findLabel(wrapper, "minimum").props().messages).toEqual(undefined);
239
- expect(findLabel(wrapper, "goal").props().messages).toEqual(undefined);
240
-
241
- findField(wrapper, "minimum").simulate("change", eventMock, {
242
- name: "minimum",
243
- value: "101",
244
- });
245
-
246
- expect(findLabel(wrapper, "minimum").props().messages).toEqual([
247
- "rule.form.validation.max_minimum",
248
- ]);
249
- });
250
-
251
- it("shows correct messages for minimum and goal number ranges in a Rule with result_type numeric", () => {
252
- const props = {
253
- rule: { ...rule, result_type: "errors_number" },
254
- handleSubmit,
255
- templatesLoaded,
256
- isSubmitting,
257
- template,
258
- business_concept_id,
259
- applyTemplate: applyTemplate(template),
260
- };
261
-
262
- const wrapper = shallowWithIntl(<RuleForm {...props} />);
263
-
264
- findField(wrapper, "goal").simulate("change", eventMock, {
265
- name: "goal",
266
- value: "4",
267
- });
268
- expect(findLabel(wrapper, "goal").props().messages).toEqual([
269
- "rule.form.validation.goal.less_eq.minimum",
270
- ]);
271
- findField(wrapper, "goal").simulate("change", eventMock, {
272
- name: "goal",
273
- value: "1",
274
- });
275
- expect(findLabel(wrapper, "goal").props().messages).toEqual(undefined);
276
-
277
- findField(wrapper, "minimum").simulate("change", eventMock, {
278
- name: "minimum",
279
- value: "5",
280
- });
281
- findField(wrapper, "goal").simulate("change", eventMock, {
282
- name: "goal",
283
- value: "10",
284
- });
285
- expect(findLabel(wrapper, "minimum").props().messages).toEqual([
286
- "rule.form.validation.minimum.greater_eq.goal",
287
- ]);
288
- expect(findLabel(wrapper, "goal").props().messages).toEqual([
289
- "rule.form.validation.goal.less_eq.minimum",
290
- ]);
291
-
292
- findField(wrapper, "minimum").simulate("change", eventMock, {
293
- name: "minimum",
294
- value: "15",
295
- });
296
-
297
- expect(findLabel(wrapper, "minimum").props().messages).toEqual(undefined);
298
- expect(findLabel(wrapper, "goal").props().messages).toEqual(undefined);
299
- });
300
-
301
110
  it("handles correctly active field", () => {
302
111
  const wrapper = shallowWithIntl(<RuleForm {...defaultProps} />);
303
112
 
@@ -6,6 +6,7 @@ const state = {
6
6
  authentication: { role: "admin" },
7
7
  rule: { id: 1, name: "foo" },
8
8
  ruleImplementation: {
9
+ rule_id: 1,
9
10
  implementation_key: "impl key",
10
11
  id: 1,
11
12
  },