@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,184 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { intl } from "@truedat/test/intl-stub";
|
|
3
|
-
import { render, waitFor } from "@testing-library/react";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
import { LinkStructureTagForm } from "../LinkStructureTagForm";
|
|
6
|
-
|
|
7
|
-
// workaround for enzyme issue with React.useContext
|
|
8
|
-
// see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
|
|
9
|
-
jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
10
|
-
|
|
11
|
-
describe("<LinkStructureTagForm />", () => {
|
|
12
|
-
const deleteLinkStructureTag = jest.fn();
|
|
13
|
-
const linkStructureTag = jest.fn();
|
|
14
|
-
const structureTags = [
|
|
15
|
-
{ id: 1, name: "Tag1", description: "description test" },
|
|
16
|
-
{ id: 2, name: "Tag2", description: "large desc".repeat(5) },
|
|
17
|
-
{ id: 3, name: "Tag without description" },
|
|
18
|
-
];
|
|
19
|
-
const linkedStructureTags = [
|
|
20
|
-
{
|
|
21
|
-
id: 1,
|
|
22
|
-
comment: "foo",
|
|
23
|
-
inserted_at: "foo",
|
|
24
|
-
updated_at: "foo",
|
|
25
|
-
_embedded: {
|
|
26
|
-
data_structure: { id: 1, external_id: "baz" },
|
|
27
|
-
data_structure_tag: { ...structureTags[2] },
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const comment = "foo";
|
|
33
|
-
const structureId = 1;
|
|
34
|
-
const tagId = 3;
|
|
35
|
-
const linkId = 1;
|
|
36
|
-
|
|
37
|
-
const propsCreate = {
|
|
38
|
-
deleteLinkStructureTag,
|
|
39
|
-
linkedStructureTags,
|
|
40
|
-
linkStructureTag,
|
|
41
|
-
structureId,
|
|
42
|
-
structureTags,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const propsUpdate = {
|
|
46
|
-
deleteLinkStructureTag,
|
|
47
|
-
comment,
|
|
48
|
-
linkedStructureTags,
|
|
49
|
-
linkId,
|
|
50
|
-
linkStructureTag,
|
|
51
|
-
structureId,
|
|
52
|
-
structureTags,
|
|
53
|
-
tagId,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
it("matches the latest snapshot create", async () => {
|
|
57
|
-
const { container, findByRole } = render(
|
|
58
|
-
<LinkStructureTagForm {...propsCreate} />
|
|
59
|
-
);
|
|
60
|
-
await findByRole("button", { name: /add/ });
|
|
61
|
-
expect(container).toMatchSnapshot();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("matches the latest snapshot edit", async () => {
|
|
65
|
-
const { container, findByRole } = render(
|
|
66
|
-
<LinkStructureTagForm {...propsUpdate} />
|
|
67
|
-
);
|
|
68
|
-
await findByRole("button", { name: /edit/ });
|
|
69
|
-
await findByRole("button", { name: /delete/ });
|
|
70
|
-
expect(container).toMatchSnapshot();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("matches the latest snapshot create without comment", async () => {
|
|
74
|
-
const linkedStructureTagWithoutComment = {
|
|
75
|
-
...linkedStructureTags[0],
|
|
76
|
-
};
|
|
77
|
-
delete linkedStructureTagWithoutComment.comment;
|
|
78
|
-
|
|
79
|
-
const propsCreateWithoutComment = {
|
|
80
|
-
...propsCreate,
|
|
81
|
-
linkedStructureTags: [linkedStructureTagWithoutComment],
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const { container, getByRole, findByText } = render(
|
|
85
|
-
<LinkStructureTagForm {...propsCreateWithoutComment} />
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// Select tag
|
|
89
|
-
userEvent.click(await findByText("Tag2"));
|
|
90
|
-
|
|
91
|
-
await waitFor(() =>
|
|
92
|
-
expect(getByRole("button", { name: /add/ })).not.toBeDisabled()
|
|
93
|
-
);
|
|
94
|
-
expect(container).toMatchSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("create button enabled if there is only one tag available", async () => {
|
|
98
|
-
const propsCreateWithOneStrutureTagAvailable = {
|
|
99
|
-
...propsCreate,
|
|
100
|
-
structureTags: [structureTags[1], structureTags[2]],
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const { container, getByRole } = render(
|
|
104
|
-
<LinkStructureTagForm {...propsCreateWithOneStrutureTagAvailable} />
|
|
105
|
-
);
|
|
106
|
-
await waitFor(() =>
|
|
107
|
-
expect(getByRole("button", { name: /add/ })).not.toBeDisabled()
|
|
108
|
-
);
|
|
109
|
-
expect(container).toMatchSnapshot();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("Tag dropdown show tag description", async () => {
|
|
113
|
-
const { getByText } = render(<LinkStructureTagForm {...propsCreate} />);
|
|
114
|
-
await waitFor(() =>
|
|
115
|
-
expect(getByText("description test")).toBeInTheDocument()
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("Tag dropdown with tag with large description show ellipsis", async () => {
|
|
120
|
-
const { getByText } = render(<LinkStructureTagForm {...propsCreate} />);
|
|
121
|
-
|
|
122
|
-
const tagElement = getByText("Tag2");
|
|
123
|
-
|
|
124
|
-
await waitFor(() => expect(tagElement).toBeInTheDocument());
|
|
125
|
-
|
|
126
|
-
const descriptionElement = tagElement.parentElement.firstElementChild;
|
|
127
|
-
|
|
128
|
-
expect(descriptionElement).toHaveClass("description");
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("calls ", async () => {
|
|
132
|
-
const { queryByTestId, findByRole, findByText, getByRole } = render(
|
|
133
|
-
<LinkStructureTagForm {...{ ...propsCreate, linkedStructureTags: [] }} />
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
// Submit button should initially be disabled
|
|
137
|
-
await waitFor(() =>
|
|
138
|
-
expect(getByRole("button", { name: /add/ })).toBeDisabled()
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
// Select tag
|
|
142
|
-
userEvent.click(await findByText("Tag1"));
|
|
143
|
-
|
|
144
|
-
// Submit button should now be enabled
|
|
145
|
-
await waitFor(() =>
|
|
146
|
-
expect(getByRole("button", { name: /add/ })).not.toBeDisabled()
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
// Description
|
|
150
|
-
// Issue: https://github.com/testing-library/user-event/issues/346
|
|
151
|
-
userEvent.type(queryByTestId("comment-id"), "x");
|
|
152
|
-
userEvent.type(queryByTestId("comment-id"), "yz");
|
|
153
|
-
|
|
154
|
-
userEvent.click(await findByRole("button", { name: /add/ }));
|
|
155
|
-
|
|
156
|
-
await waitFor(() =>
|
|
157
|
-
expect(linkStructureTag).toHaveBeenCalledWith({
|
|
158
|
-
structureId,
|
|
159
|
-
tagId: 1,
|
|
160
|
-
tag: { comment: "xyz" },
|
|
161
|
-
})
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("calls deleteLinkStructureTag on delete", async () => {
|
|
166
|
-
const { findByRole, getByRole } = render(
|
|
167
|
-
<LinkStructureTagForm {...propsUpdate} />
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
// Delete button should be enabled
|
|
171
|
-
await waitFor(() =>
|
|
172
|
-
expect(getByRole("button", { name: /delete/ })).not.toBeDisabled()
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
userEvent.click(await findByRole("button", { name: /delete/ }));
|
|
176
|
-
|
|
177
|
-
await waitFor(() =>
|
|
178
|
-
expect(deleteLinkStructureTag).toHaveBeenCalledWith({
|
|
179
|
-
structureId,
|
|
180
|
-
tagId,
|
|
181
|
-
})
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
-
import { waitFor, fireEvent } from "@testing-library/react";
|
|
4
|
-
import { LinkedStructureTag } from "../LinkedStructureTag";
|
|
5
|
-
|
|
6
|
-
describe("<LinkedStructureTag />", () => {
|
|
7
|
-
const structureTags = [
|
|
8
|
-
{ id: 1, name: "Tag1", description: "description test" },
|
|
9
|
-
{ id: 2, name: "Tag2", description: "large desc".repeat(5) },
|
|
10
|
-
{ id: 3, name: "Tag without description" },
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
const props = {
|
|
14
|
-
id: 1,
|
|
15
|
-
_embedded: {
|
|
16
|
-
data_structure: { id: 1, external_id: "baz" },
|
|
17
|
-
data_structure_tag: { ...structureTags[2] },
|
|
18
|
-
},
|
|
19
|
-
editable: true,
|
|
20
|
-
comment: "foo comment",
|
|
21
|
-
loading: false,
|
|
22
|
-
structureTags,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const state = {
|
|
26
|
-
editableStructureTags: structureTags,
|
|
27
|
-
linkingStructureTags: false,
|
|
28
|
-
deletingStructureTags: false,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const renderOpts = {
|
|
32
|
-
state,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
it("matches the latest snapshot", () => {
|
|
36
|
-
const { container } = render(<LinkedStructureTag {...props} />, renderOpts);
|
|
37
|
-
expect(container).toMatchSnapshot();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("Show update modal when click in tad edit icon", async () => {
|
|
41
|
-
const { getByText, container } = render(
|
|
42
|
-
<LinkedStructureTag {...props} />,
|
|
43
|
-
renderOpts
|
|
44
|
-
);
|
|
45
|
-
fireEvent.click(container.getElementsByClassName("edit")[0]);
|
|
46
|
-
await waitFor(() => expect(getByText("Tag1")).toBeTruthy());
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("Show tooltip with description and comment", async () => {
|
|
50
|
-
const tagWithDescriptionProps = {
|
|
51
|
-
...props,
|
|
52
|
-
_embedded: {
|
|
53
|
-
...props._embedded,
|
|
54
|
-
data_structure_tag: { ...structureTags[0] },
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const { getByText } = render(
|
|
59
|
-
<LinkedStructureTag {...tagWithDescriptionProps} />,
|
|
60
|
-
renderOpts
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
fireEvent.mouseEnter(getByText("Tag1"));
|
|
64
|
-
|
|
65
|
-
await waitFor(() => expect(getByText("Comment")).toBeTruthy());
|
|
66
|
-
await waitFor(() => expect(getByText("foo comment")).toBeTruthy());
|
|
67
|
-
await waitFor(() =>
|
|
68
|
-
expect(getByText(structureTags[0].description)).toBeTruthy()
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("Show tooltip with description", async () => {
|
|
73
|
-
const tagWithDescriptionWithoutCommentProps = {
|
|
74
|
-
...props,
|
|
75
|
-
_embedded: {
|
|
76
|
-
...props._embedded,
|
|
77
|
-
data_structure_tag: { ...structureTags[0] },
|
|
78
|
-
},
|
|
79
|
-
comment: undefined,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const { getByText, queryByText } = render(
|
|
83
|
-
<LinkedStructureTag {...tagWithDescriptionWithoutCommentProps} />,
|
|
84
|
-
renderOpts
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
fireEvent.mouseEnter(getByText("Tag1"));
|
|
88
|
-
|
|
89
|
-
await waitFor(() => expect(queryByText("Comment")).toBeNull());
|
|
90
|
-
await waitFor(() => expect(queryByText("foo comment")).toBeNull());
|
|
91
|
-
await waitFor(() =>
|
|
92
|
-
expect(getByText(structureTags[0].description)).toBeTruthy()
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("Show tooltip with comment", async () => {
|
|
97
|
-
const { getByText, queryByText } = render(
|
|
98
|
-
<LinkedStructureTag {...props} />,
|
|
99
|
-
renderOpts
|
|
100
|
-
);
|
|
101
|
-
fireEvent.mouseEnter(getByText("Tag without description"));
|
|
102
|
-
|
|
103
|
-
await waitFor(() => expect(getByText("Comment")).toBeTruthy());
|
|
104
|
-
await waitFor(() => expect(getByText("foo comment")).toBeTruthy());
|
|
105
|
-
await waitFor(() =>
|
|
106
|
-
expect(queryByText(structureTags[0].description)).toBeNull()
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("Tooltip not show without description and without comment", async () => {
|
|
111
|
-
const tagWithoutDescriptionWithoutComment = {
|
|
112
|
-
...props,
|
|
113
|
-
comment: undefined,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const { getByText, queryByText, container } = render(
|
|
117
|
-
<LinkedStructureTag {...tagWithoutDescriptionWithoutComment} />,
|
|
118
|
-
renderOpts
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
fireEvent.mouseEnter(getByText("Tag without description"));
|
|
122
|
-
|
|
123
|
-
await waitFor(() => expect(queryByText("Comment")).toBeNull());
|
|
124
|
-
await waitFor(() => expect(queryByText("foo comment")).toBeNull());
|
|
125
|
-
await waitFor(() =>
|
|
126
|
-
expect(queryByText(structureTags[0].description)).toBeNull()
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
await waitFor(() =>
|
|
130
|
-
expect(container.getElementsByClassName("popup")).toHaveLength(0)
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
-
import StructureTags from "../StructureTags";
|
|
4
|
-
import en from "../../messages/en";
|
|
5
|
-
|
|
6
|
-
const messages = { en };
|
|
7
|
-
const renderOpts = { messages };
|
|
8
|
-
|
|
9
|
-
describe("<StructureTags />", () => {
|
|
10
|
-
it("matches the latest snapshot", () => {
|
|
11
|
-
const { container } = render(<StructureTags />, renderOpts);
|
|
12
|
-
expect(container).toMatchSnapshot();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { shallow } from "enzyme";
|
|
3
|
-
import { StructureTagsCrumbs } from "../StructureTagsCrumbs";
|
|
4
|
-
|
|
5
|
-
describe("<StructureTagsCrumbs />", () => {
|
|
6
|
-
const structureTag = { id: 1, name: "doc" };
|
|
7
|
-
|
|
8
|
-
it("matches the latest snapshot", () => {
|
|
9
|
-
const props = { structureTag };
|
|
10
|
-
const wrapper = shallow(<StructureTagsCrumbs {...props} />);
|
|
11
|
-
expect(wrapper).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
});
|