@truedat/bg 6.3.2 → 6.3.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.
Files changed (113) hide show
  1. package/package.json +6 -6
  2. package/src/concepts/api.js +3 -7
  3. package/src/concepts/components/ConceptActions.js +1 -0
  4. package/src/concepts/components/ConceptCreate.js +6 -4
  5. package/src/concepts/components/ConceptRoutes.js +10 -33
  6. package/src/concepts/components/Concepts.js +25 -16
  7. package/src/concepts/components/ConceptsActions.js +8 -14
  8. package/src/concepts/components/ConceptsBulkUpdate.js +25 -64
  9. package/src/concepts/components/ConceptsLabelResults.js +13 -26
  10. package/src/concepts/components/ConceptsLinksManagement.js +6 -92
  11. package/src/concepts/components/ConceptsPagination.js +13 -11
  12. package/src/concepts/components/ConceptsPanel.js +51 -22
  13. package/src/concepts/components/ConceptsTable.js +77 -106
  14. package/src/concepts/components/ConceptsUpdateButton.js +49 -37
  15. package/src/concepts/components/DomainConcepts.js +2 -11
  16. package/src/concepts/components/LinkedMessage.js +81 -0
  17. package/src/concepts/components/__tests__/ConceptLinksManagement.spec.js +60 -12
  18. package/src/concepts/components/__tests__/Concepts.spec.js +66 -11
  19. package/src/concepts/components/__tests__/ConceptsActions.spec.js +47 -3
  20. package/src/concepts/components/__tests__/ConceptsBulkUpdate.spec.js +7 -3
  21. package/src/concepts/components/__tests__/ConceptsLabelResults.spec.js +34 -4
  22. package/src/concepts/components/__tests__/ConceptsPanel.spec.js +59 -13
  23. package/src/concepts/components/__tests__/ConceptsTable.spec.js +53 -6
  24. package/src/concepts/components/__tests__/ConceptsUpdateButton.spec.js +26 -13
  25. package/src/concepts/components/__tests__/__snapshots__/ConceptLinksManagement.spec.js.snap +164 -8
  26. package/src/concepts/components/__tests__/__snapshots__/Concepts.spec.js.snap +284 -34
  27. package/src/concepts/components/__tests__/__snapshots__/ConceptsActions.spec.js.snap +1 -1
  28. package/src/concepts/components/__tests__/__snapshots__/ConceptsPanel.spec.js.snap +125 -2
  29. package/src/concepts/components/__tests__/__snapshots__/ConceptsTable.spec.js.snap +28 -44
  30. package/src/concepts/components/__tests__/__snapshots__/ConceptsUpdateButton.spec.js.snap +10 -47
  31. package/src/concepts/hooks/useConcepts.js +34 -0
  32. package/src/concepts/reducers/bulkUpdateQueryInfo.js +12 -0
  33. package/src/concepts/reducers/index.js +2 -26
  34. package/src/concepts/relations/components/ConceptRelationsRoutes.js +39 -35
  35. package/src/concepts/relations/components/ConceptSelector.js +37 -31
  36. package/src/concepts/relations/components/__tests__/ConceptRelationForm.spec.js +63 -23
  37. package/src/concepts/relations/components/__tests__/ConceptSelector.spec.js +74 -41
  38. package/src/concepts/relations/components/__tests__/ConceptSelector2.spec.js +72 -0
  39. package/src/concepts/relations/components/__tests__/__snapshots__/ConceptRelationForm.spec.js.snap +44 -8
  40. package/src/concepts/relations/components/__tests__/__snapshots__/ConceptSelector.spec.js.snap +44 -27
  41. package/src/concepts/routines.js +2 -29
  42. package/src/concepts/sagas/__tests__/bulkUpdate.spec.js +6 -10
  43. package/src/concepts/sagas/__tests__/downloadConcepts.spec.js +4 -8
  44. package/src/concepts/sagas/bulkUpdate.js +6 -5
  45. package/src/concepts/sagas/downloadConcepts.js +3 -4
  46. package/src/concepts/sagas/index.js +2 -17
  47. package/src/concepts/selectors/getConceptColumns.js +12 -21
  48. package/src/concepts/selectors/index.js +1 -7
  49. package/src/concepts/utils/filterOptions.js +6 -5
  50. package/src/concepts/components/ConceptFilters.js +0 -20
  51. package/src/concepts/components/ConceptFiltersLoader.js +0 -27
  52. package/src/concepts/components/ConceptSelectedFilters.js +0 -29
  53. package/src/concepts/components/ConceptSelectedFiltersDefault.js +0 -42
  54. package/src/concepts/components/ConceptSelectedFiltersPending.js +0 -41
  55. package/src/concepts/components/ConceptSelectedFiltersPublished.js +0 -73
  56. package/src/concepts/components/ConceptUserFiltersLoader.js +0 -27
  57. package/src/concepts/components/ConceptsLoader.js +0 -38
  58. package/src/concepts/components/ConceptsSearch.js +0 -32
  59. package/src/concepts/components/__tests__/ConceptFilters.spec.js +0 -19
  60. package/src/concepts/components/__tests__/ConceptSelectedFilters.spec.js +0 -10
  61. package/src/concepts/components/__tests__/ConceptUserFiltersLoader.spec.js +0 -27
  62. package/src/concepts/components/__tests__/ConceptsLoader.spec.js +0 -34
  63. package/src/concepts/components/__tests__/__snapshots__/ConceptFilters.spec.js.snap +0 -47
  64. package/src/concepts/components/__tests__/__snapshots__/ConceptSelectedFilters.spec.js.snap +0 -9
  65. package/src/concepts/components/__tests__/__snapshots__/ConceptUserFiltersLoader.spec.js.snap +0 -3
  66. package/src/concepts/reducers/__tests__/conceptActiveFilters.spec.js +0 -83
  67. package/src/concepts/reducers/__tests__/conceptCount.spec.js +0 -33
  68. package/src/concepts/reducers/__tests__/conceptFilters.spec.js +0 -49
  69. package/src/concepts/reducers/__tests__/conceptFiltersLoading.spec.js +0 -28
  70. package/src/concepts/reducers/__tests__/conceptQuery.spec.js +0 -75
  71. package/src/concepts/reducers/__tests__/conceptSelectedFilter.spec.js +0 -66
  72. package/src/concepts/reducers/__tests__/conceptSelectedUserFilter.spec.js +0 -53
  73. package/src/concepts/reducers/__tests__/conceptUserFilters.spec.js +0 -76
  74. package/src/concepts/reducers/__tests__/concepts.spec.js +0 -40
  75. package/src/concepts/reducers/__tests__/conceptsActions.spec.js +0 -38
  76. package/src/concepts/reducers/__tests__/conceptsLoading.spec.js +0 -32
  77. package/src/concepts/reducers/__tests__/conceptsPageSize.spec.js +0 -33
  78. package/src/concepts/reducers/__tests__/previousConceptQuery.spec.js +0 -23
  79. package/src/concepts/reducers/conceptActiveFilters.js +0 -58
  80. package/src/concepts/reducers/conceptCount.js +0 -20
  81. package/src/concepts/reducers/conceptFilters.js +0 -21
  82. package/src/concepts/reducers/conceptFiltersLoading.js +0 -14
  83. package/src/concepts/reducers/conceptQuery.js +0 -60
  84. package/src/concepts/reducers/conceptSelectedFilter.js +0 -34
  85. package/src/concepts/reducers/conceptSelectedUserFilter.js +0 -31
  86. package/src/concepts/reducers/conceptUserFilters.js +0 -36
  87. package/src/concepts/reducers/concepts.js +0 -21
  88. package/src/concepts/reducers/conceptsActions.js +0 -24
  89. package/src/concepts/reducers/conceptsLoading.js +0 -16
  90. package/src/concepts/reducers/conceptsPageSize.js +0 -16
  91. package/src/concepts/reducers/previousConceptQuery.js +0 -15
  92. package/src/concepts/sagas/__tests__/deleteConceptUserFilter.spec.js +0 -75
  93. package/src/concepts/sagas/__tests__/fetchConceptUserFilters.spec.js +0 -70
  94. package/src/concepts/sagas/__tests__/fetchConcepts.spec.js +0 -87
  95. package/src/concepts/sagas/__tests__/saveConceptFilters.spec.js +0 -78
  96. package/src/concepts/sagas/deleteConceptUserFilter.js +0 -34
  97. package/src/concepts/sagas/fecthConceptUserFilters.js +0 -30
  98. package/src/concepts/sagas/fetchConceptFilters.js +0 -29
  99. package/src/concepts/sagas/fetchConcepts.js +0 -27
  100. package/src/concepts/sagas/saveConceptFilters.js +0 -30
  101. package/src/concepts/selectors/__tests__/getConceptAvailableFilters.spec.js +0 -16
  102. package/src/concepts/selectors/__tests__/getConceptFilterTypes.spec.js +0 -19
  103. package/src/concepts/selectors/__tests__/getConceptSelectedFilterActiveValues.spec.js +0 -16
  104. package/src/concepts/selectors/__tests__/getConceptSelectedFilterValues.spec.js +0 -15
  105. package/src/concepts/selectors/__tests__/getConceptSelectedFilters.spec.js +0 -15
  106. package/src/concepts/selectors/__tests__/mapSelectedFilterStateToPropsByStatus.spec.js +0 -37
  107. package/src/concepts/selectors/getConceptAvailableFilters.js +0 -15
  108. package/src/concepts/selectors/getConceptFilterTypes.js +0 -7
  109. package/src/concepts/selectors/getConceptSelectedFilterActiveValues.js +0 -9
  110. package/src/concepts/selectors/getConceptSelectedFilterValues.js +0 -12
  111. package/src/concepts/selectors/getConceptSelectedFilters.js +0 -7
  112. package/src/concepts/selectors/getPreviousConceptQuery.js +0 -1
  113. package/src/concepts/selectors/mapSelectedFilterStateToPropsByStatus.js +0 -47
@@ -1,58 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { fetchDomain } from "../../taxonomy/routines";
3
- import {
4
- addConceptFilter,
5
- applyConceptUserFilter,
6
- closeConceptFilter,
7
- removeConceptFilter,
8
- resetConceptFilters,
9
- toggleConceptFilterValue,
10
- } from "../routines";
11
-
12
- export const initialState = {};
13
-
14
- export const conceptActiveFilters = (
15
- state = initialState,
16
- { type, payload }
17
- ) => {
18
- switch (type) {
19
- case addConceptFilter.TRIGGER: {
20
- const { filter } = payload;
21
- return { ...state, [filter]: [] };
22
- }
23
- case applyConceptUserFilter.TRIGGER: {
24
- const { userFilter } = payload;
25
- return _.prop("filters")(userFilter);
26
- }
27
- case closeConceptFilter.TRIGGER: {
28
- const { filter } = payload;
29
- const values = _.propOr([], filter)(state);
30
- return _.isEmpty(values)
31
- ? _.omit(filter)(state)
32
- : { ...state, [filter]: values };
33
- }
34
- case removeConceptFilter.TRIGGER: {
35
- const { filter } = payload;
36
- return _.omit(filter)(state);
37
- }
38
- case resetConceptFilters.TRIGGER: {
39
- return initialState;
40
- }
41
- case toggleConceptFilterValue.TRIGGER: {
42
- const { filter, value } = payload;
43
- if (_.isArray(value)) {
44
- return { ...state, [filter]: value };
45
- }
46
- const values = _.propOr([], filter)(state);
47
- const nextValues = _.includes(value)(values)
48
- ? _.without([value])(values)
49
- : _.union([value])(values);
50
- return { ...state, [filter]: nextValues };
51
- }
52
- case fetchDomain.TRIGGER: {
53
- return _.omit("taxonomy")(state);
54
- }
55
- default:
56
- return state;
57
- }
58
- };
@@ -1,20 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { fetchConcepts, clearConcepts } from "../routines";
3
-
4
- const initialState = 0;
5
-
6
- const conceptCount = (state = initialState, { type, payload }) => {
7
- switch (type) {
8
- case clearConcepts.TRIGGER:
9
- return initialState;
10
- case fetchConcepts.SUCCESS: {
11
- const headers = _.propOr({}, "headers")(payload);
12
- const count = _.propOr("0", "x-total-count")(headers);
13
- return parseInt(count);
14
- }
15
- default:
16
- return state;
17
- }
18
- };
19
-
20
- export { conceptCount };
@@ -1,21 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { clearConceptFilters, fetchConceptFilters } from "../routines";
3
-
4
- const initialState = {};
5
-
6
- const conceptFilters = (state = initialState, { type, payload }) => {
7
- switch (type) {
8
- case clearConceptFilters.TRIGGER:
9
- return initialState;
10
- case fetchConceptFilters.SUCCESS:
11
- return _.flow(
12
- _.propOr({}, "data"),
13
- _.omit(["current", "domain_ids"]),
14
- _.omitBy(_.flow(_.getOr([], "values"), _.isEmpty))
15
- )(payload);
16
- default:
17
- return state;
18
- }
19
- };
20
-
21
- export { conceptFilters };
@@ -1,14 +0,0 @@
1
- import { fetchConceptFilters } from "../routines";
2
-
3
- const conceptFiltersLoading = (state = false, { type }) => {
4
- switch (type) {
5
- case fetchConceptFilters.REQUEST:
6
- return true;
7
- case fetchConceptFilters.FULFILL:
8
- return false;
9
- default:
10
- return state;
11
- }
12
- };
13
-
14
- export { conceptFiltersLoading };
@@ -1,60 +0,0 @@
1
- import _ from "lodash/fp";
2
- import {
3
- applyConceptUserFilter,
4
- clearConceptFilters,
5
- removeConceptFilter,
6
- toggleConceptFilterValue,
7
- searchConcepts,
8
- selectConceptPage,
9
- sortConcepts,
10
- } from "../routines";
11
-
12
- const defaultPage = 1;
13
- const defaultSize = 20;
14
- const defaultSort = [{ _score: "desc" }, { "name.raw": "asc" }];
15
- const byNameSort = [{ "name.raw": "asc" }];
16
-
17
- export const initialState = {
18
- query: "",
19
- page: defaultPage,
20
- size: defaultSize,
21
- sort: byNameSort,
22
- };
23
-
24
- const conceptQuery = (state = initialState, { type, payload }) => {
25
- switch (type) {
26
- case clearConceptFilters.TRIGGER:
27
- const page = defaultPage;
28
- return { ...state, page };
29
- case removeConceptFilter.TRIGGER: {
30
- const page = defaultPage;
31
- return { ...state, page };
32
- }
33
- case toggleConceptFilterValue.TRIGGER: {
34
- const page = defaultPage;
35
- return { ...state, page };
36
- }
37
- case searchConcepts.TRIGGER: {
38
- const page = defaultPage;
39
- const query = _.propOr("", "query")(payload);
40
- const sort = query != "" ? defaultSort : byNameSort;
41
- return { ...state, query, page, sort };
42
- }
43
- case selectConceptPage.TRIGGER: {
44
- const { activePage } = payload;
45
- return { ...state, page: activePage };
46
- }
47
- case sortConcepts.TRIGGER: {
48
- const sort = payload;
49
- return { ...state, sort, page: 1 };
50
- }
51
- case applyConceptUserFilter.TRIGGER: {
52
- const page = defaultPage;
53
- return { ...state, page };
54
- }
55
- default:
56
- return state;
57
- }
58
- };
59
-
60
- export { conceptQuery };
@@ -1,34 +0,0 @@
1
- import {
2
- addConceptFilter,
3
- closeConceptFilter,
4
- openConceptFilter,
5
- removeConceptFilter,
6
- resetConceptFilters
7
- } from "../routines";
8
-
9
- /** @type {string} */
10
- export const initialState = null;
11
-
12
- export const conceptSelectedFilter = (
13
- state = initialState,
14
- { type, payload }
15
- ) => {
16
- switch (type) {
17
- case addConceptFilter.TRIGGER: {
18
- const { filter } = payload;
19
- return filter;
20
- }
21
- case closeConceptFilter.TRIGGER:
22
- return initialState;
23
- case openConceptFilter.TRIGGER: {
24
- const { filter } = payload;
25
- return filter;
26
- }
27
- case removeConceptFilter.TRIGGER:
28
- return initialState;
29
- case resetConceptFilters.TRIGGER:
30
- return initialState;
31
- default:
32
- return state;
33
- }
34
- };
@@ -1,31 +0,0 @@
1
- import {
2
- applyConceptUserFilter,
3
- removeConceptFilter,
4
- resetConceptFilters
5
- } from "../routines";
6
-
7
- /** @type {string} */
8
- export const initialState = null;
9
-
10
- export const conceptSelectedUserFilter = (
11
- state = initialState,
12
- { type, payload }
13
- ) => {
14
- switch (type) {
15
- case applyConceptUserFilter.TRIGGER:
16
- const {
17
- userFilter: { name: name }
18
- } = payload;
19
- if (state == name) {
20
- return initialState;
21
- } else {
22
- return name;
23
- }
24
- case removeConceptFilter.TRIGGER:
25
- return initialState;
26
- case resetConceptFilters.TRIGGER:
27
- return initialState;
28
- default:
29
- return state;
30
- }
31
- };
@@ -1,36 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
3
- import {
4
- fetchConceptUserFilters,
5
- clearConceptUserFilters,
6
- deleteConceptUserFilter,
7
- saveConceptFilters
8
- } from "../routines";
9
-
10
- export const initialState = [];
11
-
12
- const conceptUserFilters = (state = initialState, { type, payload, meta }) => {
13
- switch (type) {
14
- case clearConceptUserFilters.TRIGGER:
15
- return initialState;
16
- case fetchConceptUserFilters.SUCCESS: {
17
- const userFilters = _.propOr([], "data")(payload);
18
- return _.sortBy(accentInsensitivePathOrder("name"))(userFilters);
19
- }
20
- case fetchConceptUserFilters.FAILURE:
21
- return initialState;
22
- case saveConceptFilters.SUCCESS:
23
- const userFilter = _.propOr({}, "data")(payload);
24
- return _.flow(
25
- _.concat([userFilter]),
26
- _.sortBy(accentInsensitivePathOrder("name"))
27
- )(state);
28
- case deleteConceptUserFilter.SUCCESS:
29
- const { id } = meta;
30
- return _.reject(_.propEq("id", id))(state);
31
- default:
32
- return state;
33
- }
34
- };
35
-
36
- export { conceptUserFilters };
@@ -1,21 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { fetchConcepts, clearConcepts } from "../routines";
3
-
4
- const initialState = [];
5
-
6
- const concepts = (state = initialState, { type, payload }) => {
7
- switch (type) {
8
- case clearConcepts.TRIGGER:
9
- return initialState;
10
- case fetchConcepts.SUCCESS: {
11
- const data = _.propOr({}, "data")(payload);
12
- return _.propOr([], "data")(data);
13
- }
14
- case fetchConcepts.FAILURE:
15
- return initialState;
16
- default:
17
- return state;
18
- }
19
- };
20
-
21
- export { concepts };
@@ -1,24 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { fetchConcepts, clearConcepts } from "../routines";
3
-
4
- const initialState = {};
5
-
6
- export const conceptsActions = (state = initialState, { type, payload }) => {
7
- switch (type) {
8
- case clearConcepts.TRIGGER:
9
- return initialState;
10
- case fetchConcepts.REQUEST: {
11
- const { query } = payload || {};
12
- return query ? state : initialState;
13
- }
14
- case fetchConcepts.SUCCESS: {
15
- const data = _.propOr({}, "data")(payload);
16
- const actions = _.propOr(initialState, "_actions")(data);
17
- return _.isEqual(actions)(state) ? state : actions;
18
- }
19
- default:
20
- return state;
21
- }
22
- };
23
-
24
- export default conceptsActions;
@@ -1,16 +0,0 @@
1
- import { fetchConcepts } from "../routines";
2
-
3
- const conceptsLoading = (state = false, { type }) => {
4
- switch (type) {
5
- case fetchConcepts.REQUEST:
6
- return true;
7
- case fetchConcepts.SUCCESS:
8
- return false;
9
- case fetchConcepts.FAILURE:
10
- return false;
11
- default:
12
- return state;
13
- }
14
- };
15
-
16
- export { conceptsLoading };
@@ -1,16 +0,0 @@
1
- import _ from "lodash/fp";
2
- import { fetchConcepts } from "../routines";
3
-
4
- const defaultPageSize = 20;
5
-
6
- const conceptsPageSize = (state = defaultPageSize, { type, payload }) => {
7
- switch (type) {
8
- case fetchConcepts.TRIGGER:
9
- const { size } = payload;
10
- return size || state;
11
- default:
12
- return state;
13
- }
14
- };
15
-
16
- export { conceptsPageSize };
@@ -1,15 +0,0 @@
1
- import { clearConcepts, fetchConcepts } from "../routines";
2
- import { initialState } from "./conceptQuery";
3
-
4
- const previousConceptQuery = (state = initialState, { type, payload }) => {
5
- switch (type) {
6
- case fetchConcepts.TRIGGER:
7
- return payload;
8
- case clearConcepts.TRIGGER:
9
- return initialState;
10
- default:
11
- return state;
12
- }
13
- };
14
-
15
- export { previousConceptQuery };
@@ -1,75 +0,0 @@
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
- deleteConceptUserFilterSaga,
6
- deleteConceptUserFilterRequestSaga
7
- } from "../deleteConceptUserFilter";
8
- import { deleteConceptUserFilter } from "../../routines";
9
- import { API_CONCEPT_USER_FILTER } from "../../api";
10
-
11
- describe("sagas: deleteConceptUserFilterRequestSaga", () => {
12
- it("should invoke deleteConceptUserFilterSaga on deleteConceptUserFilter.TRIGGER", () => {
13
- expect(() => {
14
- testSaga(deleteConceptUserFilterRequestSaga)
15
- .next()
16
- .takeLatest(
17
- deleteConceptUserFilter.TRIGGER,
18
- deleteConceptUserFilterSaga
19
- )
20
- .finish()
21
- .isDone();
22
- }).not.toThrow();
23
- });
24
-
25
- it("should throw exception if an unhandled action is received", () => {
26
- expect(() => {
27
- testSaga(deleteConceptUserFilterRequestSaga)
28
- .next()
29
- .takeLatest("FOO", deleteConceptUserFilterRequestSaga);
30
- }).toThrow();
31
- });
32
- });
33
-
34
- describe("sagas: deleteConceptUserFilterSaga", () => {
35
- const payload = { id: 1 };
36
- const { id } = payload;
37
- const url = compile(API_CONCEPT_USER_FILTER)({ id });
38
- const meta = { id };
39
-
40
- it("should put a success action when a response is returned", () => {
41
- expect(() => {
42
- testSaga(deleteConceptUserFilterSaga, { payload })
43
- .next()
44
- .put({ meta, ...deleteConceptUserFilter.request() })
45
- .next()
46
- .call(apiJsonDelete, url, JSON_OPTS)
47
- .next({ data: payload })
48
- .put({ meta, ...deleteConceptUserFilter.success(payload) })
49
- .next()
50
- .put(deleteConceptUserFilter.fulfill())
51
- .next()
52
- .isDone();
53
- }).not.toThrow();
54
- });
55
-
56
- it("should put a failure action when the call returns an error", () => {
57
- const message = "Request failed";
58
- const error = { message };
59
- const meta = { id: 1 };
60
-
61
- expect(() => {
62
- testSaga(deleteConceptUserFilterSaga, { payload })
63
- .next()
64
- .put({ meta, ...deleteConceptUserFilter.request() })
65
- .next()
66
- .call(apiJsonDelete, url, JSON_OPTS)
67
- .throw(error)
68
- .put(deleteConceptUserFilter.failure(message))
69
- .next()
70
- .put(deleteConceptUserFilter.fulfill())
71
- .next()
72
- .isDone();
73
- }).not.toThrow();
74
- });
75
- });
@@ -1,70 +0,0 @@
1
- import { testSaga } from "redux-saga-test-plan";
2
- import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
3
- import {
4
- fetchConceptUserFiltersRequestSaga,
5
- fetchConceptUserFiltersSaga
6
- } from "../fecthConceptUserFilters";
7
- import { fetchConceptUserFilters } from "../../routines";
8
- import { API_GET_CONCEPT_USER_FILTERS } from "../../api";
9
-
10
- describe("sagas: fetchConceptUserFiltersRequestSaga", () => {
11
- it("should invoke fetchConceptUserFiltersSaga on fetchConceptUserFilters.TRIGGER", () => {
12
- expect(() => {
13
- testSaga(fetchConceptUserFiltersRequestSaga)
14
- .next()
15
- .takeLatest(
16
- fetchConceptUserFilters.TRIGGER,
17
- fetchConceptUserFiltersSaga
18
- )
19
- .finish()
20
- .isDone();
21
- }).not.toThrow();
22
- });
23
-
24
- it("should throw exception if an unhandled action is received", () => {
25
- expect(() => {
26
- testSaga(fetchConceptUserFiltersRequestSaga)
27
- .next()
28
- .takeLatest("FOO", fetchConceptUserFiltersRequestSaga);
29
- }).toThrow();
30
- });
31
- });
32
-
33
- describe("sagas: fetchConceptUserFiltersSaga", () => {
34
- const data = [{ id: 1, name: "a" }];
35
-
36
- it("should put a success action when a response is returned", () => {
37
- expect(() => {
38
- testSaga(fetchConceptUserFiltersSaga)
39
- .next()
40
- .put(fetchConceptUserFilters.request())
41
- .next()
42
- .call(apiJson, API_GET_CONCEPT_USER_FILTERS, JSON_OPTS)
43
- .next({ data })
44
- .put(fetchConceptUserFilters.success(data))
45
- .next()
46
- .put(fetchConceptUserFilters.fulfill())
47
- .next()
48
- .isDone();
49
- }).not.toThrow();
50
- });
51
-
52
- it("should put a failure action when the call returns an error", () => {
53
- const message = "Request failed";
54
- const error = { message };
55
-
56
- expect(() => {
57
- testSaga(fetchConceptUserFiltersSaga)
58
- .next()
59
- .put(fetchConceptUserFilters.request())
60
- .next()
61
- .call(apiJson, API_GET_CONCEPT_USER_FILTERS, JSON_OPTS)
62
- .throw(error)
63
- .put(fetchConceptUserFilters.failure(message))
64
- .next()
65
- .put(fetchConceptUserFilters.fulfill())
66
- .next()
67
- .isDone();
68
- }).not.toThrow();
69
- });
70
- });
@@ -1,87 +0,0 @@
1
- import { testSaga } from "redux-saga-test-plan";
2
- import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
3
- import { fetchConceptsRequestSaga, fetchConceptsSaga } from "../fetchConcepts";
4
- import { fetchConcepts } from "../../routines";
5
- import { API_BUSINESS_CONCEPT_VERSIONS_SEARCH } from "../../api";
6
-
7
- describe("sagas: fetchConceptsRequestSaga", () => {
8
- it("should invoke fetchConceptsSaga on fetchConcepts.TRIGGER", () => {
9
- expect(() => {
10
- testSaga(fetchConceptsRequestSaga)
11
- .next()
12
- .takeLatest(fetchConcepts.TRIGGER, fetchConceptsSaga)
13
- .finish()
14
- .isDone();
15
- }).not.toThrow();
16
- });
17
-
18
- it("should throw exception if an unhandled action is received", () => {
19
- expect(() => {
20
- testSaga(fetchConceptsRequestSaga)
21
- .next()
22
- .takeLatest("FOO", fetchConceptsRequestSaga);
23
- }).toThrow();
24
- });
25
- });
26
-
27
- describe("sagas: fetchConceptsSaga", () => {
28
- const conceptQuery = { filters: {} };
29
- const data = {
30
- collection: [
31
- { id: 1, name: "Concept 1", description: "desc1" },
32
- { id: 2, name: "Concept 2", description: "desc2" }
33
- ]
34
- };
35
- const headers = {
36
- "x-total-count": "123"
37
- };
38
-
39
- it("should pass the query parameter to the API with 100ms delay", () => {
40
- expect(() => {
41
- testSaga(fetchConceptsSaga, { payload: conceptQuery })
42
- .next()
43
- .delay(100)
44
- .next()
45
- .put(fetchConcepts.request(conceptQuery))
46
- .next()
47
- .call(
48
- apiJsonPost,
49
- API_BUSINESS_CONCEPT_VERSIONS_SEARCH,
50
- conceptQuery,
51
- JSON_OPTS
52
- )
53
- .next({ data, headers })
54
- .put(fetchConcepts.success({ data, headers }))
55
- .next()
56
- .put(fetchConcepts.fulfill())
57
- .next()
58
- .isDone();
59
- }).not.toThrow();
60
- });
61
-
62
- it("should put a failure action when the call returns an error", () => {
63
- const message = "Request failed";
64
- const error = { message };
65
-
66
- expect(() => {
67
- testSaga(fetchConceptsSaga, { payload: conceptQuery })
68
- .next()
69
- .delay(100)
70
- .next()
71
- .put(fetchConcepts.request(conceptQuery))
72
- .next()
73
- .call(
74
- apiJsonPost,
75
- API_BUSINESS_CONCEPT_VERSIONS_SEARCH,
76
- conceptQuery,
77
- JSON_OPTS
78
- )
79
- .throw(error)
80
- .put(fetchConcepts.failure(message))
81
- .next()
82
- .put(fetchConcepts.fulfill())
83
- .next()
84
- .isDone();
85
- }).not.toThrow();
86
- });
87
- });
@@ -1,78 +0,0 @@
1
- import { testSaga } from "redux-saga-test-plan";
2
- import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
3
- import {
4
- saveConceptFiltersRequestSaga,
5
- saveConceptFiltersSaga,
6
- } from "../saveConceptFilters";
7
- import { saveConceptFilters } from "../../routines";
8
- import { API_CONCEPT_USER_FILTERS } from "../../api";
9
-
10
- describe("sagas: saveConceptFiltersRequestSaga", () => {
11
- it("should invoke saveConceptFiltersSaga on saveConceptFilters.TRIGGER", () => {
12
- expect(() => {
13
- testSaga(saveConceptFiltersRequestSaga)
14
- .next()
15
- .takeLatest(saveConceptFilters.TRIGGER, saveConceptFiltersSaga)
16
- .finish()
17
- .isDone();
18
- }).not.toThrow();
19
- });
20
-
21
- it("should throw exception if an unhandled action is received", () => {
22
- expect(() => {
23
- testSaga(saveConceptFiltersRequestSaga)
24
- .next()
25
- .takeLatest("FOO", saveConceptFiltersRequestSaga);
26
- }).toThrow();
27
- });
28
- });
29
-
30
- describe("sagas: saveConceptFiltersSaga", () => {
31
- const data = { user_search_filter: { id: 1, name: "a" } };
32
- const payload = {
33
- filterName: "a",
34
- filters: { country: ["A"] },
35
- isGlobal: true,
36
- };
37
- const requestData = {
38
- user_search_filter: {
39
- name: "a",
40
- filters: { country: ["A"] },
41
- is_global: true,
42
- },
43
- };
44
- it("should put a success action when a response is returned", () => {
45
- expect(() => {
46
- testSaga(saveConceptFiltersSaga, { payload })
47
- .next()
48
- .put(saveConceptFilters.request())
49
- .next()
50
- .call(apiJsonPost, API_CONCEPT_USER_FILTERS, requestData, JSON_OPTS)
51
- .next({ data })
52
- .put(saveConceptFilters.success(data))
53
- .next()
54
- .put(saveConceptFilters.fulfill())
55
- .next()
56
- .isDone();
57
- }).not.toThrow();
58
- });
59
-
60
- it("should put a failure action when the call returns an error", () => {
61
- const message = "Request failed";
62
- const error = { message };
63
-
64
- expect(() => {
65
- testSaga(saveConceptFiltersSaga, { payload })
66
- .next()
67
- .put(saveConceptFilters.request())
68
- .next()
69
- .call(apiJsonPost, API_CONCEPT_USER_FILTERS, requestData, JSON_OPTS)
70
- .throw(error)
71
- .put(saveConceptFilters.failure(message))
72
- .next()
73
- .put(saveConceptFilters.fulfill())
74
- .next()
75
- .isDone();
76
- }).not.toThrow();
77
- });
78
- });