@truedat/bg 4.51.2 → 4.51.4
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 +7 -0
- package/package.json +5 -5
- package/src/concepts/components/ConceptForm.js +21 -11
- package/src/concepts/components/ConceptManageDomain.js +23 -40
- package/src/concepts/components/ConceptRoutes.js +12 -21
- package/src/concepts/components/ConceptsBulkUpdate.js +48 -53
- package/src/concepts/components/SharedToForm.js +15 -27
- package/src/concepts/components/__tests__/ConceptForm.spec.js +18 -4
- package/src/concepts/components/__tests__/ConceptsBulkUpdate.spec.js +72 -277
- package/src/concepts/components/__tests__/SharedToForm.spec.js +22 -12
- package/src/concepts/components/__tests__/__snapshots__/ConceptForm.spec.js.snap +63 -209
- package/src/concepts/components/__tests__/__snapshots__/ConceptManageDomain.spec.js.snap +1 -99
- package/src/concepts/components/__tests__/__snapshots__/ConceptsBulkUpdate.spec.js.snap +138 -105
- package/src/concepts/components/__tests__/__snapshots__/SharedToForm.spec.js.snap +10 -15
- package/src/taxonomy/components/index.js +1 -9
- package/src/taxonomy/components/DomainDropdownSelector.js +0 -200
- package/src/taxonomy/components/DomainMenuSelector.js +0 -188
- package/src/taxonomy/components/__tests__/DomainDropdownSelector.spec.js +0 -119
- package/src/taxonomy/components/__tests__/DomainMenuSelector.spec.js +0 -122
- package/src/taxonomy/components/__tests__/__snapshots__/DomainDropdownSelector.spec.js.snap +0 -86
- package/src/taxonomy/components/__tests__/__snapshots__/DomainMenuSelector.spec.js.snap +0 -74
|
@@ -1,291 +1,86 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { render } from "@truedat/test/render";
|
|
5
|
+
import { domainsMock } from "@truedat/test/mocks";
|
|
6
|
+
import { bulkUpdate } from "../../routines";
|
|
7
|
+
import ConceptsBulkUpdate from "../ConceptsBulkUpdate";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const content = [
|
|
10
|
+
{ name: "g1", fields: [{ name: "f1", label: "f1", placeholder: "p1" }] },
|
|
11
|
+
];
|
|
12
|
+
const template = { name: "t1", id: 123, content };
|
|
13
|
+
const state = {
|
|
14
|
+
conceptCount: 1,
|
|
15
|
+
concepts: [{ type: "t1" }],
|
|
16
|
+
template,
|
|
17
|
+
templates: [template],
|
|
18
|
+
};
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const renderOpts = {
|
|
21
|
+
fallback: "lazy",
|
|
22
|
+
mocks: [domainsMock({ action: "manageConcept" })],
|
|
23
|
+
state,
|
|
24
|
+
};
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
jest.spyOn(ConceptsBulkUpdate.prototype, "componentDidMount");
|
|
30
|
-
shallow(<ConceptsBulkUpdate {...props} />);
|
|
31
|
-
expect(
|
|
32
|
-
ConceptsBulkUpdate.prototype.componentDidMount.mock.calls.length
|
|
33
|
-
).toBe(1);
|
|
34
|
-
expect(props.selectTemplate).toHaveBeenCalledTimes(1);
|
|
26
|
+
describe("<ConceptsBulkUpdate />", () => {
|
|
27
|
+
it("matches the latest snapshot", async () => {
|
|
28
|
+
const { container, queryByText } = render(
|
|
29
|
+
<ConceptsBulkUpdate />,
|
|
30
|
+
renderOpts
|
|
31
|
+
);
|
|
32
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
33
|
+
expect(container).toMatchSnapshot();
|
|
35
34
|
});
|
|
36
35
|
|
|
37
|
-
it("calls
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
expect(
|
|
36
|
+
it("calls applyTemplate when selectedDomain changes", async () => {
|
|
37
|
+
const applyTemplate = jest.fn();
|
|
38
|
+
const { findByText, queryByText } = render(
|
|
39
|
+
<ConceptsBulkUpdate applyTemplate={applyTemplate} />,
|
|
40
|
+
renderOpts
|
|
41
|
+
);
|
|
42
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
43
|
+
await waitFor(() => expect(queryByText(/fooDomain/)).toBeInTheDocument());
|
|
44
|
+
expect(applyTemplate).toHaveBeenCalledTimes(0);
|
|
45
|
+
userEvent.click(await findByText("fooDomain"));
|
|
46
|
+
expect(applyTemplate).toHaveBeenCalledTimes(1);
|
|
47
|
+
userEvent.click(await findByText("barDomain"));
|
|
48
|
+
expect(applyTemplate).toHaveBeenCalledTimes(2);
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
it("DynamicForm rendered if template, template_id, selectedDomain informed", () => {
|
|
53
|
-
const props = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const wrapper = shallow(<ConceptsBulkUpdate {...props} />);
|
|
62
|
-
expect(wrapper.find({ fieldsToOmit: ["_confidential"] })).toHaveLength(1);
|
|
51
|
+
it("DynamicForm rendered if template, template_id, selectedDomain informed", async () => {
|
|
52
|
+
const props = { applyTemplate: jest.fn() };
|
|
53
|
+
const { findByText, queryByText } = render(
|
|
54
|
+
<ConceptsBulkUpdate {...props} />,
|
|
55
|
+
renderOpts
|
|
56
|
+
);
|
|
57
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
58
|
+
userEvent.click(await findByText("fooDomain"));
|
|
59
|
+
await waitFor(() => expect(queryByText(/f1/)).toBeInTheDocument());
|
|
63
60
|
});
|
|
64
61
|
|
|
65
|
-
it("calls bulkUpdate on onClick", () => {
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
description: "a",
|
|
70
|
-
id: 2,
|
|
71
|
-
name: "Dos",
|
|
72
|
-
},
|
|
73
|
-
];
|
|
74
|
-
const template = {
|
|
75
|
-
content: [
|
|
76
|
-
{
|
|
77
|
-
fields: [
|
|
78
|
-
{
|
|
79
|
-
cardinality: "1",
|
|
80
|
-
default: 3,
|
|
81
|
-
label: "bg_number",
|
|
82
|
-
name: "bg_number",
|
|
83
|
-
type: "number",
|
|
84
|
-
values: null,
|
|
85
|
-
widget: "number",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
cardinality: "1",
|
|
89
|
-
default: "22-03-2020",
|
|
90
|
-
label: "bg_date",
|
|
91
|
-
name: "bg_date",
|
|
92
|
-
type: "date",
|
|
93
|
-
values: null,
|
|
94
|
-
widget: "date",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
cardinality: "?",
|
|
98
|
-
default: "19-05-2020 18:10:00",
|
|
99
|
-
label: "bg_datetime",
|
|
100
|
-
name: "bg_datetime",
|
|
101
|
-
type: "datetime",
|
|
102
|
-
values: null,
|
|
103
|
-
widget: "datetime",
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
is_secret: false,
|
|
107
|
-
name: "",
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
id: 10,
|
|
111
|
-
label: "nuevos tipos",
|
|
112
|
-
name: "nuevostipos",
|
|
113
|
-
scope: "bg",
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const concepts = [
|
|
62
|
+
it("calls bulkUpdate on onClick", async () => {
|
|
63
|
+
const dispatch = jest.fn();
|
|
64
|
+
const { findByText, queryByText, findByPlaceholderText } = render(
|
|
65
|
+
<ConceptsBulkUpdate />,
|
|
117
66
|
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
bg_datetime: "2020-05-02 18:00",
|
|
136
|
-
bg_number: -1,
|
|
137
|
-
},
|
|
138
|
-
id: 19,
|
|
139
|
-
name: "numero 2",
|
|
140
|
-
type: "nuevostipos",
|
|
141
|
-
},
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
const props = {
|
|
145
|
-
loading: false,
|
|
146
|
-
template,
|
|
147
|
-
selectTemplate,
|
|
148
|
-
bulkUpdate,
|
|
149
|
-
applyTemplate: applyTemplateWithoutDefaults(template),
|
|
150
|
-
concepts,
|
|
151
|
-
domains,
|
|
152
|
-
selectedDomain: { id: 1 },
|
|
153
|
-
};
|
|
154
|
-
const wrapper = shallow(<ConceptsBulkUpdate {...props} />);
|
|
155
|
-
wrapper.setState({
|
|
156
|
-
content: {
|
|
157
|
-
bg_number: 1,
|
|
158
|
-
bg_date: "2020-05-14",
|
|
159
|
-
bg_datetime: "2020-05-28 22:50",
|
|
160
|
-
},
|
|
161
|
-
domain_id: 1,
|
|
162
|
-
});
|
|
163
|
-
_.find({ key: "yes" })(
|
|
164
|
-
wrapper
|
|
165
|
-
.find("ConfirmModal")
|
|
166
|
-
.dive()
|
|
167
|
-
.find("Modal")
|
|
168
|
-
.dive()
|
|
169
|
-
.find("ModalActions")
|
|
170
|
-
.props().actions
|
|
171
|
-
).onClick({ preventDefault() {} });
|
|
172
|
-
|
|
173
|
-
expect(props.bulkUpdate.mock.calls.length).toBe(1);
|
|
174
|
-
expect(props.bulkUpdate).toHaveBeenCalledWith({
|
|
175
|
-
update_attributes: {
|
|
176
|
-
domain_id: 1,
|
|
177
|
-
content: {
|
|
178
|
-
bg_date: "2020-05-14",
|
|
179
|
-
bg_datetime: "2020-05-28 22:50",
|
|
180
|
-
bg_number: 1,
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("calls bulkUpdate excluding empty content on onClick", () => {
|
|
187
|
-
const bulkUpdate = jest.fn();
|
|
188
|
-
const domains = [
|
|
189
|
-
{
|
|
190
|
-
description: "a",
|
|
191
|
-
id: 2,
|
|
192
|
-
name: "Dos",
|
|
193
|
-
},
|
|
194
|
-
];
|
|
195
|
-
const template = {
|
|
196
|
-
content: [
|
|
197
|
-
{
|
|
198
|
-
fields: [
|
|
199
|
-
{
|
|
200
|
-
cardinality: "1",
|
|
201
|
-
default: 3,
|
|
202
|
-
label: "bg_number",
|
|
203
|
-
name: "bg_number",
|
|
204
|
-
type: "number",
|
|
205
|
-
values: null,
|
|
206
|
-
widget: "number",
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
cardinality: "1",
|
|
210
|
-
default: "22-03-2020",
|
|
211
|
-
label: "bg_date",
|
|
212
|
-
name: "bg_date",
|
|
213
|
-
type: "date",
|
|
214
|
-
values: null,
|
|
215
|
-
widget: "date",
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
cardinality: "?",
|
|
219
|
-
default: "19-05-2020 18:10:00",
|
|
220
|
-
label: "bg_datetime",
|
|
221
|
-
name: "bg_datetime",
|
|
222
|
-
type: "datetime",
|
|
223
|
-
values: null,
|
|
224
|
-
widget: "datetime",
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
is_secret: false,
|
|
228
|
-
name: "",
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
|
-
id: 10,
|
|
232
|
-
label: "nuevos tipos",
|
|
233
|
-
name: "nuevostipos",
|
|
234
|
-
scope: "bg",
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
const concepts = [
|
|
238
|
-
{
|
|
239
|
-
business_concept_id: 18,
|
|
240
|
-
id: 18,
|
|
241
|
-
name: "numero",
|
|
242
|
-
type: "nuevostipos",
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
business_concept_id: 19,
|
|
246
|
-
id: 19,
|
|
247
|
-
name: "numero 2",
|
|
248
|
-
type: "nuevostipos",
|
|
249
|
-
},
|
|
250
|
-
];
|
|
251
|
-
|
|
252
|
-
const props = {
|
|
253
|
-
loading: false,
|
|
254
|
-
template,
|
|
255
|
-
selectTemplate,
|
|
256
|
-
bulkUpdate,
|
|
257
|
-
applyTemplate: applyTemplateWithoutDefaults(template),
|
|
258
|
-
concepts,
|
|
259
|
-
domains,
|
|
260
|
-
selectedDomain: { id: 1 },
|
|
261
|
-
};
|
|
262
|
-
const wrapper = shallow(<ConceptsBulkUpdate {...props} />);
|
|
263
|
-
wrapper.setState({
|
|
264
|
-
content: {
|
|
265
|
-
bg_number: 0,
|
|
266
|
-
bg_date: "",
|
|
267
|
-
bg_datetime: "",
|
|
268
|
-
},
|
|
269
|
-
domain_id: 1,
|
|
270
|
-
});
|
|
271
|
-
_.find({ key: "yes" })(
|
|
272
|
-
wrapper
|
|
273
|
-
.find("ConfirmModal")
|
|
274
|
-
.dive()
|
|
275
|
-
.find("Modal")
|
|
276
|
-
.dive()
|
|
277
|
-
.find("ModalActions")
|
|
278
|
-
.props().actions
|
|
279
|
-
).onClick({ preventDefault() {} });
|
|
280
|
-
|
|
281
|
-
expect(props.bulkUpdate.mock.calls.length).toBe(1);
|
|
282
|
-
expect(props.bulkUpdate).toHaveBeenCalledWith({
|
|
283
|
-
update_attributes: {
|
|
284
|
-
domain_id: 1,
|
|
285
|
-
content: {
|
|
286
|
-
bg_number: 0,
|
|
287
|
-
},
|
|
288
|
-
},
|
|
67
|
+
...renderOpts,
|
|
68
|
+
dispatch,
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
72
|
+
userEvent.click(await findByText("fooDomain"));
|
|
73
|
+
await waitFor(() => expect(queryByText(/f1/)).toBeInTheDocument());
|
|
74
|
+
userEvent.type(await findByPlaceholderText("p1"), "abc123456");
|
|
75
|
+
await waitFor(() => expect(queryByText(/Save/)).toBeEnabled());
|
|
76
|
+
userEvent.click(await findByText("Save"));
|
|
77
|
+
userEvent.click(await findByText("Yes"));
|
|
78
|
+
await waitFor(() => {
|
|
79
|
+
expect(dispatch).toHaveBeenLastCalledWith(
|
|
80
|
+
bulkUpdate({
|
|
81
|
+
update_attributes: { content: { f1: "abc123456" }, domain_id: 1 },
|
|
82
|
+
})
|
|
83
|
+
);
|
|
289
84
|
});
|
|
290
85
|
});
|
|
291
86
|
});
|
|
@@ -2,20 +2,18 @@ import React from "react";
|
|
|
2
2
|
import { waitFor } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import { render } from "@truedat/test/render";
|
|
5
|
+
import { domainsMock } from "@truedat/test/mocks";
|
|
5
6
|
import { SharedToForm } from "../SharedToForm";
|
|
6
7
|
|
|
8
|
+
const mocks = [domainsMock({ action: "shareConcept" })];
|
|
9
|
+
const renderOpts = { mocks };
|
|
10
|
+
|
|
7
11
|
describe("<SharedToForm />", () => {
|
|
8
12
|
const id = 5;
|
|
9
|
-
const domainOptions = [
|
|
10
|
-
{ id: 1, name: "foo", level: 0 },
|
|
11
|
-
{ id: 2, name: "bar", level: 0 },
|
|
12
|
-
{ id: 3, name: "baz", level: 0 },
|
|
13
|
-
];
|
|
14
13
|
const saveSharedTo = jest.fn();
|
|
15
14
|
const saving = false;
|
|
16
15
|
const sharedTo = [{ id: 2, name: "bar" }];
|
|
17
16
|
const props = {
|
|
18
|
-
domainOptions,
|
|
19
17
|
id,
|
|
20
18
|
saveSharedTo,
|
|
21
19
|
saving,
|
|
@@ -23,27 +21,39 @@ describe("<SharedToForm />", () => {
|
|
|
23
21
|
};
|
|
24
22
|
|
|
25
23
|
it("matches the latest snapshot", async () => {
|
|
26
|
-
const { container } = render(
|
|
24
|
+
const { container, queryByText } = render(
|
|
25
|
+
<SharedToForm {...props} />,
|
|
26
|
+
renderOpts
|
|
27
|
+
);
|
|
28
|
+
await waitFor(() => {
|
|
29
|
+
expect(queryByText(/fooDomain/)).toBeInTheDocument();
|
|
30
|
+
});
|
|
27
31
|
await waitFor(() => {
|
|
28
32
|
expect(container).toMatchSnapshot();
|
|
29
33
|
});
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
it("enables share button when we select a domain", async () => {
|
|
33
|
-
const { findByText, queryByText } = render(
|
|
37
|
+
const { findByText, queryByText } = render(
|
|
38
|
+
<SharedToForm {...props} />,
|
|
39
|
+
renderOpts
|
|
40
|
+
);
|
|
34
41
|
|
|
35
42
|
expect(queryByText("Share")).toBeDisabled();
|
|
36
|
-
userEvent.click(await findByText(/
|
|
43
|
+
userEvent.click(await findByText(/fooDomain/));
|
|
37
44
|
await waitFor(() => {
|
|
38
45
|
expect(queryByText("Share")).not.toBeDisabled();
|
|
39
46
|
});
|
|
40
47
|
});
|
|
41
48
|
|
|
42
49
|
it("invokes function when submit button clicked", async () => {
|
|
43
|
-
const { findByText, queryByText } = render(
|
|
50
|
+
const { findByText, queryByText } = render(
|
|
51
|
+
<SharedToForm {...props} />,
|
|
52
|
+
renderOpts
|
|
53
|
+
);
|
|
44
54
|
|
|
45
55
|
expect(queryByText("Share")).toBeDisabled();
|
|
46
|
-
userEvent.click(await findByText(/
|
|
56
|
+
userEvent.click(await findByText(/fooDomain/));
|
|
47
57
|
await waitFor(() => {
|
|
48
58
|
expect(queryByText("Share")).not.toBeDisabled();
|
|
49
59
|
});
|
|
@@ -52,7 +62,7 @@ describe("<SharedToForm />", () => {
|
|
|
52
62
|
expect(saveSharedTo.mock.calls.length).toBe(1);
|
|
53
63
|
});
|
|
54
64
|
expect(saveSharedTo).toHaveBeenCalledWith(
|
|
55
|
-
expect.objectContaining({ id, sharedTo: [2,
|
|
65
|
+
expect.objectContaining({ id, sharedTo: ["2", "1"] })
|
|
56
66
|
);
|
|
57
67
|
});
|
|
58
68
|
});
|