@truedat/dq 4.40.6 → 4.40.9
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/CHANGELOG.md +12 -0
- package/package.json +5 -5
- package/src/api.js +2 -0
- package/src/components/ExecutionDetails.js +65 -40
- package/src/components/ImplementationResultBar.js +1 -1
- package/src/components/NewRemediation.js +64 -0
- package/src/components/RemediationCrumbs.js +76 -0
- package/src/components/RemediationForm.js +129 -0
- package/src/components/RemediationPlan.js +164 -0
- package/src/components/RuleImplementation.js +1 -1
- package/src/components/RuleImplementationResults.js +2 -1
- package/src/components/RuleResultRow.js +4 -1
- package/src/components/RuleRoutes.js +324 -296
- package/src/components/__tests__/ExecutionDetails.spec.js +17 -5
- package/src/components/__tests__/RemediationForm.spec.js +68 -0
- package/src/components/__tests__/RemediationPlan.spec.js +106 -0
- package/src/components/__tests__/__snapshots__/ExecutionDetails.spec.js.snap +104 -0
- package/src/components/__tests__/__snapshots__/RemediationForm.spec.js.snap +19 -0
- package/src/components/__tests__/__snapshots__/RemediationPlan.spec.js.snap +3 -0
- package/src/messages/en.js +7 -0
- package/src/messages/es.js +7 -0
- package/src/reducers/__tests__/remediation.spec.js +83 -0
- package/src/reducers/__tests__/remediationActions.spec.js +46 -0
- package/src/reducers/__tests__/remediationLoading.spec.js +50 -0
- package/src/reducers/dqMessage.js +8 -2
- package/src/reducers/index.js +6 -0
- package/src/reducers/remediation.js +35 -0
- package/src/reducers/remediationActions.js +19 -0
- package/src/reducers/remediationLoading.js +29 -0
- package/src/routines.js +6 -0
- package/src/sagas/__tests__/createRemediation.spec.js +83 -0
- package/src/sagas/__tests__/deleteRemediation.spec.js +82 -0
- package/src/sagas/__tests__/fetchRemediation.spec.js +78 -0
- package/src/sagas/__tests__/fetchRuleImplementation.spec.js +1 -1
- package/src/sagas/__tests__/updateRemediation.spec.js +81 -0
- package/src/sagas/createRemediation.js +31 -0
- package/src/sagas/deleteRemediation.js +29 -0
- package/src/sagas/fetchRemediation.js +30 -0
- package/src/sagas/index.js +12 -0
- package/src/sagas/updateRemediation.js +29 -0
- package/src/styles/executionDetails.less +3 -0
- package/src/styles/remediationPlan.less +8 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from "react";
|
|
1
|
+
import React, { Suspense } from "react";
|
|
3
2
|
import { render } from "@truedat/test/render";
|
|
4
3
|
import messages from "@truedat/dq/messages";
|
|
5
4
|
import { ExecutionDetails } from "../ExecutionDetails";
|
|
@@ -14,6 +13,7 @@ const renderOpts = {
|
|
|
14
13
|
en: {
|
|
15
14
|
...messages.en,
|
|
16
15
|
"ruleResult.details.props.test": "TestMessage",
|
|
16
|
+
"actions.create": "create",
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
};
|
|
@@ -25,7 +25,12 @@ describe("<ExecutionDetails>", () => {
|
|
|
25
25
|
results: [{ foo: "bar", id: 100, details: { Query: "ImZvbyI=" } }],
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
|
-
const { container } = render(
|
|
28
|
+
const { container } = render(
|
|
29
|
+
<Suspense fallback={null}>
|
|
30
|
+
<ExecutionDetails {...props} />
|
|
31
|
+
</Suspense>,
|
|
32
|
+
renderOpts
|
|
33
|
+
);
|
|
29
34
|
expect(container).toMatchSnapshot();
|
|
30
35
|
});
|
|
31
36
|
|
|
@@ -44,7 +49,12 @@ describe("<ExecutionDetails>", () => {
|
|
|
44
49
|
],
|
|
45
50
|
},
|
|
46
51
|
};
|
|
47
|
-
const { getByText } = render(
|
|
52
|
+
const { getByText } = render(
|
|
53
|
+
<Suspense fallback={null}>
|
|
54
|
+
<ExecutionDetails {...props} />
|
|
55
|
+
</Suspense>,
|
|
56
|
+
renderOpts
|
|
57
|
+
);
|
|
48
58
|
expect(getByText("TestMessage")).toBeInTheDocument();
|
|
49
59
|
expect(getByText("Base64_value")).toBeInTheDocument();
|
|
50
60
|
});
|
|
@@ -56,7 +66,9 @@ describe("<ExecutionDetails>", () => {
|
|
|
56
66
|
},
|
|
57
67
|
};
|
|
58
68
|
const { container } = render(
|
|
59
|
-
<
|
|
69
|
+
<Suspense fallback={null}>
|
|
70
|
+
<ExecutionDetails {...propsWithoutDetails} />
|
|
71
|
+
</Suspense>,
|
|
60
72
|
renderOpts
|
|
61
73
|
);
|
|
62
74
|
expect(container).toMatchSnapshot();
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { Suspense } from "react";
|
|
2
|
+
import { shallowWithIntl, intl } from "@truedat/test/intl-stub";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
import { RemediationForm } from "../RemediationForm";
|
|
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
|
+
|
|
10
|
+
jest.mock("react-router-dom", () => ({
|
|
11
|
+
...jest.requireActual("react-router-dom"), // use actual for all non-hook parts
|
|
12
|
+
useParams: () => ({
|
|
13
|
+
id: 777,
|
|
14
|
+
implementation_id: 862,
|
|
15
|
+
rule_result_id: 66322,
|
|
16
|
+
}),
|
|
17
|
+
useRouteMatch: () => ({
|
|
18
|
+
url: "/rules/777/implementations/862/results/66322",
|
|
19
|
+
}),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
describe("<RemediationForm />", () => {
|
|
23
|
+
const createRemediation = jest.fn();
|
|
24
|
+
const updateRemediation = jest.fn();
|
|
25
|
+
const template1 = { id: 1, name: "template1" };
|
|
26
|
+
const template2 = { id: 2, name: "template2" };
|
|
27
|
+
const templates = [template1, template2];
|
|
28
|
+
const remediation = {};
|
|
29
|
+
const onSave = jest.fn();
|
|
30
|
+
|
|
31
|
+
const props = {
|
|
32
|
+
createRemediation,
|
|
33
|
+
updateRemediation,
|
|
34
|
+
templates,
|
|
35
|
+
remediation,
|
|
36
|
+
onSave,
|
|
37
|
+
};
|
|
38
|
+
const renderOpts = {
|
|
39
|
+
messages: {
|
|
40
|
+
en: {
|
|
41
|
+
"actions.save": "save",
|
|
42
|
+
"actions.cancel": "create",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
describe("with multiple templates", () => {
|
|
48
|
+
it("matches the latest snapshot", () => {
|
|
49
|
+
const { container } = render(
|
|
50
|
+
<Suspense fallback={null}>
|
|
51
|
+
<RemediationForm {...props} />
|
|
52
|
+
</Suspense>,
|
|
53
|
+
renderOpts
|
|
54
|
+
);
|
|
55
|
+
expect(container).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("selecting a template shows a dynamic form passing that template as a property", () => {
|
|
59
|
+
const e = { preventDefault: jest.fn() };
|
|
60
|
+
const wrapper = shallowWithIntl(
|
|
61
|
+
<RemediationForm templates={templates} {...props} />
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
wrapper.find({ name: "template" }).simulate("change", e, { value: 2 });
|
|
65
|
+
expect(wrapper.find({ template: { id: 2 } }).exists()).toBeTruthy;
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React, { Suspense } from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { RemediationPlan } from "../RemediationPlan";
|
|
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
|
+
|
|
10
|
+
jest.mock("react-router-dom", () => ({
|
|
11
|
+
...jest.requireActual("react-router-dom"), // use actual for all non-hook parts
|
|
12
|
+
useParams: () => ({
|
|
13
|
+
id: 777,
|
|
14
|
+
implementation_id: 862,
|
|
15
|
+
rule_result_id: 66322,
|
|
16
|
+
}),
|
|
17
|
+
useRouteMatch: () => ({
|
|
18
|
+
url: "/rules/777/implementations/862/results/66322",
|
|
19
|
+
}),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
describe("<RemediationPlan />", () => {
|
|
23
|
+
const template1 = { id: 1, name: "remediation_template1" };
|
|
24
|
+
const template2 = { id: 2, name: "remediation_template2" };
|
|
25
|
+
const props = {
|
|
26
|
+
remediationLoading: false,
|
|
27
|
+
clearRemediation: jest.fn(),
|
|
28
|
+
fetchRemediation: jest.fn(),
|
|
29
|
+
templates: [template1, template2],
|
|
30
|
+
lastResultId: undefined,
|
|
31
|
+
manageRemediations: true,
|
|
32
|
+
};
|
|
33
|
+
const remediation = {
|
|
34
|
+
df_content: {
|
|
35
|
+
texto: "66322_cambiado",
|
|
36
|
+
},
|
|
37
|
+
df_name: "remediation_template",
|
|
38
|
+
id: 60,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const renderOpts = {
|
|
42
|
+
messages: {
|
|
43
|
+
en: {
|
|
44
|
+
"actions.cancel": "Cancel",
|
|
45
|
+
"actions.edit": "Edit",
|
|
46
|
+
"actions.save": "Save",
|
|
47
|
+
remediation: "Remediation plan",
|
|
48
|
+
"remediation.actions.create": "Create Remediation Plan",
|
|
49
|
+
"remediation.actions.edit": "Edit Remediation Plan",
|
|
50
|
+
"template.not_found.message": "Error: Invalid template",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
it("matches the latest snapshot", () => {
|
|
56
|
+
const { container } = render(
|
|
57
|
+
<Suspense fallback={null}>
|
|
58
|
+
<RemediationPlan {...props} />
|
|
59
|
+
</Suspense>,
|
|
60
|
+
renderOpts
|
|
61
|
+
);
|
|
62
|
+
expect(container).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("New remediation component is shown if there is no existing remediation", () => {
|
|
66
|
+
const state = {
|
|
67
|
+
remediationActions: {
|
|
68
|
+
create: { href: "something" },
|
|
69
|
+
},
|
|
70
|
+
templates: props.templates,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const { queryByText } = render(<RemediationPlan {...props} />, {
|
|
74
|
+
...renderOpts,
|
|
75
|
+
state,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(queryByText(/Create Remediation Plan/)).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("Remediation view is shown if there is an existing remediation", () => {
|
|
82
|
+
const { queryByText } = render(
|
|
83
|
+
<Suspense fallback={null}>
|
|
84
|
+
<RemediationPlan {...props} remediation={remediation} />
|
|
85
|
+
</Suspense>,
|
|
86
|
+
renderOpts
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(queryByText(/Edit/)).toBeInTheDocument();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("Remediation form is shown if edit button is clicked", async () => {
|
|
93
|
+
const { queryByText, findByRole } = await render(
|
|
94
|
+
<Suspense fallback={null}>
|
|
95
|
+
<RemediationPlan {...props} remediation={remediation} />
|
|
96
|
+
</Suspense>,
|
|
97
|
+
renderOpts
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
userEvent.click(await queryByText(/Edit/));
|
|
101
|
+
|
|
102
|
+
expect(
|
|
103
|
+
await findByRole("form", { name: "remediation-form" })
|
|
104
|
+
).toBeInTheDocument();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -2,8 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<ExecutionDetails> matches the latest snapshot 1`] = `
|
|
4
4
|
<div>
|
|
5
|
+
<h2
|
|
6
|
+
class="ui header"
|
|
7
|
+
style="display: none;"
|
|
8
|
+
>
|
|
9
|
+
<i
|
|
10
|
+
aria-hidden="true"
|
|
11
|
+
class="chart pie circular icon"
|
|
12
|
+
/>
|
|
13
|
+
<div
|
|
14
|
+
class="content"
|
|
15
|
+
>
|
|
16
|
+
Rule execution result
|
|
17
|
+
</div>
|
|
18
|
+
</h2>
|
|
5
19
|
<table
|
|
6
20
|
class="ui table implementation-results medium"
|
|
21
|
+
style="display: none;"
|
|
7
22
|
>
|
|
8
23
|
<thead
|
|
9
24
|
class=""
|
|
@@ -110,11 +125,63 @@ exports[`<ExecutionDetails> matches the latest snapshot 1`] = `
|
|
|
110
125
|
</tr>
|
|
111
126
|
</tbody>
|
|
112
127
|
</table>
|
|
128
|
+
<h2
|
|
129
|
+
class="ui header"
|
|
130
|
+
style="display: none;"
|
|
131
|
+
>
|
|
132
|
+
<i
|
|
133
|
+
aria-hidden="true"
|
|
134
|
+
class="rain circular icon"
|
|
135
|
+
/>
|
|
136
|
+
<div
|
|
137
|
+
class="content"
|
|
138
|
+
>
|
|
139
|
+
Remediation plan
|
|
140
|
+
</div>
|
|
141
|
+
</h2>
|
|
142
|
+
<div
|
|
143
|
+
class="ui segment execution-details-remediation"
|
|
144
|
+
style="display: none;"
|
|
145
|
+
>
|
|
146
|
+
<div
|
|
147
|
+
class="ui grid"
|
|
148
|
+
>
|
|
149
|
+
<div
|
|
150
|
+
class="eight wide column"
|
|
151
|
+
>
|
|
152
|
+
<form
|
|
153
|
+
aria-label="remediation-form"
|
|
154
|
+
class="ui form"
|
|
155
|
+
>
|
|
156
|
+
<button
|
|
157
|
+
class="ui primary disabled button"
|
|
158
|
+
disabled=""
|
|
159
|
+
tabindex="-1"
|
|
160
|
+
>
|
|
161
|
+
create
|
|
162
|
+
</button>
|
|
163
|
+
</form>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
113
167
|
</div>
|
|
114
168
|
`;
|
|
115
169
|
|
|
116
170
|
exports[`<ExecutionDetails> without details 1`] = `
|
|
117
171
|
<div>
|
|
172
|
+
<h2
|
|
173
|
+
class="ui header"
|
|
174
|
+
>
|
|
175
|
+
<i
|
|
176
|
+
aria-hidden="true"
|
|
177
|
+
class="chart pie circular icon"
|
|
178
|
+
/>
|
|
179
|
+
<div
|
|
180
|
+
class="content"
|
|
181
|
+
>
|
|
182
|
+
Rule execution result
|
|
183
|
+
</div>
|
|
184
|
+
</h2>
|
|
118
185
|
<table
|
|
119
186
|
class="ui table implementation-results medium"
|
|
120
187
|
>
|
|
@@ -191,5 +258,42 @@ exports[`<ExecutionDetails> without details 1`] = `
|
|
|
191
258
|
</tr>
|
|
192
259
|
</tbody>
|
|
193
260
|
</table>
|
|
261
|
+
<h2
|
|
262
|
+
class="ui header"
|
|
263
|
+
>
|
|
264
|
+
<i
|
|
265
|
+
aria-hidden="true"
|
|
266
|
+
class="rain circular icon"
|
|
267
|
+
/>
|
|
268
|
+
<div
|
|
269
|
+
class="content"
|
|
270
|
+
>
|
|
271
|
+
Remediation plan
|
|
272
|
+
</div>
|
|
273
|
+
</h2>
|
|
274
|
+
<div
|
|
275
|
+
class="ui segment execution-details-remediation"
|
|
276
|
+
>
|
|
277
|
+
<div
|
|
278
|
+
class="ui grid"
|
|
279
|
+
>
|
|
280
|
+
<div
|
|
281
|
+
class="eight wide column"
|
|
282
|
+
>
|
|
283
|
+
<form
|
|
284
|
+
aria-label="remediation-form"
|
|
285
|
+
class="ui form"
|
|
286
|
+
>
|
|
287
|
+
<button
|
|
288
|
+
class="ui primary disabled button"
|
|
289
|
+
disabled=""
|
|
290
|
+
tabindex="-1"
|
|
291
|
+
>
|
|
292
|
+
create
|
|
293
|
+
</button>
|
|
294
|
+
</form>
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
194
298
|
</div>
|
|
195
299
|
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<RemediationForm /> with multiple templates matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<form
|
|
6
|
+
aria-label="remediation-form"
|
|
7
|
+
class="ui form"
|
|
8
|
+
style="display: none;"
|
|
9
|
+
>
|
|
10
|
+
<button
|
|
11
|
+
class="ui primary disabled button"
|
|
12
|
+
disabled=""
|
|
13
|
+
tabindex="-1"
|
|
14
|
+
>
|
|
15
|
+
actions.create
|
|
16
|
+
</button>
|
|
17
|
+
</form>
|
|
18
|
+
</div>
|
|
19
|
+
`;
|
package/src/messages/en.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable prettier/prettier */
|
|
2
2
|
export default {
|
|
3
3
|
"actions.cancel": "Cancel",
|
|
4
|
+
"actions.edit": "Edit",
|
|
4
5
|
"actions.next": "Next",
|
|
5
6
|
"actions.prev": "Previous",
|
|
6
7
|
"actions.save": "Save",
|
|
@@ -124,6 +125,11 @@ export default {
|
|
|
124
125
|
"quality_result.under_minimum": "Under threshold",
|
|
125
126
|
"quality_result.under_minumum": "Under threshold",
|
|
126
127
|
"quality_result.failed": "Failed",
|
|
128
|
+
"remediation": "Remediation plan",
|
|
129
|
+
"remediation.actions.create": "Create Remediation Plan",
|
|
130
|
+
"remediation.actions.delete.confirmation.content": "Remediation plan will be deleted. Are you sure?",
|
|
131
|
+
"remediation.actions.delete.confirmation.header": "Delete remediation plan",
|
|
132
|
+
"remediation.actions.edit": "Edit Remediation Plan",
|
|
127
133
|
rule: "Quality Rule",
|
|
128
134
|
"rule.date.placeholder": "YYYY-MM-DD",
|
|
129
135
|
"rule.error.goal.required": "Goal required",
|
|
@@ -518,6 +524,7 @@ export default {
|
|
|
518
524
|
"Error uploading file. No rules have been created.",
|
|
519
525
|
"ruleImplementations.upload.failed.misssing_required_columns":
|
|
520
526
|
"Faltan columnas obligatorias en el fichero. Esperado [{expected}]. Recibido [{found}].",
|
|
527
|
+
"ruleResult": "Rule execution result",
|
|
521
528
|
"ruleResults.actions.upload.tooltip": "Upload rule results",
|
|
522
529
|
"ruleResults.actions.upload.confirmation.header": "Upload rule results",
|
|
523
530
|
"ruleResults.upload.success.header": "Upload successful!",
|
package/src/messages/es.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable prettier/prettier */
|
|
2
2
|
export default {
|
|
3
3
|
"actions.cancel": "Cancelar",
|
|
4
|
+
"actions.edit": "Editar",
|
|
4
5
|
"actions.next": "Siguiente",
|
|
5
6
|
"actions.prev": "Anterior",
|
|
6
7
|
"actions.save": "Guardar",
|
|
@@ -126,6 +127,11 @@ export default {
|
|
|
126
127
|
"quality.thresholds": "Umbrales",
|
|
127
128
|
"quality.type_params": "Parámetros",
|
|
128
129
|
"quality.type": "Tipo",
|
|
130
|
+
"remediation": "Plan de remediación",
|
|
131
|
+
"remediation.actions.create": "Crear plan de remediación",
|
|
132
|
+
"remediation.actions.delete.confirmation.content": "Se va a eliminar el plan de remediación. ¿Está seguro?",
|
|
133
|
+
"remediation.actions.delete.confirmation.header": "Eliminar plan de remediación",
|
|
134
|
+
"remediation.actions.edit": "Editar plan de remediación",
|
|
129
135
|
"rule_result.actions.delete.confirmation.content":
|
|
130
136
|
"¿Desea eliminar el resultado de la implementación?",
|
|
131
137
|
"rule_result.actions.delete.confirmation.header": "Eliminar resultado",
|
|
@@ -540,6 +546,7 @@ export default {
|
|
|
540
546
|
"Error al subir el fichero. No se ha realizado ninguna inserción.",
|
|
541
547
|
"ruleImplementations.upload.failed.misssing_required_columns":
|
|
542
548
|
"Faltan columnas obligatorias en el fichero. Esperado [{expected}]. Recibido [{found}].",
|
|
549
|
+
"ruleResult": "Resultado de ejecución de regla",
|
|
543
550
|
"ruleResults.actions.upload.tooltip": "Subir resultados",
|
|
544
551
|
"ruleResults.actions.upload.confirmation.header":
|
|
545
552
|
"Subir resultados de implementaciones",
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearRemediation,
|
|
3
|
+
createRemediation,
|
|
4
|
+
fetchRemediation,
|
|
5
|
+
updateRemediation,
|
|
6
|
+
} from "../../routines";
|
|
7
|
+
import { remediation } from "..";
|
|
8
|
+
|
|
9
|
+
const state = { foo: "bar" };
|
|
10
|
+
|
|
11
|
+
describe("reducers: remediation", () => {
|
|
12
|
+
const initialState = {};
|
|
13
|
+
|
|
14
|
+
const data = {
|
|
15
|
+
df_content: {
|
|
16
|
+
texto: "66256_____aeaeae",
|
|
17
|
+
},
|
|
18
|
+
df_name: "remediation_template",
|
|
19
|
+
id: 58,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it("should provide the initial state", () => {
|
|
23
|
+
expect(remediation(undefined, {})).toEqual(initialState);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should handle the fetchRemediation.TRIGGER action", () => {
|
|
27
|
+
expect(remediation(state, { type: fetchRemediation.TRIGGER })).toEqual(
|
|
28
|
+
initialState
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should handle the clearRemediation.TRIGGER action", () => {
|
|
33
|
+
expect(remediation(state, { type: clearRemediation.TRIGGER })).toEqual(
|
|
34
|
+
initialState
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should handle the fetchRemediation.SUCCESS action", () => {
|
|
39
|
+
expect(
|
|
40
|
+
remediation(state, {
|
|
41
|
+
type: fetchRemediation.SUCCESS,
|
|
42
|
+
payload: { data },
|
|
43
|
+
})
|
|
44
|
+
).toEqual(data);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should handle the fetchRemediation.SUCCESS action", () => {
|
|
48
|
+
expect(
|
|
49
|
+
remediation(state, {
|
|
50
|
+
type: createRemediation.SUCCESS,
|
|
51
|
+
payload: { data },
|
|
52
|
+
})
|
|
53
|
+
).toEqual(data);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should handle the updateRemediation.SUCCESS action", () => {
|
|
57
|
+
expect(
|
|
58
|
+
remediation(state, {
|
|
59
|
+
type: updateRemediation.SUCCESS,
|
|
60
|
+
payload: { data },
|
|
61
|
+
})
|
|
62
|
+
).toEqual(data);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should handle the 404 status fetchRemediation.FAILURE action", () => {
|
|
66
|
+
expect(
|
|
67
|
+
remediation(state, {
|
|
68
|
+
type: fetchRemediation.FAILURE,
|
|
69
|
+
payload: { data, status: 404 },
|
|
70
|
+
})
|
|
71
|
+
).toEqual(state);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should handle the non 404 status fetchRemediation.FAILURE action", () => {
|
|
75
|
+
const errorData = { error: "some error" };
|
|
76
|
+
expect(
|
|
77
|
+
remediation(state, {
|
|
78
|
+
type: fetchRemediation.FAILURE,
|
|
79
|
+
payload: { data: errorData, status: 500 },
|
|
80
|
+
})
|
|
81
|
+
).toEqual(errorData);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { clearRemediation, fetchRemediation } from "../../routines";
|
|
2
|
+
import { remediationActions } from "../remediationActions";
|
|
3
|
+
|
|
4
|
+
const fooState = { foo: "bar" };
|
|
5
|
+
const payload = {};
|
|
6
|
+
|
|
7
|
+
describe("reducers: remediationActions", () => {
|
|
8
|
+
const initialState = {};
|
|
9
|
+
|
|
10
|
+
it("should provide the initial state", () => {
|
|
11
|
+
expect(remediationActions(undefined, {})).toEqual(initialState);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should be the initial state after receiving the clearRemediation.TRIGGER action", () => {
|
|
15
|
+
expect(
|
|
16
|
+
remediationActions(fooState, {
|
|
17
|
+
type: clearRemediation.TRIGGER,
|
|
18
|
+
payload,
|
|
19
|
+
})
|
|
20
|
+
).toEqual(initialState);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should be the initial state after receiving the fetchRemediation.TRIGGER action", () => {
|
|
24
|
+
expect(
|
|
25
|
+
remediationActions(fooState, {
|
|
26
|
+
type: fetchRemediation.TRIGGER,
|
|
27
|
+
payload,
|
|
28
|
+
})
|
|
29
|
+
).toEqual(initialState);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should extract _actions from the fetchRemediation.SUCCESS action", () => {
|
|
33
|
+
const _actions = { delete: { foo: "bar" } };
|
|
34
|
+
const payload = { _actions };
|
|
35
|
+
expect(
|
|
36
|
+
remediationActions(fooState, {
|
|
37
|
+
type: fetchRemediation.SUCCESS,
|
|
38
|
+
payload,
|
|
39
|
+
})
|
|
40
|
+
).toMatchObject(_actions);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should ignore unhandled actions", () => {
|
|
44
|
+
expect(remediationActions(fooState, { type: "FOO" })).toBe(fooState);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRemediation,
|
|
3
|
+
fetchRemediation,
|
|
4
|
+
updateRemediation,
|
|
5
|
+
} from "../../routines";
|
|
6
|
+
import { remediationLoading } from "..";
|
|
7
|
+
|
|
8
|
+
const state = { foo: "bar" };
|
|
9
|
+
|
|
10
|
+
describe("reducers: remediationLoading", () => {
|
|
11
|
+
it("should provide the initial state", () => {
|
|
12
|
+
expect(remediationLoading(undefined, {})).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should be true after receiving the fetchRemediation.TRIGGER action", () => {
|
|
16
|
+
expect(remediationLoading(state, { type: fetchRemediation.TRIGGER })).toBe(
|
|
17
|
+
true
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should be false after receiving the fetchRemediation.FULFILL action", () => {
|
|
22
|
+
expect(remediationLoading(state, { type: fetchRemediation.FULFILL })).toBe(
|
|
23
|
+
false
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should be true after receiving the updateRemediation.TRIGGER action", () => {
|
|
28
|
+
expect(remediationLoading(state, { type: updateRemediation.TRIGGER })).toBe(
|
|
29
|
+
true
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should be false after receiving the updateRemediation.FULFILL action", () => {
|
|
34
|
+
expect(remediationLoading(state, { type: updateRemediation.FULFILL })).toBe(
|
|
35
|
+
false
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should be true after receiving the createRemediation.TRIGGER action", () => {
|
|
40
|
+
expect(remediationLoading(state, { type: createRemediation.TRIGGER })).toBe(
|
|
41
|
+
true
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should be false after receiving the createRemediation.FULFILL action", () => {
|
|
46
|
+
expect(remediationLoading(state, { type: createRemediation.FULFILL })).toBe(
|
|
47
|
+
false
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import { dismissAlert } from "@truedat/core/routines";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
uploadRules,
|
|
5
|
+
uploadImplementations,
|
|
6
|
+
uploadResults,
|
|
7
|
+
fetchRemediation,
|
|
8
|
+
} from "../routines";
|
|
4
9
|
|
|
5
10
|
const initialState = {};
|
|
6
11
|
|
|
@@ -126,7 +131,8 @@ const dqMessage = (state = initialState, { type, payload }) => {
|
|
|
126
131
|
} else {
|
|
127
132
|
return null;
|
|
128
133
|
}
|
|
129
|
-
|
|
134
|
+
case fetchRemediation.FAILURE:
|
|
135
|
+
return { error: false };
|
|
130
136
|
default:
|
|
131
137
|
return state;
|
|
132
138
|
}
|
package/src/reducers/index.js
CHANGED
|
@@ -9,6 +9,9 @@ import { implementationActions } from "./implementationActions";
|
|
|
9
9
|
import { executionGroupLoading } from "./executionGroupLoading";
|
|
10
10
|
import { implementationsActions } from "./implementationsActions";
|
|
11
11
|
import { previousRuleImplementationQuery } from "./previousRuleImplementationQuery";
|
|
12
|
+
import { remediation } from "./remediation";
|
|
13
|
+
import { remediationActions } from "./remediationActions";
|
|
14
|
+
import { remediationLoading } from "./remediationLoading";
|
|
12
15
|
import { resultsUploading } from "./resultsUploading";
|
|
13
16
|
import { rule } from "./rule";
|
|
14
17
|
import { ruleActions } from "./ruleActions";
|
|
@@ -59,6 +62,9 @@ export {
|
|
|
59
62
|
executionGroupLoading,
|
|
60
63
|
implementationsActions,
|
|
61
64
|
previousRuleImplementationQuery,
|
|
65
|
+
remediation,
|
|
66
|
+
remediationActions,
|
|
67
|
+
remediationLoading,
|
|
62
68
|
resultsUploading,
|
|
63
69
|
rule,
|
|
64
70
|
ruleActions,
|