@truedat/dd 4.47.6 → 4.47.9
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 +24 -0
- package/package.json +6 -6
- package/src/api/fragments.js +1 -0
- package/src/api/queries.js +10 -0
- package/src/components/LinkStructureTagForm.js +14 -11
- package/src/components/LinkedStructureTag.js +43 -8
- package/src/components/ReferenceDatasetSelectorInputField.js +107 -0
- package/src/components/StructureFieldsDropdown.js +30 -12
- package/src/components/StructureSelectorInputField.js +0 -1
- package/src/components/StructureSelectorInputFieldJoin.js +15 -15
- package/src/components/StructureTagForm.js +23 -1
- package/src/components/StructureTagsCards.js +3 -0
- package/src/components/ValueConditionStructure.js +1 -7
- package/src/components/__tests__/LinkStructureTagForm.spec.js +80 -26
- package/src/components/__tests__/LinkedStructureTag.spec.js +133 -0
- package/src/components/__tests__/StructureTagForm.spec.js +6 -1
- package/src/components/__tests__/StructureTagsCards.spec.js +2 -0
- package/src/components/__tests__/__snapshots__/LinkStructureTagForm.spec.js.snap +267 -17
- package/src/components/__tests__/__snapshots__/LinkedStructureTag.spec.js.snap +16 -0
- package/src/components/__tests__/__snapshots__/StructureSelectorInputFieldJoin.spec.js.snap +30 -5
- package/src/components/__tests__/__snapshots__/StructureTagForm.spec.js.snap +20 -0
- package/src/components/__tests__/__snapshots__/StructureTagsCards.spec.js.snap +10 -0
- package/src/index.js +2 -1
- package/src/messages/en.js +4 -2
- package/src/messages/es.js +4 -2
- package/src/reducers/__tests__/linkedStructureTags.spec.js +1 -1
- package/src/sagas/requestGrantRemoval.js +0 -1
- package/src/selectors/getStructureFieldOptionValue.js +8 -0
- package/src/selectors/getStructuresFields.js +24 -10
|
@@ -11,26 +11,27 @@ jest.spyOn(React, "useContext").mockImplementation(() => intl);
|
|
|
11
11
|
describe("<LinkStructureTagForm />", () => {
|
|
12
12
|
const deleteLinkStructureTag = jest.fn();
|
|
13
13
|
const linkStructureTag = jest.fn();
|
|
14
|
-
const
|
|
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
|
+
];
|
|
15
19
|
const linkedStructureTags = [
|
|
16
20
|
{
|
|
17
21
|
id: 1,
|
|
18
|
-
|
|
22
|
+
comment: "foo",
|
|
19
23
|
inserted_at: "foo",
|
|
20
24
|
updated_at: "foo",
|
|
21
25
|
_embedded: {
|
|
22
26
|
data_structure: { id: 1, external_id: "baz" },
|
|
23
|
-
data_structure_tag: {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
];
|
|
27
|
-
const structureTags = [
|
|
28
|
-
{ id: 1, name: "foo" },
|
|
29
|
-
{ id: 2, name: "bar" }
|
|
27
|
+
data_structure_tag: { ...structureTags[2] },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
+
const comment = "foo";
|
|
32
33
|
const structureId = 1;
|
|
33
|
-
const tagId =
|
|
34
|
+
const tagId = 3;
|
|
34
35
|
const linkId = 1;
|
|
35
36
|
|
|
36
37
|
const propsCreate = {
|
|
@@ -38,18 +39,18 @@ describe("<LinkStructureTagForm />", () => {
|
|
|
38
39
|
linkedStructureTags,
|
|
39
40
|
linkStructureTag,
|
|
40
41
|
structureId,
|
|
41
|
-
structureTags
|
|
42
|
+
structureTags,
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
const propsUpdate = {
|
|
45
46
|
deleteLinkStructureTag,
|
|
46
|
-
|
|
47
|
+
comment,
|
|
47
48
|
linkedStructureTags,
|
|
48
49
|
linkId,
|
|
49
50
|
linkStructureTag,
|
|
50
51
|
structureId,
|
|
51
52
|
structureTags,
|
|
52
|
-
tagId
|
|
53
|
+
tagId,
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
it("matches the latest snapshot create", async () => {
|
|
@@ -69,6 +70,64 @@ describe("<LinkStructureTagForm />", () => {
|
|
|
69
70
|
expect(container).toMatchSnapshot();
|
|
70
71
|
});
|
|
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
|
+
|
|
72
131
|
it("calls ", async () => {
|
|
73
132
|
const { queryByTestId, findByRole, findByText, getByRole } = render(
|
|
74
133
|
<LinkStructureTagForm {...{ ...propsCreate, linkedStructureTags: [] }} />
|
|
@@ -80,30 +139,25 @@ describe("<LinkStructureTagForm />", () => {
|
|
|
80
139
|
);
|
|
81
140
|
|
|
82
141
|
// Select tag
|
|
83
|
-
userEvent.click(await findByText("
|
|
142
|
+
userEvent.click(await findByText("Tag1"));
|
|
84
143
|
|
|
85
|
-
// Submit button should
|
|
144
|
+
// Submit button should now be enabled
|
|
86
145
|
await waitFor(() =>
|
|
87
|
-
expect(getByRole("button", { name: /add/ })).toBeDisabled()
|
|
146
|
+
expect(getByRole("button", { name: /add/ })).not.toBeDisabled()
|
|
88
147
|
);
|
|
89
148
|
|
|
90
149
|
// Description
|
|
91
150
|
// Issue: https://github.com/testing-library/user-event/issues/346
|
|
92
|
-
userEvent.type(queryByTestId("
|
|
93
|
-
userEvent.type(queryByTestId("
|
|
94
|
-
|
|
95
|
-
// Submit button should now be enabled
|
|
96
|
-
await waitFor(() =>
|
|
97
|
-
expect(getByRole("button", { name: /add/ })).not.toBeDisabled()
|
|
98
|
-
);
|
|
151
|
+
userEvent.type(queryByTestId("comment-id"), "x");
|
|
152
|
+
userEvent.type(queryByTestId("comment-id"), "yz");
|
|
99
153
|
|
|
100
154
|
userEvent.click(await findByRole("button", { name: /add/ }));
|
|
101
155
|
|
|
102
156
|
await waitFor(() =>
|
|
103
157
|
expect(linkStructureTag).toHaveBeenCalledWith({
|
|
104
158
|
structureId,
|
|
105
|
-
tagId:
|
|
106
|
-
tag: {
|
|
159
|
+
tagId: 1,
|
|
160
|
+
tag: { comment: "xyz" },
|
|
107
161
|
})
|
|
108
162
|
);
|
|
109
163
|
});
|
|
@@ -123,7 +177,7 @@ describe("<LinkStructureTagForm />", () => {
|
|
|
123
177
|
await waitFor(() =>
|
|
124
178
|
expect(deleteLinkStructureTag).toHaveBeenCalledWith({
|
|
125
179
|
structureId,
|
|
126
|
-
tagId
|
|
180
|
+
tagId,
|
|
127
181
|
})
|
|
128
182
|
);
|
|
129
183
|
});
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
});
|
|
@@ -19,6 +19,7 @@ describe("<StructureTagForm />", () => {
|
|
|
19
19
|
const structureTag = {
|
|
20
20
|
id: 1,
|
|
21
21
|
name: "foo",
|
|
22
|
+
description: "bar",
|
|
22
23
|
domainIds: [],
|
|
23
24
|
};
|
|
24
25
|
const saving = false;
|
|
@@ -45,7 +46,7 @@ describe("<StructureTagForm />", () => {
|
|
|
45
46
|
expect(getByRole("button", { name: /save/i })).toBeDisabled()
|
|
46
47
|
);
|
|
47
48
|
|
|
48
|
-
//
|
|
49
|
+
// Name
|
|
49
50
|
userEvent.type(getByRole("textbox", { name: /name/i }), "foo");
|
|
50
51
|
|
|
51
52
|
// Submit button should now be enabled
|
|
@@ -53,6 +54,9 @@ describe("<StructureTagForm />", () => {
|
|
|
53
54
|
expect(getByRole("button", { name: /save/i })).not.toBeDisabled()
|
|
54
55
|
);
|
|
55
56
|
|
|
57
|
+
// Name
|
|
58
|
+
userEvent.type(getByRole("textbox", { name: /description/i }), "bar");
|
|
59
|
+
|
|
56
60
|
// Submit
|
|
57
61
|
userEvent.click(getByRole("button", { name: /save/i }));
|
|
58
62
|
|
|
@@ -61,6 +65,7 @@ describe("<StructureTagForm />", () => {
|
|
|
61
65
|
});
|
|
62
66
|
expect(onSubmit.mock.calls[0][0]).toMatchObject({
|
|
63
67
|
name: "foofoo",
|
|
68
|
+
description: "barbar",
|
|
64
69
|
domainIds: [],
|
|
65
70
|
});
|
|
66
71
|
});
|
|
@@ -14,6 +14,7 @@ const structureTagsMock = {
|
|
|
14
14
|
__typename: "StructureTag",
|
|
15
15
|
id: "1",
|
|
16
16
|
name: "tag1",
|
|
17
|
+
description: "tag_desc_1",
|
|
17
18
|
domainIds: [],
|
|
18
19
|
structureCount: 1,
|
|
19
20
|
},
|
|
@@ -21,6 +22,7 @@ const structureTagsMock = {
|
|
|
21
22
|
__typename: "StructureTag",
|
|
22
23
|
id: "2",
|
|
23
24
|
name: "tag2",
|
|
25
|
+
description: "tag_desc_2",
|
|
24
26
|
domainIds: ["1"],
|
|
25
27
|
structureCount: 1,
|
|
26
28
|
},
|