@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.
Files changed (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +5 -5
  3. package/src/api/fragments.js +2 -2
  4. package/src/api/mutations.js +33 -11
  5. package/src/api/queries.js +37 -10
  6. package/src/api.js +0 -4
  7. package/src/components/DictionaryRoutes.js +4 -4
  8. package/src/components/StructureSummary.js +12 -22
  9. package/src/components/StructureTag.js +83 -54
  10. package/src/components/StructureTagForm.js +149 -89
  11. package/src/components/StructureTags.js +57 -27
  12. package/src/components/Tag.js +62 -0
  13. package/src/components/TagCards.js +85 -0
  14. package/src/components/TagCrumbs.js +25 -0
  15. package/src/components/TagForm.js +102 -0
  16. package/src/components/TagStructureButton.js +58 -0
  17. package/src/components/Tags.js +33 -0
  18. package/src/components/TagsRoutes.js +39 -0
  19. package/src/components/__tests__/StructureSummary.spec.js +0 -7
  20. package/src/components/__tests__/StructureTag.spec.js +79 -5
  21. package/src/components/__tests__/StructureTagForm.spec.js +99 -50
  22. package/src/components/__tests__/Tag.spec.js +11 -0
  23. package/src/components/__tests__/{StructureTagsCards.spec.js → TagCards.spec.js} +10 -10
  24. package/src/components/__tests__/TagCrumbs.spec.js +10 -0
  25. package/src/components/__tests__/TagForm.spec.js +72 -0
  26. package/src/components/__tests__/Tags.spec.js +10 -0
  27. package/src/components/__tests__/__snapshots__/StructureSummary.spec.js.snap +18 -42
  28. package/src/components/__tests__/__snapshots__/StructureTag.spec.js.snap +10 -30
  29. package/src/components/__tests__/__snapshots__/StructureTagForm.spec.js.snap +255 -51
  30. package/src/components/__tests__/__snapshots__/Tag.spec.js.snap +36 -0
  31. package/src/components/__tests__/__snapshots__/{StructureTagsCards.spec.js.snap → TagCards.spec.js.snap} +1 -1
  32. package/src/components/__tests__/__snapshots__/TagCrumbs.spec.js.snap +102 -0
  33. package/src/components/__tests__/__snapshots__/TagForm.spec.js.snap +70 -0
  34. package/src/components/__tests__/__snapshots__/{StructureTags.spec.js.snap → Tags.spec.js.snap} +1 -1
  35. package/src/messages/en.js +25 -30
  36. package/src/messages/es.js +25 -30
  37. package/src/reducers/__tests__/{editableStructureTags.spec.js → availableTags.spec.js} +7 -11
  38. package/src/reducers/__tests__/structureTagSaving.spec.js +36 -0
  39. package/src/reducers/__tests__/tagSaving.spec.js +32 -0
  40. package/src/reducers/{editableStructureTags.js → availableTags.js} +2 -2
  41. package/src/reducers/index.js +6 -12
  42. package/src/reducers/structureRedirect.js +7 -7
  43. package/src/reducers/structureTagSaving.js +12 -10
  44. package/src/reducers/tagSaving.js +18 -0
  45. package/src/routines.js +5 -6
  46. package/src/sagas/__tests__/createTag.spec.js +81 -0
  47. package/src/sagas/__tests__/deleteStructureTag.spec.js +11 -12
  48. package/src/sagas/__tests__/deleteTag.spec.js +76 -0
  49. package/src/sagas/__tests__/tagStructure.spec.js +86 -0
  50. package/src/sagas/__tests__/updateTag.spec.js +81 -0
  51. package/src/sagas/createTag.js +29 -0
  52. package/src/sagas/deleteStructureTag.js +12 -9
  53. package/src/sagas/deleteTag.js +34 -0
  54. package/src/sagas/index.js +15 -18
  55. package/src/sagas/tagStructure.js +37 -0
  56. package/src/sagas/updateTag.js +23 -0
  57. package/src/components/LinkStructureTagForm.js +0 -163
  58. package/src/components/LinkedStructureTag.js +0 -124
  59. package/src/components/StructureLinkTagButton.js +0 -47
  60. package/src/components/StructureTagsCards.js +0 -92
  61. package/src/components/StructureTagsCrumbs.js +0 -44
  62. package/src/components/StructureTagsRoutes.js +0 -45
  63. package/src/components/TagsHeader.js +0 -32
  64. package/src/components/__tests__/LinkStructureTagForm.spec.js +0 -184
  65. package/src/components/__tests__/LinkedStructureTag.spec.js +0 -133
  66. package/src/components/__tests__/StructureTags.spec.js +0 -14
  67. package/src/components/__tests__/StructureTagsCrumbs.spec.js +0 -13
  68. package/src/components/__tests__/__snapshots__/LinkStructureTagForm.spec.js.snap +0 -456
  69. package/src/components/__tests__/__snapshots__/LinkedStructureTag.spec.js.snap +0 -16
  70. package/src/components/__tests__/__snapshots__/StructureTagsCrumbs.spec.js.snap +0 -36
  71. package/src/reducers/__tests__/deletingStructureTags.spec.js +0 -30
  72. package/src/reducers/__tests__/linkedStructureTags.spec.js +0 -69
  73. package/src/reducers/__tests__/linkedStructureTagsLoading.spec.js +0 -32
  74. package/src/reducers/__tests__/linkingStructureTags.spec.js +0 -30
  75. package/src/reducers/__tests__/structureTagsSaving.spec.js +0 -40
  76. package/src/reducers/deletingStructureTags.js +0 -16
  77. package/src/reducers/linkedStructureTags.js +0 -28
  78. package/src/reducers/linkedStructureTagsLoading.js +0 -16
  79. package/src/reducers/linkingStructureTags.js +0 -16
  80. package/src/sagas/__tests__/createStructureTag.spec.js +0 -85
  81. package/src/sagas/__tests__/deleteLinkStructureTag.spec.js +0 -96
  82. package/src/sagas/__tests__/fetchLinksStructureTags.spec.js +0 -105
  83. package/src/sagas/__tests__/linkStructureTag.spec.js +0 -102
  84. package/src/sagas/__tests__/updateStructureTag.spec.js +0 -84
  85. package/src/sagas/createStructureTag.js +0 -29
  86. package/src/sagas/deleteLinkStructureTag.js +0 -29
  87. package/src/sagas/fetchLinksStructureTags.js +0 -31
  88. package/src/sagas/linkStructureTag.js +0 -30
  89. 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
- });