@truedat/dq 4.33.8 → 4.34.2

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 (90) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/package.json +5 -5
  3. package/src/api.js +5 -1
  4. package/src/components/ConditionSummary.js +23 -21
  5. package/src/components/ExecutionDetails.js +11 -14
  6. package/src/components/ExecutionForm.js +116 -0
  7. package/src/components/ExecutionGroup.js +24 -15
  8. package/src/components/ExecutionPopup.js +58 -0
  9. package/src/components/ImplementationResultBar.js +80 -0
  10. package/src/components/ImplementationSummary.js +33 -72
  11. package/src/components/ImplementationsRoutes.js +15 -5
  12. package/src/components/ImplementationsUploadButton.js +63 -0
  13. package/src/components/InformationSummary.js +68 -0
  14. package/src/components/NewRuleImplementation.js +12 -0
  15. package/src/components/RuleForm.js +0 -178
  16. package/src/components/RuleImplementation.js +10 -6
  17. package/src/components/RuleImplementationProperties.js +31 -64
  18. package/src/components/RuleImplementationResults.js +87 -53
  19. package/src/components/RuleImplementationsActions.js +18 -48
  20. package/src/components/RuleProperties.js +1 -10
  21. package/src/components/RuleResultDecorator.js +43 -26
  22. package/src/components/RuleResultRow.js +4 -1
  23. package/src/components/RuleRoutes.js +0 -13
  24. package/src/components/RuleSummary.js +15 -2
  25. package/src/components/RulesActions.js +17 -10
  26. package/src/components/RulesUploadButton.js +58 -0
  27. package/src/components/__tests__/ExecutionForm.spec.js +25 -0
  28. package/src/components/__tests__/ExecutionGroup.spec.js +11 -7
  29. package/src/components/__tests__/ExecutionPopup.spec.js +20 -0
  30. package/src/components/__tests__/ImplementationResultBar.spec.js +98 -0
  31. package/src/components/__tests__/ImplementationSummary.spec.js +9 -26
  32. package/src/components/__tests__/InformationSummary.spec.js +35 -0
  33. package/src/components/__tests__/NewRuleImplementation.spec.js +1 -1
  34. package/src/components/__tests__/RuleForm.spec.js +0 -191
  35. package/src/components/__tests__/RuleImplementation.spec.js +1 -0
  36. package/src/components/__tests__/RuleImplementationProperties.spec.js +23 -33
  37. package/src/components/__tests__/RuleImplementationsActions.spec.js +10 -32
  38. package/src/components/__tests__/RuleProperties.spec.js +7 -9
  39. package/src/components/__tests__/RuleResultDecorator.spec.js +17 -11
  40. package/src/components/__tests__/RuleResultRow.spec.js +25 -46
  41. package/src/components/__tests__/RuleRow.spec.js +0 -4
  42. package/src/components/__tests__/RuleSummary.spec.js +6 -6
  43. package/src/components/__tests__/Rules.spec.js +15 -39
  44. package/src/components/__tests__/__snapshots__/ConditionSummary.spec.js.snap +55 -51
  45. package/src/components/__tests__/__snapshots__/ExecutionForm.spec.js.snap +33 -0
  46. package/src/components/__tests__/__snapshots__/ExecutionGroup.spec.js.snap +5 -4
  47. package/src/components/__tests__/__snapshots__/ExecutionPopup.spec.js.snap +11 -0
  48. package/src/components/__tests__/__snapshots__/ImplementationResultBar.spec.js.snap +141 -0
  49. package/src/components/__tests__/__snapshots__/ImplementationSummary.spec.js.snap +194 -457
  50. package/src/components/__tests__/__snapshots__/InformationSummary.spec.js.snap +185 -0
  51. package/src/components/__tests__/__snapshots__/NewRuleImplementation.spec.js.snap +6 -0
  52. package/src/components/__tests__/__snapshots__/RuleForm.spec.js.snap +0 -148
  53. package/src/components/__tests__/__snapshots__/RuleImplementation.spec.js.snap +20 -0
  54. package/src/components/__tests__/__snapshots__/RuleImplementationProperties.spec.js.snap +43 -49
  55. package/src/components/__tests__/__snapshots__/RuleImplementationResults.spec.js.snap +63 -61
  56. package/src/components/__tests__/__snapshots__/RuleImplementationsActions.spec.js.snap +5 -49
  57. package/src/components/__tests__/__snapshots__/RuleProperties.spec.js.snap +0 -1
  58. package/src/components/__tests__/__snapshots__/RuleRow.spec.js.snap +0 -28
  59. package/src/components/__tests__/__snapshots__/Rules.spec.js.snap +0 -101
  60. package/src/components/ruleImplementationForm/InformationForm.js +5 -5
  61. package/src/components/ruleImplementationForm/LimitsForm.js +142 -0
  62. package/src/components/ruleImplementationForm/RuleImplementationForm.js +14 -4
  63. package/src/components/ruleImplementationForm/RuleImplementationRawForm.js +16 -6
  64. package/src/components/ruleImplementationForm/__tests__/LimitsForm.spec.js +186 -0
  65. package/src/components/ruleImplementationForm/__tests__/RuleImplementationRawForm.spec.js +42 -35
  66. package/src/components/ruleImplementationForm/__tests__/__snapshots__/LimitsForm.spec.js.snap +1104 -0
  67. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationForm.spec.js.snap +4 -1
  68. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationRawForm.spec.js.snap +12 -1
  69. package/src/components/ruleImplementationForm/limitsValidation.js +72 -0
  70. package/src/messages/en.js +145 -71
  71. package/src/messages/es.js +270 -180
  72. package/src/reducers/__tests__/rule.spec.js +2 -4
  73. package/src/reducers/__tests__/ruleImplementation.spec.js +2 -0
  74. package/src/reducers/__tests__/ruleImplementations.spec.js +12 -8
  75. package/src/reducers/dqMessage.js +100 -1
  76. package/src/reducers/index.js +4 -0
  77. package/src/reducers/rule.js +0 -3
  78. package/src/reducers/ruleImplementation.js +3 -0
  79. package/src/reducers/ruleImplementationRedirect.js +6 -1
  80. package/src/reducers/ruleImplementations.js +3 -0
  81. package/src/reducers/ruleRedirect.js +5 -0
  82. package/src/reducers/uploadImplementationsFile.js +28 -0
  83. package/src/reducers/uploadRulesFile.js +25 -0
  84. package/src/routines.js +2 -0
  85. package/src/sagas/index.js +6 -0
  86. package/src/sagas/uploadImplementations.js +28 -0
  87. package/src/sagas/uploadRules.js +28 -0
  88. package/src/selectors/getRuleImplementationColumns.js +38 -3
  89. package/src/selectors/ruleColumnsSelector.js +0 -31
  90. package/src/styles/ruleSummary.less +17 -10
@@ -5,26 +5,33 @@ import { Link } from "react-router-dom";
5
5
  import { Button } from "semantic-ui-react";
6
6
  import { FormattedMessage } from "react-intl";
7
7
  import { RULE_NEW } from "@truedat/core/routes";
8
+ import { uploadRules } from "../routines";
9
+ import RulesUploadButton from "./RulesUploadButton";
8
10
 
9
- export const RulesActions = ({ userRulesPermissions }) => (
11
+ export const RulesActions = ({ userRulesPermissions, upload }) => (
10
12
  <div style={{ float: "right" }}>
11
13
  {userRulesPermissions.manage_quality_rules && (
12
- <Button
13
- primary
14
- as={Link}
15
- to={RULE_NEW}
16
- content={<FormattedMessage id="quality.actions.create" />}
17
- />
14
+ <>
15
+ <Button
16
+ primary
17
+ as={Link}
18
+ to={RULE_NEW}
19
+ content={<FormattedMessage id="quality.actions.create" />}
20
+ />
21
+ {upload && <RulesUploadButton />}
22
+ <RulesUploadButton />
23
+ </>
18
24
  )}
19
25
  </div>
20
26
  );
21
27
 
22
28
  RulesActions.propTypes = {
23
- userRulesPermissions: PropTypes.object
29
+ userRulesPermissions: PropTypes.object,
30
+ upload: PropTypes.bool,
24
31
  };
25
32
 
26
33
  const mapStateToProps = ({ userRulesPermissions }) => ({
27
- userRulesPermissions
34
+ userRulesPermissions,
28
35
  });
29
36
 
30
- export default connect(mapStateToProps)(RulesActions);
37
+ export default connect(mapStateToProps)(RulesActions, uploadRules);
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { connect } from "react-redux";
4
+ import { Button } from "semantic-ui-react";
5
+ import { FormattedMessage, useIntl } from "react-intl";
6
+ import { UploadModal } from "@truedat/core/components";
7
+ import { API_RULES_UPLOAD } from "../api";
8
+ import { uploadRules } from "../routines";
9
+
10
+ const uploadAction = {
11
+ method: "POST",
12
+ href: API_RULES_UPLOAD,
13
+ };
14
+
15
+ export const RulesUploadButton = ({ uploadRules, loading }) => {
16
+ const { formatMessage } = useIntl();
17
+ return (
18
+ <UploadModal
19
+ icon="upload"
20
+ trigger={
21
+ <Button
22
+ secondary
23
+ floated="right"
24
+ icon="upload"
25
+ loading={loading}
26
+ data-tooltip={formatMessage({
27
+ id: "rules.actions.upload.tooltip",
28
+ })}
29
+ />
30
+ }
31
+ header={
32
+ <FormattedMessage id="rules.actions.upload.confirmation.header" />
33
+ }
34
+ content={
35
+ <FormattedMessage id="rules.actions.upload.confirmation.content" />
36
+ }
37
+ param={"rules"}
38
+ handleSubmit={(data) =>
39
+ uploadRules({
40
+ action: "upload",
41
+ data,
42
+ ...uploadAction,
43
+ })
44
+ }
45
+ />
46
+ );
47
+ };
48
+
49
+ RulesUploadButton.propTypes = {
50
+ uploadRules: PropTypes.func,
51
+ loading: PropTypes.bool,
52
+ };
53
+
54
+ const mapStateToProps = ({ uploadRulesFile: { loading } }) => ({
55
+ loading,
56
+ });
57
+
58
+ export default connect(mapStateToProps, { uploadRules })(RulesUploadButton);
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import { ExecutionForm } from "../ExecutionForm";
4
+
5
+ describe("<ExecutionForm />", () => {
6
+ const handleSubmit = jest.fn();
7
+ const selectTemplate = jest.fn();
8
+ const props = { count: 1, templates: [], handleSubmit, selectTemplate };
9
+ const renderOpts = {
10
+ messages: {
11
+ en: {
12
+ "actions.cancel": "cancel",
13
+ "actions.create": "create",
14
+ "implementations.actions.execution.confirmation.content": "content",
15
+ "implementations.actions.execution.confirmation.header": "header",
16
+ "implementations.actions.execution.confirmation.legend": "legend",
17
+ },
18
+ },
19
+ };
20
+
21
+ it("matches the latest snapshot", () => {
22
+ const { container } = render(<ExecutionForm {...props} />, renderOpts);
23
+ expect(container).toMatchSnapshot();
24
+ });
25
+ });
@@ -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,20 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import { ExecutionPopup } from "../ExecutionPopup";
4
+
5
+ describe("<ExecutionPopup />", () => {
6
+ const handleSubmit = jest.fn();
7
+ const props = { count: 1, handleSubmit };
8
+ const renderOpts = {
9
+ messages: {
10
+ en: {
11
+ "implementations.actions.do_execution": "do_execution",
12
+ },
13
+ },
14
+ };
15
+
16
+ it("matches the latest snapshot", () => {
17
+ const { container } = render(<ExecutionPopup {...props} />, renderOpts);
18
+ expect(container).toMatchSnapshot();
19
+ });
20
+ });
@@ -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
  },