@truedat/dd 4.48.12 → 4.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +5 -5
- package/src/api/fragments.js +2 -2
- package/src/api/mutations.js +33 -11
- package/src/api/queries.js +37 -10
- package/src/api.js +0 -4
- package/src/components/DictionaryRoutes.js +4 -4
- package/src/components/StructureSummary.js +12 -22
- package/src/components/StructureTag.js +83 -54
- package/src/components/StructureTagForm.js +149 -89
- package/src/components/StructureTags.js +57 -27
- package/src/components/Tag.js +62 -0
- package/src/components/TagCards.js +85 -0
- package/src/components/TagCrumbs.js +25 -0
- package/src/components/TagForm.js +102 -0
- package/src/components/TagStructureButton.js +58 -0
- package/src/components/Tags.js +33 -0
- package/src/components/TagsRoutes.js +39 -0
- package/src/components/__tests__/StructureSummary.spec.js +0 -7
- package/src/components/__tests__/StructureTag.spec.js +79 -5
- package/src/components/__tests__/StructureTagForm.spec.js +99 -50
- package/src/components/__tests__/Tag.spec.js +11 -0
- package/src/components/__tests__/{StructureTagsCards.spec.js → TagCards.spec.js} +10 -10
- package/src/components/__tests__/TagCrumbs.spec.js +10 -0
- package/src/components/__tests__/TagForm.spec.js +72 -0
- package/src/components/__tests__/Tags.spec.js +10 -0
- package/src/components/__tests__/__snapshots__/StructureSummary.spec.js.snap +18 -42
- package/src/components/__tests__/__snapshots__/StructureTag.spec.js.snap +10 -30
- package/src/components/__tests__/__snapshots__/StructureTagForm.spec.js.snap +255 -51
- package/src/components/__tests__/__snapshots__/Tag.spec.js.snap +36 -0
- package/src/components/__tests__/__snapshots__/{StructureTagsCards.spec.js.snap → TagCards.spec.js.snap} +1 -1
- package/src/components/__tests__/__snapshots__/TagCrumbs.spec.js.snap +102 -0
- package/src/components/__tests__/__snapshots__/TagForm.spec.js.snap +70 -0
- package/src/components/__tests__/__snapshots__/{StructureTags.spec.js.snap → Tags.spec.js.snap} +1 -1
- package/src/messages/en.js +25 -30
- package/src/messages/es.js +25 -30
- package/src/reducers/__tests__/{editableStructureTags.spec.js → availableTags.spec.js} +7 -11
- package/src/reducers/__tests__/structureTagSaving.spec.js +36 -0
- package/src/reducers/__tests__/tagSaving.spec.js +32 -0
- package/src/reducers/{editableStructureTags.js → availableTags.js} +2 -2
- package/src/reducers/index.js +6 -12
- package/src/reducers/structureRedirect.js +7 -7
- package/src/reducers/structureTagSaving.js +12 -10
- package/src/reducers/tagSaving.js +18 -0
- package/src/routines.js +5 -6
- package/src/sagas/__tests__/createTag.spec.js +81 -0
- package/src/sagas/__tests__/deleteStructureTag.spec.js +11 -12
- package/src/sagas/__tests__/deleteTag.spec.js +76 -0
- package/src/sagas/__tests__/tagStructure.spec.js +86 -0
- package/src/sagas/__tests__/updateTag.spec.js +81 -0
- package/src/sagas/createTag.js +29 -0
- package/src/sagas/deleteStructureTag.js +12 -9
- package/src/sagas/deleteTag.js +34 -0
- package/src/sagas/index.js +15 -18
- package/src/sagas/tagStructure.js +37 -0
- package/src/sagas/updateTag.js +23 -0
- package/src/components/LinkStructureTagForm.js +0 -163
- package/src/components/LinkedStructureTag.js +0 -124
- package/src/components/StructureLinkTagButton.js +0 -47
- package/src/components/StructureTagsCards.js +0 -92
- package/src/components/StructureTagsCrumbs.js +0 -44
- package/src/components/StructureTagsRoutes.js +0 -45
- package/src/components/TagsHeader.js +0 -32
- package/src/components/__tests__/LinkStructureTagForm.spec.js +0 -184
- package/src/components/__tests__/LinkedStructureTag.spec.js +0 -133
- package/src/components/__tests__/StructureTags.spec.js +0 -14
- package/src/components/__tests__/StructureTagsCrumbs.spec.js +0 -13
- package/src/components/__tests__/__snapshots__/LinkStructureTagForm.spec.js.snap +0 -456
- package/src/components/__tests__/__snapshots__/LinkedStructureTag.spec.js.snap +0 -16
- package/src/components/__tests__/__snapshots__/StructureTagsCrumbs.spec.js.snap +0 -36
- package/src/reducers/__tests__/deletingStructureTags.spec.js +0 -30
- package/src/reducers/__tests__/linkedStructureTags.spec.js +0 -69
- package/src/reducers/__tests__/linkedStructureTagsLoading.spec.js +0 -32
- package/src/reducers/__tests__/linkingStructureTags.spec.js +0 -30
- package/src/reducers/__tests__/structureTagsSaving.spec.js +0 -40
- package/src/reducers/deletingStructureTags.js +0 -16
- package/src/reducers/linkedStructureTags.js +0 -28
- package/src/reducers/linkedStructureTagsLoading.js +0 -16
- package/src/reducers/linkingStructureTags.js +0 -16
- package/src/sagas/__tests__/createStructureTag.spec.js +0 -85
- package/src/sagas/__tests__/deleteLinkStructureTag.spec.js +0 -96
- package/src/sagas/__tests__/fetchLinksStructureTags.spec.js +0 -105
- package/src/sagas/__tests__/linkStructureTag.spec.js +0 -102
- package/src/sagas/__tests__/updateStructureTag.spec.js +0 -84
- package/src/sagas/createStructureTag.js +0 -29
- package/src/sagas/deleteLinkStructureTag.js +0 -29
- package/src/sagas/fetchLinksStructureTags.js +0 -31
- package/src/sagas/linkStructureTag.js +0 -30
- package/src/sagas/updateStructureTag.js +0 -23
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { createStructureTag, updateStructureTag } from "../../routines";
|
|
2
|
-
import { structureTagSaving } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: structureTagSaving", () => {
|
|
7
|
-
const initialState = false;
|
|
8
|
-
|
|
9
|
-
it("should provide the initial state", () => {
|
|
10
|
-
expect(structureTagSaving(undefined, {})).toBe(initialState);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should handle the createStructureTag.TRIGGER action", () => {
|
|
14
|
-
expect(
|
|
15
|
-
structureTagSaving(fooState, { type: createStructureTag.TRIGGER })
|
|
16
|
-
).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle the createStructureTag.FULFILL action", () => {
|
|
20
|
-
expect(
|
|
21
|
-
structureTagSaving(fooState, { type: createStructureTag.FULFILL })
|
|
22
|
-
).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should handle the updateStructureTag.TRIGGER action", () => {
|
|
26
|
-
expect(
|
|
27
|
-
structureTagSaving(fooState, { type: updateStructureTag.TRIGGER })
|
|
28
|
-
).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should handle the updateStructureTag.FULFILL action", () => {
|
|
32
|
-
expect(
|
|
33
|
-
structureTagSaving(fooState, { type: updateStructureTag.FULFILL })
|
|
34
|
-
).toBe(false);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should ignore unknown actions", () => {
|
|
38
|
-
expect(structureTagSaving(fooState, { type: "FOO" })).toBe(fooState);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { deleteLinkStructureTag } from "../routines";
|
|
2
|
-
|
|
3
|
-
const initialState = false;
|
|
4
|
-
|
|
5
|
-
const deletingStructureTags = (state = initialState, { type }) => {
|
|
6
|
-
switch (type) {
|
|
7
|
-
case deleteLinkStructureTag.TRIGGER:
|
|
8
|
-
return true;
|
|
9
|
-
case deleteLinkStructureTag.FULFILL:
|
|
10
|
-
return initialState;
|
|
11
|
-
default:
|
|
12
|
-
return state;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { deletingStructureTags };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import {
|
|
3
|
-
clearStructure,
|
|
4
|
-
fetchStructure,
|
|
5
|
-
fetchLinksStructureTags,
|
|
6
|
-
updateStructure,
|
|
7
|
-
} from "../routines";
|
|
8
|
-
|
|
9
|
-
const initialState = [];
|
|
10
|
-
|
|
11
|
-
const linkedStructureTags = (state = initialState, { type, payload }) => {
|
|
12
|
-
switch (type) {
|
|
13
|
-
case clearStructure.TRIGGER:
|
|
14
|
-
return initialState;
|
|
15
|
-
case fetchStructure.TRIGGER:
|
|
16
|
-
return state;
|
|
17
|
-
case fetchLinksStructureTags.SUCCESS:
|
|
18
|
-
return payload.data;
|
|
19
|
-
case fetchStructure.SUCCESS:
|
|
20
|
-
return _.pathOr([], "data.tags")(payload);
|
|
21
|
-
case updateStructure.SUCCESS:
|
|
22
|
-
return _.pathOr([], "data.tags")(payload);
|
|
23
|
-
default:
|
|
24
|
-
return state;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { linkedStructureTags };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { fetchLinksStructureTags } from "../routines";
|
|
2
|
-
|
|
3
|
-
const initialState = false;
|
|
4
|
-
|
|
5
|
-
const linkedStructureTagsLoading = (state = initialState, { type }) => {
|
|
6
|
-
switch (type) {
|
|
7
|
-
case fetchLinksStructureTags.TRIGGER:
|
|
8
|
-
return true;
|
|
9
|
-
case fetchLinksStructureTags.FULFILL:
|
|
10
|
-
return initialState;
|
|
11
|
-
default:
|
|
12
|
-
return state;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { linkedStructureTagsLoading };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { linkStructureTag } from "../routines";
|
|
2
|
-
|
|
3
|
-
const initialState = false;
|
|
4
|
-
|
|
5
|
-
const linkingStructureTags = (state = initialState, { type }) => {
|
|
6
|
-
switch (type) {
|
|
7
|
-
case linkStructureTag.TRIGGER:
|
|
8
|
-
return true;
|
|
9
|
-
case linkStructureTag.FULFILL:
|
|
10
|
-
return initialState;
|
|
11
|
-
default:
|
|
12
|
-
return state;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { linkingStructureTags };
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
-
import {
|
|
3
|
-
createStructureTagRequestSaga,
|
|
4
|
-
createStructureTagSaga,
|
|
5
|
-
onSuccess,
|
|
6
|
-
} from "../createStructureTag";
|
|
7
|
-
import { CREATE_STRUCTURE_TAG } from "../../api/mutations";
|
|
8
|
-
import { createStructureTag } from "../../routines";
|
|
9
|
-
|
|
10
|
-
describe("sagas: createStructureTagRequestSaga", () => {
|
|
11
|
-
it("should invoke createStructureTagSaga on createStructureTag.TRIGGER", () => {
|
|
12
|
-
expect(() => {
|
|
13
|
-
testSaga(createStructureTagRequestSaga)
|
|
14
|
-
.next()
|
|
15
|
-
.takeLatest(createStructureTag.TRIGGER, createStructureTagSaga)
|
|
16
|
-
.finish()
|
|
17
|
-
.isDone();
|
|
18
|
-
}).not.toThrow();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should throw exception if an unhandled action is received", () => {
|
|
22
|
-
expect(() => {
|
|
23
|
-
testSaga(createStructureTagRequestSaga)
|
|
24
|
-
.next()
|
|
25
|
-
.takeLatest("FOO", createStructureTagRequestSaga);
|
|
26
|
-
}).toThrow();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("sagas: createStructureTagSaga", () => {
|
|
31
|
-
const client = { mutate: jest.fn() };
|
|
32
|
-
const structureTag = {
|
|
33
|
-
name: "tag1",
|
|
34
|
-
domainIds: ["1", "2"],
|
|
35
|
-
};
|
|
36
|
-
const payload = structureTag;
|
|
37
|
-
const data = { foo: "bar" };
|
|
38
|
-
|
|
39
|
-
it("should put a success action when a response is returned", () => {
|
|
40
|
-
expect(() => {
|
|
41
|
-
testSaga(createStructureTagSaga, { payload })
|
|
42
|
-
.next()
|
|
43
|
-
.getContext("client")
|
|
44
|
-
.next(client)
|
|
45
|
-
.put(createStructureTag.request(payload))
|
|
46
|
-
.next()
|
|
47
|
-
.call(client.mutate, {
|
|
48
|
-
mutation: CREATE_STRUCTURE_TAG,
|
|
49
|
-
update: onSuccess,
|
|
50
|
-
variables: { structureTag },
|
|
51
|
-
})
|
|
52
|
-
.next({ data })
|
|
53
|
-
.put(createStructureTag.success(data))
|
|
54
|
-
.next()
|
|
55
|
-
.put(createStructureTag.fulfill())
|
|
56
|
-
.next()
|
|
57
|
-
.isDone();
|
|
58
|
-
}).not.toThrow();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should put a failure action when the call returns an error", () => {
|
|
62
|
-
const message = "Request failed";
|
|
63
|
-
const error = { message };
|
|
64
|
-
|
|
65
|
-
expect(() => {
|
|
66
|
-
testSaga(createStructureTagSaga, { payload })
|
|
67
|
-
.next()
|
|
68
|
-
.getContext("client")
|
|
69
|
-
.next(client)
|
|
70
|
-
.put(createStructureTag.request(payload))
|
|
71
|
-
.next()
|
|
72
|
-
.call(client.mutate, {
|
|
73
|
-
mutation: CREATE_STRUCTURE_TAG,
|
|
74
|
-
update: onSuccess,
|
|
75
|
-
variables: { structureTag },
|
|
76
|
-
})
|
|
77
|
-
.throw(error)
|
|
78
|
-
.put(createStructureTag.failure(message))
|
|
79
|
-
.next()
|
|
80
|
-
.put(createStructureTag.fulfill())
|
|
81
|
-
.next()
|
|
82
|
-
.isDone();
|
|
83
|
-
}).not.toThrow();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,96 +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
|
-
deleteLinkStructureTagSaga,
|
|
6
|
-
deleteLinkStructureTagRequestSaga
|
|
7
|
-
} from "../deleteLinkStructureTag";
|
|
8
|
-
import {
|
|
9
|
-
fetchLinksStructureTags,
|
|
10
|
-
deleteLinkStructureTag
|
|
11
|
-
} from "../../routines";
|
|
12
|
-
import { API_STRUCTURES_TAG } from "../../api";
|
|
13
|
-
|
|
14
|
-
describe("sagas: deleteLinkStructureTagRequestSaga", () => {
|
|
15
|
-
it("should invoke deleteLinkStructureTagSaga on deleteLinkStructureTag.TRIGGER", () => {
|
|
16
|
-
expect(() => {
|
|
17
|
-
testSaga(deleteLinkStructureTagRequestSaga)
|
|
18
|
-
.next()
|
|
19
|
-
.takeLatest(deleteLinkStructureTag.TRIGGER, deleteLinkStructureTagSaga)
|
|
20
|
-
.finish()
|
|
21
|
-
.isDone();
|
|
22
|
-
}).not.toThrow();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should throw exception if an unhandled action is received", () => {
|
|
26
|
-
expect(() => {
|
|
27
|
-
testSaga(deleteLinkStructureTagRequestSaga)
|
|
28
|
-
.next()
|
|
29
|
-
.takeLatest("FOO", deleteLinkStructureTagSaga);
|
|
30
|
-
}).toThrow();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe("sagas: deleteLinkStructureTagSaga", () => {
|
|
35
|
-
const payload = { structureId: 1, tagId: 2 };
|
|
36
|
-
const data = { id: 1 };
|
|
37
|
-
const { structureId: data_structure_id, tagId: id } = payload;
|
|
38
|
-
const url = compile(API_STRUCTURES_TAG)({ data_structure_id, id });
|
|
39
|
-
|
|
40
|
-
it("should put a success action when a response is returned", () => {
|
|
41
|
-
expect(() => {
|
|
42
|
-
testSaga(deleteLinkStructureTagSaga, { payload })
|
|
43
|
-
.next()
|
|
44
|
-
.put(deleteLinkStructureTag.request())
|
|
45
|
-
.next()
|
|
46
|
-
.call(apiJsonDelete, url, JSON_OPTS)
|
|
47
|
-
.next({ data })
|
|
48
|
-
.put(deleteLinkStructureTag.success(data))
|
|
49
|
-
.next()
|
|
50
|
-
.put(fetchLinksStructureTags.trigger(payload))
|
|
51
|
-
.next()
|
|
52
|
-
.put(deleteLinkStructureTag.fulfill())
|
|
53
|
-
.next()
|
|
54
|
-
.isDone();
|
|
55
|
-
}).not.toThrow();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should put a failure action when the call returns an error with message", () => {
|
|
59
|
-
const message = "Request failed";
|
|
60
|
-
const error = { message };
|
|
61
|
-
|
|
62
|
-
expect(() => {
|
|
63
|
-
testSaga(deleteLinkStructureTagSaga, { payload })
|
|
64
|
-
.next()
|
|
65
|
-
.put(deleteLinkStructureTag.request())
|
|
66
|
-
.next()
|
|
67
|
-
.call(apiJsonDelete, url, JSON_OPTS)
|
|
68
|
-
.throw(error)
|
|
69
|
-
.put(deleteLinkStructureTag.failure(message))
|
|
70
|
-
.next()
|
|
71
|
-
.put(deleteLinkStructureTag.fulfill())
|
|
72
|
-
.next()
|
|
73
|
-
.isDone();
|
|
74
|
-
}).not.toThrow();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("should put a failure action when the call returns an error with response", () => {
|
|
78
|
-
const status = "foo";
|
|
79
|
-
const data = "bar";
|
|
80
|
-
const error = { response: { status, data } };
|
|
81
|
-
|
|
82
|
-
expect(() => {
|
|
83
|
-
testSaga(deleteLinkStructureTagSaga, { payload })
|
|
84
|
-
.next()
|
|
85
|
-
.put(deleteLinkStructureTag.request())
|
|
86
|
-
.next()
|
|
87
|
-
.call(apiJsonDelete, url, JSON_OPTS)
|
|
88
|
-
.throw(error)
|
|
89
|
-
.put(deleteLinkStructureTag.failure({ status, data }))
|
|
90
|
-
.next()
|
|
91
|
-
.put(deleteLinkStructureTag.fulfill())
|
|
92
|
-
.next()
|
|
93
|
-
.isDone();
|
|
94
|
-
}).not.toThrow();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
|
-
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
-
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
-
import {
|
|
5
|
-
fetchLinksStructureTagsRequestSaga,
|
|
6
|
-
fetchLinksStructureTagsSaga
|
|
7
|
-
} from "../fetchLinksStructureTags";
|
|
8
|
-
import { fetchLinksStructureTags } from "../../routines";
|
|
9
|
-
import { API_STRUCTURES_TAGS } from "../../api";
|
|
10
|
-
|
|
11
|
-
describe("sagas: fetchLinksStructureTagsRequestSaga", () => {
|
|
12
|
-
it("should invoke fetchLinksStructureTagsSaga on trigger", () => {
|
|
13
|
-
expect(() => {
|
|
14
|
-
testSaga(fetchLinksStructureTagsRequestSaga)
|
|
15
|
-
.next()
|
|
16
|
-
.takeLatest(
|
|
17
|
-
fetchLinksStructureTags.TRIGGER,
|
|
18
|
-
fetchLinksStructureTagsSaga
|
|
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(fetchLinksStructureTagsRequestSaga)
|
|
28
|
-
.next()
|
|
29
|
-
.takeLatest("FOO", fetchLinksStructureTags);
|
|
30
|
-
}).toThrow();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe("sagas: fetchLinksStructureTagsSaga", () => {
|
|
35
|
-
const payload = { structureId: 1 };
|
|
36
|
-
const { structureId: data_structure_id } = payload;
|
|
37
|
-
const data = [
|
|
38
|
-
{
|
|
39
|
-
id: 1,
|
|
40
|
-
description: "foo",
|
|
41
|
-
inserted_at: "foo",
|
|
42
|
-
updated_at: "foo",
|
|
43
|
-
_embedded: {
|
|
44
|
-
data_structure: { id: 1, external_id: "baz" },
|
|
45
|
-
data_structure_tag: { id: 1, name: "bar" }
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
];
|
|
49
|
-
const url = compile(API_STRUCTURES_TAGS)({ data_structure_id });
|
|
50
|
-
|
|
51
|
-
it("should put a success action when a response is returned", () => {
|
|
52
|
-
expect(() => {
|
|
53
|
-
testSaga(fetchLinksStructureTagsSaga, { payload })
|
|
54
|
-
.next()
|
|
55
|
-
.put(fetchLinksStructureTags.request())
|
|
56
|
-
.next()
|
|
57
|
-
.call(apiJson, url, JSON_OPTS)
|
|
58
|
-
.next({ data })
|
|
59
|
-
.put(fetchLinksStructureTags.success(data))
|
|
60
|
-
.next()
|
|
61
|
-
.put(fetchLinksStructureTags.fulfill())
|
|
62
|
-
.next()
|
|
63
|
-
.isDone();
|
|
64
|
-
}).not.toThrow();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("should put a failure action when the call returns an error with message", () => {
|
|
68
|
-
const message = "Request failed";
|
|
69
|
-
const error = { message };
|
|
70
|
-
|
|
71
|
-
expect(() => {
|
|
72
|
-
testSaga(fetchLinksStructureTagsSaga, { payload })
|
|
73
|
-
.next()
|
|
74
|
-
.put(fetchLinksStructureTags.request())
|
|
75
|
-
.next()
|
|
76
|
-
.call(apiJson, url, JSON_OPTS)
|
|
77
|
-
.throw(error)
|
|
78
|
-
.put(fetchLinksStructureTags.failure(message))
|
|
79
|
-
.next()
|
|
80
|
-
.put(fetchLinksStructureTags.fulfill())
|
|
81
|
-
.next()
|
|
82
|
-
.isDone();
|
|
83
|
-
}).not.toThrow();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("should put a failure action when the call returns an error with response", () => {
|
|
87
|
-
const status = "foo";
|
|
88
|
-
const data = "bar";
|
|
89
|
-
const error = { response: { status, data } };
|
|
90
|
-
|
|
91
|
-
expect(() => {
|
|
92
|
-
testSaga(fetchLinksStructureTagsSaga, { payload })
|
|
93
|
-
.next()
|
|
94
|
-
.put(fetchLinksStructureTags.request())
|
|
95
|
-
.next()
|
|
96
|
-
.call(apiJson, url, JSON_OPTS)
|
|
97
|
-
.throw(error)
|
|
98
|
-
.put(fetchLinksStructureTags.failure({ status, data }))
|
|
99
|
-
.next()
|
|
100
|
-
.put(fetchLinksStructureTags.fulfill())
|
|
101
|
-
.next()
|
|
102
|
-
.isDone();
|
|
103
|
-
}).not.toThrow();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
|
-
import { testSaga } from "redux-saga-test-plan";
|
|
3
|
-
import { apiJsonPatch, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
-
import {
|
|
5
|
-
linkStructureTagRequestSaga,
|
|
6
|
-
linkStructureTagSaga
|
|
7
|
-
} from "../linkStructureTag";
|
|
8
|
-
import { fetchLinksStructureTags, linkStructureTag } from "../../routines";
|
|
9
|
-
import { API_STRUCTURES_TAG } from "../../api";
|
|
10
|
-
|
|
11
|
-
describe("sagas: linkStructureTagRequestSaga", () => {
|
|
12
|
-
it("should invoke linkStructureTagSaga on trigger", () => {
|
|
13
|
-
expect(() => {
|
|
14
|
-
testSaga(linkStructureTagRequestSaga)
|
|
15
|
-
.next()
|
|
16
|
-
.takeLatest(linkStructureTag.TRIGGER, linkStructureTagSaga)
|
|
17
|
-
.finish()
|
|
18
|
-
.isDone();
|
|
19
|
-
}).not.toThrow();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should throw exception if an unhandled action is received", () => {
|
|
23
|
-
expect(() => {
|
|
24
|
-
testSaga(linkStructureTagRequestSaga)
|
|
25
|
-
.next()
|
|
26
|
-
.takeLatest("FOO", linkStructureTagSaga);
|
|
27
|
-
}).toThrow();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe("sagas: linkStructureTagSaga", () => {
|
|
32
|
-
const tag = { description: "foo" };
|
|
33
|
-
const payload = { structureId: 1, tagId: 2, tag };
|
|
34
|
-
const { structureId: data_structure_id, tagId: id } = payload;
|
|
35
|
-
const url = compile(API_STRUCTURES_TAG)({ data_structure_id, id });
|
|
36
|
-
const requestData = { tag };
|
|
37
|
-
const data = {
|
|
38
|
-
id: 1,
|
|
39
|
-
description: "foo",
|
|
40
|
-
_embedded: {
|
|
41
|
-
data_structure: { id: 1, external_id: "bar" },
|
|
42
|
-
data_structure_tag: { id: 2, name: "xyz" }
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
it("should put a success action when a response is returned", () => {
|
|
47
|
-
expect(() => {
|
|
48
|
-
testSaga(linkStructureTagSaga, { payload })
|
|
49
|
-
.next()
|
|
50
|
-
.put(linkStructureTag.request())
|
|
51
|
-
.next()
|
|
52
|
-
.call(apiJsonPatch, url, requestData, JSON_OPTS)
|
|
53
|
-
.next({ data })
|
|
54
|
-
.put(linkStructureTag.success(data))
|
|
55
|
-
.next()
|
|
56
|
-
.put(fetchLinksStructureTags.trigger(payload))
|
|
57
|
-
.next()
|
|
58
|
-
.put(linkStructureTag.fulfill())
|
|
59
|
-
.next()
|
|
60
|
-
.isDone();
|
|
61
|
-
}).not.toThrow();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should put a failure action when the call returns an error message", () => {
|
|
65
|
-
const message = "Request failed";
|
|
66
|
-
const error = { message };
|
|
67
|
-
|
|
68
|
-
expect(() => {
|
|
69
|
-
testSaga(linkStructureTagSaga, { payload })
|
|
70
|
-
.next()
|
|
71
|
-
.put(linkStructureTag.request())
|
|
72
|
-
.next()
|
|
73
|
-
.call(apiJsonPatch, url, requestData, JSON_OPTS)
|
|
74
|
-
.throw(error)
|
|
75
|
-
.put(linkStructureTag.failure(message))
|
|
76
|
-
.next()
|
|
77
|
-
.put(linkStructureTag.fulfill())
|
|
78
|
-
.next()
|
|
79
|
-
.isDone();
|
|
80
|
-
}).not.toThrow();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should put a failure action when the call returns an error response", () => {
|
|
84
|
-
const status = "foo";
|
|
85
|
-
const data = "bar";
|
|
86
|
-
const error = { response: { status, data } };
|
|
87
|
-
|
|
88
|
-
expect(() => {
|
|
89
|
-
testSaga(linkStructureTagSaga, { payload })
|
|
90
|
-
.next()
|
|
91
|
-
.put(linkStructureTag.request())
|
|
92
|
-
.next()
|
|
93
|
-
.call(apiJsonPatch, url, requestData, JSON_OPTS)
|
|
94
|
-
.throw(error)
|
|
95
|
-
.put(linkStructureTag.failure({ status, data }))
|
|
96
|
-
.next()
|
|
97
|
-
.put(linkStructureTag.fulfill())
|
|
98
|
-
.next()
|
|
99
|
-
.isDone();
|
|
100
|
-
}).not.toThrow();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { testSaga } from "redux-saga-test-plan";
|
|
2
|
-
import {
|
|
3
|
-
updateStructureTagRequestSaga,
|
|
4
|
-
updateStructureTagSaga,
|
|
5
|
-
} from "../updateStructureTag";
|
|
6
|
-
import { UPDATE_STRUCTURE_TAG } from "../../api/mutations";
|
|
7
|
-
import { updateStructureTag } from "../../routines";
|
|
8
|
-
|
|
9
|
-
describe("sagas: updateStructureTagRequestSaga", () => {
|
|
10
|
-
it("should invoke updateStructureTagSaga on updateStructureTag.TRIGGER", () => {
|
|
11
|
-
expect(() => {
|
|
12
|
-
testSaga(updateStructureTagRequestSaga)
|
|
13
|
-
.next()
|
|
14
|
-
.takeLatest(updateStructureTag.TRIGGER, updateStructureTagSaga)
|
|
15
|
-
.finish()
|
|
16
|
-
.isDone();
|
|
17
|
-
}).not.toThrow();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should throw exception if an unhandled action is received", () => {
|
|
21
|
-
expect(() => {
|
|
22
|
-
testSaga(updateStructureTagRequestSaga)
|
|
23
|
-
.next()
|
|
24
|
-
.takeLatest("FOO", updateStructureTagRequestSaga);
|
|
25
|
-
}).toThrow();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("sagas: updateStructureTagSaga", () => {
|
|
30
|
-
const client = { mutate: jest.fn() };
|
|
31
|
-
const structureTag = {
|
|
32
|
-
id: "123",
|
|
33
|
-
name: "tag1",
|
|
34
|
-
domainIds: ["1", "2"],
|
|
35
|
-
};
|
|
36
|
-
const payload = structureTag;
|
|
37
|
-
const variables = { id: structureTag.id, structureTag };
|
|
38
|
-
const data = { foo: "bar" };
|
|
39
|
-
|
|
40
|
-
it("should put a success action when a response is returned", () => {
|
|
41
|
-
expect(() => {
|
|
42
|
-
testSaga(updateStructureTagSaga, { payload })
|
|
43
|
-
.next()
|
|
44
|
-
.getContext("client")
|
|
45
|
-
.next(client)
|
|
46
|
-
.put(updateStructureTag.request(payload))
|
|
47
|
-
.next()
|
|
48
|
-
.call(client.mutate, {
|
|
49
|
-
mutation: UPDATE_STRUCTURE_TAG,
|
|
50
|
-
variables,
|
|
51
|
-
})
|
|
52
|
-
.next({ data })
|
|
53
|
-
.put(updateStructureTag.success(data))
|
|
54
|
-
.next()
|
|
55
|
-
.put(updateStructureTag.fulfill())
|
|
56
|
-
.next()
|
|
57
|
-
.isDone();
|
|
58
|
-
}).not.toThrow();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should put a failure action when the call returns an error", () => {
|
|
62
|
-
const message = "Request failed";
|
|
63
|
-
const error = { message };
|
|
64
|
-
|
|
65
|
-
expect(() => {
|
|
66
|
-
testSaga(updateStructureTagSaga, { payload })
|
|
67
|
-
.next()
|
|
68
|
-
.getContext("client")
|
|
69
|
-
.next(client)
|
|
70
|
-
.put(updateStructureTag.request(payload))
|
|
71
|
-
.next()
|
|
72
|
-
.call(client.mutate, {
|
|
73
|
-
mutation: UPDATE_STRUCTURE_TAG,
|
|
74
|
-
variables,
|
|
75
|
-
})
|
|
76
|
-
.throw(error)
|
|
77
|
-
.put(updateStructureTag.failure(message))
|
|
78
|
-
.next()
|
|
79
|
-
.put(updateStructureTag.fulfill())
|
|
80
|
-
.next()
|
|
81
|
-
.isDone();
|
|
82
|
-
}).not.toThrow();
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { call, put, takeLatest, getContext } from "redux-saga/effects";
|
|
2
|
-
import { CREATE_STRUCTURE_TAG } from "../api/mutations";
|
|
3
|
-
import { createStructureTag } from "../routines";
|
|
4
|
-
|
|
5
|
-
export const onSuccess = (cache) => {
|
|
6
|
-
cache.evict({ id: "ROOT_QUERY", fieldName: "structureTags" });
|
|
7
|
-
cache.gc();
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function* createStructureTagSaga({ payload }) {
|
|
11
|
-
const client = yield getContext("client");
|
|
12
|
-
try {
|
|
13
|
-
yield put(createStructureTag.request(payload));
|
|
14
|
-
const { data } = yield call(client.mutate, {
|
|
15
|
-
mutation: CREATE_STRUCTURE_TAG,
|
|
16
|
-
update: onSuccess,
|
|
17
|
-
variables: { structureTag: payload },
|
|
18
|
-
});
|
|
19
|
-
yield put(createStructureTag.success(data));
|
|
20
|
-
} catch (error) {
|
|
21
|
-
yield put(createStructureTag.failure(error.message));
|
|
22
|
-
} finally {
|
|
23
|
-
yield put(createStructureTag.fulfill());
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function* createStructureTagRequestSaga() {
|
|
28
|
-
yield takeLatest(createStructureTag.TRIGGER, createStructureTagSaga);
|
|
29
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
|
-
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
-
import { apiJsonDelete, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
-
import { fetchLinksStructureTags, deleteLinkStructureTag } from "../routines";
|
|
5
|
-
import { API_STRUCTURES_TAG } from "../api";
|
|
6
|
-
|
|
7
|
-
export function* deleteLinkStructureTagSaga({ payload }) {
|
|
8
|
-
try {
|
|
9
|
-
const { structureId: data_structure_id, tagId: id } = payload;
|
|
10
|
-
const url = compile(API_STRUCTURES_TAG)({ data_structure_id, id });
|
|
11
|
-
yield put(deleteLinkStructureTag.request());
|
|
12
|
-
const { data } = yield call(apiJsonDelete, url, JSON_OPTS);
|
|
13
|
-
yield put(deleteLinkStructureTag.success(data));
|
|
14
|
-
yield put(fetchLinksStructureTags.trigger(payload));
|
|
15
|
-
} catch (error) {
|
|
16
|
-
if (error.response) {
|
|
17
|
-
const { status, data } = error.response;
|
|
18
|
-
yield put(deleteLinkStructureTag.failure({ status, data }));
|
|
19
|
-
} else {
|
|
20
|
-
yield put(deleteLinkStructureTag.failure(error.message));
|
|
21
|
-
}
|
|
22
|
-
} finally {
|
|
23
|
-
yield put(deleteLinkStructureTag.fulfill());
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function* deleteLinkStructureTagRequestSaga() {
|
|
28
|
-
yield takeLatest(deleteLinkStructureTag.TRIGGER, deleteLinkStructureTagSaga);
|
|
29
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
|
-
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
-
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
-
import { fetchLinksStructureTags } from "../routines";
|
|
5
|
-
import { API_STRUCTURES_TAGS } from "../api";
|
|
6
|
-
|
|
7
|
-
export function* fetchLinksStructureTagsSaga({ payload }) {
|
|
8
|
-
try {
|
|
9
|
-
const { structureId: data_structure_id } = payload;
|
|
10
|
-
const url = compile(API_STRUCTURES_TAGS)({ data_structure_id });
|
|
11
|
-
yield put(fetchLinksStructureTags.request());
|
|
12
|
-
const { data } = yield call(apiJson, url, JSON_OPTS);
|
|
13
|
-
yield put(fetchLinksStructureTags.success(data));
|
|
14
|
-
} catch (error) {
|
|
15
|
-
if (error.response) {
|
|
16
|
-
const { status, data } = error.response;
|
|
17
|
-
yield put(fetchLinksStructureTags.failure({ status, data }));
|
|
18
|
-
} else {
|
|
19
|
-
yield put(fetchLinksStructureTags.failure(error.message));
|
|
20
|
-
}
|
|
21
|
-
} finally {
|
|
22
|
-
yield put(fetchLinksStructureTags.fulfill());
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function* fetchLinksStructureTagsRequestSaga() {
|
|
27
|
-
yield takeLatest(
|
|
28
|
-
fetchLinksStructureTags.TRIGGER,
|
|
29
|
-
fetchLinksStructureTagsSaga
|
|
30
|
-
);
|
|
31
|
-
}
|