@truedat/bg 7.8.3 → 7.8.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/package.json +3 -3
- package/src/concepts/relations/components/ConceptLinkstRequestGrantButton.js +1 -10
- package/src/concepts/relations/components/ConceptStructureLinks.js +0 -1
- package/src/concepts/relations/components/__tests__/ConceptLinksActions.spec.js +2 -2
- package/src/concepts/relations/components/__tests__/ConceptLinkstRequestGrantButton.spec.js +18 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/bg",
|
|
3
|
-
"version": "7.8.
|
|
3
|
+
"version": "7.8.4",
|
|
4
4
|
"description": "Truedat Web Business Glossary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "7.8.
|
|
51
|
+
"@truedat/test": "7.8.4",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
82
82
|
"swr": "^2.3.3"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "9132f94c91f8a749e0363ef1d6ce8af40284236d"
|
|
85
85
|
}
|
|
@@ -18,21 +18,12 @@ export const ConceptLinkstRequestGrantButton = ({
|
|
|
18
18
|
|
|
19
19
|
const requestAllStructures = () => {
|
|
20
20
|
_.forEach((structure) => {
|
|
21
|
-
const authorizedRequest = _.pathOr(
|
|
22
|
-
false,
|
|
23
|
-
"request_grant"
|
|
24
|
-
)(structure.user_permissions);
|
|
25
|
-
|
|
26
21
|
const isRequested = _.flow(
|
|
27
22
|
_.find({ id: `${structure.id}` }),
|
|
28
23
|
_.negate(_.isUndefined)
|
|
29
24
|
)(requested);
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
_.has("my_grant_request")(structure) &&
|
|
33
|
-
_.get("my_grant_request.status")(structure) !== "rejected";
|
|
34
|
-
|
|
35
|
-
if (authorizedRequest && !isRequested && !granted)
|
|
26
|
+
if (!isRequested)
|
|
36
27
|
addGrantRequestToCart({
|
|
37
28
|
...structure,
|
|
38
29
|
id: `${structure.id}`,
|
|
@@ -23,7 +23,6 @@ const ConceptStructureLinksSegment = ({ groups, visible }) => {
|
|
|
23
23
|
const { conceptContext, setConceptContextProperty } = useConceptContext();
|
|
24
24
|
const { searchData, loading } = useSearchContext();
|
|
25
25
|
const structures = searchData?.data;
|
|
26
|
-
|
|
27
26
|
const { grantView } = conceptContext;
|
|
28
27
|
|
|
29
28
|
const onGrantViewChange = (grantViewNewState) =>
|
|
@@ -28,7 +28,7 @@ const renderOpts = {
|
|
|
28
28
|
|
|
29
29
|
describe("<ConceptLinksActions />", () => {
|
|
30
30
|
it("matches the latest snapshot with Grant Requests permission", async () => {
|
|
31
|
-
useSearchContext.mockReturnValue({ searchData: [] });
|
|
31
|
+
useSearchContext.mockReturnValue({ searchData: { data: [] } });
|
|
32
32
|
|
|
33
33
|
const grRenderOpts = {
|
|
34
34
|
...renderOpts,
|
|
@@ -52,7 +52,7 @@ describe("<ConceptLinksActions />", () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
it("matches the latest snapshot without Grant Requests permission", async () => {
|
|
55
|
-
useSearchContext.mockReturnValue({ searchData: [] });
|
|
55
|
+
useSearchContext.mockReturnValue({ searchData: { data: [] } });
|
|
56
56
|
|
|
57
57
|
const rendered = render(
|
|
58
58
|
<ConceptLinksActions onGrantViewChange={jest.fn()} />,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import userEvent from "@testing-library/user-event";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
4
|
import { useSearchContext } from "@truedat/core/search/SearchContext";
|
|
4
|
-
import ConceptLinkstRequestGrantButton from "../ConceptLinkstRequestGrantButton";
|
|
5
|
+
import { ConceptLinkstRequestGrantButton } from "../ConceptLinkstRequestGrantButton";
|
|
5
6
|
|
|
6
7
|
jest.mock("@truedat/core/search/SearchContext", () => {
|
|
7
8
|
const originalModule = jest.requireActual(
|
|
@@ -34,4 +35,19 @@ describe("<ConceptLinkstRequestGrantButton />", () => {
|
|
|
34
35
|
|
|
35
36
|
expect(container).toMatchSnapshot();
|
|
36
37
|
});
|
|
38
|
+
|
|
39
|
+
it("should not add a structure to the cart if it is already requested", async () => {
|
|
40
|
+
const addGrantRequestToCart = jest.fn();
|
|
41
|
+
useSearchContext.mockReturnValue({ searchData: { data: [{ id: "1" }, { id: "2" }] } });
|
|
42
|
+
|
|
43
|
+
const rendered = render(
|
|
44
|
+
<ConceptLinkstRequestGrantButton onGrantViewChange={jest.fn()} addGrantRequestToCart={addGrantRequestToCart} />,
|
|
45
|
+
{ state: { grantRequestsCart: { structures: [{ id: "1" }] } } }
|
|
46
|
+
);
|
|
47
|
+
await waitForLoad(rendered);
|
|
48
|
+
const user = userEvent.setup({ delay: null });
|
|
49
|
+
await user.click(rendered.getByRole("button"));
|
|
50
|
+
|
|
51
|
+
expect(addGrantRequestToCart).toHaveBeenCalledWith({ id: "2" });
|
|
52
|
+
});
|
|
37
53
|
});
|