@truedat/dq 4.44.0 → 4.44.3

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 (82) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/package.json +5 -5
  3. package/src/components/EditRule.js +1 -1
  4. package/src/components/ExecutionForm.js +68 -78
  5. package/src/components/ExecutionPopup.js +10 -6
  6. package/src/components/ImplementationCrumbs.js +91 -0
  7. package/src/components/ImplementationResultBar.js +1 -2
  8. package/src/components/ImplementationStructures.js +1 -3
  9. package/src/components/Implementations.js +9 -2
  10. package/src/components/ImplementationsRoutes.js +386 -17
  11. package/src/components/NewRule.js +1 -1
  12. package/src/components/NewRuleImplementation.js +99 -135
  13. package/src/components/RemediationCrumbs.js +1 -2
  14. package/src/components/RemediationForm.js +32 -43
  15. package/src/components/RuleCrumbs.js +6 -63
  16. package/src/components/RuleForm.js +102 -103
  17. package/src/components/RuleImplementation.js +35 -40
  18. package/src/components/RuleImplementationActions.js +19 -23
  19. package/src/components/RuleImplementationLink.js +2 -3
  20. package/src/components/RuleImplementationProperties.js +13 -14
  21. package/src/components/RuleImplementationResultTabs.js +27 -35
  22. package/src/components/RuleImplementationResults.js +1 -6
  23. package/src/components/RuleImplementationResultsLink.js +3 -9
  24. package/src/components/RuleImplementationTabs.js +13 -18
  25. package/src/components/RuleImplementationsActions.js +48 -2
  26. package/src/components/RuleLink.js +3 -4
  27. package/src/components/RuleResultRow.js +1 -6
  28. package/src/components/RuleResultSegmentRow.js +0 -3
  29. package/src/components/RuleResultSegments.js +2 -6
  30. package/src/components/RuleResultsRoutes.js +45 -60
  31. package/src/components/RuleRoutes.js +41 -334
  32. package/src/components/RulesRoutes.js +0 -5
  33. package/src/components/__tests__/ExecutionForm.spec.js +7 -1
  34. package/src/components/__tests__/ExecutionPopup.spec.js +3 -2
  35. package/src/components/__tests__/ImplementationResultBar.spec.js +44 -63
  36. package/src/components/__tests__/InformationSummary.spec.js +2 -6
  37. package/src/components/__tests__/NewRuleImplementation.spec.js +4 -6
  38. package/src/components/__tests__/RemediationForm.spec.js +47 -58
  39. package/src/components/__tests__/RuleForm.spec.js +80 -207
  40. package/src/components/__tests__/RuleImplementation.spec.js +45 -22
  41. package/src/components/__tests__/RuleImplementationsActions.spec.js +0 -1
  42. package/src/components/__tests__/RuleImplementationsOptions.spec.js +1 -10
  43. package/src/components/__tests__/RuleResultsUpload.spec.js +1 -5
  44. package/src/components/__tests__/RuleSummary.spec.js +6 -11
  45. package/src/components/__tests__/__snapshots__/EditRule.spec.js.snap +1 -1
  46. package/src/components/__tests__/__snapshots__/ExecutionForm.spec.js.snap +1 -2
  47. package/src/components/__tests__/__snapshots__/ImplementationResultBar.spec.js.snap +5 -5
  48. package/src/components/__tests__/__snapshots__/NewRule.spec.js.snap +1 -1
  49. package/src/components/__tests__/__snapshots__/NewRuleImplementation.spec.js.snap +3 -0
  50. package/src/components/__tests__/__snapshots__/RemediationForm.spec.js.snap +2 -3
  51. package/src/components/__tests__/__snapshots__/RuleCrumbs.spec.js.snap +2 -73
  52. package/src/components/__tests__/__snapshots__/RuleForm.spec.js.snap +699 -385
  53. package/src/components/__tests__/__snapshots__/RuleImplementation.spec.js.snap +20 -33
  54. package/src/components/__tests__/__snapshots__/RuleImplementationResultTabs.spec.js.snap +1 -1
  55. package/src/components/__tests__/__snapshots__/RuleImplementationResults.spec.js.snap +0 -7
  56. package/src/components/__tests__/__snapshots__/RuleImplementationResultsLink.spec.js.snap +1 -1
  57. package/src/components/__tests__/__snapshots__/RuleImplementationTabs.spec.js.snap +5 -5
  58. package/src/components/__tests__/__snapshots__/RuleImplementationsActions.spec.js.snap +1 -1
  59. package/src/components/index.js +0 -2
  60. package/src/components/ruleImplementationForm/InformationForm.js +51 -74
  61. package/src/components/ruleImplementationForm/RuleImplementationForm.js +52 -47
  62. package/src/components/ruleImplementationForm/RuleImplementationRawForm.js +76 -98
  63. package/src/components/ruleImplementationForm/__tests__/LimitsForm.spec.js +9 -35
  64. package/src/components/ruleImplementationForm/__tests__/RuleImplementationForm.spec.js +26 -51
  65. package/src/components/ruleImplementationForm/__tests__/RuleImplementationRawForm.spec.js +42 -2
  66. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationForm.spec.js.snap +88 -17
  67. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationRawForm.spec.js.snap +12 -1
  68. package/src/messages/en.js +7 -6
  69. package/src/messages/es.js +7 -6
  70. package/src/reducers/__tests__/ruleImplementationRedirect.spec.js +2 -2
  71. package/src/reducers/__tests__/ruleRedirect.spec.js +3 -3
  72. package/src/reducers/ruleImplementation.js +3 -0
  73. package/src/reducers/ruleImplementationRedirect.js +7 -6
  74. package/src/reducers/ruleRedirect.js +4 -2
  75. package/src/reducers/userRulePermissions.js +3 -1
  76. package/src/sagas/__tests__/deleteRuleResult.spec.js +3 -5
  77. package/src/sagas/__tests__/setRuleImplementationStatus.spec.js +7 -4
  78. package/src/sagas/deleteRuleResult.js +2 -7
  79. package/src/sagas/setRuleImplementationStatus.js +7 -1
  80. package/src/components/DynamicRuleForm.js +0 -78
  81. package/src/components/__tests__/DynamicRuleForm.spec.js +0 -51
  82. package/src/components/__tests__/__snapshots__/DynamicRuleForm.spec.js.snap +0 -3
@@ -1,16 +1,24 @@
1
1
  import _ from "lodash/fp";
2
- import React, { useEffect, useState } from "react";
2
+ import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { connect } from "react-redux";
5
5
  import { useHistory } from "react-router-dom";
6
6
  import { FormattedMessage, useIntl } from "react-intl";
7
7
  import { Button, Form, Icon, Popup } from "semantic-ui-react";
8
+ import { TemplateSelector } from "@truedat/core/components";
8
9
  import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
9
10
  import { validateContent as validDfContent } from "@truedat/df/utils";
10
- import { selectTemplate } from "@truedat/df/routines";
11
11
  import LimitsForm from "./LimitsForm";
12
12
  import { areLimitsValid } from "./limitsValidation";
13
13
 
14
+ const DynamicForm = React.lazy(() =>
15
+ import("@truedat/df/components/DynamicForm")
16
+ );
17
+
18
+ const DomainDropdownSelector = React.lazy(() =>
19
+ import("@truedat/bg/taxonomy/components/DomainDropdownSelector")
20
+ );
21
+
14
22
  const Help = ({ message }) => {
15
23
  const { formatMessage } = useIntl();
16
24
  return (
@@ -29,82 +37,51 @@ Help.propTypes = {
29
37
  message: PropTypes.string,
30
38
  };
31
39
 
32
- const TemplateSelector = React.lazy(() =>
33
- import("@truedat/df/templates/components/TemplateSelector")
34
- );
35
-
36
- const DynamicForm = React.lazy(() =>
37
- import("@truedat/df/components/DynamicForm")
38
- );
39
-
40
- const ImplementationDynamicForm = ({
41
- ruleImplementation,
42
- onChange,
43
- selectTemplate,
44
- template,
45
- }) => {
46
- const [templateId, setTemplateId] = useState(template.id);
47
-
48
- useEffect(() => {
49
- selectTemplate({ id: templateId });
50
- }, [selectTemplate, templateId]);
51
-
52
- const handleContentChange = (content) => onChange("dfContent", content);
53
- const handleTemplateSelected = (e, { value }) => setTemplateId(value);
54
-
55
- return (
56
- <>
57
- <TemplateSelector
58
- name="template"
59
- selectedValue={_.prop("id")(template)}
60
- onChange={handleTemplateSelected}
61
- />
62
- {template && template.id && (
63
- <DynamicForm
64
- content={_.prop("dfContent")(ruleImplementation)}
65
- onChange={handleContentChange}
66
- />
67
- )}
68
- </>
69
- );
70
- };
71
-
72
- ImplementationDynamicForm.propTypes = {
73
- onChange: PropTypes.func,
74
- selectTemplate: PropTypes.func,
75
- template: PropTypes.object,
76
- ruleImplementation: PropTypes.object,
77
- };
78
-
79
40
  export const RuleImplementationRawForm = ({
80
- ruleImplementation,
81
- handleSubmit,
82
- isSubmitting,
83
41
  implementationKey,
42
+ isSubmitting,
43
+ onChange,
44
+ onSubmit,
84
45
  rawContent,
46
+ rule,
47
+ ruleImplementation,
85
48
  setImplementationKey,
86
49
  setImplementationRawContent,
87
- selectTemplate,
50
+ setTemplate,
88
51
  sources,
89
52
  sourcesLoading,
90
53
  template = {},
91
- templates,
92
- onChange,
93
54
  }) => {
94
55
  const { formatMessage } = useIntl();
95
56
  const history = useHistory();
96
57
 
58
+ const handleTemplatesLoaded = ({ templates }) => {
59
+ const name = ruleImplementation?.dfName;
60
+ const template = name
61
+ ? _.find(_.propEq("name", name))(templates)
62
+ : _.size(templates) == 1
63
+ ? templates[0]
64
+ : null;
65
+ setTemplate(template);
66
+ };
67
+
68
+ const handleTemplateSelected = (e, { template }) => {
69
+ setTemplate(template);
70
+ };
71
+
72
+ const handleContentChange = (content) => onChange("dfContent", content);
73
+
97
74
  const isNilOrEmpty = (propName) =>
98
75
  _.isNil(_.prop(propName)(rawContent)) ||
99
76
  _.prop(propName)(rawContent) === "";
100
77
 
101
78
  const isNotEmptyProp = (propName) => !isNilOrEmpty(propName);
102
79
  const hasNoErrors = (propName) =>
103
- _.path(`${propName}.hasErrors`)(errors) == false;
80
+ _.path([propName, "hasErrors"])(errors) == false;
104
81
 
105
82
  const doSubmit = () => {
106
83
  if (isValidForm()) {
107
- handleSubmit();
84
+ onSubmit();
108
85
  }
109
86
  };
110
87
 
@@ -145,17 +122,15 @@ export const RuleImplementationRawForm = ({
145
122
  template &&
146
123
  !_.isEmpty(template) &&
147
124
  _.size(validDfContent(template)(ruleImplementation?.dfContent)) == 0 &&
125
+ (!_.isEmpty(rule) || _.isNumber(_.prop("domain_id")(ruleImplementation))) &&
148
126
  areLimitsValid(ruleImplementation);
149
127
 
150
- const isValidForm = () => {
151
- return (
152
- validInformation() &&
153
- isNotEmptyProp("source_id") &&
154
- (_.isEmpty(databaseOptions) || isNotEmptyProp("database")) &&
155
- _.every(isNotEmptyProp)(["dataset", "validations"]) &&
156
- _.every(hasNoErrors)(["dataset", "population", "validations"])
157
- );
158
- };
128
+ const isValidForm = () =>
129
+ validInformation() &&
130
+ isNotEmptyProp("source_id") &&
131
+ (_.isEmpty(databaseOptions) || isNotEmptyProp("database")) &&
132
+ _.every(isNotEmptyProp)(["dataset", "validations"]) &&
133
+ _.every(hasNoErrors)(["dataset", "population", "validations"]);
159
134
 
160
135
  const validateContent = (name) => {
161
136
  const invalidContent = getBannedWordsAndChars(_.prop(name)(rawContent));
@@ -173,13 +148,11 @@ export const RuleImplementationRawForm = ({
173
148
  };
174
149
  };
175
150
 
176
- const getErrors = () => {
177
- return {
178
- dataset: validateContent("dataset"),
179
- population: validateContent("population"),
180
- validations: validateContent("validations"),
181
- };
182
- };
151
+ const getErrors = () => ({
152
+ dataset: validateContent("dataset"),
153
+ population: validateContent("population"),
154
+ validations: validateContent("validations"),
155
+ });
183
156
 
184
157
  const doCancel = () => history.goBack();
185
158
  const errors = getErrors();
@@ -209,16 +182,29 @@ export const RuleImplementationRawForm = ({
209
182
  value={implementationKey}
210
183
  />
211
184
  </Form.Field>
185
+ {_.isEmpty(rule) && !ruleImplementation?.rule_id && (
186
+ <Form.Field>
187
+ <DomainDropdownSelector
188
+ value={ruleImplementation.domain_id}
189
+ onChange={(_e, { value }) => onChange("domain_id", value)}
190
+ />
191
+ </Form.Field>
192
+ )}
212
193
  <LimitsForm onChange={onChange} ruleImplementation={ruleImplementation} />
213
- {!_.isEmpty(templates) && (
214
- <ImplementationDynamicForm
215
- selectTemplate={selectTemplate}
194
+ <TemplateSelector
195
+ scope="ri"
196
+ selectedValue={template?.id}
197
+ onChange={handleTemplateSelected}
198
+ onLoad={handleTemplatesLoaded}
199
+ required
200
+ />
201
+ {template?.id ? (
202
+ <DynamicForm
216
203
  template={template}
217
- templates={templates}
218
- ruleImplementation={ruleImplementation}
219
- onChange={onChange}
204
+ content={_.prop("dfContent")(ruleImplementation)}
205
+ onChange={handleContentChange}
220
206
  />
221
- )}
207
+ ) : null}
222
208
  <Form.Dropdown
223
209
  label={
224
210
  <label>
@@ -335,7 +321,7 @@ export const RuleImplementationRawForm = ({
335
321
  primary
336
322
  loading={isSubmitting}
337
323
  onClick={() => doSubmit()}
338
- content={formatMessage({ id: "actions.submit" })}
324
+ content={formatMessage({ id: "actions.save" })}
339
325
  />
340
326
  <Button
341
327
  content={formatMessage({ id: "actions.cancel" })}
@@ -348,32 +334,24 @@ export const RuleImplementationRawForm = ({
348
334
  };
349
335
 
350
336
  RuleImplementationRawForm.propTypes = {
351
- handleSubmit: PropTypes.func.isRequired,
352
337
  implementationKey: PropTypes.string,
353
338
  isSubmitting: PropTypes.bool,
339
+ onChange: PropTypes.func,
340
+ onSubmit: PropTypes.func.isRequired,
354
341
  rawContent: PropTypes.object,
342
+ rule: PropTypes.object,
343
+ ruleImplementation: PropTypes.object,
355
344
  setImplementationKey: PropTypes.func,
356
345
  setImplementationRawContent: PropTypes.func,
357
- selectTemplate: PropTypes.func,
346
+ setTemplate: PropTypes.func,
358
347
  sources: PropTypes.array,
359
348
  sourcesLoading: PropTypes.bool,
360
349
  template: PropTypes.object,
361
- templates: PropTypes.object,
362
- ruleImplementation: PropTypes.object,
363
- onChange: PropTypes.func,
364
350
  };
365
351
 
366
- const mapStateToProps = (state) => ({
367
- isSubmitting: state.ruleImplementationCreating,
368
- templates: state.templates,
369
- template: getTemplate(state),
352
+ const mapStateToProps = ({ rule, ruleImplementationCreating }) => ({
353
+ isSubmitting: ruleImplementationCreating,
354
+ rule,
370
355
  });
371
356
 
372
- const getTemplate = ({ template, templates, ruleImplementation }) => {
373
- const df_name = _.prop("df_name")(ruleImplementation);
374
- return _.isEmpty(template) ? _.find({ name: df_name })(templates) : template;
375
- };
376
-
377
- export default connect(mapStateToProps, { selectTemplate })(
378
- RuleImplementationRawForm
379
- );
357
+ export default connect(mapStateToProps)(RuleImplementationRawForm);
@@ -1,14 +1,9 @@
1
1
  import React from "react";
2
- import { render } from "@truedat/test/render";
3
2
  import { fireEvent } from "@testing-library/react";
3
+ import { render } from "@truedat/test/render";
4
4
  import LimitsForm from "../LimitsForm";
5
- import messages from "../../../messages/en";
6
5
 
7
6
  describe("<LimitsForm />", () => {
8
- const renderOpts = {
9
- messages: { en: messages },
10
- };
11
-
12
7
  it("input changes calls onChange prop", () => {
13
8
  const onChange = jest.fn();
14
9
  const props = {
@@ -20,7 +15,7 @@ describe("<LimitsForm />", () => {
20
15
  onChange,
21
16
  };
22
17
 
23
- const { container } = render(<LimitsForm {...props} />, renderOpts);
18
+ const { container } = render(<LimitsForm {...props} />);
24
19
 
25
20
  fireEvent.change(container.querySelector("input[name=goal]"), {
26
21
  target: { name: "goal", value: "5" },
@@ -39,10 +34,7 @@ describe("<LimitsForm />", () => {
39
34
  onChange: jest.fn(),
40
35
  };
41
36
 
42
- const { container, getByText } = render(
43
- <LimitsForm {...props} />,
44
- renderOpts
45
- );
37
+ const { container, getByText } = render(<LimitsForm {...props} />);
46
38
  expect(container).toMatchSnapshot();
47
39
 
48
40
  const errorText = "Required field is empty";
@@ -60,10 +52,7 @@ describe("<LimitsForm />", () => {
60
52
  onChange: jest.fn(),
61
53
  };
62
54
 
63
- const { container, getByText } = render(
64
- <LimitsForm {...props} />,
65
- renderOpts
66
- );
55
+ const { container, getByText } = render(<LimitsForm {...props} />);
67
56
  expect(container).toMatchSnapshot();
68
57
 
69
58
  const errorText = "Invalid number format";
@@ -81,10 +70,7 @@ describe("<LimitsForm />", () => {
81
70
  onChange: jest.fn(),
82
71
  };
83
72
 
84
- const { container, getByText } = render(
85
- <LimitsForm {...props} />,
86
- renderOpts
87
- );
73
+ const { container, getByText } = render(<LimitsForm {...props} />);
88
74
  expect(container).toMatchSnapshot();
89
75
 
90
76
  const errorText = "Goal percentage cannot be greater than 100";
@@ -101,10 +87,7 @@ describe("<LimitsForm />", () => {
101
87
  onChange: jest.fn(),
102
88
  };
103
89
 
104
- const { container, getByText } = render(
105
- <LimitsForm {...props} />,
106
- renderOpts
107
- );
90
+ const { container, getByText } = render(<LimitsForm {...props} />);
108
91
  expect(container).toMatchSnapshot();
109
92
 
110
93
  expect(getByText("Goal")).toHaveTextContent(
@@ -125,10 +108,7 @@ describe("<LimitsForm />", () => {
125
108
  onChange: jest.fn(),
126
109
  };
127
110
 
128
- const { container, getByText } = render(
129
- <LimitsForm {...props} />,
130
- renderOpts
131
- );
111
+ const { container, getByText } = render(<LimitsForm {...props} />);
132
112
  expect(container).toMatchSnapshot();
133
113
 
134
114
  expect(getByText("Threshold")).toHaveTextContent(
@@ -146,10 +126,7 @@ describe("<LimitsForm />", () => {
146
126
  onChange: jest.fn(),
147
127
  };
148
128
 
149
- const { container, getByText } = render(
150
- <LimitsForm {...props} />,
151
- renderOpts
152
- );
129
+ const { container, getByText } = render(<LimitsForm {...props} />);
153
130
  expect(container).toMatchSnapshot();
154
131
 
155
132
  expect(getByText("Goal")).toHaveTextContent(
@@ -170,10 +147,7 @@ describe("<LimitsForm />", () => {
170
147
  onChange: jest.fn(),
171
148
  };
172
149
 
173
- const { container, getByText } = render(
174
- <LimitsForm {...props} />,
175
- renderOpts
176
- );
150
+ const { container, getByText } = render(<LimitsForm {...props} />);
177
151
  expect(container).toMatchSnapshot();
178
152
 
179
153
  expect(getByText("Goal")).toHaveTextContent(
@@ -1,63 +1,38 @@
1
- import React from "react";
1
+ import React, { Suspense } from "react";
2
+ import { waitFor } from "@testing-library/react";
2
3
  import { render } from "@truedat/test/render";
3
- import { intl } from "@truedat/test/intl-stub";
4
- import { RuleImplementationForm } from "../RuleImplementationForm";
4
+ import RuleImplementationForm from "../RuleImplementationForm";
5
5
 
6
- // workaround for enzyme issue with React.useContext
7
- // see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
8
- jest.spyOn(React, "useContext").mockImplementation(() => intl);
9
- jest.mock("react-router-dom", () => ({
10
- ...jest.requireActual("react-router-dom"),
11
- useHistory: () => ({ push: jest.fn() }),
12
- }));
6
+ const renderOpts = {
7
+ state: {
8
+ rule: {},
9
+ implementationActions: { manage_segments: {} },
10
+ ruleImplementationCreating: true,
11
+ },
12
+ };
13
13
 
14
14
  describe("<RuleImplementationForm />", () => {
15
- const rule = {
16
- id: 123,
17
- rule_type: {
18
- params: {
19
- system_params: [
20
- { type: "string", name: "table" },
21
- { type: "string", name: "column" },
22
- ],
23
- },
24
- },
25
- };
26
-
27
- const ruleImplementation = {
28
- implementationKey: "foo",
29
- executable: true,
30
- result_type: "percentage",
31
- goal: 20,
32
- minimum: 10,
33
- };
34
- const handleSubmit = jest.fn();
35
- const isSubmitting = false;
36
- const systems = ["SYS"];
37
-
38
- const renderOpts = {
39
- messages: {
40
- en: {
41
- "ruleImplementation.form.tooltip.percentage.goal": "tooltip",
42
- "ruleImplementation.form.tooltip.percentage.minimum": "Minimun",
43
- "rule.form.validation.empty_required": "required",
44
- },
45
- },
46
- };
47
15
  const props = {
48
- rule,
49
- handleSubmit,
50
- isSubmitting,
51
- systems,
52
- ruleImplementation,
53
- isSubmitting: true,
16
+ onSubmit: jest.fn(),
17
+ ruleImplementation: {
18
+ implementationKey: "foo",
19
+ executable: true,
20
+ result_type: "percentage",
21
+ goal: 20,
22
+ minimum: 10,
23
+ },
54
24
  };
55
25
 
56
- it("matches the latest snapshot", () => {
57
- const { container } = render(
58
- <RuleImplementationForm {...props} />,
26
+ it("matches the latest snapshot", async () => {
27
+ const { container, queryByText } = render(
28
+ <Suspense fallback="loading...">
29
+ <RuleImplementationForm {...props} />
30
+ </Suspense>,
59
31
  renderOpts
60
32
  );
33
+ await waitFor(() => {
34
+ expect(queryByText(/loading/i)).not.toBeInTheDocument();
35
+ });
61
36
  expect(container).toMatchSnapshot();
62
37
  });
63
38
  });
@@ -1,3 +1,4 @@
1
+ import _ from "lodash/fp";
1
2
  import React from "react";
2
3
  import { shallow } from "enzyme";
3
4
  import { intl } from "@truedat/test/intl-stub";
@@ -13,7 +14,7 @@ jest.mock("react-router-dom", () => ({
13
14
  }));
14
15
 
15
16
  describe("<RuleImplementationRawForm />", () => {
16
- const handleSubmit = jest.fn();
17
+ const onSubmit = jest.fn();
17
18
  const onChange = jest.fn();
18
19
  const isSubmitting = false;
19
20
  const sources = [
@@ -52,7 +53,7 @@ describe("<RuleImplementationRawForm />", () => {
52
53
  validations: "",
53
54
  },
54
55
  setImplementationRawContent: setImplementationRawContent,
55
- handleSubmit,
56
+ onSubmit,
56
57
  isSubmitting,
57
58
  sources,
58
59
  onChange,
@@ -110,6 +111,25 @@ describe("<RuleImplementationRawForm />", () => {
110
111
  expect(databaseDropdown).toHaveLength(0);
111
112
  });
112
113
 
114
+ it("submit button enabled if there is valid content in form with database without rule", () => {
115
+ const domainProps = _.set("ruleImplementation.domain_id", 5)(props);
116
+ const customProps = {
117
+ ...domainProps,
118
+ rawContent: {
119
+ dataset: "address a on c.address_id=a.id",
120
+ source_id: 2,
121
+ database: "db2",
122
+ population: "",
123
+ validations: "a.city='MADRID'",
124
+ },
125
+ template: { id: 1 },
126
+ dfContent: {},
127
+ };
128
+ const wrapper = shallow(<RuleImplementationRawForm {...customProps} />);
129
+ const submitButton = wrapper.find("FormButton[type='submit']");
130
+ expect(submitButton.props().disabled).toBe(false);
131
+ });
132
+
113
133
  it("submit button enabled if there is valid content in form with database", () => {
114
134
  const customProps = {
115
135
  ...props,
@@ -122,6 +142,7 @@ describe("<RuleImplementationRawForm />", () => {
122
142
  },
123
143
  template: { id: 1 },
124
144
  dfContent: {},
145
+ rule: { id: 5, name: "regla" },
125
146
  };
126
147
  const wrapper = shallow(<RuleImplementationRawForm {...customProps} />);
127
148
  const submitButton = wrapper.find("FormButton[type='submit']");
@@ -177,6 +198,24 @@ describe("<RuleImplementationRawForm />", () => {
177
198
  });
178
199
  });
179
200
 
201
+ it("submit button enabled if there is valid content in form without rule", () => {
202
+ const domainProps = _.set("ruleImplementation.domain_id", 5)(props);
203
+ const customProps = {
204
+ ...domainProps,
205
+ rawContent: {
206
+ dataset: "cliente c join address a on c.address_id=a.id",
207
+ source_id: 1,
208
+ population: "",
209
+ validations: "a.city='MADRID'",
210
+ },
211
+ template: { id: 1 },
212
+ dfContent: {},
213
+ };
214
+ const wrapper = shallow(<RuleImplementationRawForm {...customProps} />);
215
+ const submitButton = wrapper.find("FormButton[type='submit']");
216
+ expect(submitButton.props().disabled).toBe(false);
217
+ });
218
+
180
219
  it("submit button enabled if there is valid content in form", () => {
181
220
  const customProps = {
182
221
  ...props,
@@ -188,6 +227,7 @@ describe("<RuleImplementationRawForm />", () => {
188
227
  },
189
228
  template: { id: 1 },
190
229
  dfContent: {},
230
+ rule: { id: 5, name: "regla" },
191
231
  };
192
232
  const wrapper = shallow(<RuleImplementationRawForm {...customProps} />);
193
233
  const submitButton = wrapper.find("FormButton[type='submit']");