@truedat/dq 4.45.4 → 4.45.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +5 -5
  3. package/src/api/mutations.js +25 -0
  4. package/src/components/ImplementationActions.js +147 -0
  5. package/src/components/ImplementationFiltersLoader.js +2 -1
  6. package/src/components/{RuleImplementations.js → ImplementationSearchResults.js} +68 -53
  7. package/src/components/Implementations.js +16 -120
  8. package/src/components/ImplementationsRoutes.js +45 -57
  9. package/src/components/NewRuleImplementation.js +4 -1
  10. package/src/components/QualityRoutes.js +12 -1
  11. package/src/components/RuleFormImplementations.js +8 -63
  12. package/src/components/RuleImplementation.js +13 -204
  13. package/src/components/RuleImplementationProperties.js +9 -2
  14. package/src/components/RuleImplementationRow.js +0 -10
  15. package/src/components/RuleImplementationsActions.js +6 -31
  16. package/src/components/RuleImplementationsFromRuleLoader.js +3 -6
  17. package/src/components/RuleImplementationsTable.js +31 -44
  18. package/src/components/Subscription.js +11 -0
  19. package/src/components/__tests__/ExecutionForm.spec.js +1 -1
  20. package/src/components/__tests__/ImplementationActions.spec.js +21 -0
  21. package/src/components/__tests__/ImplementationFiltersLoader.spec.js +20 -0
  22. package/src/components/__tests__/{RuleImplementations.spec.js → ImplementationSearchResults.spec.js} +6 -6
  23. package/src/components/__tests__/Implementations.spec.js +12 -112
  24. package/src/components/__tests__/NewRuleImplementation.spec.js +3 -2
  25. package/src/components/__tests__/RemediationForm.spec.js +1 -1
  26. package/src/components/__tests__/RemediationPlan.spec.js +1 -1
  27. package/src/components/__tests__/RuleForm.spec.js +2 -2
  28. package/src/components/__tests__/RuleFormImplementations.spec.js +2 -10
  29. package/src/components/__tests__/RuleImplementationProperties.spec.js +3 -2
  30. package/src/components/__tests__/RuleImplementationsActions.spec.js +10 -5
  31. package/src/components/__tests__/RuleImplementationsFromRuleLoader.spec.js +3 -16
  32. package/src/components/__tests__/RuleProperties.spec.js +1 -1
  33. package/src/components/__tests__/__snapshots__/ImplementationActions.spec.js.snap +71 -0
  34. package/src/components/__tests__/__snapshots__/ImplementationSearchResults.spec.js.snap +90 -0
  35. package/src/components/__tests__/__snapshots__/Implementations.spec.js.snap +159 -53
  36. package/src/components/__tests__/__snapshots__/RuleForm.spec.js.snap +6 -6
  37. package/src/components/__tests__/__snapshots__/RuleFormImplementations.spec.js.snap +6 -48
  38. package/src/components/__tests__/__snapshots__/RuleImplementation.spec.js.snap +19 -19
  39. package/src/components/__tests__/__snapshots__/RuleImplementationProperties.spec.js.snap +2 -4
  40. package/src/components/__tests__/__snapshots__/RuleImplementationsActions.spec.js.snap +37 -0
  41. package/src/components/__tests__/__snapshots__/RuleImplementationsFromRuleLoader.spec.js.snap +0 -1
  42. package/src/components/__tests__/__snapshots__/RuleImplementationsTable.spec.js.snap +0 -3
  43. package/src/components/__tests__/__snapshots__/Subscription.spec.js.snap +19 -0
  44. package/src/components/index.js +0 -2
  45. package/src/components/ruleImplementationForm/InformationForm.js +1 -0
  46. package/src/components/ruleImplementationForm/RuleImplementationForm.js +7 -3
  47. package/src/components/ruleImplementationForm/RuleImplementationRawForm.js +11 -2
  48. package/src/components/ruleImplementationForm/__tests__/RuleImplementationForm.spec.js +2 -2
  49. package/src/components/ruleImplementationForm/__tests__/RuleImplementationRawForm.spec.js +6 -4
  50. package/src/messages/en.js +11 -6
  51. package/src/messages/es.js +13 -10
  52. package/src/reducers/__tests__/implementationsActions.spec.js +0 -9
  53. package/src/reducers/__tests__/ruleImplementationRedirect.spec.js +4 -13
  54. package/src/reducers/__tests__/ruleRedirect.spec.js +47 -67
  55. package/src/reducers/implementationsActions.js +0 -2
  56. package/src/reducers/index.js +0 -4
  57. package/src/reducers/ruleImplementation.js +7 -5
  58. package/src/reducers/ruleImplementationRedirect.js +6 -5
  59. package/src/reducers/ruleRedirect.js +14 -9
  60. package/src/routines.js +76 -76
  61. package/src/sagas/__tests__/deleteImplementation.spec.js +92 -0
  62. package/src/sagas/__tests__/publishImplementation.spec.js +80 -0
  63. package/src/sagas/__tests__/rejectImplementation.spec.js +80 -0
  64. package/src/sagas/__tests__/submitImplementation.spec.js +80 -0
  65. package/src/sagas/deleteImplementation.js +28 -0
  66. package/src/sagas/index.js +12 -3
  67. package/src/sagas/publishImplementation.js +24 -0
  68. package/src/sagas/rejectImplementation.js +24 -0
  69. package/src/sagas/submitImplementation.js +24 -0
  70. package/src/selectors/getExecutionQuery.js +4 -11
  71. package/src/components/__tests__/__snapshots__/RuleImplementations.spec.js.snap +0 -130
  72. package/src/reducers/__tests__/deletionQuery.spec.js +0 -24
  73. package/src/reducers/deletionQuery.js +0 -23
  74. package/src/reducers/userImplementationsPermissions.js +0 -23
  75. package/src/sagas/__tests__/setRuleImplementationStatus.spec.js +0 -165
  76. package/src/sagas/setRuleImplementationStatus.js +0 -53
@@ -1,7 +1,6 @@
1
1
  import { conceptRules } from "./conceptRules";
2
2
  import { conceptRulesActions } from "./conceptRulesActions";
3
3
  import { conceptRulesLoading } from "./conceptRulesLoading";
4
- import { deletionQuery } from "./deletionQuery";
5
4
  import { dqMessage } from "./dqMessage";
6
5
  import { executionGroup } from "./executionGroup";
7
6
  import { implementationLinks } from "./implementationLinks";
@@ -47,7 +46,6 @@ import { rulesPageSize } from "./rulesPageSize";
47
46
  import { segmentResults } from "./segmentResults";
48
47
  import { uploadingImplementationsFile } from "./uploadingImplementationsFile";
49
48
  import { uploadingRulesFile } from "./uploadingRulesFile";
50
- import { userImplementationsPermissions } from "./userImplementationsPermissions";
51
49
  import { userRulePermissions } from "./userRulePermissions";
52
50
  import { userRulesPermissions } from "./userRulesPermissions";
53
51
 
@@ -55,7 +53,6 @@ export {
55
53
  conceptRules,
56
54
  conceptRulesActions,
57
55
  conceptRulesLoading,
58
- deletionQuery,
59
56
  dqMessage,
60
57
  executionGroup,
61
58
  implementationLinks,
@@ -101,7 +98,6 @@ export {
101
98
  segmentResults,
102
99
  uploadingImplementationsFile,
103
100
  uploadingRulesFile,
104
- userImplementationsPermissions,
105
101
  userRulePermissions,
106
102
  userRulesPermissions,
107
103
  };
@@ -4,8 +4,8 @@ import { fetchRuleImplementation, clearRuleImplementation } from "../routines";
4
4
  const initialState = {};
5
5
 
6
6
  const pickFields = _.pick([
7
- "dataset",
8
7
  "data_structures",
8
+ "dataset",
9
9
  "deleted_at",
10
10
  "df_content",
11
11
  "df_name",
@@ -15,20 +15,22 @@ const pickFields = _.pick([
15
15
  "event_message",
16
16
  "event_type",
17
17
  "executable",
18
+ "goal",
18
19
  "id",
19
20
  "implementation_key",
20
21
  "implementation_type",
22
+ "minimum",
21
23
  "populations",
22
- "segments",
23
24
  "raw_content",
25
+ "result_type",
24
26
  "results",
25
27
  "rule",
26
28
  "rule_id",
29
+ "segments",
30
+ "status",
27
31
  "system",
28
32
  "validations",
29
- "result_type",
30
- "minimum",
31
- "goal",
33
+ "version",
32
34
  ]);
33
35
 
34
36
  const ruleImplementation = (state = initialState, { type, payload }) => {
@@ -25,9 +25,9 @@ export const ruleImplementationRedirect = (
25
25
  case clearRedirect.TRIGGER:
26
26
  return initialState;
27
27
  case createRuleImplementation.SUCCESS: {
28
- const id = payload?.data?.rule_id;
28
+ const id = payload?.data?.id;
29
29
  return id
30
- ? linkTo.RULE_IMPLEMENTATIONS({ id })
30
+ ? linkTo.IMPLEMENTATION({ implementation_id: id })
31
31
  : linkTo.IMPLEMENTATIONS();
32
32
  }
33
33
  case createImplementationStructure.SUCCESS: {
@@ -38,9 +38,10 @@ export const ruleImplementationRedirect = (
38
38
  return linkTo.EXECUTION_GROUP({ id });
39
39
  }
40
40
  case updateRuleImplementation.SUCCESS: {
41
- const { data } = payload || {};
42
- const { id: implementation_id } = data;
43
- return linkTo.IMPLEMENTATION({ implementation_id });
41
+ const id = payload?.data?.id;
42
+ return id
43
+ ? linkTo.IMPLEMENTATION({ implementation_id: id })
44
+ : linkTo.IMPLEMENTATIONS();
44
45
  }
45
46
  case uploadImplementations.SUCCESS: {
46
47
  return IMPLEMENTATIONS;
@@ -8,9 +8,12 @@ import {
8
8
  } from "@truedat/core/routines";
9
9
  import {
10
10
  createRule,
11
- updateRule,
11
+ deleteImplementation,
12
12
  deleteRule,
13
- setRuleImplementationStatus,
13
+ publishImplementation,
14
+ rejectImplementation,
15
+ submitImplementation,
16
+ updateRule,
14
17
  uploadRules,
15
18
  } from "../routines";
16
19
 
@@ -21,15 +24,9 @@ export const ruleRedirect = (state = initialState, { type, payload, meta }) => {
21
24
  case clearRedirect.TRIGGER:
22
25
  return initialState;
23
26
  case createRule.SUCCESS: {
24
- const id = _.prop("data.id")(payload);
27
+ const id = payload?.data?.id;
25
28
  return linkTo.RULE({ id });
26
29
  }
27
- case setRuleImplementationStatus.SUCCESS: {
28
- const { implementation_id, ruleId: id } = payload;
29
- return id
30
- ? linkTo.RULE_IMPLEMENTATIONS({ id })
31
- : linkTo.IMPLEMENTATION({ implementation_id });
32
- }
33
30
  case deleteRule.SUCCESS:
34
31
  return RULES;
35
32
  case updateRule.SUCCESS: {
@@ -51,6 +48,14 @@ export const ruleRedirect = (state = initialState, { type, payload, meta }) => {
51
48
  const { rule_id } = payload;
52
49
  return _.isNil(rule_id) ? state : linkTo.RULE({ id: rule_id });
53
50
  }
51
+ case deleteImplementation.SUCCESS:
52
+ return payload?.redirectUrl || state;
53
+ case publishImplementation.SUCCESS:
54
+ return payload?.redirectUrl || state;
55
+ case submitImplementation.SUCCESS:
56
+ return payload?.redirectUrl || state;
57
+ case rejectImplementation.SUCCESS:
58
+ return payload?.redirectUrl || state;
54
59
  default:
55
60
  return state;
56
61
  }
package/src/routines.js CHANGED
@@ -1,108 +1,108 @@
1
1
  import { createRoutine } from "redux-saga-routines";
2
2
 
3
- export const clearRules = createRoutine("CLEAR_RULES");
4
- export const fetchRules = createRoutine("FETCH_RULES");
5
- export const clearRule = createRoutine("CLEAR_RULE");
6
- export const fetchRule = createRoutine("FETCH_RULE");
7
- export const updateRule = createRoutine("UPDATE_RULE");
8
-
9
- export const createRemediation = createRoutine("CREATE_REMEDIATION");
10
- export const updateRemediation = createRoutine("UPDATE_REMEDIATION");
11
- export const clearRemediation = createRoutine("CLEAR_REMEDIATION");
12
- export const deleteRemediation = createRoutine("DELETE_REMEDIATION");
13
-
14
- export const clearRuleImplementations = createRoutine(
15
- "CLEAR_RULE_IMPLEMENTATIONS"
3
+ export const addImplementationFilter = createRoutine(
4
+ "ADD_IMPLEMENTATION_FILTER"
16
5
  );
17
- export const fetchRuleImplementation = createRoutine(
18
- "FETCH_RULE_IMPLEMENTATION"
6
+ export const addRuleFilter = createRoutine("ADD_RULE_FILTER");
7
+ export const clearConceptRules = createRoutine("CLEAR_CONCEPT_RULES");
8
+ export const clearExecutionGroup = createRoutine("CLEAR_EXECUTION_GROUP");
9
+ export const clearImplementationDefaultFilters = createRoutine(
10
+ "CLEAR_IMPLEMENTATION_DEFAULT_FILTRERS"
11
+ );
12
+ export const clearImplementationFilters = createRoutine(
13
+ "CLEAR_IMPLEMENTATION_FILTERS"
19
14
  );
15
+ export const clearRemediation = createRoutine("CLEAR_REMEDIATION");
16
+ export const clearRule = createRoutine("CLEAR_RULE");
17
+ export const clearRuleFilters = createRoutine("CLEAR_RULE_FILTERS");
20
18
  export const clearRuleImplementation = createRoutine(
21
19
  "CLEAR_RULE_IMPLEMENTATION"
22
20
  );
23
- export const fetchRuleImplementations = createRoutine(
24
- "FETCH_RULE_IMPLEMENTATIONS"
21
+ export const clearRuleImplementations = createRoutine(
22
+ "CLEAR_RULE_IMPLEMENTATIONS"
23
+ );
24
+ export const clearRules = createRoutine("CLEAR_RULES");
25
+ export const clearSegmentResults = createRoutine("CLEAR_SEGMENT_RESULTS");
26
+ export const clearStructure = createRoutine("CLEAR_STRUCTURE");
27
+ export const closeImplementationFilter = createRoutine(
28
+ "CLOSE_IMPLEMENTATION_FILTER"
25
29
  );
30
+ export const closeRuleFilter = createRoutine("CLOSE_RULE_FILTER");
31
+ export const createExecutionGroup = createRoutine("CREATE_EXECUTION_GROUP");
32
+ export const createImplementationStructure = createRoutine(
33
+ "CREATE_IMPLEMENTATION_STRUCTURE"
34
+ );
35
+ export const createRemediation = createRoutine("CREATE_REMEDIATION");
26
36
  export const createRule = createRoutine("CREATE_RULE");
27
37
  export const createRuleImplementation = createRoutine(
28
38
  "CREATE_RULE_IMPLEMENTATION"
29
39
  );
30
- export const updateRuleImplementation = createRoutine(
31
- "UPDATE_RULE_IMPLEMENTATION"
40
+ export const deleteImplementationStructure = createRoutine(
41
+ "DELETE_IMPLEMENTATION_STRUCTURE"
32
42
  );
43
+ export const deleteRemediation = createRoutine("DELETE_REMEDIATION");
33
44
  export const deleteRule = createRoutine("DELETE_RULE");
34
- export const setRuleImplementationStatus = createRoutine(
35
- "DELETE_RULE_IMPLEMENTATION"
45
+ export const deleteRuleResult = createRoutine("DELETE_RULE_RESULT");
46
+ export const deprecateImplementation = createRoutine("CREATE_IMPLEMENTATION");
47
+ export const downloadImplementations = createRoutine(
48
+ "DOWNLOAD_IMPLEMENTATIONS"
36
49
  );
37
50
  export const fetchConceptRules = createRoutine("FETCH_CONCEPT_RULES");
38
- export const clearConceptRules = createRoutine("CLEAR_CONCEPT_RULES");
39
-
40
- export const addRuleFilter = createRoutine("ADD_RULE_FILTER");
41
- export const clearRuleFilters = createRoutine("CLEAR_RULE_FILTERS");
42
- export const closeRuleFilter = createRoutine("CLOSE_RULE_FILTER");
43
- export const openRuleFilter = createRoutine("OPEN_RULE_FILTER");
44
- export const removeRuleFilter = createRoutine("REMOVE_RULE_FILTER");
45
- export const resetRuleFilters = createRoutine("RESET_RULE_FILTERS");
51
+ export const fetchExecutionGroup = createRoutine("FETCH_EXECUTION_GROUP");
52
+ export const fetchImplementationFilters = createRoutine(
53
+ "FETCH_IMPLEMENTATION_FILTERS"
54
+ );
55
+ export const fetchRemediation = createRoutine("FETCH_REMEDIATION");
56
+ export const fetchRule = createRoutine("FETCH_RULE");
46
57
  export const fetchRuleFilters = createRoutine("FETCH_RULE_FILTERS");
47
-
48
- export const searchRules = createRoutine("SEARCH_RULES");
49
- export const sortRules = createRoutine("SORT_RULES");
50
- export const selectRulePage = createRoutine("SELECT_RULE_PAGE");
51
- export const toggleRuleFilterValue = createRoutine("TOGGLE_RULE_FILTER_VALUE");
52
- export const updateDeletionQuery = createRoutine("UPDATE_DELETION_QUERY");
53
- export const uploadRules = createRoutine("UPLOAD_RULES");
54
- export const uploadImplementations = createRoutine("UPLOAD_IMPLEMENTATIONS");
55
- export const clearStructure = createRoutine("CLEAR_STRUCTURE");
56
- export const searchRuleImplementations = createRoutine(
57
- "SEARCH_RULE_IMPLEMENTATIONS"
58
+ export const fetchRuleImplementation = createRoutine(
59
+ "FETCH_RULE_IMPLEMENTATION"
58
60
  );
59
-
60
- export const deleteRuleResult = createRoutine("DELETE_RULE_RESULT");
61
-
61
+ export const fetchRuleImplementations = createRoutine(
62
+ "FETCH_RULE_IMPLEMENTATIONS"
63
+ );
64
+ export const fetchRules = createRoutine("FETCH_RULES");
62
65
  export const fetchSegmentResults = createRoutine("FETCH_SEGMENT_RESULTS");
63
- export const clearSegmentResults = createRoutine("CLEAR_SEGMENT_RESULTS");
64
-
65
- export const clearImplementationFilters = createRoutine(
66
- "CLEAR_IMPLEMENTATION_FILTERS"
66
+ export const openImplementationFilter = createRoutine(
67
+ "OPEN_IMPLEMENTATION_FILTER"
67
68
  );
69
+ export const openRuleFilter = createRoutine("OPEN_RULE_FILTER");
70
+ export const publishImplementation = createRoutine("PUBLISH_IMPLEMENTATION");
71
+ export const rejectImplementation = createRoutine("REJECT_IMPLEMENTATION");
68
72
  export const removeImplementationFilter = createRoutine(
69
73
  "REMOVE_IMPLEMENTATION_FILTERS"
70
74
  );
71
- export const toggleImplementationFilterValue = createRoutine(
72
- "TOGGLE_IMPLEMENTATION_FILTER_VALUE"
75
+ export const removeRuleFilter = createRoutine("REMOVE_RULE_FILTER");
76
+ export const resetImplementationFilters = createRoutine(
77
+ "RESET_IMPLEMENTATION_FILTERS"
73
78
  );
79
+ export const resetRuleFilters = createRoutine("RESET_RULE_FILTERS");
74
80
  export const searchImplementations = createRoutine("SEARCH_IMPLEMENTATIONS");
81
+ export const searchRuleImplementations = createRoutine(
82
+ "SEARCH_RULE_IMPLEMENTATIONS"
83
+ );
84
+ export const searchRules = createRoutine("SEARCH_RULES");
75
85
  export const selectImplementationPage = createRoutine(
76
86
  "SELECT_IMPLEMENTATION_PAGE"
77
87
  );
78
- export const sortImplementations = createRoutine("SORT_IMPLEMENTATIONS");
79
- export const addImplementationFilter = createRoutine(
80
- "ADD_IMPLEMENTATION_FILTER"
81
- );
82
- export const closeImplementationFilter = createRoutine(
83
- "CLOSE_IMPLEMENTATION_FILTER"
84
- );
85
- export const resetImplementationFilters = createRoutine(
86
- "RESET_IMPLEMENTATION_FILTERS"
87
- );
88
- export const fetchImplementationFilters = createRoutine(
89
- "FETCH_IMPLEMENTATION_FILTERS"
88
+ export const selectRulePage = createRoutine("SELECT_RULE_PAGE");
89
+ export const setImplementationDefaultFilters = createRoutine(
90
+ "SET_IMPLEMENTATION_DEFAULT_FILTRERS"
90
91
  );
91
- export const openImplementationFilter = createRoutine(
92
- "OPEN_IMPLEMENTATION_FILTER"
92
+ export const deleteImplementation = createRoutine("DELETE_IMPLEMENTATION");
93
+ export const sortImplementations = createRoutine("SORT_IMPLEMENTATIONS");
94
+ export const sortRules = createRoutine("SORT_RULES");
95
+ export const submitImplementation = createRoutine("SUBMIT_IMPLEMENTATION");
96
+ export const toggleImplementationFilterValue = createRoutine(
97
+ "TOGGLE_IMPLEMENTATION_FILTER_VALUE"
93
98
  );
94
- export const downloadImplementations = createRoutine(
95
- "DOWNLOAD_IMPLEMENTATIONS"
99
+ export const toggleRuleFilterValue = createRoutine("TOGGLE_RULE_FILTER_VALUE");
100
+ export const updateDeletionQuery = createRoutine("UPDATE_DELETION_QUERY");
101
+ export const updateRemediation = createRoutine("UPDATE_REMEDIATION");
102
+ export const updateRule = createRoutine("UPDATE_RULE");
103
+ export const updateRuleImplementation = createRoutine(
104
+ "UPDATE_RULE_IMPLEMENTATION"
96
105
  );
106
+ export const uploadImplementations = createRoutine("UPLOAD_IMPLEMENTATIONS");
97
107
  export const uploadResults = createRoutine("UPLOAD_RESULTS");
98
- export const createExecutionGroup = createRoutine("CREATE_EXECUTION_GROUP");
99
- export const fetchExecutionGroup = createRoutine("FETCH_EXECUTION_GROUP");
100
- export const clearExecutionGroup = createRoutine("CLEAR_EXECUTION_GROUP");
101
- export const fetchRemediation = createRoutine("FETCH_REMEDIATION");
102
-
103
- export const createImplementationStructure = createRoutine(
104
- "CREATE_IMPLEMENTATION_STRUCTURE"
105
- );
106
- export const deleteImplementationStructure = createRoutine(
107
- "DELETE_IMPLEMENTATION_STRUCTURE"
108
- );
108
+ export const uploadRules = createRoutine("UPLOAD_RULES");
@@ -0,0 +1,92 @@
1
+ import { compile } from "path-to-regexp";
2
+ import { testSaga } from "redux-saga-test-plan";
3
+ import { apiJsonDelete, JSON_OPTS } from "@truedat/core/services/api";
4
+ import {
5
+ deleteImplementationRequestSaga,
6
+ deleteImplementationSaga,
7
+ } from "../deleteImplementation";
8
+ import { deleteImplementation } from "../../routines";
9
+ import { API_RULE_IMPLEMENTATION } from "../../api";
10
+
11
+ describe("sagas: deleteImplementationRequestSaga", () => {
12
+ it("should invoke deleteImplementationSaga on trigger", () => {
13
+ expect(() => {
14
+ testSaga(deleteImplementationRequestSaga)
15
+ .next()
16
+ .takeLatest(deleteImplementation.TRIGGER, deleteImplementationSaga)
17
+ .finish()
18
+ .isDone();
19
+ }).not.toThrow();
20
+ });
21
+
22
+ it("should throw exception if an unhandled action is received", () => {
23
+ expect(() => {
24
+ testSaga(deleteImplementationRequestSaga)
25
+ .next()
26
+ .takeLatest("FOO", deleteImplementation);
27
+ }).toThrow();
28
+ });
29
+ });
30
+
31
+ describe("sagas: deleteImplementationSaga", () => {
32
+ const id = 1;
33
+ const redirectUrl = "foo";
34
+ const url = compile(API_RULE_IMPLEMENTATION)({ id });
35
+ const payload = { id, redirectUrl };
36
+ const data = {};
37
+
38
+ it("should put a success action when a response is returned", () => {
39
+ expect(() => {
40
+ testSaga(deleteImplementationSaga, { payload })
41
+ .next()
42
+ .put(deleteImplementation.request())
43
+ .next()
44
+ .call(apiJsonDelete, url, JSON_OPTS)
45
+ .next({ data })
46
+ .put(deleteImplementation.success({ redirectUrl }))
47
+ .next()
48
+ .put(deleteImplementation.fulfill())
49
+ .next()
50
+ .isDone();
51
+ }).not.toThrow();
52
+ });
53
+
54
+ it("should put a failure action when the call returns an error", () => {
55
+ const message = "Request failed";
56
+ const error = { message };
57
+
58
+ expect(() => {
59
+ testSaga(deleteImplementationSaga, { payload })
60
+ .next()
61
+ .put(deleteImplementation.request())
62
+ .next()
63
+ .call(apiJsonDelete, url, JSON_OPTS)
64
+ .throw(error)
65
+ .put(deleteImplementation.failure(message))
66
+ .next()
67
+ .put(deleteImplementation.fulfill())
68
+ .next()
69
+ .isDone();
70
+ }).not.toThrow();
71
+ });
72
+
73
+ it("should put a failure action when the call returns an error with response", () => {
74
+ const status = 404;
75
+ const data = "foo";
76
+ const error = { response: { status, data } };
77
+
78
+ expect(() => {
79
+ testSaga(deleteImplementationSaga, { payload })
80
+ .next()
81
+ .put(deleteImplementation.request())
82
+ .next()
83
+ .call(apiJsonDelete, url, JSON_OPTS)
84
+ .throw(error)
85
+ .put(deleteImplementation.failure({ status, data }))
86
+ .next()
87
+ .put(deleteImplementation.fulfill())
88
+ .next()
89
+ .isDone();
90
+ }).not.toThrow();
91
+ });
92
+ });
@@ -0,0 +1,80 @@
1
+ import { testSaga } from "redux-saga-test-plan";
2
+ import {
3
+ publishImplementationRequestSaga,
4
+ publishImplementationSaga,
5
+ } from "../publishImplementation";
6
+ import { PUBLISH_IMPLEMENTATION } from "../../api/mutations";
7
+ import { publishImplementation } from "../../routines";
8
+
9
+ describe("sagas: publishImplementationRequestSaga", () => {
10
+ it("should invoke publishImplementationSaga on publishImplementation.TRIGGER", () => {
11
+ expect(() => {
12
+ testSaga(publishImplementationRequestSaga)
13
+ .next()
14
+ .takeLatest(publishImplementation.TRIGGER, publishImplementationSaga)
15
+ .finish()
16
+ .isDone();
17
+ }).not.toThrow();
18
+ });
19
+
20
+ it("should throw exception if an unhandled action is received", () => {
21
+ expect(() => {
22
+ testSaga(publishImplementationRequestSaga)
23
+ .next()
24
+ .takeLatest("FOO", publishImplementationRequestSaga);
25
+ }).toThrow();
26
+ });
27
+ });
28
+
29
+ describe("sagas: publishImplementationSaga", () => {
30
+ const client = { mutate: jest.fn() };
31
+ const id = "123";
32
+ const redirectUrl = "foo";
33
+ const payload = { id, redirectUrl };
34
+ const data = { foo: "bar" };
35
+
36
+ it("should put a success action when a response is returned", () => {
37
+ expect(() => {
38
+ testSaga(publishImplementationSaga, { payload })
39
+ .next()
40
+ .getContext("client")
41
+ .next(client)
42
+ .put(publishImplementation.request({ id }))
43
+ .next()
44
+ .call(client.mutate, {
45
+ mutation: PUBLISH_IMPLEMENTATION,
46
+ variables: payload,
47
+ })
48
+ .next({ data })
49
+ .put(publishImplementation.success({ data, redirectUrl }))
50
+ .next()
51
+ .put(publishImplementation.fulfill())
52
+ .next()
53
+ .isDone();
54
+ }).not.toThrow();
55
+ });
56
+
57
+ it("should put a failure action when the call returns an error", () => {
58
+ const message = "Request failed";
59
+ const error = { message };
60
+
61
+ expect(() => {
62
+ testSaga(publishImplementationSaga, { payload })
63
+ .next()
64
+ .getContext("client")
65
+ .next(client)
66
+ .put(publishImplementation.request({ id }))
67
+ .next()
68
+ .call(client.mutate, {
69
+ mutation: PUBLISH_IMPLEMENTATION,
70
+ variables: payload,
71
+ })
72
+ .throw(error)
73
+ .put(publishImplementation.failure(message))
74
+ .next()
75
+ .put(publishImplementation.fulfill())
76
+ .next()
77
+ .isDone();
78
+ }).not.toThrow();
79
+ });
80
+ });
@@ -0,0 +1,80 @@
1
+ import { testSaga } from "redux-saga-test-plan";
2
+ import {
3
+ rejectImplementationRequestSaga,
4
+ rejectImplementationSaga,
5
+ } from "../rejectImplementation";
6
+ import { REJECT_IMPLEMENTATION } from "../../api/mutations";
7
+ import { rejectImplementation } from "../../routines";
8
+
9
+ describe("sagas: rejectImplementationRequestSaga", () => {
10
+ it("should invoke rejectImplementationSaga on rejectImplementation.TRIGGER", () => {
11
+ expect(() => {
12
+ testSaga(rejectImplementationRequestSaga)
13
+ .next()
14
+ .takeLatest(rejectImplementation.TRIGGER, rejectImplementationSaga)
15
+ .finish()
16
+ .isDone();
17
+ }).not.toThrow();
18
+ });
19
+
20
+ it("should throw exception if an unhandled action is received", () => {
21
+ expect(() => {
22
+ testSaga(rejectImplementationRequestSaga)
23
+ .next()
24
+ .takeLatest("FOO", rejectImplementationRequestSaga);
25
+ }).toThrow();
26
+ });
27
+ });
28
+
29
+ describe("sagas: rejectImplementationSaga", () => {
30
+ const client = { mutate: jest.fn() };
31
+ const id = "123";
32
+ const redirectUrl = "foo";
33
+ const payload = { id, redirectUrl };
34
+ const data = { foo: "bar" };
35
+
36
+ it("should put a success action when a response is returned", () => {
37
+ expect(() => {
38
+ testSaga(rejectImplementationSaga, { payload })
39
+ .next()
40
+ .getContext("client")
41
+ .next(client)
42
+ .put(rejectImplementation.request({ id }))
43
+ .next()
44
+ .call(client.mutate, {
45
+ mutation: REJECT_IMPLEMENTATION,
46
+ variables: payload,
47
+ })
48
+ .next({ data })
49
+ .put(rejectImplementation.success({ data, redirectUrl }))
50
+ .next()
51
+ .put(rejectImplementation.fulfill())
52
+ .next()
53
+ .isDone();
54
+ }).not.toThrow();
55
+ });
56
+
57
+ it("should put a failure action when the call returns an error", () => {
58
+ const message = "Request failed";
59
+ const error = { message };
60
+
61
+ expect(() => {
62
+ testSaga(rejectImplementationSaga, { payload })
63
+ .next()
64
+ .getContext("client")
65
+ .next(client)
66
+ .put(rejectImplementation.request({ id }))
67
+ .next()
68
+ .call(client.mutate, {
69
+ mutation: REJECT_IMPLEMENTATION,
70
+ variables: payload,
71
+ })
72
+ .throw(error)
73
+ .put(rejectImplementation.failure(message))
74
+ .next()
75
+ .put(rejectImplementation.fulfill())
76
+ .next()
77
+ .isDone();
78
+ }).not.toThrow();
79
+ });
80
+ });
@@ -0,0 +1,80 @@
1
+ import { testSaga } from "redux-saga-test-plan";
2
+ import {
3
+ submitImplementationRequestSaga,
4
+ submitImplementationSaga,
5
+ } from "../submitImplementation";
6
+ import { SUBMIT_IMPLEMENTATION } from "../../api/mutations";
7
+ import { submitImplementation } from "../../routines";
8
+
9
+ describe("sagas: submitImplementationRequestSaga", () => {
10
+ it("should invoke submitImplementationSaga on submitImplementation.TRIGGER", () => {
11
+ expect(() => {
12
+ testSaga(submitImplementationRequestSaga)
13
+ .next()
14
+ .takeLatest(submitImplementation.TRIGGER, submitImplementationSaga)
15
+ .finish()
16
+ .isDone();
17
+ }).not.toThrow();
18
+ });
19
+
20
+ it("should throw exception if an unhandled action is received", () => {
21
+ expect(() => {
22
+ testSaga(submitImplementationRequestSaga)
23
+ .next()
24
+ .takeLatest("FOO", submitImplementationRequestSaga);
25
+ }).toThrow();
26
+ });
27
+ });
28
+
29
+ describe("sagas: submitImplementationSaga", () => {
30
+ const client = { mutate: jest.fn() };
31
+ const id = "123";
32
+ const redirectUrl = "foo";
33
+ const payload = { id, redirectUrl };
34
+ const data = { foo: "bar" };
35
+
36
+ it("should put a success action when a response is returned", () => {
37
+ expect(() => {
38
+ testSaga(submitImplementationSaga, { payload })
39
+ .next()
40
+ .getContext("client")
41
+ .next(client)
42
+ .put(submitImplementation.request({ id }))
43
+ .next()
44
+ .call(client.mutate, {
45
+ mutation: SUBMIT_IMPLEMENTATION,
46
+ variables: payload,
47
+ })
48
+ .next({ data })
49
+ .put(submitImplementation.success({ data, redirectUrl }))
50
+ .next()
51
+ .put(submitImplementation.fulfill())
52
+ .next()
53
+ .isDone();
54
+ }).not.toThrow();
55
+ });
56
+
57
+ it("should put a failure action when the call returns an error", () => {
58
+ const message = "Request failed";
59
+ const error = { message };
60
+
61
+ expect(() => {
62
+ testSaga(submitImplementationSaga, { payload })
63
+ .next()
64
+ .getContext("client")
65
+ .next(client)
66
+ .put(submitImplementation.request({ id }))
67
+ .next()
68
+ .call(client.mutate, {
69
+ mutation: SUBMIT_IMPLEMENTATION,
70
+ variables: payload,
71
+ })
72
+ .throw(error)
73
+ .put(submitImplementation.failure(message))
74
+ .next()
75
+ .put(submitImplementation.fulfill())
76
+ .next()
77
+ .isDone();
78
+ }).not.toThrow();
79
+ });
80
+ });