@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,68 +1,57 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { waitFor } from "@testing-library/react";
|
|
3
1
|
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import {
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
5
4
|
import { RelationTagForm } from "../RelationTagForm";
|
|
6
5
|
|
|
7
|
-
const renderOpts = {
|
|
8
|
-
messages: {
|
|
9
|
-
en: {
|
|
10
|
-
"actions.cancel": "cancel",
|
|
11
|
-
"actions.create": "create",
|
|
12
|
-
"form.validation.required": "required",
|
|
13
|
-
"relationTags.props.expandable": "Expandable",
|
|
14
|
-
"relationTags.props.target_type": "target",
|
|
15
|
-
"relationTags.props.target_type.placeholder": "...",
|
|
16
|
-
"relationTags.props.type": "type",
|
|
17
|
-
"relationTags.props.type.placeholder": "...",
|
|
18
|
-
"target_type.business_concept": "concept",
|
|
19
|
-
"target_type.data_field": "structure",
|
|
20
|
-
"target_type.ingest": "ingest",
|
|
21
|
-
"target_type.implementations": "implementations",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
6
|
describe("<RelationTagForm />", () => {
|
|
27
7
|
it("matches the latest snapshot", async () => {
|
|
28
|
-
const
|
|
29
|
-
await
|
|
30
|
-
|
|
8
|
+
const rendered = render(<RelationTagForm />);
|
|
9
|
+
await waitForLoad(rendered);
|
|
10
|
+
await rendered.findByRole("button", { name: /create/i });
|
|
11
|
+
expect(rendered.container).toMatchSnapshot();
|
|
31
12
|
});
|
|
32
13
|
|
|
33
14
|
it("calls createRelationTag with on submit", async () => {
|
|
34
15
|
const onSubmit = jest.fn();
|
|
16
|
+
const user = userEvent.setup({ delay: null });
|
|
35
17
|
|
|
36
|
-
const
|
|
37
|
-
<RelationTagForm onSubmit={(props) => onSubmit(props)}
|
|
38
|
-
renderOpts
|
|
18
|
+
const rendered = render(
|
|
19
|
+
<RelationTagForm onSubmit={(props) => onSubmit(props)} />
|
|
39
20
|
);
|
|
21
|
+
await waitForLoad(rendered);
|
|
40
22
|
|
|
41
23
|
// Submit button should initially be disabled
|
|
42
24
|
await waitFor(() =>
|
|
43
|
-
expect(getByRole("button", { name: /create/ })).toBeDisabled()
|
|
25
|
+
expect(rendered.getByRole("button", { name: /create/i })).toBeDisabled()
|
|
44
26
|
);
|
|
45
27
|
|
|
46
28
|
// Input name
|
|
47
|
-
|
|
29
|
+
await user.type(
|
|
30
|
+
await rendered.findByRole("textbox", { name: /type/i }),
|
|
31
|
+
"foo"
|
|
32
|
+
);
|
|
48
33
|
|
|
49
34
|
// Select type
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
await user.click(
|
|
36
|
+
await rendered.findByText("relationTags.props.target_type")
|
|
37
|
+
);
|
|
38
|
+
await user.click(await rendered.findByRole("option", { name: /concept/i }));
|
|
52
39
|
|
|
53
40
|
//expandable
|
|
54
|
-
const expandableCheckbox = await findByRole("checkbox", {
|
|
55
|
-
name: /
|
|
41
|
+
const expandableCheckbox = await rendered.findByRole("checkbox", {
|
|
42
|
+
name: /expandable/i,
|
|
56
43
|
});
|
|
57
|
-
|
|
44
|
+
await user.click(expandableCheckbox);
|
|
58
45
|
|
|
59
46
|
// Submit button should now be enabled
|
|
60
47
|
await waitFor(() =>
|
|
61
|
-
expect(
|
|
48
|
+
expect(
|
|
49
|
+
rendered.getByRole("button", { name: /create/i })
|
|
50
|
+
).not.toBeDisabled()
|
|
62
51
|
);
|
|
63
52
|
|
|
64
53
|
// Submit
|
|
65
|
-
|
|
54
|
+
await user.click(await rendered.findByRole("button", { name: /create/i }));
|
|
66
55
|
|
|
67
56
|
await waitFor(() =>
|
|
68
57
|
expect(onSubmit).toHaveBeenCalledWith({
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { RelationTagsLoader } from "../RelationTagsLoader";
|
|
4
3
|
|
|
5
4
|
describe("<RelationTagsLoader />", () => {
|
|
6
|
-
it("matches the latest snapshot", () => {
|
|
5
|
+
it("matches the latest snapshot", async () => {
|
|
7
6
|
const props = {
|
|
8
7
|
fetchRelationTags: jest.fn(),
|
|
9
8
|
clearRelationTags: jest.fn(),
|
|
10
|
-
relationTagsLoading: false
|
|
9
|
+
relationTagsLoading: false,
|
|
11
10
|
};
|
|
12
|
-
const
|
|
13
|
-
|
|
11
|
+
const rendered = render(<RelationTagsLoader {...props} />);
|
|
12
|
+
await waitForLoad(rendered);
|
|
13
|
+
expect(rendered.container).toMatchSnapshot();
|
|
14
14
|
});
|
|
15
15
|
});
|
|
@@ -1,40 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { Relations } from "../Relations";
|
|
4
3
|
|
|
5
4
|
describe("<Relations />", () => {
|
|
6
5
|
const defaultProps = {
|
|
7
6
|
relationsLoading: false,
|
|
8
|
-
relations: []
|
|
7
|
+
relations: [],
|
|
9
8
|
};
|
|
10
|
-
it("matches the latest snapshot", () => {
|
|
11
|
-
const
|
|
12
|
-
|
|
9
|
+
it("matches the latest snapshot", async () => {
|
|
10
|
+
const rendered = render(<Relations {...defaultProps} />);
|
|
11
|
+
await waitForLoad(rendered);
|
|
12
|
+
expect(rendered.container).toMatchSnapshot();
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it("renders empty relations list message whe relations list is empty", () => {
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
it("renders empty relations list message whe relations list is empty", async () => {
|
|
16
|
+
const rendered = render(<Relations {...defaultProps} />);
|
|
17
|
+
await waitForLoad(rendered);
|
|
18
|
+
expect(rendered.getByText(/relations.empty/i)).toBeInTheDocument();
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
it("renders as many RelationRow as relations in list", () => {
|
|
21
|
-
const
|
|
21
|
+
it("renders as many RelationRow as relations in list", async () => {
|
|
22
|
+
const rendered = render(
|
|
22
23
|
<Relations
|
|
23
24
|
{...{
|
|
24
25
|
...defaultProps,
|
|
25
26
|
relations: [
|
|
26
27
|
{
|
|
27
|
-
id:
|
|
28
|
+
id: 1,
|
|
28
29
|
name: "relation",
|
|
29
30
|
context: {
|
|
30
31
|
source: { name: "source name" },
|
|
31
|
-
target: { name: "target name" }
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
]
|
|
32
|
+
target: { name: "target name" },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
35
36
|
}}
|
|
36
37
|
/>
|
|
37
38
|
);
|
|
38
|
-
|
|
39
|
+
await waitForLoad(rendered);
|
|
40
|
+
expect(rendered.container.querySelectorAll("tr").length).toBe(1);
|
|
39
41
|
});
|
|
40
42
|
});
|
|
@@ -1,63 +1,69 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { mount, shallow } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { RelationsGraphLoader } from "../RelationsGraphLoader";
|
|
4
3
|
|
|
5
4
|
describe("<RelationsGraphLoader />", () => {
|
|
6
5
|
const resource_id = 1;
|
|
7
6
|
const relationsGraphLoading = false;
|
|
8
7
|
|
|
9
|
-
it("matches the latest snapshot", () => {
|
|
8
|
+
it("matches the latest snapshot", async () => {
|
|
10
9
|
const props = {
|
|
11
10
|
clearRelationsGraph: jest.fn(),
|
|
12
11
|
fetchRelationsGraph: jest.fn(),
|
|
13
12
|
relationsGraphLoading,
|
|
14
|
-
resource_id
|
|
13
|
+
resource_id,
|
|
15
14
|
};
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
const rendered = render(<RelationsGraphLoader {...props} />);
|
|
16
|
+
await waitForLoad(rendered);
|
|
17
|
+
expect(rendered.container).toMatchSnapshot();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
it("renders a loader if relationsGraphLoading is true", () => {
|
|
20
|
+
it("renders a loader if relationsGraphLoading is true", async () => {
|
|
21
21
|
const props = {
|
|
22
|
+
clearRelationsGraph: jest.fn(),
|
|
23
|
+
fetchRelationsGraph: jest.fn(),
|
|
22
24
|
relationsGraphLoading: true,
|
|
23
|
-
resource_id
|
|
25
|
+
resource_id,
|
|
24
26
|
};
|
|
25
|
-
const
|
|
26
|
-
expect(
|
|
27
|
+
const rendered = render(<RelationsGraphLoader {...props} />);
|
|
28
|
+
expect(rendered.container.querySelector(".loader")).toBeInTheDocument();
|
|
27
29
|
});
|
|
28
30
|
|
|
29
|
-
it("renders null if relationsGraphLoading is false", () => {
|
|
31
|
+
it("renders null if relationsGraphLoading is false", async () => {
|
|
30
32
|
const props = {
|
|
33
|
+
clearRelationsGraph: jest.fn(),
|
|
34
|
+
fetchRelationsGraph: jest.fn(),
|
|
31
35
|
relationsGraphLoading,
|
|
32
|
-
resource_id
|
|
36
|
+
resource_id,
|
|
33
37
|
};
|
|
34
|
-
const
|
|
35
|
-
|
|
38
|
+
const rendered = render(<RelationsGraphLoader {...props} />);
|
|
39
|
+
await waitForLoad(rendered);
|
|
40
|
+
expect(rendered.container.firstChild).toBeNull();
|
|
36
41
|
});
|
|
37
42
|
|
|
38
|
-
it("calls fetchRelationsGraph when component mounts but not when it unmounts", () => {
|
|
43
|
+
it("calls fetchRelationsGraph when component mounts but not when it unmounts", async () => {
|
|
39
44
|
const props = {
|
|
40
45
|
clearRelationsGraph: jest.fn(),
|
|
41
46
|
fetchRelationsGraph: jest.fn(),
|
|
42
47
|
relationsGraphLoading,
|
|
43
|
-
resource_id
|
|
48
|
+
resource_id,
|
|
44
49
|
};
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
const rendered = render(<RelationsGraphLoader {...props} />);
|
|
51
|
+
await waitForLoad(rendered);
|
|
52
|
+
expect(props.fetchRelationsGraph).toHaveBeenCalledTimes(1);
|
|
53
|
+
rendered.unmount();
|
|
54
|
+
expect(props.clearRelationsGraph).toHaveBeenCalledTimes(1);
|
|
49
55
|
});
|
|
50
56
|
|
|
51
|
-
it("calls clearRelationsGraph when component unmounts but not when it mounts", () => {
|
|
57
|
+
it("calls clearRelationsGraph when component unmounts but not when it mounts", async () => {
|
|
52
58
|
const props = {
|
|
53
59
|
clearRelationsGraph: jest.fn(),
|
|
54
60
|
fetchRelationsGraph: jest.fn(),
|
|
55
61
|
relationsGraphLoading: true,
|
|
56
|
-
resource_id
|
|
62
|
+
resource_id,
|
|
57
63
|
};
|
|
58
|
-
const
|
|
59
|
-
expect(props.clearRelationsGraph.
|
|
60
|
-
|
|
61
|
-
expect(props.clearRelationsGraph
|
|
64
|
+
const rendered = render(<RelationsGraphLoader {...props} />);
|
|
65
|
+
expect(props.clearRelationsGraph).not.toHaveBeenCalled();
|
|
66
|
+
rendered.unmount();
|
|
67
|
+
expect(props.clearRelationsGraph).toHaveBeenCalledTimes(1);
|
|
62
68
|
});
|
|
63
69
|
});
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { mount } from "enzyme";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
2
|
import { RelationsLoader } from "../RelationsLoader";
|
|
4
3
|
|
|
5
4
|
describe("<RelationsLoader />", () => {
|
|
6
|
-
it("calls fetchRelations on mount and clearRelations on unmount", () => {
|
|
5
|
+
it("calls fetchRelations on mount and clearRelations on unmount", async () => {
|
|
7
6
|
const props = {
|
|
8
7
|
clearRelations: jest.fn(),
|
|
9
8
|
fetchRelations: jest.fn(),
|
|
10
9
|
resource_id: 123,
|
|
11
10
|
resource_type: "foo",
|
|
12
|
-
target_type: "bar"
|
|
11
|
+
target_type: "bar",
|
|
13
12
|
};
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
expect(props.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
expect(props.
|
|
13
|
+
const rendered = render(<RelationsLoader {...props} />);
|
|
14
|
+
await waitForLoad(rendered);
|
|
15
|
+
expect(props.clearRelations).not.toHaveBeenCalled();
|
|
16
|
+
expect(props.fetchRelations).toHaveBeenCalledTimes(1);
|
|
17
|
+
rendered.unmount();
|
|
18
|
+
expect(props.fetchRelations).toHaveBeenCalledTimes(1);
|
|
19
|
+
expect(props.clearRelations).toHaveBeenCalledTimes(1);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
it("calls fetchRelations when a prop changes", () => {
|
|
22
|
+
it("calls fetchRelations when a prop changes", async () => {
|
|
23
23
|
const props = {
|
|
24
24
|
clearRelations: jest.fn(),
|
|
25
25
|
fetchRelations: jest.fn(),
|
|
26
26
|
resource_id: 123,
|
|
27
27
|
resource_type: "foo",
|
|
28
|
-
target_type: "bar"
|
|
28
|
+
target_type: "bar",
|
|
29
29
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
target_type
|
|
35
|
-
|
|
36
|
-
expect(props.fetchRelations
|
|
30
|
+
const rendered = render(<RelationsLoader {...props} />);
|
|
31
|
+
await waitForLoad(rendered);
|
|
32
|
+
expect(props.fetchRelations).toHaveBeenCalledTimes(1);
|
|
33
|
+
rendered.rerender(
|
|
34
|
+
<RelationsLoader {...props} target_type="new target_type" />
|
|
35
|
+
);
|
|
36
|
+
expect(props.fetchRelations).toHaveBeenCalledTimes(2);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
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 { StructureRelationForm } from "../StructureRelationForm";
|
|
7
6
|
import en from "../../messages/en";
|
|
8
7
|
|
|
8
|
+
jest.mock("@truedat/core/hooks/useUserFilters");
|
|
9
|
+
|
|
9
10
|
const linkConcept = jest.fn();
|
|
10
11
|
|
|
11
12
|
const data = {
|
|
@@ -115,31 +116,26 @@ const messages = {
|
|
|
115
116
|
const renderOpts = {
|
|
116
117
|
messages,
|
|
117
118
|
state: { structure },
|
|
118
|
-
fallback: "lazy",
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
describe("<StructureRelationForm />", () => {
|
|
122
122
|
it("matches the latest snapshot", async () => {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
renderOpts
|
|
126
|
-
);
|
|
123
|
+
const rendered = render(<StructureRelationForm {...props} />, renderOpts);
|
|
124
|
+
await waitForLoad(rendered);
|
|
127
125
|
|
|
128
|
-
await waitFor(
|
|
129
|
-
()
|
|
130
|
-
expect(getByText(/relates_to/)).toBeInTheDocument();
|
|
131
|
-
},
|
|
132
|
-
{ timeout: 60000 }
|
|
126
|
+
await waitFor(() =>
|
|
127
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
133
128
|
);
|
|
134
129
|
|
|
135
130
|
await waitFor(() => {
|
|
136
|
-
expect(container.querySelector(".loading")).toBeNull();
|
|
137
|
-
});
|
|
138
|
-
await waitFor(() => {
|
|
139
|
-
expect(getByText(/foo concept/)).toBeInTheDocument();
|
|
131
|
+
expect(rendered.container.querySelector(".loading")).toBeNull();
|
|
140
132
|
});
|
|
141
133
|
|
|
142
|
-
|
|
134
|
+
await waitFor(() =>
|
|
135
|
+
expect(rendered.getByText(/foo concept/i)).toBeInTheDocument()
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
expect(rendered.container).toMatchSnapshot();
|
|
143
139
|
});
|
|
144
140
|
|
|
145
141
|
it("disables submit and shows loading state if concept is linking", async () => {
|
|
@@ -148,44 +144,47 @@ describe("<StructureRelationForm />", () => {
|
|
|
148
144
|
conceptLinking: true,
|
|
149
145
|
};
|
|
150
146
|
|
|
151
|
-
const
|
|
147
|
+
const rendered = render(
|
|
152
148
|
<StructureRelationForm {...newProps} />,
|
|
153
149
|
renderOpts
|
|
154
150
|
);
|
|
155
151
|
|
|
156
|
-
await waitFor(() =>
|
|
157
|
-
expect(getByText(/relates_to/)).toBeInTheDocument()
|
|
158
|
-
|
|
152
|
+
await waitFor(() =>
|
|
153
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
154
|
+
);
|
|
159
155
|
|
|
160
|
-
expect(queryByRole("button", { name: /
|
|
161
|
-
userEvent.click(await findByText(/relates_to/));
|
|
162
|
-
userEvent.click(await findByText(/bar concept/));
|
|
156
|
+
expect(rendered.queryByRole("button", { name: /create/i })).toBeDisabled();
|
|
163
157
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
const user = userEvent.setup({ delay: null });
|
|
159
|
+
await user.click(await rendered.findByText(/relates_to/i));
|
|
160
|
+
await user.click(await rendered.findByText(/bar concept/i));
|
|
161
|
+
|
|
162
|
+
await waitFor(() =>
|
|
163
|
+
expect(rendered.queryByRole("button", { name: /create/i })).toBeEnabled()
|
|
164
|
+
);
|
|
167
165
|
|
|
168
|
-
|
|
166
|
+
await user.click(await rendered.findByRole("button", { name: /create/i }));
|
|
169
167
|
|
|
170
|
-
await waitFor(() =>
|
|
171
|
-
expect(queryByRole("button", { name: /
|
|
172
|
-
|
|
168
|
+
await waitFor(() =>
|
|
169
|
+
expect(rendered.queryByRole("button", { name: /create/i })).toHaveClass(
|
|
170
|
+
"loading"
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
it("submits the selected relation", async () => {
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
renderOpts
|
|
179
|
-
);
|
|
176
|
+
const rendered = render(<StructureRelationForm {...props} />, renderOpts);
|
|
177
|
+
await waitForLoad(rendered);
|
|
180
178
|
|
|
181
|
-
await waitFor(() =>
|
|
182
|
-
expect(getByText(/relates_to/)).toBeInTheDocument()
|
|
183
|
-
|
|
179
|
+
await waitFor(() =>
|
|
180
|
+
expect(rendered.getByText(/relates_to/i)).toBeInTheDocument()
|
|
181
|
+
);
|
|
184
182
|
|
|
185
|
-
userEvent.
|
|
186
|
-
|
|
183
|
+
const user = userEvent.setup({ delay: null });
|
|
184
|
+
await user.click(await rendered.findByText(/relates_to/i));
|
|
185
|
+
await user.click(await rendered.findByText(/bar concept/i));
|
|
187
186
|
|
|
188
|
-
|
|
187
|
+
await user.click(await rendered.findByRole("button", { name: /create/i }));
|
|
189
188
|
|
|
190
189
|
const expectedRelation = {
|
|
191
190
|
redirectUrl: linkTo.STRUCTURE_LINKS({ id: 3 }),
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { shallow } from "enzyme";
|
|
3
|
-
import { intl } from "@truedat/test/intl-stub";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
2
|
import { TagTypeSelector } from "../TagTypeSelector";
|
|
5
3
|
|
|
6
|
-
// workaround for enzyme issue with React.useContext
|
|
7
|
-
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
8
|
-
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
9
|
-
|
|
10
4
|
describe("<TagTypeSelector />", () => {
|
|
11
|
-
it("matches
|
|
12
|
-
const
|
|
13
|
-
const defaultProps = {
|
|
5
|
+
it("matches the latest snapshot", async () => {
|
|
6
|
+
const props = {
|
|
14
7
|
options: [],
|
|
15
|
-
onChange
|
|
8
|
+
onChange: jest.fn(),
|
|
16
9
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
10
|
+
const rendered = render(<TagTypeSelector {...props} />);
|
|
11
|
+
await waitForLoad(rendered);
|
|
12
|
+
expect(rendered.container).toMatchSnapshot();
|
|
19
13
|
});
|
|
20
14
|
});
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<li
|
|
8
|
-
key="0"
|
|
3
|
+
exports[`<ConceptLinkTags /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<ul
|
|
6
|
+
class="concept-link-tags"
|
|
9
7
|
>
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<MemoizedFormattedMessage
|
|
19
|
-
defaultMessage="business_concept_to_field_master"
|
|
20
|
-
id="conceptRelations.relationType.business_concept_to_field_master"
|
|
21
|
-
/>
|
|
22
|
-
</li>
|
|
23
|
-
</ul>
|
|
8
|
+
<li>
|
|
9
|
+
otro tipo
|
|
10
|
+
</li>
|
|
11
|
+
<li>
|
|
12
|
+
business_concept_to_field_master
|
|
13
|
+
</li>
|
|
14
|
+
</ul>
|
|
15
|
+
</div>
|
|
24
16
|
`;
|