@truedat/lm 7.5.9 → 7.5.11
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/index.js +5 -0
- package/package.json +43 -67
- package/src/components/ConceptImplementationLink.js +1 -2
- package/src/components/ConceptLink.js +2 -3
- package/src/components/ConceptLinkTags.js +0 -1
- package/src/components/ConceptStructureLinkForm.js +3 -3
- package/src/components/ConfirmDeleteRelation.js +0 -1
- package/src/components/ImplementationLinkRow.js +0 -1
- package/src/components/ImplementationLinks.js +1 -2
- package/src/components/ImplementationRelationForm.js +5 -8
- package/src/components/LinksPane.js +0 -1
- package/src/components/NewRelationTag.js +0 -1
- package/src/components/RelationActions.js +3 -4
- package/src/components/RelationGraph.js +17 -104
- package/src/components/RelationGraphDepth.js +0 -1
- package/src/components/RelationRoutes.js +16 -25
- package/src/components/RelationRow.js +6 -7
- package/src/components/RelationTagCards.js +3 -4
- package/src/components/RelationTagForm.js +0 -2
- package/src/components/RelationTags.js +1 -2
- package/src/components/RelationTagsLoader.js +2 -2
- package/src/components/Relations.js +0 -1
- package/src/components/RelationsGraphLoader.js +0 -1
- package/src/components/StructureLinkRow.js +0 -1
- package/src/components/StructureLinks.js +1 -2
- package/src/components/StructureRelationForm.js +5 -9
- package/src/components/TagTypeDropdownSelector.js +1 -1
- package/src/components/TagTypeSelector.js +0 -2
- package/src/components/__tests__/ConceptImplementationLink.spec.js +0 -1
- package/src/components/__tests__/ConceptLinkTags.spec.js +7 -9
- package/src/components/__tests__/ConceptStructureLinkForm.spec.js +68 -20
- package/src/components/__tests__/ConfirmDeleteRelation.spec.js +0 -1
- package/src/components/__tests__/ImplementationLinkRow.spec.js +0 -1
- package/src/components/__tests__/ImplementationLinks.spec.js +0 -1
- package/src/components/__tests__/ImplementationRelationForm.spec.js +45 -73
- package/src/components/__tests__/LinksPane.spec.js +0 -1
- package/src/components/__tests__/NewRelationTag.spec.js +0 -1
- package/src/components/__tests__/RelationActions.spec.js +14 -15
- package/src/components/__tests__/RelationRoutes.spec.js +59 -7
- package/src/components/__tests__/RelationRow.spec.js +46 -23
- package/src/components/__tests__/RelationTagCards.spec.js +0 -1
- package/src/components/__tests__/RelationTagForm.spec.js +26 -37
- package/src/components/__tests__/RelationTags.spec.js +0 -1
- package/src/components/__tests__/RelationTagsLoader.spec.js +6 -6
- package/src/components/__tests__/Relations.spec.js +19 -17
- package/src/components/__tests__/RelationsGraphLoader.spec.js +32 -26
- package/src/components/__tests__/RelationsLoader.spec.js +19 -19
- package/src/components/__tests__/StructureRelationForm.spec.js +41 -42
- package/src/components/__tests__/TagTypeSelector.spec.js +7 -13
- package/src/components/__tests__/__snapshots__/ConceptImplementationLink.spec.js.snap +1 -0
- package/src/components/__tests__/__snapshots__/ConceptLinkTags.spec.js.snap +12 -20
- package/src/components/__tests__/__snapshots__/ConceptStructureLinkForm.spec.js.snap +170 -19
- package/src/components/__tests__/__snapshots__/ImplementationLinks.spec.js.snap +4 -0
- package/src/components/__tests__/__snapshots__/ImplementationRelationForm.spec.js.snap +13 -13
- package/src/components/__tests__/__snapshots__/NewRelationTag.spec.js.snap +12 -11
- package/src/components/__tests__/__snapshots__/RelationActions.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/RelationRoutes.spec.js.snap +21 -5
- package/src/components/__tests__/__snapshots__/RelationRow.spec.js.snap +7 -1
- package/src/components/__tests__/__snapshots__/RelationTagCards.spec.js.snap +0 -1
- package/src/components/__tests__/__snapshots__/RelationTagForm.spec.js.snap +11 -10
- package/src/components/__tests__/__snapshots__/RelationTags.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/RelationTagsLoader.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/Relations.spec.js.snap +36 -27
- package/src/components/__tests__/__snapshots__/RelationsGraphLoader.spec.js.snap +1 -25
- package/src/components/__tests__/__snapshots__/StructureRelationForm.spec.js.snap +1 -1
- package/src/components/__tests__/__snapshots__/TagTypeSelector.spec.js.snap +11 -14
- package/src/hooks/useTags.js +1 -1
- package/src/sagas/__tests__/fetchRelationsGraph.spec.js +2 -2
- package/src/sagas/deleteRelation.js +1 -1
- package/src/sagas/fetchRelationsGraph.js +1 -1
- package/src/sagas/updateRelationTag.js +1 -1
- package/src/selectors/getStructureLinks.js +1 -1
- package/src/services/relationGraphTraversal.js +3 -3
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React from "react";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
4
3
|
import { connect } from "react-redux";
|
|
5
4
|
import { Table, Button, Grid } from "semantic-ui-react";
|
|
6
5
|
import { FormattedMessage } from "react-intl";
|
|
7
|
-
import { Link } from "react-router
|
|
6
|
+
import { Link } from "react-router";
|
|
8
7
|
import { linkTo } from "@truedat/core/routes";
|
|
9
8
|
import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
|
|
10
9
|
import { getStructureToConceptLinks } from "../selectors/getStructureLinks";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import
|
|
2
|
+
import { lazy, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { FormattedMessage } from "react-intl";
|
|
5
5
|
import { connect } from "react-redux";
|
|
@@ -10,12 +10,12 @@ import { linkTo } from "@truedat/core/routes";
|
|
|
10
10
|
import { linkConcept } from "../routines";
|
|
11
11
|
import RelationTagsLoader from "./RelationTagsLoader";
|
|
12
12
|
|
|
13
|
-
const ConceptSelector =
|
|
14
|
-
import("@truedat/bg/concepts/relations/components/ConceptSelector")
|
|
13
|
+
const ConceptSelector = lazy(
|
|
14
|
+
() => import("@truedat/bg/concepts/relations/components/ConceptSelector")
|
|
15
15
|
);
|
|
16
16
|
|
|
17
|
-
const TagTypeDropdownSelector =
|
|
18
|
-
import("@truedat/lm/components/TagTypeDropdownSelector")
|
|
17
|
+
const TagTypeDropdownSelector = lazy(
|
|
18
|
+
() => import("@truedat/lm/components/TagTypeDropdownSelector")
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
const filters = {
|
|
@@ -57,19 +57,16 @@ export const StructureRelationForm = ({
|
|
|
57
57
|
as="h4"
|
|
58
58
|
content={<FormattedMessage id="structures.relation.new.header" />}
|
|
59
59
|
/>
|
|
60
|
-
|
|
61
60
|
{!_.isEmpty(tagOptions) ? (
|
|
62
61
|
<Form.Field className="concept-relation-form">
|
|
63
62
|
<TagTypeDropdownSelector options={tagOptions} />
|
|
64
63
|
</Form.Field>
|
|
65
64
|
) : null}
|
|
66
|
-
|
|
67
65
|
<ConceptSelector
|
|
68
66
|
selectedConcept={selectedConcept}
|
|
69
67
|
handleConceptSelected={handleConceptSelected}
|
|
70
68
|
defaultFilters={filters}
|
|
71
69
|
/>
|
|
72
|
-
|
|
73
70
|
<div className="actions">
|
|
74
71
|
<Button
|
|
75
72
|
primary
|
|
@@ -78,7 +75,6 @@ export const StructureRelationForm = ({
|
|
|
78
75
|
loading={conceptLinking}
|
|
79
76
|
onClick={handleSubmit}
|
|
80
77
|
/>
|
|
81
|
-
|
|
82
78
|
<HistoryBackButton
|
|
83
79
|
content={<FormattedMessage id="actions.cancel" />}
|
|
84
80
|
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { Form, Dropdown } from "semantic-ui-react";
|
|
5
5
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React from "react";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
4
3
|
import { Form, Checkbox } from "semantic-ui-react";
|
|
5
4
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
@@ -35,7 +34,6 @@ export const TagTypeSelector = ({
|
|
|
35
34
|
<label>
|
|
36
35
|
<FormattedMessage id="relations.relationType" />
|
|
37
36
|
</label>
|
|
38
|
-
|
|
39
37
|
{options &&
|
|
40
38
|
options.map((option, key) => (
|
|
41
39
|
<div
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { render } from "@truedat/test/render";
|
|
4
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
5
2
|
|
|
6
3
|
import ConceptLinkTags from "../ConceptLinkTags";
|
|
7
4
|
|
|
8
|
-
describe("ConceptLinkTags", () => {
|
|
9
|
-
it("matches the latest snapshot", () => {
|
|
10
|
-
const
|
|
5
|
+
describe("<ConceptLinkTags />", () => {
|
|
6
|
+
it("matches the latest snapshot", async () => {
|
|
7
|
+
const props = {
|
|
11
8
|
tags: ["otro tipo", "business_concept_to_field_master"],
|
|
12
9
|
};
|
|
13
|
-
const
|
|
14
|
-
|
|
10
|
+
const rendered = render(<ConceptLinkTags {...props} />);
|
|
11
|
+
await waitForLoad(rendered);
|
|
12
|
+
expect(rendered.container).toMatchSnapshot();
|
|
15
13
|
});
|
|
16
14
|
});
|
|
@@ -1,40 +1,88 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow, mount } from "enzyme";
|
|
3
|
-
import { MemoryRouter } from "react-router-dom";
|
|
4
|
-
import { intl } from "@truedat/test/intl-stub";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
5
2
|
import { ConceptStructureLinkForm } from "../ConceptStructureLinkForm";
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
jest.mock("@truedat/core/hooks/useUserFilters");
|
|
5
|
+
|
|
6
|
+
const structure = {
|
|
7
|
+
external_id: "external_id",
|
|
8
|
+
id: 67583,
|
|
9
|
+
updated_at: "2021-06-10T12:01:17.343065Z",
|
|
10
|
+
name: "structure",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
jest.mock("@truedat/dd/hooks/useStructures", () => {
|
|
14
|
+
const originalModule = jest.requireActual("@truedat/dd/hooks/useStructures");
|
|
15
|
+
|
|
16
|
+
const data = {
|
|
17
|
+
_actions: { bulkUpdate: { href: "/structures/bulkUpdate" } },
|
|
18
|
+
data: [structure],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
__esModule: true,
|
|
23
|
+
...originalModule,
|
|
24
|
+
useDataStructureFilters: () => ({
|
|
25
|
+
trigger: () => ({
|
|
26
|
+
then: (callback) =>
|
|
27
|
+
callback({
|
|
28
|
+
data: { data: {} },
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
useDataStructureSearch: () => ({
|
|
33
|
+
trigger: () => ({
|
|
34
|
+
then: (callback) =>
|
|
35
|
+
callback({
|
|
36
|
+
data,
|
|
37
|
+
headers: {},
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const useFilters = jest.fn(() => ({
|
|
45
|
+
trigger: jest.fn(() => new Promise(() => {})),
|
|
46
|
+
isMutating: false,
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
const useSearch = () => ({
|
|
50
|
+
trigger: () => ({
|
|
51
|
+
then: (callback) =>
|
|
52
|
+
callback({
|
|
53
|
+
data: {
|
|
54
|
+
data: [structure],
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
10
59
|
|
|
11
60
|
const makeProps = () => ({
|
|
12
61
|
clearSelectedRelationTags: jest.fn(),
|
|
13
62
|
clearStructures: jest.fn(),
|
|
14
63
|
createRelation: jest.fn(),
|
|
15
64
|
id: 42,
|
|
16
|
-
sourceId: 42
|
|
65
|
+
sourceId: 42,
|
|
17
66
|
});
|
|
18
67
|
|
|
19
68
|
describe("<ConceptStructureLinkForm />", () => {
|
|
20
|
-
it("matches the latest snapshot", () => {
|
|
69
|
+
it("matches the latest snapshot", async () => {
|
|
21
70
|
const props = makeProps();
|
|
22
|
-
const
|
|
23
|
-
|
|
71
|
+
const rendered = render(<ConceptStructureLinkForm {...props} />);
|
|
72
|
+
await waitForLoad(rendered);
|
|
73
|
+
expect(rendered.container).toMatchSnapshot();
|
|
24
74
|
});
|
|
25
75
|
|
|
26
|
-
it("calls clearSelectedRelationTags and clearStructures on unmount", () => {
|
|
76
|
+
it("calls clearSelectedRelationTags and clearStructures on unmount", async () => {
|
|
27
77
|
const props = makeProps();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<ConceptStructureLinkForm {...props} />
|
|
32
|
-
</MemoryRouter>
|
|
33
|
-
</Suspense>
|
|
34
|
-
);
|
|
78
|
+
const rendered = render(<ConceptStructureLinkForm {...props} />);
|
|
79
|
+
await waitForLoad(rendered);
|
|
80
|
+
|
|
35
81
|
expect(props.clearSelectedRelationTags).not.toHaveBeenCalled();
|
|
36
82
|
expect(props.clearStructures).not.toHaveBeenCalled();
|
|
37
|
-
|
|
83
|
+
|
|
84
|
+
rendered.unmount();
|
|
85
|
+
|
|
38
86
|
expect(props.clearSelectedRelationTags).toHaveBeenCalled();
|
|
39
87
|
expect(props.clearStructures).toHaveBeenCalled();
|
|
40
88
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
-
import { linkTo } from "@truedat/core/routes";
|
|
4
1
|
import userEvent from "@testing-library/user-event";
|
|
5
2
|
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
|
+
import { linkTo } from "@truedat/core/routes";
|
|
6
5
|
import { ImplementationRelationForm } from "../ImplementationRelationForm";
|
|
7
|
-
import en from "../../messages/en";
|
|
8
6
|
|
|
9
7
|
const linkConcept = jest.fn();
|
|
10
8
|
|
|
9
|
+
jest.mock("@truedat/core/hooks/useUserFilters");
|
|
10
|
+
|
|
11
11
|
const data = {
|
|
12
12
|
data: [
|
|
13
13
|
{
|
|
@@ -80,8 +80,6 @@ const tagOptions = [
|
|
|
80
80
|
{ id: 2, text: "text", value: 1 },
|
|
81
81
|
];
|
|
82
82
|
|
|
83
|
-
const concepts = [];
|
|
84
|
-
|
|
85
83
|
const props = {
|
|
86
84
|
implementation: { rule_id: 2, id: 4, implementation_ref: 1 },
|
|
87
85
|
tagOptions,
|
|
@@ -90,53 +88,27 @@ const props = {
|
|
|
90
88
|
selectedRelationTags: [1],
|
|
91
89
|
};
|
|
92
90
|
|
|
93
|
-
const renderOpts = {
|
|
94
|
-
messages: {
|
|
95
|
-
en: {
|
|
96
|
-
...en,
|
|
97
|
-
"implementations.relation.new.header": "header",
|
|
98
|
-
"conceptRelations.relationType": "relationType",
|
|
99
|
-
"actions.cancel": "Cancel",
|
|
100
|
-
"actions.create": "Create",
|
|
101
|
-
"conceptRelations.relationType.text": "text",
|
|
102
|
-
"concepts.props.name": "Name",
|
|
103
|
-
"concepts.props.domain": "Domain",
|
|
104
|
-
"concepts.props.status": "Status",
|
|
105
|
-
"search.save_filters": "Save Filters",
|
|
106
|
-
"search.clear_filters": "Clear Filters",
|
|
107
|
-
"search.applied_filters": "Applied Filters",
|
|
108
|
-
"conceptRelations.relatedConcept": "Related Concept",
|
|
109
|
-
"concepts.search.placeholder": "Search",
|
|
110
|
-
"concepts.search.placeholder": "Search",
|
|
111
|
-
"search.placeholder": "Search...",
|
|
112
|
-
"concepts.search.results.empty": "No concepts found",
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
// state: {},
|
|
116
|
-
fallback: "lazy",
|
|
117
|
-
};
|
|
118
|
-
|
|
119
91
|
describe("<ImplementationRelationForm />", () => {
|
|
120
92
|
it("matches the latest snapshot", async () => {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
renderOpts
|
|
124
|
-
);
|
|
93
|
+
const rendered = render(<ImplementationRelationForm {...props} />);
|
|
94
|
+
await waitForLoad(rendered);
|
|
125
95
|
|
|
126
|
-
await waitFor(
|
|
127
|
-
()
|
|
128
|
-
expect(getByText(/relates_to/)).toBeInTheDocument();
|
|
129
|
-
},
|
|
130
|
-
{ timeout: 60000 }
|
|
96
|
+
await waitFor(() =>
|
|
97
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
131
98
|
);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
99
|
+
|
|
100
|
+
const user = userEvent.setup({ delay: null });
|
|
101
|
+
await user.click(await rendered.findByText(/some/i));
|
|
102
|
+
|
|
136
103
|
await waitFor(() => {
|
|
137
|
-
expect(
|
|
104
|
+
expect(rendered.container.querySelector(".loading")).toBeNull();
|
|
138
105
|
});
|
|
139
|
-
|
|
106
|
+
|
|
107
|
+
await waitFor(() =>
|
|
108
|
+
expect(rendered.getByText(/foo concept/i)).toBeInTheDocument()
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
expect(rendered.container).toMatchSnapshot();
|
|
140
112
|
});
|
|
141
113
|
|
|
142
114
|
it("disables submit and shows loading state if concept is linking", async () => {
|
|
@@ -145,44 +117,44 @@ describe("<ImplementationRelationForm />", () => {
|
|
|
145
117
|
conceptLinking: true,
|
|
146
118
|
};
|
|
147
119
|
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
120
|
+
const rendered = render(<ImplementationRelationForm {...newProps} />);
|
|
121
|
+
|
|
122
|
+
await waitFor(() =>
|
|
123
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
151
124
|
);
|
|
152
125
|
|
|
153
|
-
|
|
154
|
-
expect(getByText(/relates_to/)).toBeInTheDocument();
|
|
155
|
-
});
|
|
126
|
+
expect(rendered.queryByRole("button", { name: /create/i })).toBeDisabled();
|
|
156
127
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
128
|
+
const user = userEvent.setup({ delay: null });
|
|
129
|
+
await user.click(await rendered.findByText(/relates_to/i));
|
|
130
|
+
await user.click(await rendered.findByText(/bar concept/i));
|
|
160
131
|
|
|
161
|
-
await waitFor(() =>
|
|
162
|
-
expect(queryByRole("button", { name: /
|
|
163
|
-
|
|
132
|
+
await waitFor(() =>
|
|
133
|
+
expect(rendered.queryByRole("button", { name: /create/i })).toBeEnabled()
|
|
134
|
+
);
|
|
164
135
|
|
|
165
|
-
|
|
136
|
+
await user.click(await rendered.findByRole("button", { name: /create/i }));
|
|
166
137
|
|
|
167
|
-
await waitFor(() =>
|
|
168
|
-
expect(queryByRole("button", { name: /
|
|
169
|
-
|
|
138
|
+
await waitFor(() =>
|
|
139
|
+
expect(rendered.queryByRole("button", { name: /create/i })).toHaveClass(
|
|
140
|
+
"loading"
|
|
141
|
+
)
|
|
142
|
+
);
|
|
170
143
|
});
|
|
171
144
|
|
|
172
145
|
it("submits the selected relation", async () => {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
renderOpts
|
|
176
|
-
);
|
|
146
|
+
const rendered = render(<ImplementationRelationForm {...props} />);
|
|
147
|
+
await waitForLoad(rendered);
|
|
177
148
|
|
|
178
|
-
await waitFor(() =>
|
|
179
|
-
expect(getByText(/relates_to/)).toBeInTheDocument()
|
|
180
|
-
|
|
149
|
+
await waitFor(() =>
|
|
150
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
151
|
+
);
|
|
181
152
|
|
|
182
|
-
userEvent.
|
|
183
|
-
|
|
153
|
+
const user = userEvent.setup({ delay: null });
|
|
154
|
+
await user.click(await rendered.findByText(/relates_to/i));
|
|
155
|
+
await user.click(await rendered.findByText(/bar concept/i));
|
|
184
156
|
|
|
185
|
-
|
|
157
|
+
await user.click(await rendered.findByRole("button", { name: /create/i }));
|
|
186
158
|
|
|
187
159
|
const expectedRelation = {
|
|
188
160
|
redirectUrl: linkTo.IMPLEMENTATION_CONCEPT_LINKS({
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { RelationActions } from "../RelationActions";
|
|
4
3
|
|
|
5
|
-
jest.mock("react-router
|
|
6
|
-
...jest.requireActual("react-router
|
|
7
|
-
useLocation: () => ({ pathname: "my_path" })
|
|
4
|
+
jest.mock("react-router", () => ({
|
|
5
|
+
...jest.requireActual("react-router"),
|
|
6
|
+
useLocation: () => ({ pathname: "my_path" }),
|
|
8
7
|
}));
|
|
9
8
|
|
|
10
9
|
describe("<RelationActions />", () => {
|
|
11
|
-
it("matches the latest snapshot", () => {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
expect(
|
|
10
|
+
it("matches the latest snapshot", async () => {
|
|
11
|
+
const props = { addConceptRelation: false };
|
|
12
|
+
const rendered = render(<RelationActions {...props} />);
|
|
13
|
+
await waitForLoad(rendered);
|
|
14
|
+
expect(rendered.container).toMatchSnapshot();
|
|
16
15
|
});
|
|
17
16
|
|
|
18
|
-
it("when addConceptRelation it renders a button", () => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
expect(
|
|
17
|
+
it("when addConceptRelation it renders a button", async () => {
|
|
18
|
+
const props = { addConceptRelation: true };
|
|
19
|
+
const rendered = render(<RelationActions {...props} />);
|
|
20
|
+
await waitForLoad(rendered);
|
|
21
|
+
expect(rendered.getByText(/relations.actions.create/i)).toBeInTheDocument();
|
|
23
22
|
});
|
|
24
23
|
});
|
|
@@ -1,14 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import { useAuthorized } from "@truedat/core/hooks/useAuthorized";
|
|
3
|
+
import { RELATION_TAGS, RELATION_TAGS_NEW } from "@truedat/core/routes";
|
|
3
4
|
import { RelationRoutes } from "../RelationRoutes";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
// Mock the hooks module
|
|
7
|
+
jest.mock("@truedat/core/hooks/useAuthorized");
|
|
8
|
+
|
|
9
|
+
// Mock child components
|
|
10
|
+
jest.mock(
|
|
11
|
+
"../NewRelationTag",
|
|
12
|
+
() =>
|
|
13
|
+
function NewRelationTag() {
|
|
14
|
+
return <div>NewRelationTag</div>;
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
jest.mock(
|
|
18
|
+
"../RelationTags",
|
|
19
|
+
() =>
|
|
20
|
+
function RelationTags() {
|
|
21
|
+
return <div>RelationTags</div>;
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
jest.mock(
|
|
25
|
+
"../RelationTagsLoader",
|
|
26
|
+
() =>
|
|
27
|
+
function RelationTagsLoader() {
|
|
28
|
+
return <div>RelationTagsLoader</div>;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
jest.mock("@truedat/core/components", () => ({
|
|
32
|
+
Unauthorized: () => <div>Unauthorized</div>,
|
|
33
|
+
...jest.requireActual("@truedat/core/components"),
|
|
7
34
|
}));
|
|
8
35
|
|
|
9
36
|
describe("<RelationRoutes />", () => {
|
|
10
|
-
it("
|
|
11
|
-
const
|
|
12
|
-
|
|
37
|
+
it("renders correctly with default route", async () => {
|
|
38
|
+
const rendered = render(<RelationRoutes />);
|
|
39
|
+
await waitForLoad(rendered);
|
|
40
|
+
expect(rendered.container).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("renders correctly with RELATION_TAGS route", async () => {
|
|
44
|
+
const rendered = render(<RelationRoutes />, {
|
|
45
|
+
routes: [RELATION_TAGS],
|
|
46
|
+
});
|
|
47
|
+
await waitForLoad(rendered);
|
|
48
|
+
expect(rendered.container).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("renders correctly with RELATION_TAGS_NEW route", async () => {
|
|
52
|
+
const rendered = render(<RelationRoutes />, {
|
|
53
|
+
routes: [RELATION_TAGS_NEW],
|
|
54
|
+
});
|
|
55
|
+
await waitForLoad(rendered);
|
|
56
|
+
expect(rendered.container).toMatchSnapshot();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("renders unauthorized component when not authorized", async () => {
|
|
60
|
+
useAuthorized.mockReturnValueOnce(false);
|
|
61
|
+
|
|
62
|
+
const rendered = render(<RelationRoutes />);
|
|
63
|
+
await waitForLoad(rendered);
|
|
64
|
+
expect(rendered.container).toMatchSnapshot();
|
|
13
65
|
});
|
|
14
66
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { RelationRow } from "../RelationRow";
|
|
4
3
|
|
|
5
|
-
jest.mock("react-router
|
|
6
|
-
...jest.requireActual("react-router
|
|
7
|
-
|
|
4
|
+
jest.mock("react-router", () => ({
|
|
5
|
+
...jest.requireActual("react-router"),
|
|
6
|
+
useNavigate: () => jest.fn(),
|
|
8
7
|
}));
|
|
9
8
|
|
|
10
9
|
describe("<RelationRow />", () => {
|
|
@@ -15,36 +14,60 @@ describe("<RelationRow />", () => {
|
|
|
15
14
|
relationContext: {},
|
|
16
15
|
tags: [],
|
|
17
16
|
relationPath: "",
|
|
18
|
-
history: {}
|
|
17
|
+
history: {},
|
|
19
18
|
};
|
|
20
|
-
it("matches the latest snapshot", () => {
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
it("matches the latest snapshot", async () => {
|
|
20
|
+
const rendered = render(
|
|
21
|
+
<table>
|
|
22
|
+
<tbody>
|
|
23
|
+
<RelationRow {...defaultProps} />
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
);
|
|
27
|
+
await waitForLoad(rendered);
|
|
28
|
+
expect(rendered.container).toMatchSnapshot();
|
|
23
29
|
});
|
|
24
30
|
|
|
25
|
-
it("renders null when relationContext not empty and source and target whitin it are null", () => {
|
|
26
|
-
const
|
|
27
|
-
|
|
31
|
+
it("renders null when relationContext not empty and source and target whitin it are null", async () => {
|
|
32
|
+
const rendered = render(
|
|
33
|
+
<table>
|
|
34
|
+
<tbody>
|
|
35
|
+
<RelationRow {...defaultProps} />
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
);
|
|
39
|
+
await waitForLoad(rendered);
|
|
40
|
+
expect(rendered.container.firstChild.firstChild.firstChild).toBeNull();
|
|
28
41
|
});
|
|
29
42
|
|
|
30
|
-
it("renders a row with one cell when relationContext not empty and source and target whitin it are null", () => {
|
|
43
|
+
it("renders a row with one cell when relationContext not empty and source and target whitin it are null", async () => {
|
|
31
44
|
const relationContext = { source: null, target: null };
|
|
32
|
-
const
|
|
33
|
-
<
|
|
45
|
+
const rendered = render(
|
|
46
|
+
<table>
|
|
47
|
+
<tbody>
|
|
48
|
+
<RelationRow {...{ ...defaultProps, relationContext }} />
|
|
49
|
+
</tbody>
|
|
50
|
+
</table>
|
|
34
51
|
);
|
|
35
|
-
|
|
36
|
-
expect(
|
|
52
|
+
await waitForLoad(rendered);
|
|
53
|
+
expect(rendered.container.querySelectorAll("tr").length).toBe(1);
|
|
54
|
+
expect(rendered.container.querySelectorAll("td").length).toBe(1);
|
|
37
55
|
});
|
|
38
56
|
|
|
39
|
-
it("renders a row with four cells when relationContext not empty and source and target whitin it are informed", () => {
|
|
57
|
+
it("renders a row with four cells when relationContext not empty and source and target whitin it are informed", async () => {
|
|
40
58
|
const relationContext = {
|
|
41
59
|
source: { name: "source name" },
|
|
42
|
-
target: { name: "target name" }
|
|
60
|
+
target: { name: "target name" },
|
|
43
61
|
};
|
|
44
|
-
const
|
|
45
|
-
<
|
|
62
|
+
const rendered = render(
|
|
63
|
+
<table>
|
|
64
|
+
<tbody>
|
|
65
|
+
<RelationRow {...{ ...defaultProps, relationContext }} />
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>
|
|
46
68
|
);
|
|
47
|
-
|
|
48
|
-
expect(
|
|
69
|
+
await waitForLoad(rendered);
|
|
70
|
+
expect(rendered.container.querySelectorAll("tr").length).toBe(1);
|
|
71
|
+
expect(rendered.container.querySelectorAll("td").length).toBe(4);
|
|
49
72
|
});
|
|
50
73
|
});
|