@truedat/bg 7.2.0 → 7.2.2

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 (37) hide show
  1. package/package.json +6 -6
  2. package/src/concepts/components/ConceptCompleteness.js +2 -2
  3. package/src/concepts/components/ConceptCreate.js +3 -3
  4. package/src/concepts/components/ConceptDetails.js +2 -2
  5. package/src/concepts/components/ConceptEdit.js +3 -3
  6. package/src/concepts/components/ConceptsUploadButton.js +1 -1
  7. package/src/concepts/components/__tests__/ConceptCompleteness.spec.js +13 -15
  8. package/src/concepts/components/__tests__/ConceptDetails.spec.js +12 -19
  9. package/src/concepts/components/__tests__/{ConcepEdit.spec.js → ConceptEdit.spec.js} +13 -21
  10. package/src/concepts/components/__tests__/ConceptManageDomain.spec.js +28 -4
  11. package/src/concepts/components/__tests__/__snapshots__/{ConcepEdit.spec.js.snap → ConceptEdit.spec.js.snap} +7 -7
  12. package/src/concepts/components/__tests__/__snapshots__/ConceptForm.spec.js.snap +10 -12
  13. package/src/concepts/components/__tests__/__snapshots__/ConceptManageDomain.spec.js.snap +58 -1
  14. package/src/concepts/components/__tests__/__snapshots__/ConceptsBulkUpdate.spec.js.snap +10 -12
  15. package/src/concepts/components/__tests__/__snapshots__/SharedToForm.spec.js.snap +10 -12
  16. package/src/messages/en.js +2 -0
  17. package/src/messages/es.js +2 -0
  18. package/src/taxonomy/components/Domain.js +11 -71
  19. package/src/taxonomy/components/DomainCards.js +113 -0
  20. package/src/taxonomy/components/DomainContent.js +119 -0
  21. package/src/taxonomy/components/DomainTabs.js +92 -40
  22. package/src/taxonomy/components/Domains.js +144 -25
  23. package/src/taxonomy/components/DomainsActions.js +4 -4
  24. package/src/taxonomy/components/__tests__/Domain.spec.js +127 -2
  25. package/src/taxonomy/components/__tests__/DomainCards.spec.js +148 -0
  26. package/src/taxonomy/components/__tests__/DomainContent.spec.js +168 -0
  27. package/src/taxonomy/components/__tests__/DomainTabs.spec.js +108 -0
  28. package/src/taxonomy/components/__tests__/Domains.spec.js +149 -2
  29. package/src/taxonomy/components/__tests__/DomainsActions.spec.js +15 -8
  30. package/src/taxonomy/components/__tests__/__snapshots__/Domain.spec.js.snap +8 -0
  31. package/src/taxonomy/components/__tests__/__snapshots__/DomainCards.spec.js.snap +291 -0
  32. package/src/taxonomy/components/__tests__/__snapshots__/DomainContent.spec.js.snap +305 -0
  33. package/src/taxonomy/components/__tests__/__snapshots__/DomainTabs.spec.js.snap +40 -0
  34. package/src/taxonomy/components/__tests__/__snapshots__/Domains.spec.js.snap +74 -4
  35. package/src/taxonomy/components/__tests__/__snapshots__/DomainsActions.spec.js.snap +13 -22
  36. package/src/taxonomy/styles/domainCards.less +4 -0
  37. package/src/taxonomy/styles/domains.less +15 -0
@@ -0,0 +1,108 @@
1
+ import React from "react";
2
+ import { render } from "@truedat/test/render";
3
+ import { useAuthorized } from "@truedat/core/hooks";
4
+ import DomainTabs from "../DomainTabs";
5
+
6
+ jest.mock("@truedat/core/hooks", () => ({
7
+ useAuthorized: jest.fn(() => true),
8
+ }));
9
+
10
+ describe("<DomainTabs />", () => {
11
+ const domain = {
12
+ id: 1,
13
+ name: "Test Domain",
14
+ };
15
+
16
+ const taxonomyConfig = {
17
+ priorityTabs: [],
18
+ hiddenTabs: [],
19
+ };
20
+
21
+ const renderOpts = {
22
+ messages: {
23
+ en: {
24
+ "tabs.subdomains": "Subdomains",
25
+ "tabs.concepts": "Concepts",
26
+ "tabs.structures": "Structures",
27
+ "tabs.implementations": "Implementations",
28
+ "tabs.members": "Members",
29
+ },
30
+ },
31
+ };
32
+
33
+ it("matches the latest snapshot", () => {
34
+ const { container } = render(
35
+ <DomainTabs domain={domain} taxonomyConfig={taxonomyConfig} />,
36
+ renderOpts
37
+ );
38
+ expect(container).toMatchSnapshot();
39
+ });
40
+
41
+ it("renders all tabs", () => {
42
+ const { getByText } = render(
43
+ <DomainTabs domain={domain} taxonomyConfig={taxonomyConfig} />,
44
+ renderOpts
45
+ );
46
+
47
+ expect(getByText("Subdomains")).toBeInTheDocument();
48
+ expect(getByText("Concepts")).toBeInTheDocument();
49
+ expect(getByText("Structures")).toBeInTheDocument();
50
+ expect(getByText("Implementations")).toBeInTheDocument();
51
+ expect(getByText("Members")).toBeInTheDocument();
52
+ });
53
+
54
+ it("hides tabs based on hiddenTabs config", () => {
55
+ const hiddenTabsConfig = {
56
+ ...taxonomyConfig,
57
+ hiddenTabs: ["structures", "implementations"],
58
+ };
59
+
60
+ const { queryByText } = render(
61
+ <DomainTabs domain={domain} taxonomyConfig={hiddenTabsConfig} />,
62
+ renderOpts
63
+ );
64
+
65
+ expect(queryByText("Structures")).not.toBeInTheDocument();
66
+ expect(queryByText("Implementations")).not.toBeInTheDocument();
67
+ });
68
+
69
+ it("prioritizes tabs based on priorityTabs config", () => {
70
+ const priorityTabsConfig = {
71
+ ...taxonomyConfig,
72
+ priorityTabs: ["implementations", "concepts"],
73
+ };
74
+
75
+ const { container } = render(
76
+ <DomainTabs domain={domain} taxonomyConfig={priorityTabsConfig} />,
77
+ renderOpts
78
+ );
79
+
80
+ const tabs = container.querySelectorAll(".item");
81
+ expect(tabs[0].textContent).toBe("Implementations");
82
+ expect(tabs[1].textContent).toBe("Concepts");
83
+ });
84
+
85
+ it("hides 'implementations' tab if dqAuthorized is false", () => {
86
+ useAuthorized.mockImplementation(
87
+ (permission) => permission == "data_dictionary"
88
+ );
89
+
90
+ const { queryByText } = render(
91
+ <DomainTabs domain={domain} taxonomyConfig={taxonomyConfig} />,
92
+ renderOpts
93
+ );
94
+
95
+ expect(queryByText("Implementations")).not.toBeInTheDocument();
96
+ });
97
+
98
+ it("hides 'structures' tab if ddAuthorized is false", () => {
99
+ useAuthorized.mockImplementation((permission) => permission == "quality");
100
+
101
+ const { queryByText } = render(
102
+ <DomainTabs domain={domain} taxonomyConfig={taxonomyConfig} />,
103
+ renderOpts
104
+ );
105
+
106
+ expect(queryByText("Structures")).not.toBeInTheDocument();
107
+ });
108
+ });
@@ -1,7 +1,14 @@
1
1
  import React from "react";
2
+ import { waitFor } from "@testing-library/react";
3
+ import { DOMAINS_QUERY } from "@truedat/core/api/queries";
4
+ import userEvent from "@testing-library/user-event";
5
+ import { useParams, useHistory } from "react-router-dom";
2
6
  import { render } from "@truedat/test/render";
7
+ import { useDomains } from "../../../hooks/useDomains";
3
8
  import Domains from "../Domains";
4
9
 
10
+ jest.mock("../../assets/searching.png", () => "mocked-searching.png");
11
+
5
12
  jest.mock("react-router-dom", () => ({
6
13
  ...jest.requireActual("react-router-dom"),
7
14
  useHistory: jest.fn(),
@@ -103,9 +110,149 @@ jest.mock("../../../hooks/useDomains", () => ({
103
110
  })),
104
111
  }));
105
112
 
113
+ const domains = [
114
+ {
115
+ id: 10,
116
+ name: "other_domain",
117
+ parentId: null,
118
+ externalId: "10",
119
+ actions: [],
120
+ },
121
+ ];
122
+
123
+ const variables = {
124
+ action: "viewDomain",
125
+ };
126
+
127
+ const domainsMock = {
128
+ request: { query: DOMAINS_QUERY, variables },
129
+ result: { data: { domains: domains } },
130
+ };
131
+
132
+ const renderOpts = {
133
+ mocks: [domainsMock, domainsMock],
134
+ fallback: "lazy",
135
+ };
136
+
106
137
  describe("<Domains />", () => {
107
- it("matches the latest snapshot", () => {
108
- const { container } = render(<Domains />);
138
+ it("matches the latest snapshot", async () => {
139
+ const { container, queryByText } = render(<Domains />, renderOpts);
140
+
141
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
142
+ await waitFor(() =>
143
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
144
+ );
109
145
  expect(container).toMatchSnapshot();
110
146
  });
147
+
148
+ it("renders the correct number of domain elements", async () => {
149
+ const { getAllByText, queryByText } = render(<Domains />, renderOpts);
150
+
151
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
152
+ await waitFor(() =>
153
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
154
+ );
155
+ const domainElements = getAllByText(/element_/);
156
+ expect(domainElements.length).toBe(2);
157
+ });
158
+
159
+ it("renders domain elements with correct names", async () => {
160
+ const { getByText, queryByText } = render(<Domains />, renderOpts);
161
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
162
+ await waitFor(() =>
163
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
164
+ );
165
+
166
+ expect(getByText("element_2")).toBeInTheDocument();
167
+ expect(getByText("element_3")).toBeInTheDocument();
168
+
169
+ expect(queryByText("element_1")).not.toBeInTheDocument();
170
+ expect(queryByText("element_4")).not.toBeInTheDocument();
171
+ expect(queryByText("element_5")).not.toBeInTheDocument();
172
+ expect(queryByText("element_6")).not.toBeInTheDocument();
173
+ });
174
+
175
+ it("redirects to domains list if domainId is invalid", async () => {
176
+ const mockHistoryPush = jest.fn();
177
+ useHistory.mockImplementationOnce(() => ({ push: mockHistoryPush }));
178
+ useParams.mockImplementationOnce(() => ({ id: 999 }));
179
+
180
+ render(<Domains />, renderOpts);
181
+
182
+ await waitFor(() => {
183
+ expect(mockHistoryPush).toHaveBeenCalledWith("/domains");
184
+ });
185
+ });
186
+
187
+ it("renders EmptyImage when no domains available", async () => {
188
+ useParams.mockImplementationOnce(() => ({ id: undefined }));
189
+ useDomains.mockImplementationOnce(() => ({
190
+ data: [],
191
+ actions: {},
192
+ loading: false,
193
+ }));
194
+ const mockHistoryPush = jest.fn();
195
+ useHistory.mockImplementationOnce(() => ({ push: mockHistoryPush }));
196
+
197
+ const { queryByText } = render(<Domains />, renderOpts);
198
+
199
+ await waitFor(() => {
200
+ expect(
201
+ queryByText(
202
+ "Please, select a domain on the left pane to see the detail."
203
+ )
204
+ ).toBeInTheDocument();
205
+ });
206
+ });
207
+
208
+ it("handles grid control buttons correctly", async () => {
209
+ const { container, queryByText, queryByTestId } = render(
210
+ <Domains />,
211
+ renderOpts
212
+ );
213
+
214
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
215
+ await waitFor(() =>
216
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
217
+ );
218
+
219
+ await waitFor(() => {
220
+ expect(
221
+ container.querySelector(".taxonomy-domains-breadcrumb")
222
+ ).toBeInTheDocument();
223
+ });
224
+
225
+ const hideButton = container.querySelector(
226
+ "button[data-tooltip='Hide Domains List']"
227
+ );
228
+
229
+ const minimizeButton = container.querySelector(
230
+ "button[data-tooltip='domains.list.minimize']"
231
+ );
232
+
233
+ const maximizeButton = container.querySelector(
234
+ "button[data-tooltip='domains.list.maximize']"
235
+ );
236
+
237
+ userEvent.click(hideButton);
238
+ await waitFor(() => {
239
+ expect(
240
+ container.querySelector(".taxonomy-domains-grid-animation")
241
+ ).toBeNull();
242
+ });
243
+
244
+ userEvent.click(minimizeButton);
245
+ await waitFor(() => {
246
+ expect(
247
+ container.querySelector(".taxonomy-domains-grid-animation")
248
+ ).toBeNull();
249
+ });
250
+
251
+ userEvent.click(maximizeButton);
252
+ await waitFor(() => {
253
+ expect(
254
+ container.querySelector(".taxonomy-domains-grid-animation")
255
+ ).toBeInTheDocument();
256
+ });
257
+ });
111
258
  });
@@ -1,15 +1,22 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { intl } from "@truedat/test/intl-stub";
2
+ import { render } from "@truedat/test/render";
4
3
  import { DomainsActions } from "../DomainsActions";
5
4
 
6
- // workaround for enzyme issue with React.useContext
7
- // see https://github.com/airbnb/enzyme/issues/2176#issuecomment-532361526
8
- jest.spyOn(React, "useContext").mockImplementation(() => intl);
9
-
10
5
  describe("<DomainsActions />", () => {
11
6
  it("matches the latest snapshot", () => {
12
- const wrapper = shallow(<DomainsActions />);
13
- expect(wrapper).toMatchSnapshot();
7
+ const actions = {
8
+ create: { href: "/api/domains", input: {}, method: "POST" },
9
+ index: { href: "/api/domains", input: {}, method: "GET" },
10
+ };
11
+ const { container, getByText } = render(
12
+ <DomainsActions actions={actions} />
13
+ );
14
+ expect(container).toMatchSnapshot();
15
+ expect(getByText("New Domain")).toBeInTheDocument();
16
+ });
17
+
18
+ it("Do not show the button if not have actions", () => {
19
+ const { queryByText } = render(<DomainsActions />);
20
+ expect(queryByText("New Domain")).not.toBeInTheDocument();
14
21
  });
15
22
  });
@@ -50,6 +50,12 @@ exports[`<Domain /> matches the latest snapshot 1`] = `
50
50
  <div
51
51
  class="ui pointing secondary top attached tabular menu"
52
52
  >
53
+ <a
54
+ class="item"
55
+ href="/domains/3"
56
+ >
57
+ Subdomains
58
+ </a>
53
59
  <a
54
60
  class="item"
55
61
  href="/domains/3/concepts"
@@ -81,3 +87,5 @@ exports[`<Domain /> matches the latest snapshot 1`] = `
81
87
  </div>
82
88
  </div>
83
89
  `;
90
+
91
+ exports[`<Domain /> renders null when no has any domain 1`] = `<div />`;
@@ -0,0 +1,291 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<DomainCards /> matches the latest snapshot domain with subdomain 1`] = `
4
+ <div>
5
+ <h4
6
+ class="ui header"
7
+ >
8
+ <div
9
+ class="content taxonomy-domains-domaincards-header-content"
10
+ >
11
+ <div>
12
+ <div
13
+ class="ui icon input"
14
+ >
15
+ <input
16
+ placeholder="Search domains..."
17
+ type="text"
18
+ value=""
19
+ />
20
+ <i
21
+ aria-hidden="true"
22
+ class="search icon"
23
+ />
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </h4>
28
+ <div
29
+ class="ui cards"
30
+ >
31
+ <a
32
+ class="ui link card"
33
+ href="/domains/4"
34
+ >
35
+ <div
36
+ class="content"
37
+ >
38
+ <div
39
+ class="header"
40
+ >
41
+ <i
42
+ aria-hidden="true"
43
+ class="cube icon"
44
+ />
45
+ subdomain
46
+ </div>
47
+ <div
48
+ class="meta"
49
+ >
50
+ <i
51
+ aria-hidden="true"
52
+ class="object group icon"
53
+ />
54
+
55
+ DomainGroup
56
+ <br />
57
+ <span>
58
+ Domain
59
+ </span>
60
+ </div>
61
+ </div>
62
+ <div
63
+ class="content"
64
+ />
65
+ <div
66
+ class="extra content"
67
+ >
68
+ <i
69
+ aria-hidden="true"
70
+ class="cubes icon"
71
+ />
72
+ Subdomains: 0
73
+ </div>
74
+ </a>
75
+ </div>
76
+ </div>
77
+ `;
78
+
79
+ exports[`<DomainCards /> matches the latest snapshot domain without subdomain 1`] = `
80
+ <div>
81
+ <h4
82
+ class="ui header"
83
+ >
84
+ <div
85
+ class="content taxonomy-domains-domaincards-header-content"
86
+ >
87
+ <div>
88
+ <div
89
+ class="ui icon input"
90
+ >
91
+ <input
92
+ placeholder="Search domains..."
93
+ type="text"
94
+ value=""
95
+ />
96
+ <i
97
+ aria-hidden="true"
98
+ class="search icon"
99
+ />
100
+ </div>
101
+ </div>
102
+ </div>
103
+ </h4>
104
+ <div
105
+ class="ui message"
106
+ >
107
+ <div
108
+ class="content"
109
+ >
110
+ <div
111
+ class="header"
112
+ >
113
+ No subdomains found
114
+ </div>
115
+ </div>
116
+ </div>
117
+ <div
118
+ class="ui cards"
119
+ />
120
+ </div>
121
+ `;
122
+
123
+ exports[`<DomainCards /> matches the latest snapshot front page 1`] = `
124
+ <div>
125
+ <h4
126
+ class="ui header"
127
+ >
128
+ <div
129
+ class="content taxonomy-domains-domaincards-header-content"
130
+ >
131
+ <div>
132
+ <div
133
+ class="ui icon input"
134
+ >
135
+ <input
136
+ placeholder="Search domains..."
137
+ type="text"
138
+ value=""
139
+ />
140
+ <i
141
+ aria-hidden="true"
142
+ class="search icon"
143
+ />
144
+ </div>
145
+ </div>
146
+ </div>
147
+ </h4>
148
+ <div
149
+ class="ui cards"
150
+ >
151
+ <a
152
+ class="ui link card"
153
+ href="/domains/1"
154
+ >
155
+ <div
156
+ class="content"
157
+ >
158
+ <div
159
+ class="header"
160
+ >
161
+ <i
162
+ aria-hidden="true"
163
+ class="cube icon"
164
+ />
165
+ rootNoSub
166
+ </div>
167
+ <div
168
+ class="meta"
169
+ >
170
+ <i
171
+ aria-hidden="true"
172
+ class="object group icon"
173
+ />
174
+
175
+ DomainGroup
176
+ <br />
177
+ <span>
178
+ Domain
179
+ </span>
180
+ </div>
181
+ </div>
182
+ <div
183
+ class="content"
184
+ >
185
+ <div
186
+ class="description"
187
+ >
188
+ Root domain with no subdomains
189
+ </div>
190
+ </div>
191
+ <div
192
+ class="extra content"
193
+ >
194
+ <i
195
+ aria-hidden="true"
196
+ class="cubes icon"
197
+ />
198
+ Subdomains: 0
199
+ </div>
200
+ </a>
201
+ <a
202
+ class="ui link card"
203
+ href="/domains/3"
204
+ >
205
+ <div
206
+ class="content"
207
+ >
208
+ <div
209
+ class="header"
210
+ >
211
+ <i
212
+ aria-hidden="true"
213
+ class="cube icon"
214
+ />
215
+ rootOtherGroup
216
+ </div>
217
+ <div
218
+ class="meta"
219
+ >
220
+ <i
221
+ aria-hidden="true"
222
+ class="object group icon"
223
+ />
224
+
225
+ OtherDomainGroup
226
+ <br />
227
+ <span>
228
+ Domain
229
+ </span>
230
+ </div>
231
+ </div>
232
+ <div
233
+ class="content"
234
+ />
235
+ <div
236
+ class="extra content"
237
+ >
238
+ <i
239
+ aria-hidden="true"
240
+ class="cubes icon"
241
+ />
242
+ Subdomains: 0
243
+ </div>
244
+ </a>
245
+ <a
246
+ class="ui link card"
247
+ href="/domains/2"
248
+ >
249
+ <div
250
+ class="content"
251
+ >
252
+ <div
253
+ class="header"
254
+ >
255
+ <i
256
+ aria-hidden="true"
257
+ class="cube icon"
258
+ />
259
+ rootWithSub
260
+ </div>
261
+ <div
262
+ class="meta"
263
+ >
264
+ <i
265
+ aria-hidden="true"
266
+ class="object group icon"
267
+ />
268
+
269
+ DomainGroup
270
+ <br />
271
+ <span>
272
+ Domain
273
+ </span>
274
+ </div>
275
+ </div>
276
+ <div
277
+ class="content"
278
+ />
279
+ <div
280
+ class="extra content"
281
+ >
282
+ <i
283
+ aria-hidden="true"
284
+ class="cubes icon"
285
+ />
286
+ Subdomains: 1
287
+ </div>
288
+ </a>
289
+ </div>
290
+ </div>
291
+ `;