@truedat/lm 8.7.0 → 8.7.2
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/components/ConceptLinkForm.js +6 -6
- package/src/components/ConceptStructureLinkForm.js +1 -1
- package/src/components/ConceptSuggestionLinkForm.js +1 -1
- package/src/components/ImplementationLinks.js +4 -4
- package/src/components/ImplementationRelationForm.js +3 -3
- package/src/components/LinksPane.js +3 -3
- package/src/components/LinksSearch.js +1 -1
- package/src/components/QualityControlConcepts.js +1 -1
- package/src/components/QualityControlStructures.js +4 -2
- package/src/components/RelationGraph.js +20 -12
- package/src/components/RelationGraphDepth.js +22 -7
- package/src/components/RelationTagForm.js +2 -2
- package/src/components/RelationTagsLoader.js +1 -1
- package/src/components/RelationsLoader.js +1 -1
- package/src/components/StructureLinkForm.js +6 -6
- package/src/components/StructureLinks.js +3 -3
- package/src/components/StructureRelationForm.js +3 -3
- package/src/components/StructureSuggestionLinkForm.js +54 -50
- package/src/components/TagTypeDropdownSelector.js +4 -4
- package/src/components/__tests__/ConceptImplementationLink.spec.js +1 -1
- package/src/components/__tests__/ConceptLinkForm.spec.js +5 -5
- package/src/components/__tests__/ConceptSuggestionLinkForm.spec.js +7 -8
- package/src/components/__tests__/ConfirmDeleteRelation.spec.js +1 -1
- package/src/components/__tests__/ImplementationLinkRow.spec.js +1 -1
- package/src/components/__tests__/ImplementationLinks.spec.js +2 -2
- package/src/components/__tests__/ImplementationRelationForm.spec.js +8 -8
- package/src/components/__tests__/LinksPane.spec.js +28 -5
- package/src/components/__tests__/LinksSearch.spec.js +13 -13
- package/src/components/__tests__/QualityControlConcepts.spec.js +23 -23
- package/src/components/__tests__/QualityControlStructures.spec.js +15 -15
- package/src/components/__tests__/RelationRoutes.spec.js +3 -3
- package/src/components/__tests__/RelationRow.spec.js +4 -4
- package/src/components/__tests__/RelationTagForm.spec.js +7 -7
- package/src/components/__tests__/Relations.spec.js +1 -1
- package/src/components/__tests__/RelationsLoader.spec.js +1 -1
- package/src/components/__tests__/StructureLinkForm.spec.js +6 -6
- package/src/components/__tests__/StructureRelationForm.spec.js +9 -9
- package/src/components/__tests__/StructureSuggestionLinkForm.spec.js +87 -85
- package/src/hooks/useRelations.js +6 -5
- package/src/messages/en.js +2 -1
- package/src/messages/es.js +2 -1
- package/src/messages/index.js +1 -1
- package/src/reducers/__tests__/handlingRelation.spec.js +3 -3
- package/src/reducers/__tests__/relationRedirect.spec.js +8 -8
- package/src/reducers/__tests__/relationTags.spec.js +4 -4
- package/src/reducers/__tests__/relationTagsLoading.spec.js +2 -2
- package/src/reducers/__tests__/relations.spec.js +4 -4
- package/src/reducers/__tests__/relationsActions.spec.js +6 -6
- package/src/reducers/__tests__/relationsGraph.spec.js +21 -21
- package/src/reducers/__tests__/relationsGraphLoading.spec.js +2 -2
- package/src/reducers/__tests__/relationsLoading.spec.js +2 -2
- package/src/reducers/__tests__/selectedRelationTags.spec.js +5 -5
- package/src/reducers/relationTags.js +1 -1
- package/src/reducers/selectedRelationTags.js +1 -1
- package/src/routines.js +2 -2
- package/src/sagas/createRelation.js +1 -1
- package/src/sagas/createRelationTag.js +1 -1
- package/src/sagas/fetchRelations.js +1 -1
- package/src/sagas/updateRelationTag.js +1 -1
- package/src/selectors/getImplementationToConceptLinks.js +1 -1
- package/src/selectors/getStructureLinks.js +1 -1
- package/src/selectors/index.js +1 -1
- package/src/selectors/messages.js +3 -2
- package/src/services/__tests__/edgeColorPalette.spec.js +3 -5
- package/src/services/__tests__/relationGraphTraversal.spec.js +2 -2
- package/src/services/edgeColorPalette.js +6 -1
- package/src/services/relationGraphTraversal.js +14 -14
|
@@ -22,7 +22,7 @@ describe("<RelationRow />", () => {
|
|
|
22
22
|
<tbody>
|
|
23
23
|
<RelationRow {...defaultProps} />
|
|
24
24
|
</tbody>
|
|
25
|
-
</table
|
|
25
|
+
</table>,
|
|
26
26
|
);
|
|
27
27
|
await waitForLoad(rendered);
|
|
28
28
|
expect(rendered.container).toMatchSnapshot();
|
|
@@ -34,7 +34,7 @@ describe("<RelationRow />", () => {
|
|
|
34
34
|
<tbody>
|
|
35
35
|
<RelationRow {...defaultProps} />
|
|
36
36
|
</tbody>
|
|
37
|
-
</table
|
|
37
|
+
</table>,
|
|
38
38
|
);
|
|
39
39
|
await waitForLoad(rendered);
|
|
40
40
|
expect(rendered.container.firstChild.firstChild.firstChild).toBeNull();
|
|
@@ -47,7 +47,7 @@ describe("<RelationRow />", () => {
|
|
|
47
47
|
<tbody>
|
|
48
48
|
<RelationRow {...{ ...defaultProps, relationContext }} />
|
|
49
49
|
</tbody>
|
|
50
|
-
</table
|
|
50
|
+
</table>,
|
|
51
51
|
);
|
|
52
52
|
await waitForLoad(rendered);
|
|
53
53
|
expect(rendered.container.querySelectorAll("tr").length).toBe(1);
|
|
@@ -64,7 +64,7 @@ describe("<RelationRow />", () => {
|
|
|
64
64
|
<tbody>
|
|
65
65
|
<RelationRow {...{ ...defaultProps, relationContext }} />
|
|
66
66
|
</tbody>
|
|
67
|
-
</table
|
|
67
|
+
</table>,
|
|
68
68
|
);
|
|
69
69
|
await waitForLoad(rendered);
|
|
70
70
|
expect(rendered.container.querySelectorAll("tr").length).toBe(1);
|
|
@@ -16,24 +16,24 @@ describe("<RelationTagForm />", () => {
|
|
|
16
16
|
const user = userEvent.setup({ delay: null });
|
|
17
17
|
|
|
18
18
|
const rendered = render(
|
|
19
|
-
<RelationTagForm onSubmit={(props) => onSubmit(props)}
|
|
19
|
+
<RelationTagForm onSubmit={(props) => onSubmit(props)} />,
|
|
20
20
|
);
|
|
21
21
|
await waitForLoad(rendered);
|
|
22
22
|
|
|
23
23
|
// Submit button should initially be disabled
|
|
24
24
|
await waitFor(() =>
|
|
25
|
-
expect(rendered.getByRole("button", { name: /create/i })).toBeDisabled()
|
|
25
|
+
expect(rendered.getByRole("button", { name: /create/i })).toBeDisabled(),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
// Input name
|
|
29
29
|
await user.type(
|
|
30
30
|
await rendered.findByRole("textbox", { name: /type/i }),
|
|
31
|
-
"foo"
|
|
31
|
+
"foo",
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
// Select type
|
|
35
35
|
await user.click(
|
|
36
|
-
await rendered.findByText("relationTags.props.target_type")
|
|
36
|
+
await rendered.findByText("relationTags.props.target_type"),
|
|
37
37
|
);
|
|
38
38
|
await user.click(await rendered.findByRole("option", { name: /concept/i }));
|
|
39
39
|
|
|
@@ -46,8 +46,8 @@ describe("<RelationTagForm />", () => {
|
|
|
46
46
|
// Submit button should now be enabled
|
|
47
47
|
await waitFor(() =>
|
|
48
48
|
expect(
|
|
49
|
-
rendered.getByRole("button", { name: /create/i })
|
|
50
|
-
).not.toBeDisabled()
|
|
49
|
+
rendered.getByRole("button", { name: /create/i }),
|
|
50
|
+
).not.toBeDisabled(),
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
// Submit
|
|
@@ -58,7 +58,7 @@ describe("<RelationTagForm />", () => {
|
|
|
58
58
|
type: "foo",
|
|
59
59
|
target_type: "business_concept",
|
|
60
60
|
expandable: true,
|
|
61
|
-
})
|
|
61
|
+
}),
|
|
62
62
|
);
|
|
63
63
|
});
|
|
64
64
|
});
|
|
@@ -31,7 +31,7 @@ describe("<RelationsLoader />", () => {
|
|
|
31
31
|
await waitForLoad(rendered);
|
|
32
32
|
expect(props.fetchRelations).toHaveBeenCalledTimes(1);
|
|
33
33
|
rendered.rerender(
|
|
34
|
-
<RelationsLoader {...props} target_type="new target_type"
|
|
34
|
+
<RelationsLoader {...props} target_type="new target_type" />,
|
|
35
35
|
);
|
|
36
36
|
expect(props.fetchRelations).toHaveBeenCalledTimes(2);
|
|
37
37
|
});
|
|
@@ -53,7 +53,7 @@ jest.mock("../../routines", () => ({
|
|
|
53
53
|
}));
|
|
54
54
|
|
|
55
55
|
jest.mock("../RelationTagsLoader", () =>
|
|
56
|
-
jest.fn(() => <div>RelationTagsLoader</div>)
|
|
56
|
+
jest.fn(() => <div>RelationTagsLoader</div>),
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
jest.mock("@truedat/lm/components/TagTypeDropdownSelector", () =>
|
|
@@ -69,7 +69,7 @@ jest.mock("@truedat/lm/components/TagTypeDropdownSelector", () =>
|
|
|
69
69
|
</button>
|
|
70
70
|
))}
|
|
71
71
|
</div>
|
|
72
|
-
))
|
|
72
|
+
)),
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
jest.mock("@truedat/dd/components/StructureSelector", () =>
|
|
@@ -90,7 +90,7 @@ jest.mock("@truedat/dd/components/StructureSelector", () =>
|
|
|
90
90
|
<div data-testid="selected-structure">{selectedStructure.name}</div>
|
|
91
91
|
)}
|
|
92
92
|
</div>
|
|
93
|
-
))
|
|
93
|
+
)),
|
|
94
94
|
);
|
|
95
95
|
|
|
96
96
|
jest.mock("@truedat/core/components", () => ({
|
|
@@ -229,7 +229,7 @@ describe("<StructureLinkForm />", () => {
|
|
|
229
229
|
header: "relations.create.failed.header",
|
|
230
230
|
icon: "attention",
|
|
231
231
|
content: expect.any(String),
|
|
232
|
-
})
|
|
232
|
+
}),
|
|
233
233
|
);
|
|
234
234
|
});
|
|
235
235
|
});
|
|
@@ -273,12 +273,12 @@ describe("<StructureLinkForm />", () => {
|
|
|
273
273
|
const rendered = render(
|
|
274
274
|
<StructureLinkForm
|
|
275
275
|
{...{ ...props, selectTagOptions: jest.fn(() => []) }}
|
|
276
|
-
|
|
276
|
+
/>,
|
|
277
277
|
);
|
|
278
278
|
await waitForLoad(rendered);
|
|
279
279
|
|
|
280
280
|
expect(
|
|
281
|
-
rendered.queryByText("TagTypeDropdownSelector")
|
|
281
|
+
rendered.queryByText("TagTypeDropdownSelector"),
|
|
282
282
|
).not.toBeInTheDocument();
|
|
283
283
|
});
|
|
284
284
|
});
|
|
@@ -50,7 +50,7 @@ const filterData = {
|
|
|
50
50
|
|
|
51
51
|
jest.mock("@truedat/bg/concepts/hooks/useConcepts", () => {
|
|
52
52
|
const originalModule = jest.requireActual(
|
|
53
|
-
"@truedat/bg/concepts/hooks/useConcepts"
|
|
53
|
+
"@truedat/bg/concepts/hooks/useConcepts",
|
|
54
54
|
);
|
|
55
55
|
|
|
56
56
|
return {
|
|
@@ -124,7 +124,7 @@ describe("<StructureRelationForm />", () => {
|
|
|
124
124
|
await waitForLoad(rendered);
|
|
125
125
|
|
|
126
126
|
await waitFor(() =>
|
|
127
|
-
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
127
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument(),
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
await waitFor(() => {
|
|
@@ -132,7 +132,7 @@ describe("<StructureRelationForm />", () => {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
await waitFor(() =>
|
|
135
|
-
expect(rendered.getByText(/foo concept/i)).toBeInTheDocument()
|
|
135
|
+
expect(rendered.getByText(/foo concept/i)).toBeInTheDocument(),
|
|
136
136
|
);
|
|
137
137
|
|
|
138
138
|
expect(rendered.container).toMatchSnapshot();
|
|
@@ -146,11 +146,11 @@ describe("<StructureRelationForm />", () => {
|
|
|
146
146
|
|
|
147
147
|
const rendered = render(
|
|
148
148
|
<StructureRelationForm {...newProps} />,
|
|
149
|
-
renderOpts
|
|
149
|
+
renderOpts,
|
|
150
150
|
);
|
|
151
151
|
|
|
152
152
|
await waitFor(() =>
|
|
153
|
-
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
153
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument(),
|
|
154
154
|
);
|
|
155
155
|
|
|
156
156
|
expect(rendered.queryByRole("button", { name: /create/i })).toBeDisabled();
|
|
@@ -160,15 +160,15 @@ describe("<StructureRelationForm />", () => {
|
|
|
160
160
|
await user.click(await rendered.findByText(/bar concept/i));
|
|
161
161
|
|
|
162
162
|
await waitFor(() =>
|
|
163
|
-
expect(rendered.queryByRole("button", { name: /create/i })).toBeEnabled()
|
|
163
|
+
expect(rendered.queryByRole("button", { name: /create/i })).toBeEnabled(),
|
|
164
164
|
);
|
|
165
165
|
|
|
166
166
|
await user.click(await rendered.findByRole("button", { name: /create/i }));
|
|
167
167
|
|
|
168
168
|
await waitFor(() =>
|
|
169
169
|
expect(rendered.queryByRole("button", { name: /create/i })).toHaveClass(
|
|
170
|
-
"loading"
|
|
171
|
-
)
|
|
170
|
+
"loading",
|
|
171
|
+
),
|
|
172
172
|
);
|
|
173
173
|
});
|
|
174
174
|
|
|
@@ -177,7 +177,7 @@ describe("<StructureRelationForm />", () => {
|
|
|
177
177
|
await waitForLoad(rendered);
|
|
178
178
|
|
|
179
179
|
await waitFor(() =>
|
|
180
|
-
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
180
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument(),
|
|
181
181
|
);
|
|
182
182
|
|
|
183
183
|
const user = userEvent.setup({ delay: null });
|
|
@@ -1,127 +1,129 @@
|
|
|
1
1
|
import { fireEvent, screen, waitFor } from "@testing-library/react";
|
|
2
2
|
import { render } from "@truedat/test/render";
|
|
3
|
-
import { StructureSuggestionLinkForm } from "../StructureSuggestionLinkForm";
|
|
4
3
|
import { useDispatch } from "react-redux";
|
|
5
4
|
import { useParams } from "react-router";
|
|
5
|
+
import { StructureSuggestionLinkForm } from "../StructureSuggestionLinkForm";
|
|
6
6
|
import { linkConcept, clearSelectedRelationTags } from "../../routines";
|
|
7
7
|
|
|
8
8
|
jest.mock("react-redux", () => ({
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
...jest.requireActual("react-redux"),
|
|
10
|
+
useDispatch: jest.fn(),
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
13
|
jest.mock("react-router", () => ({
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
...jest.requireActual("react-router"),
|
|
15
|
+
useParams: jest.fn(),
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
jest.mock("react-intl", () => ({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
...jest.requireActual("react-intl"),
|
|
20
|
+
useIntl: () => ({
|
|
21
|
+
formatMessage: ({ id }) => id,
|
|
22
|
+
}),
|
|
24
23
|
}));
|
|
25
24
|
|
|
26
|
-
|
|
27
25
|
// Mock components
|
|
28
26
|
jest.mock("@truedat/ai/components/ConceptSuggestions", () =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
jest.fn((props) => {
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<div>MockConceptSuggestions</div>
|
|
31
|
+
<button
|
|
32
|
+
onClick={() =>
|
|
33
|
+
props.handleConceptSelected({ business_concept_id: "concept123" })
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
Select Concept
|
|
37
|
+
</button>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}),
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
jest.mock("../TagTypeDropdownSelector", () =>
|
|
44
|
-
|
|
44
|
+
jest.fn(() => <div>MockTagTypeDropdownSelector</div>),
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
jest.mock("../RelationTagsLoader", () =>
|
|
48
|
-
|
|
48
|
+
jest.fn(() => <div>RelationTagsLoader</div>),
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
jest.mock("@truedat/core/components", () => ({
|
|
52
|
-
|
|
52
|
+
HistoryBackButton: (props) => <button>{props.content}</button>,
|
|
53
53
|
}));
|
|
54
54
|
|
|
55
55
|
jest.mock("@truedat/core/routes", () => ({
|
|
56
|
-
|
|
56
|
+
linkTo: { STRUCTURE_LINKS: jest.fn(() => "/mocked/redirect/url") },
|
|
57
57
|
}));
|
|
58
58
|
|
|
59
59
|
describe("StructureSuggestionLinkForm", () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
60
|
+
const mockDispatch = jest.fn();
|
|
61
|
+
const selectedRelationTags = ["tag1"];
|
|
62
|
+
const relationTags = [
|
|
63
|
+
{
|
|
64
|
+
id: "tag1",
|
|
65
|
+
value: {
|
|
66
|
+
type: "tag1",
|
|
67
|
+
label: "tag1",
|
|
68
|
+
target_type: "data_field",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
const conceptLinking = false;
|
|
73
|
+
const state = { selectedRelationTags, relationTags, conceptLinking };
|
|
74
|
+
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
jest.clearAllMocks();
|
|
77
|
+
|
|
78
|
+
useParams.mockReturnValue({ id: "s1" });
|
|
79
|
+
useDispatch.mockReturnValue(mockDispatch);
|
|
80
|
+
|
|
81
|
+
clearSelectedRelationTags.trigger = jest.fn(() => ({ type: "CLEAR_TAGS" }));
|
|
82
|
+
linkConcept.trigger = jest.fn((payload) => ({
|
|
83
|
+
type: "LINK_CONCEPT",
|
|
84
|
+
payload,
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("renders concepet suggestions and tag dropdown", async () => {
|
|
89
|
+
render(<StructureSuggestionLinkForm />, { state });
|
|
90
|
+
|
|
91
|
+
await waitFor(() => {
|
|
92
|
+
expect(screen.getByText("MockConceptSuggestions")).toBeInTheDocument();
|
|
93
|
+
expect(screen.getByText("actions.create")).toBeDisabled();
|
|
93
94
|
});
|
|
95
|
+
});
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
fireEvent.click(screen.getByText("Select Concept"));
|
|
97
|
+
it("dispatches linkConcept on submit", async () => {
|
|
98
|
+
render(<StructureSuggestionLinkForm />, { state });
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
expect(createBtn).not.toBeDisabled();
|
|
100
|
+
fireEvent.click(screen.getByText("Select Concept"));
|
|
102
101
|
|
|
103
|
-
|
|
102
|
+
const createBtn = screen.getByText("actions.create");
|
|
103
|
+
expect(createBtn).not.toBeDisabled();
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
redirectUrl: "/mocked/redirect/url",
|
|
107
|
-
source_id: "concept123",
|
|
108
|
-
source_type: "business_concept",
|
|
109
|
-
target_id: "s1",
|
|
110
|
-
target_type: "data_structure",
|
|
111
|
-
tag_ids: ["tag1"],
|
|
112
|
-
origin: "suggested",
|
|
113
|
-
});
|
|
105
|
+
fireEvent.click(createBtn);
|
|
114
106
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
expect(linkConcept.trigger).toHaveBeenCalledWith({
|
|
108
|
+
redirectUrl: "/mocked/redirect/url",
|
|
109
|
+
source_id: "concept123",
|
|
110
|
+
source_type: "business_concept",
|
|
111
|
+
target_id: "s1",
|
|
112
|
+
target_type: "data_structure",
|
|
113
|
+
tag_ids: ["tag1"],
|
|
114
|
+
origin: "suggested",
|
|
118
115
|
});
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
expect(mockDispatch).toHaveBeenCalledWith(
|
|
118
|
+
expect.objectContaining({ type: "LINK_CONCEPT" }),
|
|
119
|
+
);
|
|
120
|
+
});
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
it("dispatches clearSelectedRelationTags on unmount", () => {
|
|
123
|
+
const { unmount } = render(<StructureSuggestionLinkForm />, { state });
|
|
124
|
+
unmount();
|
|
125
|
+
|
|
126
|
+
expect(clearSelectedRelationTags.trigger).toHaveBeenCalled();
|
|
127
|
+
expect(mockDispatch).toHaveBeenCalledWith({ type: "CLEAR_TAGS" });
|
|
128
|
+
});
|
|
127
129
|
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import useSWRMutations from "swr/mutation";
|
|
2
2
|
import { apiJsonPost, apiJsonDelete } from "@truedat/core/services/api";
|
|
3
|
+
import { compile } from "path-to-regexp";
|
|
3
4
|
import {
|
|
4
5
|
API_RELATION,
|
|
5
6
|
API_RELATIONS,
|
|
6
7
|
API_RELATIONS_INDEX_SEARCH,
|
|
7
8
|
API_RELATIONS_FILTERS,
|
|
8
9
|
} from "../api";
|
|
9
|
-
import { compile } from "path-to-regexp";
|
|
10
10
|
|
|
11
11
|
export const useRelations = (params) => {
|
|
12
12
|
const query = queryString(params);
|
|
13
13
|
return useSWRMutations(API_RELATIONS_INDEX_SEARCH, (url, { arg }) =>
|
|
14
|
-
apiJsonPost(`${url}${query}`, arg)
|
|
14
|
+
apiJsonPost(`${url}${query}`, arg),
|
|
15
15
|
);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const useRelationFilters = (params) => {
|
|
19
19
|
const query = queryString(params);
|
|
20
20
|
return useSWRMutations(API_RELATIONS_FILTERS, (url, { arg }) =>
|
|
21
|
-
apiJsonPost(`${url}${query}`, arg)
|
|
21
|
+
apiJsonPost(`${url}${query}`, arg),
|
|
22
22
|
);
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -33,18 +33,19 @@ export const useCreateRelation = () => {
|
|
|
33
33
|
// The error will still be available in the catch block
|
|
34
34
|
if (error?.response?.data?.errors) {
|
|
35
35
|
// Store original errors for our custom handling
|
|
36
|
+
// eslint-disable-next-line fp/no-mutation
|
|
36
37
|
error._originalErrors = error.response.data.errors;
|
|
37
38
|
// Remove errors so middleware doesn't dispatch logError
|
|
38
39
|
delete error.response.data.errors;
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
|
-
}
|
|
42
|
+
},
|
|
42
43
|
);
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
export const useDeleteRelation = () => {
|
|
46
47
|
return useSWRMutations(API_RELATION, (_url, { arg }) =>
|
|
47
|
-
apiJsonDelete(compile(API_RELATION)({ id: `${arg}` }))
|
|
48
|
+
apiJsonDelete(compile(API_RELATION)({ id: `${arg}` })),
|
|
48
49
|
);
|
|
49
50
|
};
|
|
50
51
|
|
package/src/messages/en.js
CHANGED
|
@@ -2,7 +2,8 @@ export default {
|
|
|
2
2
|
"implementations.relation.new.header": "Link to Concept",
|
|
3
3
|
"links.actions.suggest": "Suggest Link",
|
|
4
4
|
"links.suggest.prompt.label": "Prompt",
|
|
5
|
-
"links.suggest.prompt.placeholder":
|
|
5
|
+
"links.suggest.prompt.placeholder":
|
|
6
|
+
"Additional prompt to help find related structures (optional)",
|
|
6
7
|
"links.suggest.submit": "Search suggestions",
|
|
7
8
|
"implementations.linked_concepts.empty": "No linked business concepts found",
|
|
8
9
|
"links.actions.create": "Add Link",
|
package/src/messages/es.js
CHANGED
|
@@ -2,7 +2,8 @@ export default {
|
|
|
2
2
|
"implementations.linked_concepts.empty": "No hay conceptos relacionados",
|
|
3
3
|
"links.actions.suggest": "Sugerir vínculo",
|
|
4
4
|
"links.suggest.prompt.label": "Prompt",
|
|
5
|
-
"links.suggest.prompt.placeholder":
|
|
5
|
+
"links.suggest.prompt.placeholder":
|
|
6
|
+
"Contexto adicional para encontrar estructuras relacionadas (opcional)",
|
|
6
7
|
"links.suggest.submit": "Buscar sugerencias",
|
|
7
8
|
"implementations.relation.new.header":
|
|
8
9
|
"Vas a vincular esta implementación a un término del glosario",
|
package/src/messages/index.js
CHANGED
|
@@ -13,13 +13,13 @@ describe("reducers: handlingRelation", () => {
|
|
|
13
13
|
|
|
14
14
|
it("should handle the createRelation.SUCCESS action", () => {
|
|
15
15
|
expect(
|
|
16
|
-
handlingRelation(fooState, { type: createRelation.SUCCESS, payload })
|
|
16
|
+
handlingRelation(fooState, { type: createRelation.SUCCESS, payload }),
|
|
17
17
|
).toEqual(fooState);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it("should handle the createRelation.FAILURE action", () => {
|
|
21
21
|
expect(
|
|
22
|
-
handlingRelation(fooState, { type: createRelation.FAILURE })
|
|
22
|
+
handlingRelation(fooState, { type: createRelation.FAILURE }),
|
|
23
23
|
).toEqual(false);
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -28,7 +28,7 @@ describe("reducers: handlingRelation", () => {
|
|
|
28
28
|
handlingRelation(fooState, {
|
|
29
29
|
type: deleteRelation.SUCCESS,
|
|
30
30
|
meta: { id: "1" },
|
|
31
|
-
})
|
|
31
|
+
}),
|
|
32
32
|
).toEqual({ id: "1" });
|
|
33
33
|
});
|
|
34
34
|
});
|
|
@@ -2,7 +2,7 @@ import { clearRedirect } from "@truedat/core/routines";
|
|
|
2
2
|
import {
|
|
3
3
|
createRelation,
|
|
4
4
|
createRelationTag,
|
|
5
|
-
deleteRelationTag
|
|
5
|
+
deleteRelationTag,
|
|
6
6
|
} from "../../routines";
|
|
7
7
|
import { relationRedirect } from "..";
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ describe("reducers: relationRedirect", () => {
|
|
|
16
16
|
|
|
17
17
|
it("should handle the clearRedirect.TRIGGER action", () => {
|
|
18
18
|
expect(relationRedirect("foo", { type: clearRedirect.TRIGGER })).toEqual(
|
|
19
|
-
initialState
|
|
19
|
+
initialState,
|
|
20
20
|
);
|
|
21
21
|
});
|
|
22
22
|
|
|
@@ -24,8 +24,8 @@ describe("reducers: relationRedirect", () => {
|
|
|
24
24
|
expect(
|
|
25
25
|
relationRedirect("foo", {
|
|
26
26
|
type: createRelation.SUCCESS,
|
|
27
|
-
meta: { redirectUrl: "bar" }
|
|
28
|
-
})
|
|
27
|
+
meta: { redirectUrl: "bar" },
|
|
28
|
+
}),
|
|
29
29
|
).toEqual("bar");
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -33,8 +33,8 @@ describe("reducers: relationRedirect", () => {
|
|
|
33
33
|
expect(
|
|
34
34
|
relationRedirect("foo", {
|
|
35
35
|
type: createRelationTag.SUCCESS,
|
|
36
|
-
meta: { redirectUrl: "bar" }
|
|
37
|
-
})
|
|
36
|
+
meta: { redirectUrl: "bar" },
|
|
37
|
+
}),
|
|
38
38
|
).toEqual("bar");
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -42,8 +42,8 @@ describe("reducers: relationRedirect", () => {
|
|
|
42
42
|
expect(
|
|
43
43
|
relationRedirect("foo", {
|
|
44
44
|
type: deleteRelationTag.SUCCESS,
|
|
45
|
-
meta: { redirectUrl: "bar" }
|
|
46
|
-
})
|
|
45
|
+
meta: { redirectUrl: "bar" },
|
|
46
|
+
}),
|
|
47
47
|
).toEqual("bar");
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -12,13 +12,13 @@ describe("reducers: relationTags", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the clearRelationTags.TRIGGER action", () => {
|
|
14
14
|
expect(relationTags(fooState, { type: clearRelationTags.TRIGGER })).toEqual(
|
|
15
|
-
initialState
|
|
15
|
+
initialState,
|
|
16
16
|
);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should handle the fetchRelationTags.FAILURE action", () => {
|
|
20
20
|
expect(relationTags(fooState, { type: fetchRelationTags.FAILURE })).toEqual(
|
|
21
|
-
initialState
|
|
21
|
+
initialState,
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -29,8 +29,8 @@ describe("reducers: relationTags", () => {
|
|
|
29
29
|
expect(
|
|
30
30
|
relationTags(fooState, {
|
|
31
31
|
type: fetchRelationTags.SUCCESS,
|
|
32
|
-
payload: { data }
|
|
33
|
-
})
|
|
32
|
+
payload: { data },
|
|
33
|
+
}),
|
|
34
34
|
).toEqual(collection);
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -10,13 +10,13 @@ describe("reducers: relationTagsLoading", () => {
|
|
|
10
10
|
|
|
11
11
|
it("should be true after receiving the fetchRelationTags.TRIGGER action", () => {
|
|
12
12
|
expect(
|
|
13
|
-
relationTagsLoading(fooState, { type: fetchRelationTags.TRIGGER })
|
|
13
|
+
relationTagsLoading(fooState, { type: fetchRelationTags.TRIGGER }),
|
|
14
14
|
).toBe(true);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it("should be false after receiving the fetchRelationTags.FULFILL action", () => {
|
|
18
18
|
expect(
|
|
19
|
-
relationTagsLoading(fooState, { type: fetchRelationTags.FULFILL })
|
|
19
|
+
relationTagsLoading(fooState, { type: fetchRelationTags.FULFILL }),
|
|
20
20
|
).toBe(false);
|
|
21
21
|
});
|
|
22
22
|
|