@truedat/dd 6.0.1 → 6.0.3

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 (36) hide show
  1. package/package.json +6 -6
  2. package/src/api.js +2 -0
  3. package/src/components/BucketView.js +4 -3
  4. package/src/components/CatalogCustomViewCards.js +4 -1
  5. package/src/components/FilteredNav.js +92 -37
  6. package/src/components/StructureCrumbs.js +10 -8
  7. package/src/components/StructureItem.js +43 -6
  8. package/src/components/StructureItemRoot.js +6 -6
  9. package/src/components/StructureItems.js +6 -2
  10. package/src/components/StructureNav.js +10 -1
  11. package/src/components/StructureNavClassified.js +8 -1
  12. package/src/components/StructureNotesEdit.js +13 -5
  13. package/src/components/StructureSearch.js +16 -7
  14. package/src/components/StructureView.js +1 -1
  15. package/src/components/StructuresView.js +5 -5
  16. package/src/components/SystemStructures.js +7 -2
  17. package/src/components/__tests__/BucketView.spec.js +2 -1
  18. package/src/components/__tests__/FilteredNav.spec.js +76 -49
  19. package/src/components/__tests__/StructureItems.spec.js +2 -2
  20. package/src/components/__tests__/StructureNav.spec.js +1 -1
  21. package/src/components/__tests__/StructureNavClassified.spec.js +5 -1
  22. package/src/components/__tests__/StructureStructureLinks.spec.js +8 -7
  23. package/src/components/__tests__/StructureView.spec.js +1 -0
  24. package/src/components/__tests__/SystemFilteredNav.spec.js +4 -1
  25. package/src/hooks/useBucketPaths.js +11 -0
  26. package/src/hooks/useBucketStructures.js +17 -5
  27. package/src/reducers/navFilter.js +4 -1
  28. package/src/reducers/structure.js +1 -0
  29. package/src/reducers/structureFilters.js +1 -0
  30. package/src/selectors/getStructureParent.js +1 -2
  31. package/src/components/StructureNoteSuggestions.js +0 -179
  32. package/src/components/__tests__/StructureNoteSuggestions.spec.js +0 -151
  33. package/src/components/__tests__/StructureSearch.spec.js +0 -34
  34. package/src/components/__tests__/__snapshots__/StructureNoteSuggestions.spec.js.snap +0 -316
  35. package/src/components/__tests__/__snapshots__/StructureSearch.spec.js.snap +0 -18
  36. package/src/utils/bucketNav.js +0 -9
@@ -1,151 +0,0 @@
1
- import React, { Suspense } from "react";
2
- import { waitFor } from "@testing-library/react";
3
- import userEvent from "@testing-library/user-event";
4
- import { render } from "@truedat/test/render";
5
- import StructureNoteSuggestions from "../StructureNoteSuggestions";
6
-
7
- const mockSuggestions = {
8
- editable_field: "editable_field_value",
9
- non_editable_field: "non_editable_field_value",
10
- unselect_field: "unselect_field_value",
11
- };
12
- jest.mock("@truedat/core/services/api", () => ({
13
- apiJson: (url) => ({
14
- then: (callback) =>
15
- callback({
16
- data: {
17
- data: url.startsWith("suggestions")
18
- ? mockSuggestions
19
- : url.startsWith("error_message")
20
- ? ["error", { error: { message: "ERROR MESSAGE" } }]
21
- : ["error", "ERROR TEXT"],
22
- },
23
- }),
24
- }),
25
- }));
26
-
27
- const messages = {
28
- en: {
29
- "actions.cancel": "cancel",
30
- "actions.save": "save",
31
- "structure_note.ai_suggestion.header": "header",
32
- "actions.apply_ai_suggestion": "actions.apply_ai_suggestion",
33
- "actions.ai_suggestion": "actions.ai_suggestion",
34
- "structure_note.ai_suggestion.error": "error",
35
- },
36
- };
37
-
38
- describe("<StructureNoteSuggestions />", () => {
39
- it("matches the latest snapshot", () => {
40
- const props = {
41
- template: {},
42
- };
43
- const { container } = render(
44
- <Suspense fallback={null}>
45
- <StructureNoteSuggestions {...props} />
46
- </Suspense>,
47
- { messages }
48
- );
49
- expect(container).toMatchSnapshot();
50
- });
51
-
52
- it("component lifecycle", async () => {
53
- const applySuggestions = jest.fn();
54
- const props = {
55
- aiSuggestionsAction: { href: "suggestions" },
56
- applySuggestions,
57
- template: {
58
- content: [
59
- {
60
- fields: [
61
- {
62
- name: "editable_field",
63
- label: "EditableField",
64
- editable: true,
65
- },
66
- ],
67
- },
68
- {
69
- name: "Group2",
70
- fields: [
71
- {
72
- name: "non_editable_field",
73
- label: "NonEditableField",
74
- editable: false,
75
- },
76
- {
77
- name: "unselect_field",
78
- label: "UnselectedField",
79
- editable: true,
80
- },
81
- ],
82
- },
83
- ],
84
- },
85
- isModification: true,
86
- };
87
- const { container, findByText, queryByText } = render(
88
- <Suspense fallback={null}>
89
- <StructureNoteSuggestions {...props} />
90
- </Suspense>,
91
- { messages }
92
- );
93
-
94
- userEvent.click(await findByText(/actions.ai_suggestion/i));
95
- await waitFor(() =>
96
- expect(queryByText(/actions.ai_suggestion/i)).not.toBeInTheDocument()
97
- );
98
-
99
- expect(container).toMatchSnapshot();
100
-
101
- userEvent.click(await findByText(/UnselectedField/i));
102
- userEvent.click(await findByText(/UnselectedField/i));
103
- userEvent.click(await findByText(/UnselectedField/i));
104
-
105
- userEvent.click(await findByText(/actions.apply_ai_suggestion/i));
106
- await waitFor(() =>
107
- expect(
108
- queryByText(/actions.apply_ai_suggestion/i)
109
- ).not.toBeInTheDocument()
110
- );
111
- expect(applySuggestions).toHaveBeenCalledWith(
112
- expect.objectContaining({ editable_field: "editable_field_value" })
113
- );
114
-
115
- expect(container).toMatchSnapshot();
116
- });
117
-
118
- it("renders error with message", async () => {
119
- const props = {
120
- aiSuggestionsAction: { href: "error_message" },
121
- };
122
- const { container, findByText, queryByText } = render(
123
- <Suspense fallback={null}>
124
- <StructureNoteSuggestions {...props} />
125
- </Suspense>,
126
- { messages }
127
- );
128
-
129
- userEvent.click(await findByText(/actions.ai_suggestion/i));
130
- await waitFor(() =>
131
- expect(queryByText(/error message/i)).toBeInTheDocument()
132
- );
133
- expect(container).toMatchSnapshot();
134
- });
135
-
136
- it("renders error with message", async () => {
137
- const props = {
138
- aiSuggestionsAction: { href: "error_text" },
139
- };
140
- const { container, findByText, queryByText } = render(
141
- <Suspense fallback={null}>
142
- <StructureNoteSuggestions {...props} />
143
- </Suspense>,
144
- { messages }
145
- );
146
-
147
- userEvent.click(await findByText(/actions.ai_suggestion/i));
148
- await waitFor(() => expect(queryByText(/error text/i)).toBeInTheDocument());
149
- expect(container).toMatchSnapshot();
150
- });
151
- });
@@ -1,34 +0,0 @@
1
- import React from "react";
2
- import { shallow } from "enzyme";
3
- import { Input } from "semantic-ui-react";
4
- import { intl } from "@truedat/test/intl-stub";
5
- import { StructureSearch } from "../StructureSearch";
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("<StructureSearch/>", () => {
12
- it("matches the latest snapshot", () => {
13
- const onChange = jest.fn();
14
- const props = { onChange };
15
- const wrapper = shallow(<StructureSearch {...props} />);
16
- expect(wrapper).toMatchSnapshot();
17
- });
18
-
19
- it("dispatches onChange when Input changes", () => {
20
- const onChange = jest.fn();
21
- const props = { onChange };
22
- const eventMock = {
23
- target: {
24
- value: {
25
- toLowerCase: jest.fn()
26
- }
27
- }
28
- };
29
- const wrapper = shallow(<StructureSearch {...props} />);
30
- expect(props.onChange.mock.calls.length).toBe(0);
31
- wrapper.find(Input).simulate("change", eventMock);
32
- expect(props.onChange.mock.calls.length).toBe(1);
33
- });
34
- });
@@ -1,316 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`<StructureNoteSuggestions /> component lifecycle 1`] = `
4
- <div>
5
- <div
6
- class="ui segment"
7
- >
8
- <div
9
- class="ui container"
10
- style="display: flex; justify-content: space-between;"
11
- >
12
- <h4>
13
- <i
14
- aria-hidden="true"
15
- class="lightbulb outline icon"
16
- />
17
- header
18
- </h4>
19
- <div
20
- class="ui hidden divider"
21
- />
22
- </div>
23
- <div
24
- class="ui container"
25
- >
26
- <h5 />
27
- <div
28
- class="ui list"
29
- role="list"
30
- >
31
- <div
32
- class="item"
33
- role="listitem"
34
- style="display: flex; align-items: center; gap: 12px;"
35
- >
36
- <div
37
- class="ui checked fitted checkbox"
38
- >
39
- <input
40
- checked=""
41
- class="hidden"
42
- id="editable_field"
43
- readonly=""
44
- tabindex="0"
45
- type="checkbox"
46
- value=""
47
- />
48
- <label
49
- for="editable_field"
50
- />
51
- </div>
52
- <label
53
- disabled=""
54
- for="editable_field"
55
- style="cursor: pointer;"
56
- >
57
- <div
58
- class="header"
59
- >
60
- EditableField
61
- </div>
62
- <div
63
- class="description"
64
- >
65
- editable_field_value
66
- </div>
67
- </label>
68
- </div>
69
- </div>
70
- <div
71
- class="ui hidden divider"
72
- />
73
- </div>
74
- <div
75
- class="ui container"
76
- >
77
- <h5>
78
- Group2
79
- </h5>
80
- <div
81
- class="ui list"
82
- role="list"
83
- >
84
- <div
85
- class="item"
86
- role="listitem"
87
- style="display: flex; align-items: center; gap: 12px;"
88
- >
89
- <div
90
- class="ui disabled fitted checkbox"
91
- >
92
- <input
93
- class="hidden"
94
- disabled=""
95
- id="non_editable_field"
96
- readonly=""
97
- tabindex="-1"
98
- type="checkbox"
99
- value=""
100
- />
101
- <label
102
- for="non_editable_field"
103
- />
104
- </div>
105
- <label
106
- disabled=""
107
- for="non_editable_field"
108
- style="cursor: pointer;"
109
- >
110
- <div
111
- class="header"
112
- >
113
- NonEditableField
114
- </div>
115
- <div
116
- class="description"
117
- >
118
- non_editable_field_value
119
- </div>
120
- </label>
121
- </div>
122
- <div
123
- class="item"
124
- role="listitem"
125
- style="display: flex; align-items: center; gap: 12px;"
126
- >
127
- <div
128
- class="ui checked fitted checkbox"
129
- >
130
- <input
131
- checked=""
132
- class="hidden"
133
- id="unselect_field"
134
- readonly=""
135
- tabindex="0"
136
- type="checkbox"
137
- value=""
138
- />
139
- <label
140
- for="unselect_field"
141
- />
142
- </div>
143
- <label
144
- disabled=""
145
- for="unselect_field"
146
- style="cursor: pointer;"
147
- >
148
- <div
149
- class="header"
150
- >
151
- UnselectedField
152
- </div>
153
- <div
154
- class="description"
155
- >
156
- unselect_field_value
157
- </div>
158
- </label>
159
- </div>
160
- </div>
161
- <div
162
- class="ui hidden divider"
163
- />
164
- </div>
165
- <div
166
- class="ui right aligned container"
167
- >
168
- <button
169
- class="ui primary button"
170
- >
171
- actions.apply_ai_suggestion
172
- </button>
173
- </div>
174
- </div>
175
- </div>
176
- `;
177
-
178
- exports[`<StructureNoteSuggestions /> component lifecycle 2`] = `
179
- <div>
180
- <div
181
- class="ui segment"
182
- >
183
- <div
184
- class="ui container"
185
- style="display: flex; justify-content: space-between;"
186
- >
187
- <h4>
188
- <i
189
- aria-hidden="true"
190
- class="lightbulb icon"
191
- />
192
- header
193
- </h4>
194
- <div
195
- class="ui hidden divider"
196
- />
197
- <button
198
- class="ui button"
199
- >
200
- actions.ai_suggestion
201
- </button>
202
- </div>
203
- </div>
204
- </div>
205
- `;
206
-
207
- exports[`<StructureNoteSuggestions /> matches the latest snapshot 1`] = `
208
- <div>
209
- <div
210
- class="ui segment"
211
- >
212
- <div
213
- class="ui container"
214
- style="display: flex; justify-content: space-between;"
215
- >
216
- <h4>
217
- <i
218
- aria-hidden="true"
219
- class="lightbulb icon"
220
- />
221
- header
222
- </h4>
223
- <div
224
- class="ui hidden divider"
225
- />
226
- <button
227
- class="ui button"
228
- >
229
- actions.ai_suggestion
230
- </button>
231
- </div>
232
- </div>
233
- </div>
234
- `;
235
-
236
- exports[`<StructureNoteSuggestions /> renders error with message 1`] = `
237
- <div>
238
- <div
239
- class="ui segment"
240
- >
241
- <div
242
- class="ui container"
243
- style="display: flex; justify-content: space-between;"
244
- >
245
- <h4>
246
- <i
247
- aria-hidden="true"
248
- class="lightbulb icon"
249
- />
250
- header
251
- </h4>
252
- <div
253
- class="ui hidden divider"
254
- />
255
- <button
256
- class="ui button"
257
- >
258
- actions.ai_suggestion
259
- </button>
260
- </div>
261
- <div
262
- class="ui negative message"
263
- >
264
- <div
265
- class="header"
266
- >
267
- error
268
- </div>
269
- <p>
270
- ERROR MESSAGE
271
- </p>
272
- </div>
273
- </div>
274
- </div>
275
- `;
276
-
277
- exports[`<StructureNoteSuggestions /> renders error with message 2`] = `
278
- <div>
279
- <div
280
- class="ui segment"
281
- >
282
- <div
283
- class="ui container"
284
- style="display: flex; justify-content: space-between;"
285
- >
286
- <h4>
287
- <i
288
- aria-hidden="true"
289
- class="lightbulb icon"
290
- />
291
- header
292
- </h4>
293
- <div
294
- class="ui hidden divider"
295
- />
296
- <button
297
- class="ui button"
298
- >
299
- actions.ai_suggestion
300
- </button>
301
- </div>
302
- <div
303
- class="ui negative message"
304
- >
305
- <div
306
- class="header"
307
- >
308
- error
309
- </div>
310
- <p>
311
- ERROR TEXT
312
- </p>
313
- </div>
314
- </div>
315
- </div>
316
- `;
@@ -1,18 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`<StructureSearch/> matches the latest snapshot 1`] = `
4
- <Input
5
- fluid={true}
6
- icon={
7
- {
8
- "link": true,
9
- "name": "search",
10
- }
11
- }
12
- iconPosition="left"
13
- loading={false}
14
- onChange={[Function]}
15
- placeholder="structure.search.placeholder"
16
- type="text"
17
- />
18
- `;
@@ -1,9 +0,0 @@
1
- import _ from "lodash/fp";
2
-
3
- export const isBucketFilter = _.flow(
4
- Object.keys,
5
- // Both metadata and mutable_metadata are "metadata"
6
- _.some((key) =>
7
- ["metadata", "note"].some((searchedKey) => key.startsWith(searchedKey))
8
- )
9
- );