@truedat/dd 4.44.3 → 4.44.4
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 +10 -0
- package/package.json +6 -6
- package/src/api/mutations.js +27 -0
- package/src/api/queries.js +24 -0
- package/src/api.js +2 -0
- package/src/components/DictionaryRoutes.js +7 -5
- package/src/components/FilteredNav.js +9 -9
- package/src/components/GrantRequestApprovalPopup.js +0 -1
- package/src/components/ReferenceDataset.js +23 -0
- package/src/components/ReferenceDatasetActions.js +88 -0
- package/src/components/ReferenceDatasetBreadcrumbs.js +22 -0
- package/src/components/ReferenceDatasetCreate.js +36 -0
- package/src/components/ReferenceDatasetDetail.js +42 -0
- package/src/components/ReferenceDatasetForm.js +109 -0
- package/src/components/ReferenceDatasetHeader.js +32 -0
- package/src/components/ReferenceDatasetRoutes.js +56 -0
- package/src/components/ReferenceDatasetTable.js +42 -0
- package/src/components/ReferenceDatasets.js +61 -0
- package/src/components/ReferenceDatasetsTable.js +105 -0
- package/src/components/StructureTagsRoutes.js +0 -1
- package/src/components/StructureTypesCrumbs.js +0 -1
- package/src/components/StructureView.js +1 -3
- package/src/components/SystemForm.js +1 -1
- package/src/components/__tests__/ReferenceDataset.spec.js +64 -0
- package/src/components/__tests__/ReferenceDatasetActions.spec.js +17 -0
- package/src/components/__tests__/ReferenceDatasetBreadcrumbs.spec.js +12 -0
- package/src/components/__tests__/ReferenceDatasetCreate.spec.js +12 -0
- package/src/components/__tests__/ReferenceDatasetDetail.spec.js +37 -0
- package/src/components/__tests__/ReferenceDatasetForm.spec.js +51 -0
- package/src/components/__tests__/ReferenceDatasetHeader.spec.js +17 -0
- package/src/components/__tests__/ReferenceDatasetRoutes.spec.js +74 -0
- package/src/components/__tests__/ReferenceDatasetTable.spec.js +18 -0
- package/src/components/__tests__/ReferenceDatasets.spec.js +32 -0
- package/src/components/__tests__/ReferenceDatasetsTable.spec.js +22 -0
- package/src/components/__tests__/__snapshots__/DictionaryRoutes.spec.js.snap +4 -0
- package/src/components/__tests__/__snapshots__/ReferenceDataset.spec.js.snap +365 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetActions.spec.js.snap +65 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetBreadcrumbs.spec.js.snap +25 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetCreate.spec.js.snap +98 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetDetail.spec.js.snap +135 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetForm.spec.js.snap +61 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetHeader.spec.js.snap +95 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetRoutes.spec.js.snap +414 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetTable.spec.js.snap +75 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasets.spec.js.snap +128 -0
- package/src/components/__tests__/__snapshots__/ReferenceDatasetsTable.spec.js.snap +86 -0
- package/src/messages/en.js +18 -0
- package/src/messages/es.js +20 -0
- package/src/reducers/__tests__/ddMessage.spec.js +26 -5
- package/src/reducers/__tests__/graph.spec.js +1 -6
- package/src/reducers/__tests__/referenceDatasetSaving.spec.js +44 -0
- package/src/reducers/__tests__/structureRedirect.spec.js +37 -13
- package/src/reducers/ddMessage.js +26 -1
- package/src/reducers/index.js +2 -0
- package/src/reducers/referenceDatasetSaving.js +16 -0
- package/src/reducers/structureRedirect.js +36 -15
- package/src/reducers/structuresUploadEvents.js +0 -1
- package/src/routines.js +35 -74
- package/src/sagas/__tests__/createReferenceDataset.spec.js +90 -0
- package/src/sagas/__tests__/deleteReferenceDataset.spec.js +81 -0
- package/src/sagas/__tests__/updateReferenceDataset.spec.js +116 -0
- package/src/sagas/createReferenceDataset.js +34 -0
- package/src/sagas/deleteReferenceDataset.js +29 -0
- package/src/sagas/downloadReferenceDataset.js +44 -0
- package/src/sagas/index.js +31 -22
- package/src/sagas/updateReferenceDataset.js +35 -0
- package/src/selectors/getRelationSortingCriteria.js +3 -5
package/src/routines.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
1
2
|
import { createRoutine } from "redux-saga-routines";
|
|
2
3
|
|
|
3
4
|
export const addGrantFilter = createRoutine("ADD_GRANT_FILTER");
|
|
5
|
+
export const addGrantRequestToCart = createRoutine("ADD_GRANT_REQUEST_TO_CART");
|
|
4
6
|
export const addStructureFilter = createRoutine("ADD_STRUCTURE_FILTER");
|
|
5
|
-
export const addStructureSelectedFilter = createRoutine(
|
|
6
|
-
"ADD_STRUCTURE_SELECTED_FILTER"
|
|
7
|
-
);
|
|
7
|
+
export const addStructureSelectedFilter = createRoutine("ADD_STRUCTURE_SELECTED_FILTER");
|
|
8
8
|
export const applyGrantDateFilter = createRoutine("APPLY_GRANT_DATE_FILTER");
|
|
9
|
-
export const applyStructureDateFilter = createRoutine(
|
|
10
|
-
"APPLY_STRUCTURE_DATE_FILTER"
|
|
11
|
-
);
|
|
9
|
+
export const applyStructureDateFilter = createRoutine("APPLY_STRUCTURE_DATE_FILTER");
|
|
12
10
|
export const applyUserSearchFilter = createRoutine("APPLY_USER_SEARCH_FILTER");
|
|
13
11
|
export const bulkUpdateStructures = createRoutine("BULK_UPDATE_STRUCTURES");
|
|
14
12
|
export const cancelPoll = createRoutine("CANCEL_POLL");
|
|
13
|
+
export const checkoutGrantRequest = createRoutine("CHECKOUT_GRANT_REQUEST");
|
|
15
14
|
export const clearGrantFilters = createRoutine("CLEAR_GRANT_FILTERS");
|
|
15
|
+
export const clearGrantRequest = createRoutine("CLEAR_GRANT_REQUEST");
|
|
16
|
+
export const clearGrantRequests = createRoutine("CLEAR_GRANT_REQUESTS");
|
|
16
17
|
export const clearGrants = createRoutine("CLEAR_GRANTS");
|
|
17
18
|
export const clearGrantsSort = createRoutine("CLEAR_GRANTS_SORT");
|
|
18
19
|
export const clearGraph = createRoutine("CLEAR_GRAPH");
|
|
@@ -28,47 +29,44 @@ export const clearStructureFilters = createRoutine("CLEAR_STRUCTURE_FILTERS");
|
|
|
28
29
|
export const clearStructureNotes = createRoutine("CLEAR_STRUCTURE_NOTES");
|
|
29
30
|
export const clearStructureType = createRoutine("CLEAR_STRUCTURE_TYPE");
|
|
30
31
|
export const clearStructureTypes = createRoutine("CLEAR_STRUCTURE_TYPES");
|
|
31
|
-
export const clearUserSearchFilters = createRoutine(
|
|
32
|
-
"CLEAR_USER_SEARCH_FILTERS"
|
|
33
|
-
);
|
|
34
32
|
export const clearStructures = createRoutine("CLEAR_STRUCTURES");
|
|
35
33
|
export const clearStructuresSort = createRoutine("CLEAR_STRUCTURES_SORT");
|
|
36
34
|
export const clearSystem = createRoutine("CLEAR_SYSTEM");
|
|
37
35
|
export const clearSystemStructures = createRoutine("CLEAR_SYSTEM_STRUCTURES");
|
|
38
36
|
export const clearSystems = createRoutine("CLEAR_SYSTEMS");
|
|
37
|
+
export const clearUserSearchFilters = createRoutine("CLEAR_USER_SEARCH_FILTERS");
|
|
39
38
|
export const closeGrantFilter = createRoutine("CLOSE_GRANT_FILTER");
|
|
40
39
|
export const closeStructureFilter = createRoutine("CLOSE_STRUCTURE_FILTER");
|
|
40
|
+
export const createGrantRequestApproval = createRoutine("CREATE_GRANT_REQUEST_APPROVAL");
|
|
41
41
|
export const createGraph = createRoutine("CREATE_GRAPH");
|
|
42
42
|
export const createProfileGroup = createRoutine("CREATE_PROFILE_GROUP");
|
|
43
|
+
export const createReferenceDataset = createRoutine("CREATE_REFERENCE_DATASET");
|
|
43
44
|
export const createStructureGraph = createRoutine("CREATE_STRUCTURE_GRAPH");
|
|
44
45
|
export const createStructureTag = createRoutine("CREATE_STRUCTURE_TAG");
|
|
45
46
|
export const createStructureType = createRoutine("CREATE_STRUCTURE_TYPE");
|
|
46
|
-
export const deleteStructure = createRoutine("DELETE_STRUCTURE");
|
|
47
47
|
export const createSystem = createRoutine("CREATE_SYSTEM");
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
);
|
|
48
|
+
export const deleteReferenceDataset = createRoutine("DELETE_REFERENCE_DATASET");
|
|
49
|
+
export const deleteLinkStructureTag = createRoutine("DELETE_LINK_STRUCTURE_TAG");
|
|
50
|
+
export const deleteStructure = createRoutine("DELETE_STRUCTURE");
|
|
51
51
|
export const deleteStructureTag = createRoutine("DELETE_STRUCTURE_TAG");
|
|
52
|
-
export const deleteUserSearchFilter = createRoutine(
|
|
53
|
-
"DELETE_USER_SEARCH_FILTER"
|
|
54
|
-
);
|
|
52
|
+
export const deleteUserSearchFilter = createRoutine("DELETE_USER_SEARCH_FILTER");
|
|
55
53
|
export const doStructureNoteAction = createRoutine("DO_STRUCTURE_NOTE_ACTION");
|
|
56
54
|
export const downloadCsvGraph = createRoutine("DOWNLOAD_CSV_GRAPH");
|
|
57
|
-
export const downloadEditableStructures = createRoutine(
|
|
58
|
-
"DOWNLOAD_EDITABLE_STRUCTURES"
|
|
59
|
-
);
|
|
55
|
+
export const downloadEditableStructures = createRoutine("DOWNLOAD_EDITABLE_STRUCTURES");
|
|
60
56
|
export const downloadGrants = createRoutine("DOWNLOAD_GRANTS");
|
|
57
|
+
export const downloadReferenceDataset = createRoutine("DOWNLOAD_REFERENCE_DATASET");
|
|
61
58
|
export const downloadStructures = createRoutine("DOWNLOAD_STRUCTURES");
|
|
62
59
|
export const excludeNode = createRoutine("EXCLUDE_NODE");
|
|
63
60
|
export const fetchDomains = createRoutine("FETCH_DOMAINS"); // TODO: Is there a way to avoid repeating this routine here?
|
|
64
61
|
export const fetchGrant = createRoutine("FETCH_GRANT");
|
|
65
62
|
export const fetchGrantFilters = createRoutine("FETCH_GRANT_FILTERS");
|
|
63
|
+
export const fetchGrantRequest = createRoutine("FETCH_GRANT_REQUEST");
|
|
64
|
+
export const fetchGrantRequestTemplates = createRoutine("FETCH_GRANT_REQUEST_TEMPLATES");
|
|
65
|
+
export const fetchGrantRequests = createRoutine("FETCH_GRANT_REQUESTS");
|
|
66
66
|
export const fetchGrants = createRoutine("FETCH_GRANTS");
|
|
67
67
|
export const fetchGraph = createRoutine("FETCH_GRAPH");
|
|
68
68
|
export const fetchLineageEvents = createRoutine("FETCH_LINEAGE_EVENTS");
|
|
69
|
-
export const fetchLinksStructureTags = createRoutine(
|
|
70
|
-
"FETCH_LINKS_STRUCTURE_TAGS"
|
|
71
|
-
);
|
|
69
|
+
export const fetchLinksStructureTags = createRoutine("FETCH_LINKS_STRUCTURE_TAGS");
|
|
72
70
|
export const fetchNodes = createRoutine("FETCH_NODES");
|
|
73
71
|
export const fetchProfileExecution = createRoutine("FETCH_EXECUTION_PROFILE");
|
|
74
72
|
export const fetchProfileGroup = createRoutine("FETCH_PROFILE_GROUP");
|
|
@@ -78,89 +76,52 @@ export const fetchStructureGraph = createRoutine("FETCH_STRUCTURE_GRAPH");
|
|
|
78
76
|
export const fetchStructureNotes = createRoutine("FETCH_STRUCTURE_NOTES");
|
|
79
77
|
export const fetchStructureType = createRoutine("FETCH_STRUCTURE_TYPE");
|
|
80
78
|
export const fetchStructureTypes = createRoutine("FETCH_STRUCTURE_TYPES");
|
|
81
|
-
export const fetchUserSearchFilters = createRoutine(
|
|
82
|
-
"FETCH_USER_SEARCH_FILTERS"
|
|
83
|
-
);
|
|
84
79
|
export const fetchStructures = createRoutine("FETCH_STRUCTURES");
|
|
85
|
-
export const fetchStructuresUploadEvents = createRoutine(
|
|
86
|
-
"FETCH_STRUCTURES_UPLOAD_EVENTS"
|
|
87
|
-
);
|
|
80
|
+
export const fetchStructuresUploadEvents = createRoutine("FETCH_STRUCTURES_UPLOAD_EVENTS");
|
|
88
81
|
export const fetchSystem = createRoutine("FETCH_SYSTEM");
|
|
89
82
|
export const fetchSystemStructures = createRoutine("FETCH_SYSTEM_STRUCTURES");
|
|
90
83
|
export const fetchSystems = createRoutine("FETCH_SYSTEMS");
|
|
91
84
|
export const fetchUnitDomains = createRoutine("FETCH_UNIT_DOMAINS");
|
|
85
|
+
export const fetchUserSearchFilters = createRoutine("FETCH_USER_SEARCH_FILTERS");
|
|
92
86
|
export const filterStructures = createRoutine("FILTER_STRUCTURES");
|
|
93
87
|
export const hoverNode = createRoutine("HOVER_NODE");
|
|
94
88
|
export const initSvg = createRoutine("INIT_SVG");
|
|
95
|
-
export const loadLineageEvents = createRoutine("LOAD_LINEAGE_EVENTS");
|
|
96
89
|
export const linkStructureTag = createRoutine("LINK_STRUCTURE_TAG");
|
|
90
|
+
export const loadLineageEvents = createRoutine("LOAD_LINEAGE_EVENTS");
|
|
97
91
|
export const openGrantFilter = createRoutine("OPEN_GRANT_FILTER");
|
|
98
92
|
export const openStructureFilter = createRoutine("OPEN_STRUCTURE_FILTER");
|
|
99
93
|
export const removeGrantFilter = createRoutine("REMOVE_GRANT_FILTER");
|
|
94
|
+
export const removeGrantRequestFromCart = createRoutine("REMOVE_GRANT_REQUEST_FROM_CART");
|
|
95
|
+
export const removeGrantRequestsQuery = createRoutine("REMOVE_GRANT_REQUESTS_QUERY");
|
|
100
96
|
export const removeStructureFilter = createRoutine("REMOVE_STRUCTURE_FILTER");
|
|
101
|
-
export const removeStructureSelectedFilter = createRoutine(
|
|
102
|
-
"REMOVE_STRUCTURE_SELECTED_FILTER"
|
|
103
|
-
);
|
|
97
|
+
export const removeStructureSelectedFilter = createRoutine("REMOVE_STRUCTURE_SELECTED_FILTER");
|
|
104
98
|
export const resetGrantFilters = createRoutine("RESET_GRANT_FILTERS");
|
|
105
99
|
export const resetStructureFilters = createRoutine("RESET_STRUCTURE_FILTERS");
|
|
106
100
|
export const saveUserSearchFilters = createRoutine("SAVE_USER_SEARCH_FILTERS");
|
|
107
101
|
export const searchGrants = createRoutine("SEARCH_GRANTS");
|
|
108
102
|
export const searchStructures = createRoutine("SEARCH_STRUCTURES");
|
|
109
103
|
export const selectGrantPage = createRoutine("SELECT_GRANT_PAGE");
|
|
104
|
+
export const selectGrantRequestTemplate = createRoutine("SELECT_GRANT_REQUEST_TEMPLATE");
|
|
110
105
|
export const selectGroup = createRoutine("SELECT_GROUP");
|
|
111
106
|
export const selectNode = createRoutine("SELECT_NODE");
|
|
112
107
|
export const selectPath = createRoutine("SELECT_PATH");
|
|
113
108
|
export const selectResources = createRoutine("SELECT_RESOURCES");
|
|
114
109
|
export const selectStructure = createRoutine("SELECT_STRUCTURE");
|
|
115
110
|
export const selectStructurePage = createRoutine("SELECT_STRUCTURE_PAGE");
|
|
111
|
+
export const setGrantRequestsQuery = createRoutine("SET_GRANT_REQUESTS_QUERY");
|
|
116
112
|
export const sortGrants = createRoutine("SORT_GRANTS");
|
|
117
113
|
export const sortStructures = createRoutine("SORT_STRUCTURES");
|
|
118
114
|
export const toggleGrantDateFilter = createRoutine("TOGGLE_GRANT_DATE_FILTER");
|
|
119
|
-
export const toggleGrantFilterValue = createRoutine(
|
|
120
|
-
|
|
121
|
-
);
|
|
122
|
-
export const toggleStructureDateFilter = createRoutine(
|
|
123
|
-
"TOGGLE_STRUCTURE_DATE_FILTER"
|
|
124
|
-
);
|
|
125
|
-
export const toggleStructureFilterValue = createRoutine(
|
|
126
|
-
"TOGGLE_STRUCTURE_FILTER_VALUE"
|
|
127
|
-
);
|
|
115
|
+
export const toggleGrantFilterValue = createRoutine("TOGGLE_GRANT_FILTER_VALUE");
|
|
116
|
+
export const toggleStructureDateFilter = createRoutine("TOGGLE_STRUCTURE_DATE_FILTER");
|
|
117
|
+
export const toggleStructureFilterValue = createRoutine("TOGGLE_STRUCTURE_FILTER_VALUE");
|
|
128
118
|
export const updateGrant = createRoutine("UPDATE_GRANT");
|
|
119
|
+
export const updateGrantRequestFilter = createRoutine("UPDATE_GRANT_REQUEST_FILTER_SAGA");
|
|
120
|
+
export const updateGrantRequestTemplateContent = createRoutine("UPDATE_GRANT_REQUEST_TEMPLATE_CONTENT");
|
|
121
|
+
export const updateReferenceDataset = createRoutine("UPDATE_REFERENCE_DATASET");
|
|
129
122
|
export const updateStructure = createRoutine("UPDATE_STRUCTURE");
|
|
130
123
|
export const updateStructureTag = createRoutine("UPDATE_STRUCTURE_TAG");
|
|
131
124
|
export const updateStructureType = createRoutine("UPDATE_STRUCTURE_TYPE");
|
|
132
125
|
export const updateSystem = createRoutine("UPDATE_SYSTEM");
|
|
133
126
|
export const uploadStructures = createRoutine("UPLOAD_STRUCTURES");
|
|
134
|
-
export const uploadStructuresDomains = createRoutine(
|
|
135
|
-
"UPLOAD_STRUCTURES_DOMAINS"
|
|
136
|
-
);
|
|
137
|
-
export const addGrantRequestToCart = createRoutine("ADD_GRANT_REQUEST_TO_CART");
|
|
138
|
-
export const removeGrantRequestFromCart = createRoutine(
|
|
139
|
-
"REMOVE_GRANT_REQUEST_FROM_CART"
|
|
140
|
-
);
|
|
141
|
-
export const fetchGrantRequestTemplates = createRoutine(
|
|
142
|
-
"FETCH_GRANT_REQUEST_TEMPLATES"
|
|
143
|
-
);
|
|
144
|
-
export const selectGrantRequestTemplate = createRoutine(
|
|
145
|
-
"SELECT_GRANT_REQUEST_TEMPLATE"
|
|
146
|
-
);
|
|
147
|
-
export const updateGrantRequestTemplateContent = createRoutine(
|
|
148
|
-
"UPDATE_GRANT_REQUEST_TEMPLATE_CONTENT"
|
|
149
|
-
);
|
|
150
|
-
export const updateGrantRequestFilter = createRoutine(
|
|
151
|
-
"UPDATE_GRANT_REQUEST_FILTER_SAGA"
|
|
152
|
-
);
|
|
153
|
-
export const checkoutGrantRequest = createRoutine("CHECKOUT_GRANT_REQUEST");
|
|
154
|
-
|
|
155
|
-
export const clearGrantRequests = createRoutine("CLEAR_GRANT_REQUESTS");
|
|
156
|
-
export const fetchGrantRequests = createRoutine("FETCH_GRANT_REQUESTS");
|
|
157
|
-
export const fetchGrantRequest = createRoutine("FETCH_GRANT_REQUEST");
|
|
158
|
-
export const clearGrantRequest = createRoutine("CLEAR_GRANT_REQUEST");
|
|
159
|
-
export const removeGrantRequestsQuery = createRoutine(
|
|
160
|
-
"REMOVE_GRANT_REQUESTS_QUERY"
|
|
161
|
-
);
|
|
162
|
-
export const setGrantRequestsQuery = createRoutine("SET_GRANT_REQUESTS_QUERY");
|
|
163
|
-
|
|
164
|
-
export const createGrantRequestApproval = createRoutine(
|
|
165
|
-
"CREATE_GRANT_REQUEST_APPROVAL"
|
|
166
|
-
);
|
|
127
|
+
export const uploadStructuresDomains = createRoutine("UPLOAD_STRUCTURES_DOMAINS");
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import { toBase64 } from "@truedat/core/services/file";
|
|
3
|
+
import {
|
|
4
|
+
createReferenceDatasetRequestSaga,
|
|
5
|
+
createReferenceDatasetSaga,
|
|
6
|
+
onSuccess,
|
|
7
|
+
} from "../createReferenceDataset";
|
|
8
|
+
import { CREATE_REFERENCE_DATASET } from "../../api/mutations";
|
|
9
|
+
import { createReferenceDataset } from "../../routines";
|
|
10
|
+
|
|
11
|
+
describe("sagas: createReferenceDatasetRequestSaga", () => {
|
|
12
|
+
it("should invoke createReferenceDatasetSaga on createReferenceDataset.TRIGGER", () => {
|
|
13
|
+
expect(() => {
|
|
14
|
+
testSaga(createReferenceDatasetRequestSaga)
|
|
15
|
+
.next()
|
|
16
|
+
.takeLatest(createReferenceDataset.TRIGGER, createReferenceDatasetSaga)
|
|
17
|
+
.finish()
|
|
18
|
+
.isDone();
|
|
19
|
+
}).not.toThrow();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
23
|
+
expect(() => {
|
|
24
|
+
testSaga(createReferenceDatasetRequestSaga)
|
|
25
|
+
.next()
|
|
26
|
+
.takeLatest("FOO", createReferenceDatasetRequestSaga);
|
|
27
|
+
}).toThrow();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("sagas: createReferenceDatasetSaga", () => {
|
|
32
|
+
const client = { mutate: jest.fn() };
|
|
33
|
+
const file = { foo: "bar" };
|
|
34
|
+
const name = "foo";
|
|
35
|
+
const encoded = "data:text/csv;base64,Rk9PO0JBUjtCQVo=";
|
|
36
|
+
const payload = { name, file };
|
|
37
|
+
const dataset = { name, data: encoded };
|
|
38
|
+
const variables = { dataset };
|
|
39
|
+
|
|
40
|
+
it("should put a success action when a response is returned", () => {
|
|
41
|
+
expect(() => {
|
|
42
|
+
testSaga(createReferenceDatasetSaga, { payload })
|
|
43
|
+
.next()
|
|
44
|
+
.getContext("client")
|
|
45
|
+
.next(client)
|
|
46
|
+
.call(toBase64, file)
|
|
47
|
+
.next(encoded)
|
|
48
|
+
.put(createReferenceDataset.request(dataset))
|
|
49
|
+
.next()
|
|
50
|
+
.call(client.mutate, {
|
|
51
|
+
mutation: CREATE_REFERENCE_DATASET,
|
|
52
|
+
update: onSuccess,
|
|
53
|
+
variables,
|
|
54
|
+
})
|
|
55
|
+
.next({ data: payload })
|
|
56
|
+
.put(createReferenceDataset.success(payload))
|
|
57
|
+
.next()
|
|
58
|
+
.put(createReferenceDataset.fulfill())
|
|
59
|
+
.next()
|
|
60
|
+
.isDone();
|
|
61
|
+
}).not.toThrow();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("should put a failure action when the call returns an error", () => {
|
|
65
|
+
const message = "Request failed";
|
|
66
|
+
const error = { message };
|
|
67
|
+
|
|
68
|
+
expect(() => {
|
|
69
|
+
testSaga(createReferenceDatasetSaga, { payload })
|
|
70
|
+
.next()
|
|
71
|
+
.getContext("client")
|
|
72
|
+
.next(client)
|
|
73
|
+
.call(toBase64, file)
|
|
74
|
+
.next(encoded)
|
|
75
|
+
.put(createReferenceDataset.request(dataset))
|
|
76
|
+
.next()
|
|
77
|
+
.call(client.mutate, {
|
|
78
|
+
mutation: CREATE_REFERENCE_DATASET,
|
|
79
|
+
update: onSuccess,
|
|
80
|
+
variables,
|
|
81
|
+
})
|
|
82
|
+
.throw(error)
|
|
83
|
+
.put(createReferenceDataset.failure(message))
|
|
84
|
+
.next()
|
|
85
|
+
.put(createReferenceDataset.fulfill())
|
|
86
|
+
.next()
|
|
87
|
+
.isDone();
|
|
88
|
+
}).not.toThrow();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import {
|
|
3
|
+
deleteReferenceDatasetRequestSaga,
|
|
4
|
+
deleteReferenceDatasetSaga,
|
|
5
|
+
onSuccess,
|
|
6
|
+
} from "../deleteReferenceDataset";
|
|
7
|
+
import { DELETE_REFERENCE_DATASET } from "../../api/mutations";
|
|
8
|
+
import { deleteReferenceDataset } from "../../routines";
|
|
9
|
+
|
|
10
|
+
describe("sagas: deleteReferenceDatasetRequestSaga", () => {
|
|
11
|
+
it("should invoke deleteReferenceDatasetSaga on deleteReferenceDataset.TRIGGER", () => {
|
|
12
|
+
expect(() => {
|
|
13
|
+
testSaga(deleteReferenceDatasetRequestSaga)
|
|
14
|
+
.next()
|
|
15
|
+
.takeLatest(deleteReferenceDataset.TRIGGER, deleteReferenceDatasetSaga)
|
|
16
|
+
.finish()
|
|
17
|
+
.isDone();
|
|
18
|
+
}).not.toThrow();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
22
|
+
expect(() => {
|
|
23
|
+
testSaga(deleteReferenceDatasetRequestSaga)
|
|
24
|
+
.next()
|
|
25
|
+
.takeLatest("FOO", deleteReferenceDatasetRequestSaga);
|
|
26
|
+
}).toThrow();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("sagas: deleteReferenceDatasetSaga", () => {
|
|
31
|
+
const client = { mutate: jest.fn() };
|
|
32
|
+
const id = "123";
|
|
33
|
+
const payload = { id };
|
|
34
|
+
|
|
35
|
+
it("should put a success action when a response is returned", () => {
|
|
36
|
+
expect(() => {
|
|
37
|
+
testSaga(deleteReferenceDatasetSaga, { payload })
|
|
38
|
+
.next()
|
|
39
|
+
.getContext("client")
|
|
40
|
+
.next(client)
|
|
41
|
+
.put(deleteReferenceDataset.request(payload))
|
|
42
|
+
.next()
|
|
43
|
+
.call(client.mutate, {
|
|
44
|
+
mutation: DELETE_REFERENCE_DATASET,
|
|
45
|
+
update: onSuccess,
|
|
46
|
+
variables: payload,
|
|
47
|
+
})
|
|
48
|
+
.next({ data: payload })
|
|
49
|
+
.put(deleteReferenceDataset.success(payload))
|
|
50
|
+
.next()
|
|
51
|
+
.put(deleteReferenceDataset.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(deleteReferenceDatasetSaga, { payload })
|
|
63
|
+
.next()
|
|
64
|
+
.getContext("client")
|
|
65
|
+
.next(client)
|
|
66
|
+
.put(deleteReferenceDataset.request(payload))
|
|
67
|
+
.next()
|
|
68
|
+
.call(client.mutate, {
|
|
69
|
+
mutation: DELETE_REFERENCE_DATASET,
|
|
70
|
+
update: onSuccess,
|
|
71
|
+
variables: payload,
|
|
72
|
+
})
|
|
73
|
+
.throw(error)
|
|
74
|
+
.put(deleteReferenceDataset.failure(message))
|
|
75
|
+
.next()
|
|
76
|
+
.put(deleteReferenceDataset.fulfill())
|
|
77
|
+
.next()
|
|
78
|
+
.isDone();
|
|
79
|
+
}).not.toThrow();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import { toBase64 } from "@truedat/core/services/file";
|
|
3
|
+
import {
|
|
4
|
+
updateReferenceDatasetRequestSaga,
|
|
5
|
+
updateReferenceDatasetSaga,
|
|
6
|
+
onSuccess,
|
|
7
|
+
} from "../updateReferenceDataset";
|
|
8
|
+
import { UPDATE_REFERENCE_DATASET } from "../../api/mutations";
|
|
9
|
+
import { updateReferenceDataset } from "../../routines";
|
|
10
|
+
|
|
11
|
+
describe("sagas: updateReferenceDatasetRequestSaga", () => {
|
|
12
|
+
it("should invoke updateReferenceDatasetSaga on updateReferenceDataset.TRIGGER", () => {
|
|
13
|
+
expect(() => {
|
|
14
|
+
testSaga(updateReferenceDatasetRequestSaga)
|
|
15
|
+
.next()
|
|
16
|
+
.takeLatest(updateReferenceDataset.TRIGGER, updateReferenceDatasetSaga)
|
|
17
|
+
.finish()
|
|
18
|
+
.isDone();
|
|
19
|
+
}).not.toThrow();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
23
|
+
expect(() => {
|
|
24
|
+
testSaga(updateReferenceDatasetRequestSaga)
|
|
25
|
+
.next()
|
|
26
|
+
.takeLatest("FOO", updateReferenceDatasetRequestSaga);
|
|
27
|
+
}).toThrow();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("sagas: updateReferenceDatasetSaga", () => {
|
|
32
|
+
const client = { mutate: jest.fn() };
|
|
33
|
+
const file = { foo: "bar" };
|
|
34
|
+
const id = "42";
|
|
35
|
+
const name = "foo";
|
|
36
|
+
const encoded = "data:text/csv;base64,Rk9PO0JBUjtCQVo=";
|
|
37
|
+
const payload = { id, name, file };
|
|
38
|
+
const dataset = { id, name, data: encoded };
|
|
39
|
+
const variables = { dataset };
|
|
40
|
+
|
|
41
|
+
it("should put a success action when a response is returned", () => {
|
|
42
|
+
expect(() => {
|
|
43
|
+
testSaga(updateReferenceDatasetSaga, { payload })
|
|
44
|
+
.next()
|
|
45
|
+
.getContext("client")
|
|
46
|
+
.next(client)
|
|
47
|
+
.call(toBase64, file)
|
|
48
|
+
.next(encoded)
|
|
49
|
+
.put(updateReferenceDataset.request(dataset))
|
|
50
|
+
.next()
|
|
51
|
+
.call(client.mutate, {
|
|
52
|
+
mutation: UPDATE_REFERENCE_DATASET,
|
|
53
|
+
update: onSuccess,
|
|
54
|
+
variables,
|
|
55
|
+
})
|
|
56
|
+
.next({ data: payload })
|
|
57
|
+
.put(updateReferenceDataset.success(payload))
|
|
58
|
+
.next()
|
|
59
|
+
.put(updateReferenceDataset.fulfill())
|
|
60
|
+
.next()
|
|
61
|
+
.isDone();
|
|
62
|
+
}).not.toThrow();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should not encode file if absent from payload", () => {
|
|
66
|
+
const payload = { id, name };
|
|
67
|
+
const dataset = payload;
|
|
68
|
+
const variables = { dataset };
|
|
69
|
+
expect(() => {
|
|
70
|
+
testSaga(updateReferenceDatasetSaga, { payload })
|
|
71
|
+
.next()
|
|
72
|
+
.getContext("client")
|
|
73
|
+
.next(client)
|
|
74
|
+
.put(updateReferenceDataset.request(dataset))
|
|
75
|
+
.next()
|
|
76
|
+
.call(client.mutate, {
|
|
77
|
+
mutation: UPDATE_REFERENCE_DATASET,
|
|
78
|
+
update: onSuccess,
|
|
79
|
+
variables,
|
|
80
|
+
})
|
|
81
|
+
.next({ data: payload })
|
|
82
|
+
.put(updateReferenceDataset.success(payload))
|
|
83
|
+
.next()
|
|
84
|
+
.put(updateReferenceDataset.fulfill())
|
|
85
|
+
.next()
|
|
86
|
+
.isDone();
|
|
87
|
+
}).not.toThrow();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("should put a failure action when the call returns an error", () => {
|
|
91
|
+
const message = "Request failed";
|
|
92
|
+
const error = { message };
|
|
93
|
+
|
|
94
|
+
expect(() => {
|
|
95
|
+
testSaga(updateReferenceDatasetSaga, { payload })
|
|
96
|
+
.next()
|
|
97
|
+
.getContext("client")
|
|
98
|
+
.next(client)
|
|
99
|
+
.call(toBase64, file)
|
|
100
|
+
.next(encoded)
|
|
101
|
+
.put(updateReferenceDataset.request(dataset))
|
|
102
|
+
.next()
|
|
103
|
+
.call(client.mutate, {
|
|
104
|
+
mutation: UPDATE_REFERENCE_DATASET,
|
|
105
|
+
update: onSuccess,
|
|
106
|
+
variables,
|
|
107
|
+
})
|
|
108
|
+
.throw(error)
|
|
109
|
+
.put(updateReferenceDataset.failure(message))
|
|
110
|
+
.next()
|
|
111
|
+
.put(updateReferenceDataset.fulfill())
|
|
112
|
+
.next()
|
|
113
|
+
.isDone();
|
|
114
|
+
}).not.toThrow();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { toBase64 } from "@truedat/core/services/file";
|
|
3
|
+
import { CREATE_REFERENCE_DATASET } from "../api/mutations";
|
|
4
|
+
import { createReferenceDataset } from "../routines";
|
|
5
|
+
|
|
6
|
+
export const onSuccess = (cache) => {
|
|
7
|
+
cache.evict({ id: "ROOT_QUERY", fieldName: "referenceDatasets" });
|
|
8
|
+
cache.gc();
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function* createReferenceDatasetSaga({
|
|
12
|
+
payload: { file, ...rest } = {},
|
|
13
|
+
}) {
|
|
14
|
+
const client = yield getContext("client");
|
|
15
|
+
try {
|
|
16
|
+
const dataUrl = yield call(toBase64, file);
|
|
17
|
+
const dataset = { ...rest, data: dataUrl };
|
|
18
|
+
yield put(createReferenceDataset.request(dataset));
|
|
19
|
+
const { data } = yield call(client.mutate, {
|
|
20
|
+
mutation: CREATE_REFERENCE_DATASET,
|
|
21
|
+
update: onSuccess,
|
|
22
|
+
variables: { dataset },
|
|
23
|
+
});
|
|
24
|
+
yield put(createReferenceDataset.success(data));
|
|
25
|
+
} catch (error) {
|
|
26
|
+
yield put(createReferenceDataset.failure(error.message));
|
|
27
|
+
} finally {
|
|
28
|
+
yield put(createReferenceDataset.fulfill());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function* createReferenceDatasetRequestSaga() {
|
|
33
|
+
yield takeLatest(createReferenceDataset.TRIGGER, createReferenceDatasetSaga);
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
+
import { DELETE_REFERENCE_DATASET } from "../api/mutations";
|
|
3
|
+
import { deleteReferenceDataset } from "../routines";
|
|
4
|
+
|
|
5
|
+
export const onSuccess = (cache) => {
|
|
6
|
+
cache.evict({ id: "ROOT_QUERY", fieldName: "referenceDatasets" });
|
|
7
|
+
cache.gc();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function* deleteReferenceDatasetSaga({ payload }) {
|
|
11
|
+
const client = yield getContext("client");
|
|
12
|
+
try {
|
|
13
|
+
yield put(deleteReferenceDataset.request(payload));
|
|
14
|
+
const { data } = yield call(client.mutate, {
|
|
15
|
+
mutation: DELETE_REFERENCE_DATASET,
|
|
16
|
+
update: onSuccess,
|
|
17
|
+
variables: payload,
|
|
18
|
+
});
|
|
19
|
+
yield put(deleteReferenceDataset.success(data));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
yield put(deleteReferenceDataset.failure(error.message));
|
|
22
|
+
} finally {
|
|
23
|
+
yield put(deleteReferenceDataset.fulfill());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function* deleteReferenceDatasetRequestSaga() {
|
|
28
|
+
yield takeLatest(deleteReferenceDataset.TRIGGER, deleteReferenceDatasetSaga);
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { compile } from "path-to-regexp";
|
|
3
|
+
import FileSaver from "file-saver";
|
|
4
|
+
import { call, put, takeLatest } from "redux-saga/effects";
|
|
5
|
+
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
6
|
+
import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
7
|
+
import { downloadReferenceDataset } from "../routines";
|
|
8
|
+
import { API_REFERENCE_DATA_DOWNLOAD } from "../api";
|
|
9
|
+
|
|
10
|
+
export function saveFile(name, data) {
|
|
11
|
+
if (!_.isEmpty(data)) {
|
|
12
|
+
const fileName = lowerDeburrTrim(name);
|
|
13
|
+
const blob = new Blob([String.fromCharCode(0xfeff), data], {
|
|
14
|
+
type: "text/csv;charset=utf-8",
|
|
15
|
+
});
|
|
16
|
+
FileSaver.saveAs(blob, `${fileName}.csv`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function* downloadReferenceDatasetSaga({ payload: { id, name } = {} }) {
|
|
21
|
+
try {
|
|
22
|
+
const url = compile(API_REFERENCE_DATA_DOWNLOAD)({ id });
|
|
23
|
+
yield put(downloadReferenceDataset.request(id));
|
|
24
|
+
const { data } = yield call(apiJson, url, JSON_OPTS);
|
|
25
|
+
yield call(saveFile, name, data);
|
|
26
|
+
yield put(downloadReferenceDataset.success({ id }));
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error.response) {
|
|
29
|
+
const { status, data } = error.response;
|
|
30
|
+
yield put(downloadReferenceDataset.failure({ status, data }));
|
|
31
|
+
} else {
|
|
32
|
+
yield put(downloadReferenceDataset.failure(error.message));
|
|
33
|
+
}
|
|
34
|
+
} finally {
|
|
35
|
+
yield put(downloadReferenceDataset.fulfill());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function* downloadReferenceDatasetRequestSaga() {
|
|
40
|
+
yield takeLatest(
|
|
41
|
+
downloadReferenceDataset.TRIGGER,
|
|
42
|
+
downloadReferenceDatasetSaga
|
|
43
|
+
);
|
|
44
|
+
}
|