@truedat/dq 4.35.3 → 4.35.7
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 +6 -0
- package/package.json +4 -4
- package/src/components/ImplementationsUploadButton.js +2 -2
- package/src/components/RulesActions.js +3 -3
- package/src/components/RulesUploadButton.js +2 -2
- package/src/components/__tests__/ImplementationsUploadButton.spec.js +23 -0
- package/src/components/__tests__/Rule.spec.js +3 -2
- package/src/components/__tests__/RuleImplementation.spec.js +1 -0
- package/src/components/__tests__/RulesUploadButton.spec.js +20 -0
- package/src/components/__tests__/__snapshots__/ImplementationsUploadButton.spec.js.snap +3 -0
- package/src/components/__tests__/__snapshots__/Rule.spec.js.snap +10 -1
- package/src/components/__tests__/__snapshots__/RuleImplementation.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/RulesUploadButton.spec.js.snap +3 -0
- package/src/messages/en.js +3 -3
- package/src/messages/es.js +3 -3
- package/src/reducers/__tests__/uploadImplementationsFile.spec.js +27 -0
- package/src/reducers/__tests__/uploadRulesFile.spec.js +27 -0
- package/src/reducers/__tests__/uploadingResults.spec.js +1 -1
- package/src/reducers/index.js +4 -4
- package/src/reducers/ruleImplementationRedirect.js +3 -4
- package/src/reducers/ruleRedirect.js +1 -2
- package/src/reducers/uploadingImplementationsFile.js +19 -0
- package/src/reducers/uploadingRulesFile.js +16 -0
- package/src/sagas/__tests__/uploadImplementations.spec.js +78 -0
- package/src/sagas/__tests__/uploadRules.spec.js +65 -0
- package/src/sagas/uploadImplementations.js +10 -7
- package/src/sagas/uploadRules.js +10 -7
- package/src/reducers/uploadImplementationsFile.js +0 -28
- package/src/reducers/uploadRulesFile.js +0 -25
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dq",
|
|
3
|
-
"version": "4.35.
|
|
3
|
+
"version": "4.35.7",
|
|
4
4
|
"description": "Truedat Web Data Quality Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@apollo/client": "^3.4.10",
|
|
85
|
-
"@truedat/core": "4.35.
|
|
86
|
-
"@truedat/df": "4.35.
|
|
85
|
+
"@truedat/core": "4.35.7",
|
|
86
|
+
"@truedat/df": "4.35.7",
|
|
87
87
|
"axios": "^0.19.2",
|
|
88
88
|
"graphql": "^15.5.3",
|
|
89
89
|
"path-to-regexp": "^1.7.0",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"react-dom": ">= 16.8.6 < 17",
|
|
104
104
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "99812619b928d7802bb2f33df3f3321c9c36995e"
|
|
107
107
|
}
|
|
@@ -52,8 +52,8 @@ ImplementationsUploadButton.propTypes = {
|
|
|
52
52
|
loading: PropTypes.bool,
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const mapStateToProps = ({
|
|
56
|
-
loading,
|
|
55
|
+
const mapStateToProps = ({ uploadingImplementationsFile }) => ({
|
|
56
|
+
loading: uploadingImplementationsFile,
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
export default connect(mapStateToProps, { uploadImplementations })(
|
|
@@ -8,7 +8,7 @@ import { RULE_NEW } from "@truedat/core/routes";
|
|
|
8
8
|
import { uploadRules } from "../routines";
|
|
9
9
|
import RulesUploadButton from "./RulesUploadButton";
|
|
10
10
|
|
|
11
|
-
export const RulesActions = ({ userRulesPermissions,
|
|
11
|
+
export const RulesActions = ({ userRulesPermissions, loading }) => (
|
|
12
12
|
<div style={{ float: "right" }}>
|
|
13
13
|
{userRulesPermissions.manage_quality_rules && (
|
|
14
14
|
<>
|
|
@@ -18,7 +18,7 @@ export const RulesActions = ({ userRulesPermissions, upload }) => (
|
|
|
18
18
|
to={RULE_NEW}
|
|
19
19
|
content={<FormattedMessage id="quality.actions.create" />}
|
|
20
20
|
/>
|
|
21
|
-
{
|
|
21
|
+
{loading && <RulesUploadButton />}
|
|
22
22
|
<RulesUploadButton />
|
|
23
23
|
</>
|
|
24
24
|
)}
|
|
@@ -27,7 +27,7 @@ export const RulesActions = ({ userRulesPermissions, upload }) => (
|
|
|
27
27
|
|
|
28
28
|
RulesActions.propTypes = {
|
|
29
29
|
userRulesPermissions: PropTypes.object,
|
|
30
|
-
|
|
30
|
+
loading: PropTypes.bool,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
const mapStateToProps = ({ userRulesPermissions }) => ({
|
|
@@ -51,8 +51,8 @@ RulesUploadButton.propTypes = {
|
|
|
51
51
|
loading: PropTypes.bool,
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const mapStateToProps = ({
|
|
55
|
-
loading,
|
|
54
|
+
const mapStateToProps = ({ uploadingRulesFile }) => ({
|
|
55
|
+
loading: uploadingRulesFile,
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
export default connect(mapStateToProps, { uploadRules })(RulesUploadButton);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { ImplementationsUploadButton } from "../ImplementationsUploadButton";
|
|
4
|
+
|
|
5
|
+
describe("<ImplementationsUploadButton />", () => {
|
|
6
|
+
const props = {
|
|
7
|
+
uploadRules: jest.fn(),
|
|
8
|
+
upload: false,
|
|
9
|
+
};
|
|
10
|
+
const renderOpts = {
|
|
11
|
+
messages: {
|
|
12
|
+
en: { "ruleImplementations.actions.upload.tooltip": "Upload Rules" },
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it("matches the latest snapshot", () => {
|
|
17
|
+
const { contanier } = render(
|
|
18
|
+
<ImplementationsUploadButton {...props} />,
|
|
19
|
+
renderOpts
|
|
20
|
+
);
|
|
21
|
+
expect(contanier).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -7,9 +7,10 @@ describe("<Rule />", () => {
|
|
|
7
7
|
rule: { id: 1, name: "foo" },
|
|
8
8
|
userRulePermissions: {
|
|
9
9
|
manage_quality_rule_implementations: true,
|
|
10
|
-
manage_quality_rules: true
|
|
10
|
+
manage_quality_rules: true,
|
|
11
11
|
},
|
|
12
|
-
match: { params: { id: 1, qc: 2 } }
|
|
12
|
+
match: { params: { id: 1, qc: 2 } },
|
|
13
|
+
implementations: [{ id: 100, implementation_key: "bar" }],
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
it("matches the latest snapshot", () => {
|
|
@@ -27,6 +27,7 @@ const renderOpts = {
|
|
|
27
27
|
"ruleImplementation.actions.deprecate": "archive",
|
|
28
28
|
"ruleImplementation.actions.delete.confirmation.header": "header",
|
|
29
29
|
"ruleImplementation.actions.delete.confirmation.content": "confirm",
|
|
30
|
+
"quality.result.no.data": "No information about quality",
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
33
|
state,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { RulesUploadButton } from "../RulesUploadButton";
|
|
4
|
+
|
|
5
|
+
describe("<RulesUploadButton />", () => {
|
|
6
|
+
const props = {
|
|
7
|
+
uploadRules: jest.fn(),
|
|
8
|
+
upload: false,
|
|
9
|
+
};
|
|
10
|
+
const renderOpts = {
|
|
11
|
+
messages: {
|
|
12
|
+
en: { "rules.actions.upload.tooltip": "Upload Rules" },
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it("matches the latest snapshot", () => {
|
|
17
|
+
const { contanier } = render(<RulesUploadButton {...props} />, renderOpts);
|
|
18
|
+
expect(contanier).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -16,7 +16,16 @@ exports[`<Rule /> matches the latest snapshot 1`] = `
|
|
|
16
16
|
/>
|
|
17
17
|
<HeaderContent>
|
|
18
18
|
foo
|
|
19
|
-
<RuleSummary
|
|
19
|
+
<RuleSummary
|
|
20
|
+
implementations={
|
|
21
|
+
Array [
|
|
22
|
+
Object {
|
|
23
|
+
"id": 100,
|
|
24
|
+
"implementation_key": "bar",
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
/>
|
|
20
29
|
</HeaderContent>
|
|
21
30
|
</Header>
|
|
22
31
|
</GridColumn>
|
package/src/messages/en.js
CHANGED
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
"dataset.form.button.add_structure": "Add Structure",
|
|
27
27
|
"datasetForm.implementation_key.tooltip":
|
|
28
28
|
"Leave empty for autogeneration of implementation key after saving implementation",
|
|
29
|
-
executionGroup: "Executions",
|
|
29
|
+
"executionGroup": "Executions",
|
|
30
30
|
"executions.completed.content": "{count} executions completed.",
|
|
31
31
|
"executions.completed.header": "Executions completed",
|
|
32
32
|
"executions.pending.content":
|
|
@@ -501,7 +501,7 @@ export default {
|
|
|
501
501
|
"ruleImplementations.upload.success.errors":
|
|
502
502
|
"Error in {implementation_key} attribute: {key} message: {message} ",
|
|
503
503
|
"ruleImplementations.upload.success.header":
|
|
504
|
-
"Upload success! Loaded {count_ids} omitted {count_errors}
|
|
504
|
+
"Upload success! Loaded {count_ids} omitted {count_errors}",
|
|
505
505
|
"ruleImplementations.upload.failed.header":
|
|
506
506
|
"Error uploading file. No rules have been created.",
|
|
507
507
|
"ruleImplementations.upload.failed.misssing_required_columns":
|
|
@@ -537,7 +537,7 @@ export default {
|
|
|
537
537
|
"rules.upload.success.errors":
|
|
538
538
|
"Error in {rule_name} attribute: {key} message: {message} ",
|
|
539
539
|
"rules.upload.success.header":
|
|
540
|
-
"Upload successful! Loaded {count_ids} omitted {count_errors}
|
|
540
|
+
"Upload successful! Loaded {count_ids} omitted {count_errors}",
|
|
541
541
|
"rules.upload.failed.header":
|
|
542
542
|
"Error uploading file. No rules have been created.",
|
|
543
543
|
"rules.upload.failed.misssing_required_columns":
|
package/src/messages/es.js
CHANGED
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
"dataset.form.button.add_structure": "Añadir Estructura",
|
|
27
27
|
"datasetForm.implementation_key.tooltip":
|
|
28
28
|
"En caso de no introducir clave de implementación, se autogenerará al guardar la implementación",
|
|
29
|
-
executionGroup: "Ejecuciones",
|
|
29
|
+
"executionGroup": "Ejecuciones",
|
|
30
30
|
"executions.completed.content": "Se han ejecutado {count} implementaciones.",
|
|
31
31
|
"executions.completed.header": "Ejecuciones finalizadas",
|
|
32
32
|
"executions.pending.content":
|
|
@@ -519,7 +519,7 @@ export default {
|
|
|
519
519
|
"ruleImplementations.upload.success.errors":
|
|
520
520
|
"Error en {name} atributo: {key} mensaje: {message} ",
|
|
521
521
|
"ruleImplementations.upload.success.header":
|
|
522
|
-
"¡Fichero subido correctamente! subidos {count_ids} errores {count_errors}
|
|
522
|
+
"¡Fichero subido correctamente! subidos {count_ids} errores {count_errors}",
|
|
523
523
|
"ruleImplementations.upload.failed.header":
|
|
524
524
|
"Error al subir el fichero. No se ha realizado ninguna inserción.",
|
|
525
525
|
"ruleImplementations.upload.failed.misssing_required_columns":
|
|
@@ -552,7 +552,7 @@ export default {
|
|
|
552
552
|
"rules.upload.success.errors":
|
|
553
553
|
"Error en {rule_name} atributo: {key} mensaje: {message} ",
|
|
554
554
|
"rules.upload.success.header":
|
|
555
|
-
"¡Fichero subido correctamente! subidos {count_ids} errores {count_errors}
|
|
555
|
+
"¡Fichero subido correctamente! subidos {count_ids} errores {count_errors}",
|
|
556
556
|
"rules.upload.failed.header":
|
|
557
557
|
"Error al subir el fichero. No se ha realizado ninguna inserción.",
|
|
558
558
|
"rules.upload.failed.misssing_required_columns":
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { uploadImplementations } from "../../routines";
|
|
2
|
+
import { uploadingImplementationsFile } from "../uploadingImplementationsFile";
|
|
3
|
+
|
|
4
|
+
const fooState = { foo: "bar" };
|
|
5
|
+
const initialState = false;
|
|
6
|
+
|
|
7
|
+
describe("reduces: uploadingImplementationsFile", () => {
|
|
8
|
+
it("should provide the initial state", () => {
|
|
9
|
+
expect(uploadingImplementationsFile(undefined, {})).toEqual(initialState);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should handle the uploadingImplementationsFile.TRIGGER action", () => {
|
|
13
|
+
expect(
|
|
14
|
+
uploadingImplementationsFile(fooState, {
|
|
15
|
+
type: uploadImplementations.TRIGGER,
|
|
16
|
+
})
|
|
17
|
+
).toBeTruthy();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should handle the uploadingImplementationsFile.FULLFILL action", () => {
|
|
21
|
+
expect(
|
|
22
|
+
uploadingImplementationsFile(fooState, {
|
|
23
|
+
type: uploadImplementations.FULFILL,
|
|
24
|
+
})
|
|
25
|
+
).toBeFalsy;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { uploadRules } from "../../routines";
|
|
2
|
+
import { uploadingRulesFile } from "../uploadingRulesFile";
|
|
3
|
+
|
|
4
|
+
const fooState = { foo: "bar" };
|
|
5
|
+
const initialState = false;
|
|
6
|
+
|
|
7
|
+
describe("reduces: uploadingRulesFile", () => {
|
|
8
|
+
it("should provide the initial state", () => {
|
|
9
|
+
expect(uploadingRulesFile(undefined, {})).toEqual(initialState);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should handle the uploadingRulesFile.TRIGGER action", () => {
|
|
13
|
+
expect(
|
|
14
|
+
uploadingRulesFile(fooState, {
|
|
15
|
+
type: uploadRules.TRIGGER,
|
|
16
|
+
})
|
|
17
|
+
).toBeTruthy();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should handle the uploadingRulesFile.FULLFILL action", () => {
|
|
21
|
+
expect(
|
|
22
|
+
uploadingRulesFile(fooState, {
|
|
23
|
+
type: uploadRules.FULFILL,
|
|
24
|
+
})
|
|
25
|
+
).toBeFalsy;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -5,7 +5,7 @@ const fooState = { foo: "bar" };
|
|
|
5
5
|
|
|
6
6
|
const initialState = false;
|
|
7
7
|
|
|
8
|
-
describe("reducers:
|
|
8
|
+
describe("reducers: uploadingResults", () => {
|
|
9
9
|
it("should provide the initial state", () => {
|
|
10
10
|
expect(uploadingResults(undefined, {})).toEqual(initialState);
|
|
11
11
|
});
|
package/src/reducers/index.js
CHANGED
|
@@ -37,8 +37,8 @@ import { ruleUpdating } from "./ruleUpdating";
|
|
|
37
37
|
import { rules } from "./rules";
|
|
38
38
|
import { rulesLoading } from "./rulesLoading";
|
|
39
39
|
import { rulesPageSize } from "./rulesPageSize";
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
40
|
+
import { uploadingImplementationsFile } from "./uploadingImplementationsFile";
|
|
41
|
+
import { uploadingRulesFile } from "./uploadingRulesFile";
|
|
42
42
|
import { userRulePermissions } from "./userRulePermissions";
|
|
43
43
|
import { userRulesPermissions } from "./userRulesPermissions";
|
|
44
44
|
import { userImplementationsPermissions } from "./userImplementationsPermissions";
|
|
@@ -84,8 +84,8 @@ export {
|
|
|
84
84
|
rules,
|
|
85
85
|
rulesLoading,
|
|
86
86
|
rulesPageSize,
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
uploadingRulesFile,
|
|
88
|
+
uploadingImplementationsFile,
|
|
89
89
|
userRulePermissions,
|
|
90
90
|
userRulesPermissions,
|
|
91
91
|
userImplementationsPermissions,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { linkTo } from "@truedat/core/routes";
|
|
1
|
+
import { IMPLEMENTATIONS, linkTo } from "@truedat/core/routes";
|
|
2
2
|
import { clearRedirect } from "@truedat/core/routines";
|
|
3
3
|
import {
|
|
4
4
|
createExecutionGroup,
|
|
@@ -12,7 +12,7 @@ const initialState = "";
|
|
|
12
12
|
|
|
13
13
|
export const ruleImplementationRedirect = (
|
|
14
14
|
state = initialState,
|
|
15
|
-
{ type, payload
|
|
15
|
+
{ type, payload }
|
|
16
16
|
) => {
|
|
17
17
|
switch (type) {
|
|
18
18
|
case clearRedirect.TRIGGER:
|
|
@@ -31,8 +31,7 @@ export const ruleImplementationRedirect = (
|
|
|
31
31
|
return linkTo.RULE_IMPLEMENTATION({ id, implementation_id });
|
|
32
32
|
}
|
|
33
33
|
case uploadImplementations.SUCCESS: {
|
|
34
|
-
|
|
35
|
-
return redirectUrl;
|
|
34
|
+
return IMPLEMENTATIONS;
|
|
36
35
|
}
|
|
37
36
|
case deleteRuleResult.SUCCESS: {
|
|
38
37
|
const { rule_implementation_id: implementation_id, rule_id: id } =
|
|
@@ -39,8 +39,7 @@ export const ruleRedirect = (state = initialState, { type, payload, meta }) => {
|
|
|
39
39
|
return _.isNil(rule_id) ? state : linkTo.RULE({ id: rule_id });
|
|
40
40
|
}
|
|
41
41
|
case uploadRules.SUCCESS: {
|
|
42
|
-
|
|
43
|
-
return redirectUrl;
|
|
42
|
+
return RULES;
|
|
44
43
|
}
|
|
45
44
|
case deleteSubscription.SUCCESS: {
|
|
46
45
|
const { rule_id } = payload;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { uploadImplementations } from "../routines";
|
|
2
|
+
|
|
3
|
+
const initialState = false;
|
|
4
|
+
|
|
5
|
+
export const uploadingImplementationsFile = (
|
|
6
|
+
state = initialState,
|
|
7
|
+
{ type }
|
|
8
|
+
) => {
|
|
9
|
+
switch (type) {
|
|
10
|
+
case uploadImplementations.TRIGGER:
|
|
11
|
+
return true;
|
|
12
|
+
case uploadImplementations.FULFILL:
|
|
13
|
+
return false;
|
|
14
|
+
default:
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default uploadingImplementationsFile;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { uploadRules } from "../routines";
|
|
2
|
+
|
|
3
|
+
const initialState = false;
|
|
4
|
+
|
|
5
|
+
export const uploadingRulesFile = (state = initialState, { type }) => {
|
|
6
|
+
switch (type) {
|
|
7
|
+
case uploadRules.TRIGGER:
|
|
8
|
+
return true;
|
|
9
|
+
case uploadRules.FULFILL:
|
|
10
|
+
return false;
|
|
11
|
+
default:
|
|
12
|
+
return state;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default uploadingRulesFile;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import { apiJsonPost, UPLOAD_JSON_OPTS } from "@truedat/core/services/api";
|
|
3
|
+
import {
|
|
4
|
+
uploadImplementationsRequestsSaga,
|
|
5
|
+
uploadImplementationsSaga,
|
|
6
|
+
} from "../uploadImplementations";
|
|
7
|
+
import { uploadImplementations } from "../../routines";
|
|
8
|
+
import { API_RULE_IMPLEMENTATIONS_UPLOAD } from "../../api";
|
|
9
|
+
|
|
10
|
+
describe("sagas: uploadImplementationsRequestsSaga", () => {
|
|
11
|
+
it("should invoke uploadImplementationsSaga on trigger", () => {
|
|
12
|
+
expect(() => {
|
|
13
|
+
testSaga(uploadImplementationsRequestsSaga)
|
|
14
|
+
.next()
|
|
15
|
+
.takeLatest(uploadImplementations.TRIGGER, uploadImplementationsSaga)
|
|
16
|
+
.finish()
|
|
17
|
+
.isDone();
|
|
18
|
+
}).not.toThrow();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should throw exception if an unhandle actios is received", () => {
|
|
22
|
+
expect(() => {
|
|
23
|
+
testSaga(uploadImplementationsRequestsSaga)
|
|
24
|
+
.next()
|
|
25
|
+
.takeLatest("FOO", uploadImplementationsSaga);
|
|
26
|
+
}).toThrow;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("sagas: uploadImplementationsSaga", () => {
|
|
31
|
+
const body = { implementations: "content" };
|
|
32
|
+
const payload = { data: body };
|
|
33
|
+
const data = { message: [1, 2] };
|
|
34
|
+
it("should put a access action when a response is returned", () => {
|
|
35
|
+
expect(() => {
|
|
36
|
+
testSaga(uploadImplementationsSaga, { payload })
|
|
37
|
+
.next()
|
|
38
|
+
.put(uploadImplementations.request())
|
|
39
|
+
.next()
|
|
40
|
+
.call(
|
|
41
|
+
apiJsonPost,
|
|
42
|
+
API_RULE_IMPLEMENTATIONS_UPLOAD,
|
|
43
|
+
body,
|
|
44
|
+
UPLOAD_JSON_OPTS
|
|
45
|
+
)
|
|
46
|
+
.next({ data })
|
|
47
|
+
.put(uploadImplementations.success(data))
|
|
48
|
+
.next()
|
|
49
|
+
.put(uploadImplementations.fulfill())
|
|
50
|
+
.next()
|
|
51
|
+
.isDone();
|
|
52
|
+
}).not.toThrow();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should put a failure action when the call returns an error", () => {
|
|
56
|
+
const message = "Request failed";
|
|
57
|
+
const error = { message };
|
|
58
|
+
|
|
59
|
+
expect(() => {
|
|
60
|
+
testSaga(uploadImplementationsSaga, { payload })
|
|
61
|
+
.next()
|
|
62
|
+
.put(uploadImplementations.request())
|
|
63
|
+
.next()
|
|
64
|
+
.call(
|
|
65
|
+
apiJsonPost,
|
|
66
|
+
API_RULE_IMPLEMENTATIONS_UPLOAD,
|
|
67
|
+
body,
|
|
68
|
+
UPLOAD_JSON_OPTS
|
|
69
|
+
)
|
|
70
|
+
.throw(error)
|
|
71
|
+
.put(uploadImplementations.failure(message))
|
|
72
|
+
.next()
|
|
73
|
+
.put(uploadImplementations.fulfill())
|
|
74
|
+
.next()
|
|
75
|
+
.isDone();
|
|
76
|
+
}).not.toThrow();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import { apiJsonPost, UPLOAD_JSON_OPTS } from "@truedat/core/services/api";
|
|
3
|
+
import { uploadRulesRequestsSaga, uploadRulesSaga } from "../uploadRules";
|
|
4
|
+
import { uploadRules } from "../../routines";
|
|
5
|
+
import { API_RULES_UPLOAD } from "../../api";
|
|
6
|
+
|
|
7
|
+
describe("sagas: uploadRulesRequestsSaga", () => {
|
|
8
|
+
it("should invoke uploadRulesSaga on trigger", () => {
|
|
9
|
+
expect(() => {
|
|
10
|
+
testSaga(uploadRulesRequestsSaga)
|
|
11
|
+
.next()
|
|
12
|
+
.takeLatest(uploadRules.TRIGGER, uploadRulesSaga)
|
|
13
|
+
.finish()
|
|
14
|
+
.isDone();
|
|
15
|
+
}).not.toThrow();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should throw exception if an unhandle actios is received", () => {
|
|
19
|
+
expect(() => {
|
|
20
|
+
testSaga(uploadRulesRequestsSaga)
|
|
21
|
+
.next()
|
|
22
|
+
.takeLatest("FOO", uploadRulesSaga);
|
|
23
|
+
}).toThrow;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("sagas: uploadRulesSaga", () => {
|
|
28
|
+
const body = { rules: "content" };
|
|
29
|
+
const payload = { data: body };
|
|
30
|
+
const data = { message: [1, 2] };
|
|
31
|
+
it("should put a access action when a response is returned", () => {
|
|
32
|
+
expect(() => {
|
|
33
|
+
testSaga(uploadRulesSaga, { payload })
|
|
34
|
+
.next()
|
|
35
|
+
.put(uploadRules.request())
|
|
36
|
+
.next()
|
|
37
|
+
.call(apiJsonPost, API_RULES_UPLOAD, body, UPLOAD_JSON_OPTS)
|
|
38
|
+
.next({ data })
|
|
39
|
+
.put(uploadRules.success(data))
|
|
40
|
+
.next()
|
|
41
|
+
.put(uploadRules.fulfill())
|
|
42
|
+
.next()
|
|
43
|
+
.isDone();
|
|
44
|
+
}).not.toThrow();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should put a failure action when the call returns an error", () => {
|
|
48
|
+
const message = "Request failed";
|
|
49
|
+
const error = { message };
|
|
50
|
+
|
|
51
|
+
expect(() => {
|
|
52
|
+
testSaga(uploadRulesSaga, { payload })
|
|
53
|
+
.next()
|
|
54
|
+
.put(uploadRules.request())
|
|
55
|
+
.next()
|
|
56
|
+
.call(apiJsonPost, API_RULES_UPLOAD, body, UPLOAD_JSON_OPTS)
|
|
57
|
+
.throw(error)
|
|
58
|
+
.put(uploadRules.failure(message))
|
|
59
|
+
.next()
|
|
60
|
+
.put(uploadRules.fulfill())
|
|
61
|
+
.next()
|
|
62
|
+
.isDone();
|
|
63
|
+
}).not.toThrow();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { call, put, takeLatest } from "redux-saga/effects";
|
|
2
|
-
import { IMPLEMENTATIONS } from "@truedat/core/routes";
|
|
3
2
|
import { apiJsonPost, UPLOAD_JSON_OPTS } from "@truedat/core/services/api";
|
|
4
3
|
import { uploadImplementations } from "../routines";
|
|
4
|
+
import { API_RULE_IMPLEMENTATIONS_UPLOAD } from "../api";
|
|
5
5
|
|
|
6
6
|
export function* uploadImplementationsSaga({ payload }) {
|
|
7
7
|
try {
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const { data: body } = payload;
|
|
9
|
+
yield put(uploadImplementations.request());
|
|
10
|
+
const { data } = yield call(
|
|
11
|
+
apiJsonPost,
|
|
12
|
+
API_RULE_IMPLEMENTATIONS_UPLOAD,
|
|
13
|
+
body,
|
|
14
|
+
UPLOAD_JSON_OPTS
|
|
15
|
+
);
|
|
16
|
+
yield put(uploadImplementations.success(data));
|
|
14
17
|
} catch (error) {
|
|
15
18
|
if (error.response) {
|
|
16
19
|
const { status, data } = error.response;
|
package/src/sagas/uploadRules.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { call, put, takeLatest } from "redux-saga/effects";
|
|
2
|
-
import { RULES } from "@truedat/core/routes";
|
|
3
2
|
import { apiJsonPost, UPLOAD_JSON_OPTS } from "@truedat/core/services/api";
|
|
4
3
|
import { uploadRules } from "../routines";
|
|
4
|
+
import { API_RULES_UPLOAD } from "../api";
|
|
5
5
|
|
|
6
6
|
export function* uploadRulesSaga({ payload }) {
|
|
7
7
|
try {
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const { data: body } = payload;
|
|
9
|
+
yield put(uploadRules.request());
|
|
10
|
+
const { data } = yield call(
|
|
11
|
+
apiJsonPost,
|
|
12
|
+
API_RULES_UPLOAD,
|
|
13
|
+
body,
|
|
14
|
+
UPLOAD_JSON_OPTS
|
|
15
|
+
);
|
|
16
|
+
yield put(uploadRules.success(data));
|
|
14
17
|
} catch (error) {
|
|
15
18
|
if (error.response) {
|
|
16
19
|
const { status, data } = error.response;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { uploadImplementations } from "../routines";
|
|
2
|
-
|
|
3
|
-
const initialState = {
|
|
4
|
-
loading: false,
|
|
5
|
-
error: {},
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const uploadImplementationsFile = (
|
|
9
|
-
state = initialState,
|
|
10
|
-
{ type, payload }
|
|
11
|
-
) => {
|
|
12
|
-
switch (type) {
|
|
13
|
-
case uploadImplementations.TRIGGER:
|
|
14
|
-
return state;
|
|
15
|
-
case uploadImplementations.REQUEST:
|
|
16
|
-
return { ...state, loading: true };
|
|
17
|
-
case uploadImplementations.SUCCESS:
|
|
18
|
-
return state;
|
|
19
|
-
case uploadImplementations.FAILURE:
|
|
20
|
-
return { ...state, error: payload };
|
|
21
|
-
case uploadImplementations.FULFILL:
|
|
22
|
-
return { ...state, loading: false };
|
|
23
|
-
default:
|
|
24
|
-
return state;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default uploadImplementationsFile;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { uploadRules } from "../routines";
|
|
2
|
-
|
|
3
|
-
const initialState = {
|
|
4
|
-
loading: false,
|
|
5
|
-
error: {},
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const uploadRulesFile = (state = initialState, { type, payload }) => {
|
|
9
|
-
switch (type) {
|
|
10
|
-
case uploadRules.TRIGGER:
|
|
11
|
-
return state;
|
|
12
|
-
case uploadRules.REQUEST:
|
|
13
|
-
return { ...state, loading: true };
|
|
14
|
-
case uploadRules.SUCCESS:
|
|
15
|
-
return state;
|
|
16
|
-
case uploadRules.FAILURE:
|
|
17
|
-
return { ...state, error: payload };
|
|
18
|
-
case uploadRules.FULFILL:
|
|
19
|
-
return { ...state, loading: false };
|
|
20
|
-
default:
|
|
21
|
-
return state;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default uploadRulesFile;
|