@truedat/bg 7.2.1 → 7.2.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 (29) hide show
  1. package/package.json +6 -6
  2. package/src/concepts/components/ConceptsUploadButton.js +1 -1
  3. package/src/concepts/components/__tests__/ConceptManageDomain.spec.js +28 -4
  4. package/src/concepts/components/__tests__/__snapshots__/ConceptForm.spec.js.snap +10 -12
  5. package/src/concepts/components/__tests__/__snapshots__/ConceptManageDomain.spec.js.snap +58 -1
  6. package/src/concepts/components/__tests__/__snapshots__/ConceptsBulkUpdate.spec.js.snap +10 -12
  7. package/src/concepts/components/__tests__/__snapshots__/SharedToForm.spec.js.snap +10 -12
  8. package/src/messages/en.js +2 -0
  9. package/src/messages/es.js +2 -0
  10. package/src/taxonomy/components/Domain.js +11 -71
  11. package/src/taxonomy/components/DomainCards.js +113 -0
  12. package/src/taxonomy/components/DomainContent.js +119 -0
  13. package/src/taxonomy/components/DomainTabs.js +92 -40
  14. package/src/taxonomy/components/Domains.js +144 -25
  15. package/src/taxonomy/components/DomainsActions.js +4 -4
  16. package/src/taxonomy/components/__tests__/Domain.spec.js +127 -2
  17. package/src/taxonomy/components/__tests__/DomainCards.spec.js +148 -0
  18. package/src/taxonomy/components/__tests__/DomainContent.spec.js +168 -0
  19. package/src/taxonomy/components/__tests__/DomainTabs.spec.js +108 -0
  20. package/src/taxonomy/components/__tests__/Domains.spec.js +149 -2
  21. package/src/taxonomy/components/__tests__/DomainsActions.spec.js +15 -8
  22. package/src/taxonomy/components/__tests__/__snapshots__/Domain.spec.js.snap +8 -0
  23. package/src/taxonomy/components/__tests__/__snapshots__/DomainCards.spec.js.snap +291 -0
  24. package/src/taxonomy/components/__tests__/__snapshots__/DomainContent.spec.js.snap +305 -0
  25. package/src/taxonomy/components/__tests__/__snapshots__/DomainTabs.spec.js.snap +40 -0
  26. package/src/taxonomy/components/__tests__/__snapshots__/Domains.spec.js.snap +74 -4
  27. package/src/taxonomy/components/__tests__/__snapshots__/DomainsActions.spec.js.snap +13 -22
  28. package/src/taxonomy/styles/domainCards.less +4 -0
  29. package/src/taxonomy/styles/domains.less +15 -0
@@ -0,0 +1,119 @@
1
+ import _ from "lodash/fp";
2
+ import React from "react";
3
+ import { Unauthorized } from "@truedat/core/components";
4
+ import { useAuthorized } from "@truedat/core/hooks";
5
+ import UserSearchFiltersLoader from "@truedat/dd/components/UserSearchFiltersLoader";
6
+ import PropTypes from "prop-types";
7
+ import { Route, Switch } from "react-router-dom/cjs/react-router-dom.min";
8
+ import {
9
+ DOMAIN,
10
+ DOMAIN_CONCEPTS,
11
+ DOMAIN_IMPLEMENTATIONS,
12
+ DOMAIN_MEMBERS,
13
+ DOMAIN_MEMBERS_NEW,
14
+ DOMAIN_STRUCTURES,
15
+ DOMAIN_SUBDOMAINS,
16
+ } from "@truedat/core/routes";
17
+ import DomainConcepts from "../../concepts/components/DomainConcepts";
18
+ import DomainCards from "./DomainCards";
19
+ import DomainStructures from "./DomainStructures";
20
+ import DomainImplementations from "./DomainImplementations";
21
+ import DomainMembers from "./DomainMembers";
22
+ import AddDomainMember from "./AddDomainMember";
23
+
24
+ const RolesLoader = React.lazy(() =>
25
+ import("@truedat/auth/roles/components/RolesLoader")
26
+ );
27
+
28
+ const DomainContent = ({
29
+ domain,
30
+ domains,
31
+ taxonomyConfig: { priorityTabs, hiddenTabs },
32
+ }) => {
33
+ const ddAuthorized = useAuthorized("data_dictionary");
34
+ const dqAuthorized = useAuthorized("quality");
35
+
36
+ const routes = [
37
+ {
38
+ key: "subdomains",
39
+ path: DOMAIN_SUBDOMAINS,
40
+ component: <DomainCards domain={domain} domains={domains} />,
41
+ },
42
+ {
43
+ key: "concepts",
44
+ path: DOMAIN_CONCEPTS,
45
+ component: <DomainConcepts domain={domain} />,
46
+ },
47
+ {
48
+ key: "structures",
49
+ path: DOMAIN_STRUCTURES,
50
+ component: ddAuthorized ? (
51
+ <DomainStructures domain={domain} />
52
+ ) : (
53
+ <Unauthorized />
54
+ ),
55
+ },
56
+ {
57
+ key: "implementations",
58
+ path: DOMAIN_IMPLEMENTATIONS,
59
+ component: dqAuthorized ? (
60
+ <>
61
+ <UserSearchFiltersLoader scope="rule_implementation" />
62
+ <DomainImplementations domain={domain} />
63
+ </>
64
+ ) : (
65
+ <Unauthorized />
66
+ ),
67
+ },
68
+ {
69
+ key: "members",
70
+ path: DOMAIN_MEMBERS,
71
+ component: <DomainMembers domainId={domain.id} />,
72
+ },
73
+ {
74
+ key: "members-new",
75
+ path: DOMAIN_MEMBERS_NEW,
76
+ component: (
77
+ <>
78
+ <RolesLoader />
79
+ <AddDomainMember id={parseInt(domain.id)} />
80
+ </>
81
+ ),
82
+ },
83
+ ];
84
+
85
+ const getPaths = ({ key, path }) =>
86
+ _.cond([
87
+ [
88
+ (key) => !_.head(priorityTabs) && key === _.head(routes).key,
89
+ () => [path, DOMAIN],
90
+ ],
91
+ [(key) => key === _.head(priorityTabs), () => [path, DOMAIN]],
92
+ [_.stubTrue, () => path],
93
+ ])(key);
94
+
95
+ return (
96
+ <Switch>
97
+ {_.map((route) =>
98
+ _.includes(route.key, hiddenTabs) && false ? (
99
+ <Unauthorized key={route.key} />
100
+ ) : (
101
+ <Route
102
+ exact
103
+ key={route.key}
104
+ path={getPaths(route)}
105
+ render={() => route.component}
106
+ />
107
+ )
108
+ )(routes)}
109
+ </Switch>
110
+ );
111
+ };
112
+
113
+ DomainContent.propTypes = {
114
+ domain: PropTypes.object,
115
+ domains: PropTypes.array,
116
+ taxonomyConfig: PropTypes.object,
117
+ };
118
+
119
+ export default DomainContent;
@@ -1,3 +1,4 @@
1
+ import _ from "lodash/fp";
1
2
  import React from "react";
2
3
  import PropTypes from "prop-types";
3
4
  import { FormattedMessage } from "react-intl";
@@ -6,67 +7,118 @@ import { Menu } from "semantic-ui-react";
6
7
  import { compile } from "path-to-regexp";
7
8
  import { useAuthorized } from "@truedat/core/hooks";
8
9
  import {
10
+ DOMAIN,
9
11
  DOMAIN_CONCEPTS,
10
12
  DOMAIN_IMPLEMENTATIONS,
11
13
  DOMAIN_MEMBERS,
12
14
  DOMAIN_MEMBERS_NEW,
13
15
  DOMAIN_STRUCTURES,
16
+ DOMAIN_SUBDOMAINS,
14
17
  linkTo,
15
18
  } from "@truedat/core/routes";
16
19
 
17
- const DomainTabs = ({ domain }) => {
20
+ const DomainTabs = ({
21
+ domain,
22
+ taxonomyConfig: { priorityTabs, hiddenTabs },
23
+ }) => {
18
24
  const { pathname: path } = useLocation();
19
25
  const ddAuthorized = useAuthorized("data_dictionary");
20
26
  const dqAuthorized = useAuthorized("quality");
21
27
  const id = domain.id;
22
28
 
29
+ const getPriority = (key) =>
30
+ _.includes(key, priorityTabs)
31
+ ? _.indexOf(key, priorityTabs)
32
+ : priorityTabs.length;
33
+
34
+ const tabs = [
35
+ {
36
+ key: "subdomains",
37
+ priority: getPriority("subdomains"),
38
+ url: DOMAIN_SUBDOMAINS,
39
+ to: linkTo.DOMAIN_SUBDOMAINS({ id }),
40
+ label: "tabs.subdomains",
41
+ },
42
+ {
43
+ key: "concepts",
44
+ priority: getPriority("concepts"),
45
+ url: DOMAIN_CONCEPTS,
46
+ to: linkTo.DOMAIN_CONCEPTS({ id }),
47
+ label: "tabs.concepts",
48
+ },
49
+ {
50
+ key: "structures",
51
+ priority: getPriority("structures"),
52
+ url: DOMAIN_STRUCTURES,
53
+ to: linkTo.DOMAIN_STRUCTURES({ id }),
54
+ label: "tabs.structures",
55
+ },
56
+ {
57
+ key: "implementations",
58
+ priority: getPriority("implementations"),
59
+ url: DOMAIN_IMPLEMENTATIONS,
60
+ to: linkTo.DOMAIN_IMPLEMENTATIONS({ id }),
61
+ label: "tabs.implementations",
62
+ },
63
+ {
64
+ key: "members",
65
+ priority: getPriority("members"),
66
+ url: [DOMAIN_MEMBERS, DOMAIN_MEMBERS_NEW],
67
+ to: linkTo.DOMAIN_MEMBERS({ id }),
68
+ label: "tabs.members",
69
+ },
70
+ ];
71
+
72
+ const setMainTab = (orderedTabs) =>
73
+ _.flow(_.head, _.set("to", linkTo.DOMAIN({ id })), (mainTab) => [
74
+ mainTab,
75
+ ..._.tail(orderedTabs),
76
+ ])(orderedTabs);
77
+
78
+ const orderedTabs = _.flow(
79
+ _.filter((tab) => ddAuthorized || tab.key !== "structures"),
80
+ _.filter((tab) => dqAuthorized || tab.key !== "implementations"),
81
+ _.reject((tab) => hiddenTabs.includes(tab.key)),
82
+ _.sortBy("priority"),
83
+ setMainTab
84
+ )(tabs);
85
+
86
+ const getActived = (key, url, id) => {
87
+ const tabUrls = _.isArray(url) ? url : [url];
88
+
89
+ const maybeAddMain =
90
+ key === _.head(orderedTabs).key
91
+ ? _.concat([compile(DOMAIN)({ id })], tabUrls)
92
+ : tabUrls;
93
+
94
+ return _.flow(
95
+ _.map((url) => compile(url)({ id })),
96
+ _.some((url) => path === url)
97
+ )(maybeAddMain);
98
+ };
99
+
23
100
  return (
24
101
  <Menu attached="top" pointing secondary tabular>
25
- <Menu.Item
26
- active={path === compile(DOMAIN_CONCEPTS)({ id })}
27
- as={Link}
28
- to={linkTo.DOMAIN_CONCEPTS({ id })}
29
- replace
30
- >
31
- <FormattedMessage id="tabs.concepts" />
32
- </Menu.Item>
33
- {ddAuthorized ? (
34
- <Menu.Item
35
- active={path === compile(DOMAIN_STRUCTURES)({ id })}
36
- as={Link}
37
- to={linkTo.DOMAIN_STRUCTURES({ id })}
38
- replace
39
- >
40
- <FormattedMessage id="tabs.structures" />
41
- </Menu.Item>
42
- ) : null}
43
- {dqAuthorized ? (
44
- <Menu.Item
45
- active={path === compile(DOMAIN_IMPLEMENTATIONS)({ id })}
46
- as={Link}
47
- to={linkTo.DOMAIN_IMPLEMENTATIONS({ id })}
48
- replace
49
- >
50
- <FormattedMessage id="tabs.implementations" />
51
- </Menu.Item>
52
- ) : null}
53
- <Menu.Item
54
- active={
55
- path === compile(DOMAIN_MEMBERS)({ id }) ||
56
- path === compile(DOMAIN_MEMBERS_NEW)({ id })
57
- }
58
- as={Link}
59
- to={linkTo.DOMAIN_MEMBERS({ id })}
60
- replace
61
- >
62
- <FormattedMessage id="tabs.members" />
63
- </Menu.Item>
102
+ {_.map(({ key, url, to, label }) => {
103
+ return (
104
+ <Menu.Item
105
+ key={key}
106
+ active={getActived(key, url, id)}
107
+ as={Link}
108
+ to={to}
109
+ replace
110
+ >
111
+ <FormattedMessage id={label} />
112
+ </Menu.Item>
113
+ );
114
+ }, orderedTabs)}
64
115
  </Menu>
65
116
  );
66
117
  };
67
118
 
68
119
  DomainTabs.propTypes = {
69
120
  domain: PropTypes.object,
121
+ taxonomyConfig: PropTypes.object,
70
122
  };
71
123
 
72
124
  export default DomainTabs;
@@ -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
  });