@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
@@ -1,7 +1,18 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
2
+ import React, { useState } from "react";
3
+ import { connect } from "react-redux";
4
+ import PropTypes from "prop-types";
3
5
  import { FormattedMessage, useIntl } from "react-intl";
4
- import { Grid, Header, Icon, Image, Segment } from "semantic-ui-react";
6
+ import {
7
+ Button,
8
+ ButtonGroup,
9
+ Grid,
10
+ Header,
11
+ Icon,
12
+ Image,
13
+ Segment,
14
+ } from "semantic-ui-react";
15
+ import { Loading } from "@truedat/core/components";
5
16
  import HierarchyNodeFinder from "@truedat/core/components/HierarchyNodeFinder";
6
17
  import { linkTo } from "@truedat/core/routes";
7
18
  import { useHistory, useParams } from "react-router-dom";
@@ -9,15 +20,27 @@ import searchImage from "assets/searching.png";
9
20
  import { useDomains } from "../../hooks/useDomains";
10
21
  import Domain from "./Domain";
11
22
  import DomainCrumbs from "./DomainCrumbs";
12
- import DomainsActions from "./DomainsActions";
23
+ import DomainCards from "./DomainCards";
13
24
 
14
- export const Domains = () => {
25
+ export const Domains = ({ taxonomyConfig }) => {
26
+ const { minDomainsListWidth, maxDomainsListWidth, defaultDomainsListWidth } =
27
+ taxonomyConfig;
28
+ const [gridControl, setGridControl] = useState({
29
+ list: defaultDomainsListWidth,
30
+ content: 16 - defaultDomainsListWidth,
31
+ animated: defaultDomainsListWidth > 0,
32
+ });
15
33
  const { formatMessage } = useIntl();
16
34
  const history = useHistory();
17
- const { data: domains, actions } = useDomains();
35
+ const { data: domains, actions, loading } = useDomains();
18
36
  const { id: urlId } = useParams();
19
37
  const domainId = !isNaN(parseInt(urlId)) ? parseInt(urlId) : undefined;
20
38
  const domain = _.find((d) => d.id == domainId)(domains);
39
+
40
+ if (!loading && domainId && !domain) {
41
+ history.push(linkTo.DOMAINS());
42
+ }
43
+
21
44
  const EmptyImage = () => (
22
45
  <div
23
46
  style={{
@@ -32,9 +55,30 @@ export const Domains = () => {
32
55
  </div>
33
56
  );
34
57
 
35
- const onClick = (id) => {
36
- history.push(linkTo.DOMAIN_CONCEPTS({ id }));
58
+ const handleHide = () => {
59
+ setGridControl({
60
+ list: 0,
61
+ content: 16,
62
+ animated: false,
63
+ });
64
+ };
65
+ const handleMinimize = () => {
66
+ const shouldAnimate = gridControl.list > 0;
67
+ setGridControl({
68
+ list: minDomainsListWidth,
69
+ content: 16 - minDomainsListWidth,
70
+ animated: shouldAnimate,
71
+ });
72
+ };
73
+ const handleMaximize = () => {
74
+ const shouldAnimate = gridControl.list > 0;
75
+ setGridControl({
76
+ list: maxDomainsListWidth,
77
+ content: 16 - maxDomainsListWidth,
78
+ animated: shouldAnimate,
79
+ });
37
80
  };
81
+
38
82
  return (
39
83
  <Segment>
40
84
  <Header as="h2">
@@ -55,30 +99,87 @@ export const Domains = () => {
55
99
  <Segment attached="bottom">
56
100
  <Grid>
57
101
  <Grid.Row>
58
- <Grid.Column width={16}>
102
+ <Grid.Column
103
+ width={16}
104
+ verticalAlign="bottom"
105
+ className="taxonomy-domains-breadcrumb"
106
+ >
107
+ <ButtonGroup icon className="taxonomy-domains-breadcrumb-control">
108
+ <Button
109
+ icon="eye slash"
110
+ basic={gridControl.content < 16}
111
+ onClick={handleHide}
112
+ data-tooltip={formatMessage({ id: "domains.list.hide" })}
113
+ data-position="top left"
114
+ />
115
+ <Button
116
+ icon="compress"
117
+ basic={
118
+ gridControl.content >= 16 ||
119
+ gridControl.list > minDomainsListWidth
120
+ }
121
+ onClick={handleMinimize}
122
+ data-tooltip={formatMessage({ id: "domains.list.minimize" })}
123
+ data-position="top left"
124
+ />
125
+ <Button
126
+ icon="expand"
127
+ basic={
128
+ gridControl.content >= 16 ||
129
+ gridControl.list <= minDomainsListWidth
130
+ }
131
+ onClick={handleMaximize}
132
+ data-tooltip={formatMessage({ id: "domains.list.maximize" })}
133
+ data-position="top left"
134
+ />
135
+ </ButtonGroup>
59
136
  {domain ? <DomainCrumbs domain={domain} /> : null}
60
137
  </Grid.Column>
61
138
  </Grid.Row>
62
- <Grid.Row stretched>
63
- <Grid.Column width={3}>
64
- <HierarchyNodeFinder
65
- nodes={domains}
66
- onClick={onClick}
67
- idSelectedNode={domainId}
68
- />
69
- </Grid.Column>
70
- <Grid.Column width={13}>
139
+ <Grid.Row stretched className="taxonomy-domains-content">
140
+ {gridControl.list > 0 ? (
141
+ <Grid.Column
142
+ width={gridControl.list}
143
+ className={`${
144
+ gridControl.animated
145
+ ? "taxonomy-domains-grid-animation"
146
+ : null
147
+ } `}
148
+ >
149
+ {loading ? (
150
+ <Loading />
151
+ ) : (
152
+ <HierarchyNodeFinder
153
+ nodes={domains}
154
+ idSelectedNode={domainId}
155
+ />
156
+ )}
157
+ </Grid.Column>
158
+ ) : null}
159
+ <Grid.Column
160
+ width={gridControl.list > 0 ? gridControl.content : 16}
161
+ className={`${
162
+ gridControl.animated ? "taxonomy-domains-grid-animation" : null
163
+ } `}
164
+ >
71
165
  {domainId ? (
72
- <Domain domainId={domainId} />
166
+ <Domain
167
+ domainId={domainId}
168
+ domains={domains}
169
+ taxonomyConfig={taxonomyConfig}
170
+ />
73
171
  ) : (
74
172
  <Segment>
75
173
  <Grid.Row>
76
- <Grid.Column style={{ textAlign: "right" }}>
77
- <DomainsActions actions={actions} />
78
- </Grid.Column>
79
- </Grid.Row>
80
- <Grid.Row>
81
- <EmptyImage />
174
+ {domains && _.size(domains) > 0 ? (
175
+ <DomainCards
176
+ domain={domain}
177
+ domains={domains}
178
+ actions={actions}
179
+ />
180
+ ) : (
181
+ <EmptyImage />
182
+ )}
82
183
  </Grid.Row>
83
184
  </Segment>
84
185
  )}
@@ -90,4 +191,22 @@ export const Domains = () => {
90
191
  );
91
192
  };
92
193
 
93
- export default Domains;
194
+ Domains.propTypes = {
195
+ taxonomyConfig: PropTypes.object,
196
+ };
197
+
198
+ const mapStateToProps = ({ taxonomyConfig: stateTaxonomyConfig }) => {
199
+ const taxonomyConfig = _.merge({
200
+ priorityTabs: [],
201
+ hiddenTabs: [],
202
+ minDomainsListWidth: 3,
203
+ maxDomainsListWidth: 6,
204
+ defaultDomainsListWidth: 3,
205
+ })(stateTaxonomyConfig);
206
+
207
+ return {
208
+ taxonomyConfig,
209
+ };
210
+ };
211
+
212
+ export default connect(mapStateToProps)(Domains);
@@ -7,12 +7,12 @@ import { Button } from "semantic-ui-react";
7
7
  import { DOMAINS_NEW } from "@truedat/core/routes";
8
8
 
9
9
  export const DomainsActions = ({ actions }) => {
10
- const createUrl = () =>
11
- !_.isEmpty(actions) && _.has("create")(actions) ? DOMAINS_NEW : undefined;
10
+ const canCreate = !_.isEmpty(actions) && _.has("create")(actions);
11
+ const createUrl = () => DOMAINS_NEW;
12
12
  const { formatMessage } = useIntl();
13
13
  return (
14
14
  <>
15
- {createUrl && (
15
+ {canCreate ? (
16
16
  <Button
17
17
  primary
18
18
  content={formatMessage({ id: "domains.actions.create" })}
@@ -20,7 +20,7 @@ export const DomainsActions = ({ actions }) => {
20
20
  as={Link}
21
21
  to={createUrl}
22
22
  />
23
- )}
23
+ ) : null}
24
24
  </>
25
25
  );
26
26
  };
@@ -1,5 +1,10 @@
1
1
  import React from "react";
2
2
  import { render } from "@truedat/test/render";
3
+ import { waitFor } from "@testing-library/react";
4
+ import { DOMAIN_NEW, DOMAIN_EDIT } from "@truedat/core/routes";
5
+ import { MemoryRouter } from "react-router-dom/cjs/react-router-dom.min";
6
+ import { DOMAINS_QUERY } from "@truedat/core/api/queries";
7
+ import { useDomain } from "../../../hooks/useDomains";
3
8
  import Domain from "../Domain";
4
9
 
5
10
  jest.mock("@truedat/core/hooks", () => ({
@@ -22,10 +27,130 @@ jest.mock("../../../hooks/useDomains", () => ({
22
27
  })),
23
28
  }));
24
29
 
30
+ const domains = [
31
+ {
32
+ id: "3",
33
+ name: "DOMAIN NAME",
34
+ parentId: "6",
35
+ actions: [],
36
+ externalId: "EXTERNAL ID",
37
+ },
38
+ ];
39
+
40
+ const variables = {
41
+ action: "viewDomain",
42
+ fetchPolicy: "no-cache",
43
+ };
44
+
45
+ const domainsMock = {
46
+ request: { query: DOMAINS_QUERY, variables },
47
+ result: { data: { domains: domains } },
48
+ };
49
+
50
+ const renderOpts = {
51
+ mocks: [domainsMock],
52
+ fallback: "lazy",
53
+ };
54
+
25
55
  describe("<Domain />", () => {
26
56
  const domainId = 3;
27
- it("matches the latest snapshot", () => {
28
- const { container } = render(<Domain domainId={domainId} />);
57
+ const taxonomyConfig = {
58
+ priorityTabs: [],
59
+ hiddenTabs: [],
60
+ };
61
+
62
+ it("matches the latest snapshot", async () => {
63
+ const { container, queryByText } = render(
64
+ <Domain domainId={domainId} taxonomyConfig={taxonomyConfig} />,
65
+ renderOpts
66
+ );
67
+
68
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
69
+ await waitFor(() =>
70
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
71
+ );
72
+ expect(container).toMatchSnapshot();
73
+ });
74
+
75
+ it("renders DomainDetail component", async () => {
76
+ const { getByText, queryByText } = render(
77
+ <Domain domainId={domainId} taxonomyConfig={taxonomyConfig} />,
78
+ renderOpts
79
+ );
80
+
81
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
82
+ await waitFor(() =>
83
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
84
+ );
85
+ expect(getByText("DOMAIN NAME")).toBeInTheDocument();
86
+ });
87
+
88
+ it("renders DomainTabs component", async () => {
89
+ const { getByText, queryByText } = render(
90
+ <Domain domainId={domainId} taxonomyConfig={taxonomyConfig} />,
91
+ renderOpts
92
+ );
93
+
94
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
95
+ await waitFor(() =>
96
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
97
+ );
98
+
99
+ expect(getByText("DOMAIN DESCRIPTION")).toBeInTheDocument();
100
+ });
101
+
102
+ it("renders DomainContent component", async () => {
103
+ const { getByText, queryByText } = render(
104
+ <Domain domainId={domainId} taxonomyConfig={taxonomyConfig} />,
105
+ renderOpts
106
+ );
107
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
108
+ await waitFor(() =>
109
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
110
+ );
111
+
112
+ expect(getByText("DOMAIN DESCRIPTION")).toBeInTheDocument();
113
+ });
114
+
115
+ it("renders Edit Domain component when path is DOMAIN_EDIT", async () => {
116
+ const { getByText, queryByText } = render(
117
+ <MemoryRouter initialEntries={[DOMAIN_EDIT]}>
118
+ <Domain domainId={domainId} taxonomyConfig={taxonomyConfig} />
119
+ </MemoryRouter>,
120
+ renderOpts
121
+ );
122
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
123
+ await waitFor(() =>
124
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
125
+ );
126
+
127
+ expect(getByText("Edit Domain")).toBeInTheDocument();
128
+ });
129
+
130
+ it("renders New Subdomain component when path is DOMAIN_NEW", async () => {
131
+ const { getByText, queryByText } = render(
132
+ <MemoryRouter initialEntries={[DOMAIN_NEW]}>
133
+ <Domain taxonomyConfig={taxonomyConfig} />
134
+ </MemoryRouter>,
135
+ renderOpts
136
+ );
137
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
138
+ await waitFor(() =>
139
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
140
+ );
141
+
142
+ expect(getByText("New Subdomain")).toBeInTheDocument();
143
+ });
144
+
145
+ it("renders null when no has any domain", async () => {
146
+ useDomain.mockImplementationOnce(() => ({
147
+ data: undefined,
148
+ }));
149
+
150
+ const { container } = render(
151
+ <Domain domainId={domainId} taxonomyConfig={taxonomyConfig} />,
152
+ renderOpts
153
+ );
29
154
  expect(container).toMatchSnapshot();
30
155
  });
31
156
  });
@@ -0,0 +1,148 @@
1
+ import _ from "lodash/fp";
2
+ import React from "react";
3
+ import { render } from "@truedat/test/render";
4
+ import { fireEvent } from "@testing-library/react";
5
+ import { DomainCards } from "../DomainCards";
6
+
7
+ describe("<DomainCards />", () => {
8
+ const renderOpts = {
9
+ messages: {
10
+ en: {
11
+ "domain.children.empty": "No subdomains found",
12
+ "domain.props.children": "Subdomains: {count}",
13
+ "domains.actions.create": "New Domain",
14
+ "domains.search.placeholder": "Search domains...",
15
+ "domains.search.results.count": "Results: {count}",
16
+ domain: "Domain",
17
+ },
18
+ },
19
+ };
20
+ const domains = [
21
+ {
22
+ id: 1,
23
+ name: "rootNoSub",
24
+ type: null,
25
+ description: "Root domain with no subdomains",
26
+ parents: [
27
+ {
28
+ id: 1,
29
+ name: "rootNoSub",
30
+ external_id: "rootNoSub",
31
+ },
32
+ ],
33
+ domain_group: {
34
+ id: 1,
35
+ name: "DomainGroup",
36
+ },
37
+ parent_id: null,
38
+ external_id: "rootNoSub",
39
+ },
40
+ {
41
+ id: 2,
42
+ name: "rootWithSub",
43
+ type: null,
44
+ description: null,
45
+ parents: [
46
+ {
47
+ id: 2,
48
+ name: "rootWithSub",
49
+ external_id: "rootWithSub",
50
+ },
51
+ ],
52
+ domain_group: {
53
+ id: 1,
54
+ name: "DomainGroup",
55
+ },
56
+ parent_id: null,
57
+ external_id: "rootWithSub",
58
+ },
59
+ {
60
+ id: 3,
61
+ name: "rootOtherGroup",
62
+ type: null,
63
+ description: null,
64
+ parents: [
65
+ {
66
+ id: 3,
67
+ name: "rootOtherGroup",
68
+ external_id: "rootOtherGroup",
69
+ },
70
+ ],
71
+ domain_group: {
72
+ id: 2,
73
+ name: "OtherDomainGroup",
74
+ },
75
+ parent_id: null,
76
+ external_id: "rootOtherGroup",
77
+ },
78
+ {
79
+ id: 4,
80
+ name: "subdomain",
81
+ type: null,
82
+ description: null,
83
+ parents: [
84
+ {
85
+ id: 3,
86
+ name: "subdomain",
87
+ external_id: "subdomain",
88
+ },
89
+ {
90
+ id: 2,
91
+ name: "rootWithSub",
92
+ external_id: "rootWithSub",
93
+ },
94
+ ],
95
+ domain_group: {
96
+ id: 1,
97
+ name: "DomainGroup",
98
+ },
99
+ parent_id: 2,
100
+ external_id: "subdomain",
101
+ },
102
+ ];
103
+ it("matches the latest snapshot front page", () => {
104
+ const props = { domains };
105
+ const { container } = render(<DomainCards {...props} />, renderOpts);
106
+ expect(container).toMatchSnapshot();
107
+ });
108
+
109
+ it("matches the latest snapshot domain without subdomain", () => {
110
+ const domain = _.find(["id", 1])(domains);
111
+ const props = { domains, domain };
112
+ const { container } = render(<DomainCards {...props} />, renderOpts);
113
+ expect(container).toMatchSnapshot();
114
+ });
115
+
116
+ it("matches the latest snapshot domain with subdomain", () => {
117
+ const domain = _.find(["id", 2])(domains);
118
+ const props = { domains, domain };
119
+ const { container } = render(<DomainCards {...props} />, renderOpts);
120
+ expect(container).toMatchSnapshot();
121
+ });
122
+
123
+ it("filters domains based on search input", () => {
124
+ const props = { domains };
125
+ const { getByPlaceholderText, getByText } = render(
126
+ <DomainCards {...props} />,
127
+ renderOpts
128
+ );
129
+
130
+ const searchInput = getByPlaceholderText("Search domains...");
131
+ fireEvent.change(searchInput, { target: { value: "other" } });
132
+
133
+ expect(getByText("rootOtherGroup")).toBeInTheDocument();
134
+ });
135
+
136
+ it("displays 'No subdomains found' message when no subdomains are present", () => {
137
+ const domain = _.find(["id", 1])(domains);
138
+ const props = { domains, domain };
139
+ const { getByText } = render(<DomainCards {...props} />, renderOpts);
140
+ expect(getByText("No subdomains found")).toBeInTheDocument();
141
+ });
142
+
143
+ it("renders DomainsActions component when no domain is selected", () => {
144
+ const props = { domains, actions: { create: { href: "" } } };
145
+ const { getByText } = render(<DomainCards {...props} />, renderOpts);
146
+ expect(getByText("New Domain")).toBeInTheDocument();
147
+ });
148
+ });
@@ -0,0 +1,168 @@
1
+ import _ from "lodash/fp";
2
+ import React from "react";
3
+ import { render } from "@truedat/test/render";
4
+ import { MemoryRouter } from "react-router-dom";
5
+ import DomainContent from "../DomainContent";
6
+
7
+ jest.mock("../../../hooks/useDomains", () => ({
8
+ ...jest.requireActual("../../../hooks/useDomains"),
9
+ useDomain: jest.fn((domainId) => ({
10
+ data: {
11
+ description: "DOMAIN DESCRIPTION",
12
+ domain_group: null,
13
+ external_id: "EXTERNAL ID",
14
+ id: domainId,
15
+ name: "DOMAIN NAME",
16
+ parent_id: 6,
17
+ parents: null,
18
+ type: null,
19
+ },
20
+ })),
21
+ }));
22
+
23
+ describe("<DomainContent />", () => {
24
+ const domains = [
25
+ {
26
+ id: 1,
27
+ name: "rootNoSub",
28
+ type: null,
29
+ description: "Root domain with no subdomains",
30
+ parents: [
31
+ {
32
+ id: 1,
33
+ name: "rootNoSub",
34
+ external_id: "rootNoSub",
35
+ },
36
+ ],
37
+ domain_group: {
38
+ id: 1,
39
+ name: "DomainGroup",
40
+ },
41
+ parent_id: null,
42
+ external_id: "rootNoSub",
43
+ },
44
+ {
45
+ id: 2,
46
+ name: "rootWithSub",
47
+ type: null,
48
+ description: null,
49
+ parents: [
50
+ {
51
+ id: 2,
52
+ name: "rootWithSub",
53
+ external_id: "rootWithSub",
54
+ },
55
+ ],
56
+ domain_group: {
57
+ id: 1,
58
+ name: "DomainGroup",
59
+ },
60
+ parent_id: null,
61
+ external_id: "rootWithSub",
62
+ },
63
+ {
64
+ id: 3,
65
+ name: "rootOtherGroup",
66
+ type: null,
67
+ description: null,
68
+ parents: [
69
+ {
70
+ id: 3,
71
+ name: "rootOtherGroup",
72
+ external_id: "rootOtherGroup",
73
+ },
74
+ ],
75
+ domain_group: {
76
+ id: 2,
77
+ name: "OtherDomainGroup",
78
+ },
79
+ parent_id: null,
80
+ external_id: "rootOtherGroup",
81
+ },
82
+ {
83
+ id: 4,
84
+ name: "childSubdomain",
85
+ type: null,
86
+ description: null,
87
+ parents: [
88
+ {
89
+ id: 3,
90
+ name: "childSubdomain",
91
+ external_id: "subdomain",
92
+ },
93
+ {
94
+ id: 2,
95
+ name: "rootWithSub",
96
+ external_id: "rootWithSub",
97
+ },
98
+ ],
99
+ domain_group: {
100
+ id: 1,
101
+ name: "DomainGroup",
102
+ },
103
+ parent_id: 2,
104
+ external_id: "subdomain",
105
+ },
106
+ ];
107
+
108
+ const taxonomyConfig = {
109
+ priorityTabs: [],
110
+ hiddenTabs: [],
111
+ };
112
+
113
+ const testList = [
114
+ {
115
+ content: "subdomains",
116
+ domainId: 1,
117
+ textToSearch: "This domain has no subdomains",
118
+ },
119
+ {
120
+ content: "subdomains",
121
+ domainId: 2,
122
+ textToSearch: "childSubdomain",
123
+ },
124
+ {
125
+ content: "concepts",
126
+ domainId: 1,
127
+ textToSearch: "Searching...",
128
+ },
129
+ {
130
+ content: "structures",
131
+ domainId: 1,
132
+ textToSearch: "You are not authorized to view this content",
133
+ },
134
+ {
135
+ content: "implementations",
136
+ domainId: 1,
137
+ textToSearch: "You are not authorized to view this content",
138
+ },
139
+ {
140
+ content: "members",
141
+ domainId: 1,
142
+ textToSearch: "This domain has no members",
143
+ },
144
+ ];
145
+ const renderOpts = {
146
+ mocks: [],
147
+ fallback: "lazy",
148
+ };
149
+
150
+ test.each(testList)(
151
+ "Render %s content for %s domain with text %s",
152
+ ({ content, domainId, textToSearch }) => {
153
+ const domain = _.find(["id", domainId])(domains);
154
+ const { container, getByText } = render(
155
+ <MemoryRouter initialEntries={[`/domains/${domainId}/${content}`]}>
156
+ <DomainContent
157
+ domain={domain}
158
+ domains={domains}
159
+ taxonomyConfig={taxonomyConfig}
160
+ />
161
+ </MemoryRouter>,
162
+ renderOpts
163
+ );
164
+ expect(container).toMatchSnapshot();
165
+ expect(getByText(textToSearch)).toBeInTheDocument();
166
+ }
167
+ );
168
+ });