@truedat/dd 7.11.2 → 7.11.3
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/package.json +2 -2
- package/src/api/queries.js +285 -28
- package/src/components/ImplementationStructuresLoader.js +6 -6
- package/src/components/StructureSelectorInputField.js +7 -5
- package/src/components/__tests__/ImplementationStructuresLoader.spec.js +5 -5
- package/src/components/__tests__/ProfileExecutionLoader.spec.js +1 -1
- package/src/components/__tests__/ProfileGroupLoader.spec.js +1 -1
- package/src/reducers/__tests__/graph.spec.js +3 -3
- package/src/reducers/__tests__/graphLoading.spec.js +3 -3
- package/src/reducers/__tests__/graphRedirect.spec.js +3 -3
- package/src/reducers/__tests__/structureFields.spec.js +7 -7
- package/src/reducers/__tests__/structureImpactGraph.spec.js +3 -3
- package/src/reducers/__tests__/structureImpactId.spec.js +3 -3
- package/src/reducers/__tests__/structureLineageGraph.spec.js +3 -3
- package/src/reducers/__tests__/structureLineageId.spec.js +3 -3
- package/src/reducers/__tests__/structureLinks.spec.js +5 -5
- package/src/reducers/__tests__/structureRedirect.spec.js +1 -1
- package/src/reducers/__tests__/structureRelations.spec.js +1 -1
- package/src/reducers/__tests__/structureSystem.spec.js +3 -3
- package/src/reducers/graph.js +2 -2
- package/src/reducers/graphLoading.js +2 -2
- package/src/reducers/graphRedirect.js +2 -2
- package/src/reducers/structureFields.js +4 -4
- package/src/reducers/structureImpactGraph.js +2 -2
- package/src/reducers/structureImpactId.js +2 -2
- package/src/reducers/structureLineageGraph.js +2 -2
- package/src/reducers/structureLineageId.js +2 -2
- package/src/reducers/structureLinks.js +3 -3
- package/src/reducers/structureSiblings.js +7 -1
- package/src/reducers/structureSystem.js +2 -2
- package/src/reducers/structureVersions.js +2 -3
- package/src/routines.js +1 -0
- package/src/sagas/__tests__/legacyFetchStructure.spec.js +148 -0
- package/src/sagas/__tests__/requestGrantRemoval.spec.js +132 -0
- package/src/sagas/createGrantRequestStatus.js +1 -0
- package/src/sagas/index.js +3 -2
- package/src/sagas/legacyFetchStructure.js +55 -0
- package/src/sagas/requestGrantRemoval.js +2 -2
- package/src/selectors/getStructuresFields.js +3 -2
- package/src/selectors/getTabVisibility.js +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { initialState, structureLineageId } from "../structureLineageId";
|
|
2
|
-
import {
|
|
2
|
+
import { legacyFetchStructure, createStructureGraph } from "../../routines";
|
|
3
3
|
|
|
4
4
|
const fooState = { foo: "bar" };
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ describe("reducers: structureLineageId", () => {
|
|
|
8
8
|
expect(structureLineageId(undefined, {})).toBe(initialState);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
it("should return the initial state after receiving the
|
|
12
|
-
expect(structureLineageId(fooState, { type:
|
|
11
|
+
it("should return the initial state after receiving the legacyFetchStructure.TRIGGER action", () => {
|
|
12
|
+
expect(structureLineageId(fooState, { type: legacyFetchStructure.TRIGGER })).toBe(
|
|
13
13
|
initialState
|
|
14
14
|
);
|
|
15
15
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clearStructure,
|
|
1
|
+
import { clearStructure, legacyFetchStructure } from "../../routines";
|
|
2
2
|
import { structureLinks } from "..";
|
|
3
3
|
|
|
4
4
|
const fooState = { foo: "bar" };
|
|
@@ -16,19 +16,19 @@ describe("reducers: structureLinks", () => {
|
|
|
16
16
|
);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("should handle the
|
|
20
|
-
expect(structureLinks(fooState, { type:
|
|
19
|
+
it("should handle the legacyFetchStructure.TRIGGER action", () => {
|
|
20
|
+
expect(structureLinks(fooState, { type: legacyFetchStructure.TRIGGER })).toEqual(
|
|
21
21
|
initialState
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
it("should handle the
|
|
25
|
+
it("should handle the legacyFetchStructure.SUCCESS action", () => {
|
|
26
26
|
const links = [{ id: 1, name: "Field 1" }];
|
|
27
27
|
const data = { links };
|
|
28
28
|
|
|
29
29
|
expect(
|
|
30
30
|
structureLinks(fooState, {
|
|
31
|
-
type:
|
|
31
|
+
type: legacyFetchStructure.SUCCESS,
|
|
32
32
|
payload: { data }
|
|
33
33
|
})
|
|
34
34
|
).toMatchObject(links);
|
|
@@ -16,7 +16,7 @@ describe("reducers: structureRedirect", () => {
|
|
|
16
16
|
expect(structureRedirect(undefined, {})).toBe(initialState);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("should be initial state after receiving the
|
|
19
|
+
it("should be initial state after receiving the clearRedirect.TRIGGER action", () => {
|
|
20
20
|
expect(structureRedirect(fooState, { type: clearRedirect.TRIGGER })).toBe(
|
|
21
21
|
initialState
|
|
22
22
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clearStructure,
|
|
1
|
+
import { clearStructure, fetchStructureChildrens, fetchStructureParents } from "../../routines";
|
|
2
2
|
import { childrenRelations, parentRelations } from "..";
|
|
3
3
|
|
|
4
4
|
const fooState = { foo: "bar" };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clearStructure,
|
|
1
|
+
import { clearStructure, legacyFetchStructure } from "../../routines";
|
|
2
2
|
import { structureSystem } from "..";
|
|
3
3
|
|
|
4
4
|
const fooState = { foo: "bar" };
|
|
@@ -16,13 +16,13 @@ describe("reducers: structureSystem", () => {
|
|
|
16
16
|
);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("should handle the
|
|
19
|
+
it("should handle the legacyFetchStructure.SUCCESS action", () => {
|
|
20
20
|
const system = "foo";
|
|
21
21
|
const data = { system };
|
|
22
22
|
|
|
23
23
|
expect(
|
|
24
24
|
structureSystem(fooState, {
|
|
25
|
-
type:
|
|
25
|
+
type: legacyFetchStructure.SUCCESS,
|
|
26
26
|
payload: { data }
|
|
27
27
|
})
|
|
28
28
|
).toEqual(system);
|
package/src/reducers/graph.js
CHANGED
|
@@ -2,7 +2,7 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import {
|
|
3
3
|
clearGraph,
|
|
4
4
|
fetchGraph,
|
|
5
|
-
|
|
5
|
+
legacyFetchStructure,
|
|
6
6
|
createGraph,
|
|
7
7
|
} from "../routines";
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ export const initialState = {};
|
|
|
10
10
|
|
|
11
11
|
export const graph = (state = initialState, { type, payload }) => {
|
|
12
12
|
switch (type) {
|
|
13
|
-
case
|
|
13
|
+
case legacyFetchStructure.TRIGGER:
|
|
14
14
|
return initialState;
|
|
15
15
|
case clearGraph.TRIGGER:
|
|
16
16
|
return initialState;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createGraph,
|
|
5
5
|
createStructureGraph,
|
|
6
6
|
fetchGraph,
|
|
7
|
-
|
|
7
|
+
legacyFetchStructure,
|
|
8
8
|
fetchStructureGraph,
|
|
9
9
|
} from "../routines";
|
|
10
10
|
|
|
@@ -30,7 +30,7 @@ export const graphLoading = (state = false, { type, payload }) => {
|
|
|
30
30
|
return payload || true;
|
|
31
31
|
case fetchGraph.FAILURE:
|
|
32
32
|
return payload;
|
|
33
|
-
case
|
|
33
|
+
case legacyFetchStructure.TRIGGER:
|
|
34
34
|
return false;
|
|
35
35
|
case fetchStructureGraph.FULFILL:
|
|
36
36
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clearRedirect } from "@truedat/core/routines";
|
|
2
2
|
import { linkTo } from "@truedat/core/routes";
|
|
3
|
-
import { createGraph, clearStructure,
|
|
3
|
+
import { createGraph, clearStructure, legacyFetchStructure } from "../routines";
|
|
4
4
|
|
|
5
5
|
export const initialState = "";
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ export const graphRedirect = (state = initialState, { type, payload }) => {
|
|
|
8
8
|
switch (type) {
|
|
9
9
|
case clearStructure.TRIGGER:
|
|
10
10
|
return initialState;
|
|
11
|
-
case
|
|
11
|
+
case legacyFetchStructure.TRIGGER:
|
|
12
12
|
return initialState;
|
|
13
13
|
case clearRedirect.TRIGGER:
|
|
14
14
|
return initialState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import { clearStructure,
|
|
2
|
+
import { clearStructure, legacyFetchStructure } from "../routines";
|
|
3
3
|
|
|
4
4
|
const initialState = [];
|
|
5
5
|
|
|
@@ -7,9 +7,9 @@ const structureFields = (state = initialState, { type, payload }) => {
|
|
|
7
7
|
switch (type) {
|
|
8
8
|
case clearStructure.TRIGGER:
|
|
9
9
|
return initialState;
|
|
10
|
-
case
|
|
10
|
+
case legacyFetchStructure.TRIGGER:
|
|
11
11
|
return initialState;
|
|
12
|
-
case
|
|
12
|
+
case legacyFetchStructure.SUCCESS:
|
|
13
13
|
return _.pathOr([], "data.data_fields")(payload);
|
|
14
14
|
default:
|
|
15
15
|
return state;
|
|
@@ -22,7 +22,7 @@ const structuresFields = (state = structures, { type, payload }) => {
|
|
|
22
22
|
switch (type) {
|
|
23
23
|
case clearStructure.TRIGGER:
|
|
24
24
|
return structures;
|
|
25
|
-
case
|
|
25
|
+
case legacyFetchStructure.SUCCESS:
|
|
26
26
|
const id = _.path("data.data_structure.id")(payload);
|
|
27
27
|
const data_fields = _.pathOr([], "data.data_fields")(payload);
|
|
28
28
|
return _.set(id, data_fields)(state);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import {
|
|
3
3
|
clearStructure,
|
|
4
|
-
|
|
4
|
+
legacyFetchStructure,
|
|
5
5
|
fetchStructureGraph,
|
|
6
6
|
createGraph,
|
|
7
7
|
} from "../routines";
|
|
@@ -15,7 +15,7 @@ export const structureImpactGraph = (
|
|
|
15
15
|
switch (type) {
|
|
16
16
|
case clearStructure.TRIGGER:
|
|
17
17
|
return initialState;
|
|
18
|
-
case
|
|
18
|
+
case legacyFetchStructure.TRIGGER:
|
|
19
19
|
return initialState;
|
|
20
20
|
case createGraph.SUCCESS:
|
|
21
21
|
case fetchStructureGraph.SUCCESS:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import { createStructureGraph } from "../routines";
|
|
3
|
-
import {
|
|
3
|
+
import { legacyFetchStructure } from "../../../dd/src/routines";
|
|
4
4
|
|
|
5
5
|
export const initialState = null;
|
|
6
6
|
|
|
7
7
|
export const structureImpactId = (state = initialState, { type, payload }) => {
|
|
8
8
|
switch (type) {
|
|
9
|
-
case
|
|
9
|
+
case legacyFetchStructure.TRIGGER:
|
|
10
10
|
return initialState;
|
|
11
11
|
case createStructureGraph.SUCCESS:
|
|
12
12
|
return _.pathEq("data.type", "impact")(payload)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import {
|
|
3
3
|
clearStructure,
|
|
4
|
-
|
|
4
|
+
legacyFetchStructure,
|
|
5
5
|
fetchStructureGraph,
|
|
6
6
|
createGraph,
|
|
7
7
|
} from "../routines";
|
|
@@ -15,7 +15,7 @@ export const structureLineageGraph = (
|
|
|
15
15
|
switch (type) {
|
|
16
16
|
case clearStructure.TRIGGER:
|
|
17
17
|
return initialState;
|
|
18
|
-
case
|
|
18
|
+
case legacyFetchStructure.TRIGGER:
|
|
19
19
|
return initialState;
|
|
20
20
|
case createGraph.SUCCESS:
|
|
21
21
|
case fetchStructureGraph.SUCCESS:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import { createStructureGraph } from "../routines";
|
|
3
|
-
import {
|
|
3
|
+
import { legacyFetchStructure } from "../../../dd/src/routines";
|
|
4
4
|
|
|
5
5
|
export const initialState = null;
|
|
6
6
|
|
|
7
7
|
export const structureLineageId = (state = initialState, { type, payload }) => {
|
|
8
8
|
switch (type) {
|
|
9
|
-
case
|
|
9
|
+
case legacyFetchStructure.TRIGGER:
|
|
10
10
|
return initialState;
|
|
11
11
|
case createStructureGraph.SUCCESS:
|
|
12
12
|
return _.pathEq("data.type", "lineage")(payload)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import { clearStructure,
|
|
2
|
+
import { clearStructure, legacyFetchStructure } from "../routines";
|
|
3
3
|
|
|
4
4
|
const initialState = [];
|
|
5
5
|
|
|
@@ -7,9 +7,9 @@ const structureLinks = (state = initialState, { type, payload }) => {
|
|
|
7
7
|
switch (type) {
|
|
8
8
|
case clearStructure.TRIGGER:
|
|
9
9
|
return initialState;
|
|
10
|
-
case
|
|
10
|
+
case legacyFetchStructure.TRIGGER:
|
|
11
11
|
return initialState;
|
|
12
|
-
case
|
|
12
|
+
case legacyFetchStructure.SUCCESS:
|
|
13
13
|
return _.pathOr([], "data.links")(payload);
|
|
14
14
|
default:
|
|
15
15
|
return state;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
clearStructure,
|
|
4
|
+
fetchStructure,
|
|
5
|
+
legacyFetchStructure,
|
|
6
|
+
} from "../routines";
|
|
3
7
|
|
|
4
8
|
const initialState = [];
|
|
5
9
|
|
|
@@ -8,6 +12,7 @@ const structureSiblings = (state = initialState, { type, payload }) => {
|
|
|
8
12
|
case clearStructure.TRIGGER:
|
|
9
13
|
return initialState;
|
|
10
14
|
case fetchStructure.SUCCESS:
|
|
15
|
+
case legacyFetchStructure.SUCCESS:
|
|
11
16
|
return _.pathOr([], "data.siblings")(payload);
|
|
12
17
|
default:
|
|
13
18
|
return state;
|
|
@@ -19,6 +24,7 @@ const structuresSiblings = (state = {}, { type, payload }) => {
|
|
|
19
24
|
case clearStructure.TRIGGER:
|
|
20
25
|
return {};
|
|
21
26
|
case fetchStructure.SUCCESS:
|
|
27
|
+
case legacyFetchStructure.SUCCESS:
|
|
22
28
|
const id = _.path("data.data_structure.id")(payload);
|
|
23
29
|
const siblings = _.pathOr([], "data.siblings")(payload);
|
|
24
30
|
return _.set(id, siblings)(state);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import { clearStructure,
|
|
2
|
+
import { clearStructure, legacyFetchStructure } from "../routines";
|
|
3
3
|
|
|
4
4
|
const initialState = null;
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ const structureSystem = (state = initialState, { type, payload }) => {
|
|
|
7
7
|
switch (type) {
|
|
8
8
|
case clearStructure.TRIGGER:
|
|
9
9
|
return initialState;
|
|
10
|
-
case
|
|
10
|
+
case legacyFetchStructure.SUCCESS:
|
|
11
11
|
return _.propOr(initialState, "system")(payload.data);
|
|
12
12
|
default:
|
|
13
13
|
return state;
|
|
@@ -3,18 +3,17 @@ import { clearStructure, fetchStructureVersions } from "../routines";
|
|
|
3
3
|
|
|
4
4
|
const initialState = [];
|
|
5
5
|
|
|
6
|
-
const structureVersions
|
|
6
|
+
const structureVersions = (state = initialState, { type, payload }) => {
|
|
7
7
|
switch (type) {
|
|
8
8
|
case clearStructure.TRIGGER:
|
|
9
9
|
return initialState;
|
|
10
10
|
case fetchStructureVersions.TRIGGER:
|
|
11
11
|
return initialState;
|
|
12
12
|
case fetchStructureVersions.SUCCESS:
|
|
13
|
-
console.log("payload", payload);
|
|
14
13
|
return _.pathOr([], "data.versions")(payload);
|
|
15
14
|
default:
|
|
16
15
|
return state;
|
|
17
16
|
}
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
export { structureVersions
|
|
19
|
+
export { structureVersions };
|
package/src/routines.js
CHANGED
|
@@ -89,6 +89,7 @@ export const fetchNodes = createRoutine("FETCH_NODES");
|
|
|
89
89
|
export const fetchProfileExecution = createRoutine("FETCH_EXECUTION_PROFILE");
|
|
90
90
|
export const fetchProfileGroup = createRoutine("FETCH_PROFILE_GROUP");
|
|
91
91
|
export const fetchStructure = createRoutine("FETCH_STRUCTURE");
|
|
92
|
+
export const legacyFetchStructure = createRoutine("LEGACY_FETCH_STRUCTURE");
|
|
92
93
|
export const fetchStructureParents = createRoutine("FETCH_STRUCTURE_PARENTS");
|
|
93
94
|
export const fetchStructureChildrens = createRoutine("FETCH_STRUCTURE_CHILDREN");
|
|
94
95
|
export const fetchStructureVersions = createRoutine("FETCH_STRUCTURE_VERSIONS");
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import {
|
|
3
|
+
legacyFetchStructureRequestSaga,
|
|
4
|
+
legacyFetchStructureSaga,
|
|
5
|
+
} from "../legacyFetchStructure";
|
|
6
|
+
|
|
7
|
+
import { legacyFetchStructure } from "../../routines";
|
|
8
|
+
import { LEGACY_DATA_STRUCTURE_VERSION_QUERY } from "../../api/queries";
|
|
9
|
+
import { getStructureFieldColumns } from "../../selectors";
|
|
10
|
+
|
|
11
|
+
describe("sagas: fetchStructureRequestSaga", () => {
|
|
12
|
+
it("should invoke fetchStructureSaga on trigger", () => {
|
|
13
|
+
expect(() => {
|
|
14
|
+
testSaga(legacyFetchStructureRequestSaga)
|
|
15
|
+
.next()
|
|
16
|
+
.takeLatest(legacyFetchStructure.TRIGGER, legacyFetchStructureSaga)
|
|
17
|
+
.finish()
|
|
18
|
+
.isDone();
|
|
19
|
+
}).not.toThrow();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
23
|
+
expect(() => {
|
|
24
|
+
testSaga(legacyFetchStructureRequestSaga)
|
|
25
|
+
.next()
|
|
26
|
+
.takeLatest("FOO", legacyFetchStructureSaga);
|
|
27
|
+
}).toThrow();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("sagas: legacyFetchStructureSaga", () => {
|
|
32
|
+
const client = { query: jest.fn() };
|
|
33
|
+
const id = 1;
|
|
34
|
+
const version = "latest";
|
|
35
|
+
const payload = { id };
|
|
36
|
+
const variables = {
|
|
37
|
+
dataStructureId: id,
|
|
38
|
+
version,
|
|
39
|
+
note_fields: ["note_field"],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const structureFieldColumns = [{ name: "id" }, { name: "note.note_field" }];
|
|
43
|
+
|
|
44
|
+
const _actions = { test: true };
|
|
45
|
+
const user_permissions = { permission1: true };
|
|
46
|
+
|
|
47
|
+
const dataStructureVersion = {
|
|
48
|
+
id,
|
|
49
|
+
name: "Structure 1",
|
|
50
|
+
description: "desc1",
|
|
51
|
+
_actions,
|
|
52
|
+
user_permissions,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const data = {
|
|
56
|
+
data: dataStructureVersion,
|
|
57
|
+
_actions,
|
|
58
|
+
user_permissions,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
it("should put a success action when a response is returned", () => {
|
|
62
|
+
const meta = { version };
|
|
63
|
+
|
|
64
|
+
expect(() => {
|
|
65
|
+
testSaga(legacyFetchStructureSaga, { payload })
|
|
66
|
+
.next()
|
|
67
|
+
.select(getStructureFieldColumns)
|
|
68
|
+
.next(structureFieldColumns)
|
|
69
|
+
.getContext("client")
|
|
70
|
+
.next(client)
|
|
71
|
+
.put(legacyFetchStructure.request())
|
|
72
|
+
.next()
|
|
73
|
+
|
|
74
|
+
.call(client.query, {
|
|
75
|
+
fetchPolicy: "network-only",
|
|
76
|
+
query: LEGACY_DATA_STRUCTURE_VERSION_QUERY,
|
|
77
|
+
variables,
|
|
78
|
+
})
|
|
79
|
+
.next({ data: { dataStructureVersion } })
|
|
80
|
+
.put({ meta, ...legacyFetchStructure.success(data) })
|
|
81
|
+
.next()
|
|
82
|
+
.put(legacyFetchStructure.fulfill())
|
|
83
|
+
.next()
|
|
84
|
+
.isDone();
|
|
85
|
+
}).not.toThrow();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should put a success action when a response is returned - with version", () => {
|
|
89
|
+
const version = 23;
|
|
90
|
+
const payload = { id, version };
|
|
91
|
+
const meta = { version };
|
|
92
|
+
|
|
93
|
+
const variables = {
|
|
94
|
+
dataStructureId: id,
|
|
95
|
+
version,
|
|
96
|
+
note_fields: ["note_field"],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
expect(() => {
|
|
100
|
+
testSaga(legacyFetchStructureSaga, { payload })
|
|
101
|
+
.next()
|
|
102
|
+
.select(getStructureFieldColumns)
|
|
103
|
+
.next(structureFieldColumns)
|
|
104
|
+
.getContext("client")
|
|
105
|
+
.next(client)
|
|
106
|
+
.put(legacyFetchStructure.request())
|
|
107
|
+
.next()
|
|
108
|
+
.call(client.query, {
|
|
109
|
+
fetchPolicy: "network-only",
|
|
110
|
+
query: LEGACY_DATA_STRUCTURE_VERSION_QUERY,
|
|
111
|
+
variables,
|
|
112
|
+
})
|
|
113
|
+
.next({ data: { dataStructureVersion } })
|
|
114
|
+
.put({ meta, ...legacyFetchStructure.success(data) })
|
|
115
|
+
.next()
|
|
116
|
+
.put(legacyFetchStructure.fulfill())
|
|
117
|
+
.next()
|
|
118
|
+
.isDone();
|
|
119
|
+
}).not.toThrow();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should put a failure action when the call returns an error", () => {
|
|
123
|
+
const message = "Request failed";
|
|
124
|
+
const error = { message };
|
|
125
|
+
|
|
126
|
+
expect(() => {
|
|
127
|
+
testSaga(legacyFetchStructureSaga, { payload })
|
|
128
|
+
.next()
|
|
129
|
+
.select(getStructureFieldColumns)
|
|
130
|
+
.next(structureFieldColumns)
|
|
131
|
+
.getContext("client")
|
|
132
|
+
.next(client)
|
|
133
|
+
.put(legacyFetchStructure.request())
|
|
134
|
+
.next()
|
|
135
|
+
.call(client.query, {
|
|
136
|
+
fetchPolicy: "network-only",
|
|
137
|
+
query: LEGACY_DATA_STRUCTURE_VERSION_QUERY,
|
|
138
|
+
variables,
|
|
139
|
+
})
|
|
140
|
+
.throw(error)
|
|
141
|
+
.put(legacyFetchStructure.failure(message))
|
|
142
|
+
.next()
|
|
143
|
+
.put(legacyFetchStructure.fulfill())
|
|
144
|
+
.next()
|
|
145
|
+
.isDone();
|
|
146
|
+
}).not.toThrow();
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import { compile } from "path-to-regexp";
|
|
3
|
+
import {
|
|
4
|
+
requestGrantRemovalSaga,
|
|
5
|
+
requestGrantRemovalRequestSaga,
|
|
6
|
+
} from "../requestGrantRemoval";
|
|
7
|
+
import {
|
|
8
|
+
requestGrantRemoval,
|
|
9
|
+
legacyFetchStructure,
|
|
10
|
+
fetchStructures,
|
|
11
|
+
} from "../../routines";
|
|
12
|
+
import { API_GRANT } from "../../api";
|
|
13
|
+
import { apiJsonPatch, JSON_OPTS } from "@truedat/core/services/api";
|
|
14
|
+
|
|
15
|
+
describe("sagas: requestGrantRemovalRequestSaga", () => {
|
|
16
|
+
it("should invoke requestGrantRemovalSaga on requestGrantRemoval.TRIGGER", () => {
|
|
17
|
+
expect(() => {
|
|
18
|
+
testSaga(requestGrantRemovalRequestSaga)
|
|
19
|
+
.next()
|
|
20
|
+
.takeLatest(requestGrantRemoval.TRIGGER, requestGrantRemovalSaga)
|
|
21
|
+
.finish()
|
|
22
|
+
.isDone();
|
|
23
|
+
}).not.toThrow();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should throw exception if an unhandled action is received", () => {
|
|
27
|
+
expect(() => {
|
|
28
|
+
testSaga(requestGrantRemovalRequestSaga)
|
|
29
|
+
.next()
|
|
30
|
+
.takeLatest("FOO", requestGrantRemovalSaga);
|
|
31
|
+
}).toThrow();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("sagas: requestGrantRemovalSaga", () => {
|
|
36
|
+
const id = "1";
|
|
37
|
+
const action = "REMOVE";
|
|
38
|
+
const data_structure_id = 2;
|
|
39
|
+
const version = "v3";
|
|
40
|
+
const previousStructureQuery = { foo: "bar" };
|
|
41
|
+
const payloadWithPrevQuery = {
|
|
42
|
+
id,
|
|
43
|
+
action,
|
|
44
|
+
data_structure_id,
|
|
45
|
+
version,
|
|
46
|
+
previousStructureQuery,
|
|
47
|
+
};
|
|
48
|
+
const payloadWithoutPrevQuery = {
|
|
49
|
+
id,
|
|
50
|
+
action,
|
|
51
|
+
data_structure_id,
|
|
52
|
+
version,
|
|
53
|
+
previousStructureQuery: undefined,
|
|
54
|
+
};
|
|
55
|
+
const requestData = { action };
|
|
56
|
+
const url = compile(API_GRANT)({ id: `${id}` });
|
|
57
|
+
|
|
58
|
+
it("should put a success action and fetchStructures.trigger when previousStructureQuery is provided", () => {
|
|
59
|
+
expect(() => {
|
|
60
|
+
testSaga(requestGrantRemovalSaga, { payload: payloadWithPrevQuery })
|
|
61
|
+
.next()
|
|
62
|
+
.put(requestGrantRemoval.request())
|
|
63
|
+
.next()
|
|
64
|
+
.call(apiJsonPatch, url, requestData, JSON_OPTS)
|
|
65
|
+
.next({ data: "result" })
|
|
66
|
+
.put(requestGrantRemoval.success("result"))
|
|
67
|
+
.next()
|
|
68
|
+
.put(fetchStructures.trigger(previousStructureQuery))
|
|
69
|
+
.next()
|
|
70
|
+
.put(requestGrantRemoval.fulfill())
|
|
71
|
+
.next()
|
|
72
|
+
.isDone();
|
|
73
|
+
}).not.toThrow();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should put a success action and legacyFetchStructure.trigger when previousStructureQuery is not provided", () => {
|
|
77
|
+
expect(() => {
|
|
78
|
+
testSaga(requestGrantRemovalSaga, { payload: payloadWithoutPrevQuery })
|
|
79
|
+
.next()
|
|
80
|
+
.put(requestGrantRemoval.request())
|
|
81
|
+
.next()
|
|
82
|
+
.call(apiJsonPatch, url, requestData, JSON_OPTS)
|
|
83
|
+
.next({ data: "result" })
|
|
84
|
+
.put(requestGrantRemoval.success("result"))
|
|
85
|
+
.next()
|
|
86
|
+
.put(
|
|
87
|
+
legacyFetchStructure.trigger({
|
|
88
|
+
id: data_structure_id,
|
|
89
|
+
version,
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
.next()
|
|
93
|
+
.put(requestGrantRemoval.fulfill())
|
|
94
|
+
.next()
|
|
95
|
+
.isDone();
|
|
96
|
+
}).not.toThrow();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should put a failure action with response when error.response exists", () => {
|
|
100
|
+
const error = { response: { status: 403, data: { err: "bad" } } };
|
|
101
|
+
expect(() => {
|
|
102
|
+
testSaga(requestGrantRemovalSaga, { payload: payloadWithPrevQuery })
|
|
103
|
+
.next()
|
|
104
|
+
.put(requestGrantRemoval.request())
|
|
105
|
+
.next()
|
|
106
|
+
.call(apiJsonPatch, url, requestData, JSON_OPTS)
|
|
107
|
+
.throw(error)
|
|
108
|
+
.put(requestGrantRemoval.failure({ status: 403, data: { err: "bad" } }))
|
|
109
|
+
.next()
|
|
110
|
+
.put(requestGrantRemoval.fulfill())
|
|
111
|
+
.next()
|
|
112
|
+
.isDone();
|
|
113
|
+
}).not.toThrow();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("should put a failure action with error.message when error.response does not exist", () => {
|
|
117
|
+
const error = { message: "Some other error" };
|
|
118
|
+
expect(() => {
|
|
119
|
+
testSaga(requestGrantRemovalSaga, { payload: payloadWithoutPrevQuery })
|
|
120
|
+
.next()
|
|
121
|
+
.put(requestGrantRemoval.request())
|
|
122
|
+
.next()
|
|
123
|
+
.call(apiJsonPatch, url, requestData, JSON_OPTS)
|
|
124
|
+
.throw(error)
|
|
125
|
+
.put(requestGrantRemoval.failure("Some other error"))
|
|
126
|
+
.next()
|
|
127
|
+
.put(requestGrantRemoval.fulfill())
|
|
128
|
+
.next()
|
|
129
|
+
.isDone();
|
|
130
|
+
}).not.toThrow();
|
|
131
|
+
});
|
|
132
|
+
});
|
package/src/sagas/index.js
CHANGED
|
@@ -32,8 +32,7 @@ import { fetchProfileGroupRequestSaga } from "./fetchProfileGroup";
|
|
|
32
32
|
import { fetchStructureGraphRequestSaga } from "./fetchStructureGraph";
|
|
33
33
|
import { fetchStructureNotesRequestSaga } from "./fetchStructureNotes";
|
|
34
34
|
import { fetchStructureRequestSaga } from "./fetchStructure";
|
|
35
|
-
import {
|
|
36
|
-
import { fetchStructureChildrensRequestSaga } from "./fetchStructureChildrens";
|
|
35
|
+
import { legacyFetchStructureRequestSaga } from "./legacyFetchStructure";
|
|
37
36
|
import { fetchStructureTypeRequestSaga } from "./fetchStructureType";
|
|
38
37
|
import { fetchStructureTypesRequestSaga } from "./fetchStructureTypes";
|
|
39
38
|
import { fetchStructuresRequestSaga } from "./fetchStructures";
|
|
@@ -98,6 +97,7 @@ export {
|
|
|
98
97
|
fetchSystemStructuresRequestSaga,
|
|
99
98
|
fetchUserSearchFiltersRequestSaga,
|
|
100
99
|
linkStructureToStructureRequestSaga,
|
|
100
|
+
legacyFetchStructureRequestSaga,
|
|
101
101
|
tagStructureRequestSaga,
|
|
102
102
|
operateGrantRequestToCartRequestSaga,
|
|
103
103
|
requestGrantRemovalRequestSaga,
|
|
@@ -155,6 +155,7 @@ export default [
|
|
|
155
155
|
fetchSystemStructuresRequestSaga(),
|
|
156
156
|
fetchUserSearchFiltersRequestSaga(),
|
|
157
157
|
linkStructureToStructureRequestSaga(),
|
|
158
|
+
legacyFetchStructureRequestSaga(),
|
|
158
159
|
tagStructureRequestSaga(),
|
|
159
160
|
operateGrantRequestToCartRequestSaga(),
|
|
160
161
|
requestGrantRemovalRequestSaga(),
|