@truedat/bg 4.51.2 → 4.51.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.51.3] 2022-09-16
4
+
5
+ ### Changed
6
+
7
+ - [TD-4794] Replace `DomainDropdownSelector` and `DomainMenuSelector` with
8
+ common `DomainSelector`
9
+
3
10
  ## [4.49.7] 2022-11-08
4
11
 
5
12
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/bg",
3
- "version": "4.51.2",
3
+ "version": "4.51.3",
4
4
  "description": "Truedat Web Business Glossary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.4",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.47.9",
37
+ "@truedat/test": "4.51.3",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -86,8 +86,8 @@
86
86
  ]
87
87
  },
88
88
  "dependencies": {
89
- "@truedat/core": "4.51.2",
90
- "@truedat/df": "4.51.2",
89
+ "@truedat/core": "4.51.3",
90
+ "@truedat/df": "4.51.3",
91
91
  "file-saver": "^2.0.5",
92
92
  "moment": "^2.24.0",
93
93
  "path-to-regexp": "^1.7.0",
@@ -107,5 +107,5 @@
107
107
  "react-dom": ">= 16.8.6 < 17",
108
108
  "semantic-ui-react": ">= 0.88.2 < 2.1"
109
109
  },
110
- "gitHead": "9bdc76f3ee59a6e28fb2312e26d0cba2807f069b"
110
+ "gitHead": "69d6cf8f7379eb2ef5744a4fdd357a7dd662b115"
111
111
  }
@@ -13,9 +13,12 @@ import {
13
13
  import { compose } from "redux";
14
14
  import { connect } from "react-redux";
15
15
  import { injectIntl, FormattedMessage } from "react-intl";
16
- import { HistoryBackButton, RichTextEditor } from "@truedat/core/components";
16
+ import {
17
+ DomainSelector,
18
+ HistoryBackButton,
19
+ RichTextEditor,
20
+ } from "@truedat/core/components";
17
21
  import { conceptAction } from "../routines";
18
- import DomainDropdownSelector from "../../taxonomy/components/DomainDropdownSelector";
19
22
 
20
23
  const SelectableDynamicForm = React.lazy(() =>
21
24
  import("@truedat/df/components/SelectableDynamicForm")
@@ -25,10 +28,11 @@ const actionKey = "create";
25
28
 
26
29
  const staticFields = ["name", "description"];
27
30
 
28
- const initialState = {
31
+ const INITIAL_STATE = {
29
32
  name: "",
30
33
  description: {},
31
34
  content: {},
35
+ domainsLoading: true,
32
36
  };
33
37
 
34
38
  const isNonEmptyString = _.flow(_.trim, _.negate(_.isEmpty));
@@ -47,11 +51,10 @@ export class ConceptForm extends React.Component {
47
51
  intl: PropTypes.object,
48
52
  };
49
53
 
50
- state = initialState;
54
+ state = INITIAL_STATE;
51
55
 
52
56
  handleDomainSelected = (_e, { value }) => {
53
- const domain_id = value;
54
- this.setState({ domain_id });
57
+ this.setState({ domain_id: _.toInteger(value) });
55
58
  };
56
59
 
57
60
  handleEditorChange = (e, { value }) => {
@@ -68,6 +71,8 @@ export class ConceptForm extends React.Component {
68
71
 
69
72
  handleContentChange = ({ content }) => this.setState({ content });
70
73
 
74
+ handleDomainsLoaded = () => this.setState({ domainsLoading: false });
75
+
71
76
  isInvalid = () => _.negate(isValid)(this.state);
72
77
 
73
78
  handleSubmit = (e) => {
@@ -94,7 +99,8 @@ export class ConceptForm extends React.Component {
94
99
  intl: { formatMessage },
95
100
  } = this.props;
96
101
 
97
- const { name, description, content, type, domain_id } = this.state;
102
+ const { name, description, content, type, domain_id, domainsLoading } =
103
+ this.state;
98
104
 
99
105
  const loading =
100
106
  action && action.href && conceptActionLoading === action.href;
@@ -107,15 +113,19 @@ export class ConceptForm extends React.Component {
107
113
  <FormattedMessage id="concepts.actions.create" />
108
114
  </Header.Content>
109
115
  </Header>
110
- <Form loading={loading}>
116
+ <Form loading={loading || domainsLoading}>
111
117
  <Header
112
118
  as="h3"
113
119
  content={formatMessage({ id: "concepts.form.required_fields" })}
114
120
  />
115
- <DomainDropdownSelector
116
- name="domain"
117
- invalid={!_.isFinite(domain_id)}
121
+ <DomainSelector
122
+ action="createBusinessConcept"
123
+ label={formatMessage({ id: "domain.selector.label" })}
124
+ labels
125
+ required
118
126
  onChange={this.handleDomainSelected}
127
+ onLoad={this.handleDomainsLoaded}
128
+ value={domain_id}
119
129
  />
120
130
  <Form.Field required>
121
131
  <label>
@@ -1,35 +1,25 @@
1
- import _ from "lodash/fp";
2
- import React from "react";
1
+ import React, { useState } from "react";
3
2
  import { Button, Container, Form, Header } from "semantic-ui-react";
4
3
  import { connect } from "react-redux";
5
4
  import { useForm, Controller } from "react-hook-form";
6
5
  import { useIntl } from "react-intl";
7
6
  import PropTypes from "prop-types";
8
- import DomainDropdownSelector from "../../taxonomy/components/DomainDropdownSelector";
9
- import { getDomainConceptSelectorOptions } from "../../taxonomy/selectors/getDomainsConcept";
7
+ import { DomainSelector } from "@truedat/core/components";
10
8
  import { conceptAction } from "../routines";
11
9
 
12
- const actionKey = "update_domain";
13
-
14
- export const ConceptManageDomain = ({
15
- domainOptions,
16
- conceptAction,
17
- action,
18
- setToDomain,
19
- }) => {
10
+ export const ConceptManageDomain = ({ domainId, conceptAction, action }) => {
20
11
  const { formatMessage } = useIntl();
12
+ const [loading, setLoading] = useState(true);
21
13
  const { handleSubmit, control, formState } = useForm({
22
14
  mode: "all",
23
- defaultValues: {
24
- setToDomain: _.prop("id")(setToDomain),
25
- },
15
+ defaultValues: { domainId },
26
16
  });
27
17
  const { isDirty, isValid } = formState;
28
- const onSubmit = ({ setToDomain }) => {
18
+ const onSubmit = ({ domainId }) => {
29
19
  conceptAction({
30
- action: actionKey,
20
+ action: "update_domain",
31
21
  ...action,
32
- domain_id: setToDomain,
22
+ domain_id: domainId,
33
23
  });
34
24
  };
35
25
 
@@ -37,27 +27,21 @@ export const ConceptManageDomain = ({
37
27
  <Container style={{ width: "400px" }}>
38
28
  <Header
39
29
  as="h2"
40
- content={formatMessage({
41
- id: "concept.changeDomain.header",
42
- })}
30
+ content={formatMessage({ id: "concept.changeDomain.header" })}
43
31
  />
44
- <Form onSubmit={handleSubmit(onSubmit)}>
32
+ <Form loading={loading} onSubmit={handleSubmit(onSubmit)}>
45
33
  <Controller
46
34
  control={control}
47
- name="setToDomain"
48
- render={({
49
- field: { onBlur, onChange, value },
50
- fieldState: { error },
51
- }) => (
52
- <DomainDropdownSelector
53
- domainOptions={domainOptions}
54
- name="setToDomain"
55
- clearable={false}
56
- error={!!error}
57
- label={formatMessage({ id: "concept.changeDomain.label" })}
35
+ name="domainId"
36
+ rules={{ required: true }}
37
+ render={({ field: { onBlur, onChange, value } }) => (
38
+ <DomainSelector
39
+ action="manageConcept"
40
+ labels
58
41
  onBlur={onBlur}
59
- required
60
42
  onChange={(_e, { value }) => onChange(value)}
43
+ onLoad={() => setLoading(false)}
44
+ required
61
45
  value={value}
62
46
  />
63
47
  )}
@@ -76,15 +60,14 @@ export const ConceptManageDomain = ({
76
60
  };
77
61
 
78
62
  ConceptManageDomain.propTypes = {
79
- domainOptions: PropTypes.array,
63
+ action: PropTypes.object,
80
64
  conceptAction: PropTypes.func,
81
- setToDomain: PropTypes.array,
65
+ domainId: PropTypes.number,
82
66
  };
83
67
 
84
- const mapStateToProps = (state) => ({
85
- domainOptions: getDomainConceptSelectorOptions(state),
86
- action: _.prop(actionKey)(state.conceptActions),
87
- setToDomain: state.concept.domain,
68
+ const mapStateToProps = ({ concept, conceptActions }) => ({
69
+ action: conceptActions?.update_domain,
70
+ domainId: concept?.domain?.id,
88
71
  });
89
72
 
90
73
  export default connect(mapStateToProps, { conceptAction })(ConceptManageDomain);
@@ -2,7 +2,6 @@ import _ from "lodash/fp";
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { Route, Switch } from "react-router-dom";
5
- import { useActiveRoutes } from "@truedat/core/hooks";
6
5
  import { connect } from "react-redux";
7
6
  import { Unauthorized } from "@truedat/core/components";
8
7
  import { useAuthorized } from "@truedat/core/hooks";
@@ -14,7 +13,6 @@ import {
14
13
  CONCEPT_EDIT,
15
14
  CONCEPT_VERSION,
16
15
  } from "@truedat/core/routes";
17
- import DomainsLoader from "../../taxonomy/components/DomainsLoader";
18
16
  import Concept from "./Concept";
19
17
  import ConceptCrumbs from "./ConceptCrumbs";
20
18
  import ConceptEdit from "./ConceptEdit";
@@ -79,11 +77,7 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
79
77
  <Route
80
78
  path={CONCEPTS}
81
79
  render={() => (
82
- <ConceptsLoader
83
- defaultFilters={{
84
- status: ["published"],
85
- }}
86
- />
80
+ <ConceptsLoader defaultFilters={{ status: ["published"] }} />
87
81
  )}
88
82
  />
89
83
  <Route
@@ -97,9 +91,7 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
97
91
  render={() => (
98
92
  <>
99
93
  <ConceptFiltersLoader
100
- defaultFilters={{
101
- status: ["published"],
102
- }}
94
+ defaultFilters={{ status: ["published"] }}
103
95
  />
104
96
  <ConceptUserFiltersLoader />
105
97
  <Concepts
@@ -115,7 +107,6 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
115
107
  path={CONCEPTS_BULK_UPDATE}
116
108
  render={() => (
117
109
  <>
118
- <DomainsLoader />
119
110
  <ConceptCrumbs conceptAction="actions.update" />
120
111
  <TemplatesLoader scope="bg" />
121
112
  {templatesLoaded && <ConceptsBulkUpdate />}
@@ -127,7 +118,6 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
127
118
  path={CONCEPTS_NEW}
128
119
  render={() => (
129
120
  <>
130
- <DomainsLoader actions="create_business_concept" />
131
121
  <ConceptCrumbs conceptAction="concepts.actions.create" />
132
122
  <ConceptForm />
133
123
  </>
@@ -141,7 +131,7 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
141
131
  <ConceptCrumbs conceptAction="concepts.actions.edit" />
142
132
  <TemplatesLoader scope="bg" />
143
133
  <ConceptLoader />
144
- {conceptLoaded && templatesLoaded && <ConceptEdit />}
134
+ {conceptLoaded && templatesLoaded ? <ConceptEdit /> : null}
145
135
  </>
146
136
  )}
147
137
  />
@@ -150,15 +140,16 @@ export const ConceptRoutes = ({ concept, conceptLoaded, templatesLoaded }) => {
150
140
  render={() => (
151
141
  <>
152
142
  <ConceptLoader />
153
- <DomainsLoader />
154
- {conceptLoaded && <ConceptSubscriptionLoader />}
155
143
  <RelationTagsLoader />
156
- {conceptLoaded && (
157
- <RelationsGraphLoader
158
- resource_id={_.prop("business_concept_id")(concept)}
159
- />
160
- )}
161
- {conceptLoaded && <Concept />}
144
+ {conceptLoaded ? (
145
+ <>
146
+ <ConceptSubscriptionLoader />
147
+ <RelationsGraphLoader
148
+ resource_id={concept?.business_concept_id}
149
+ />
150
+ <Concept />
151
+ </>
152
+ ) : null}
162
153
  </>
163
154
  )}
164
155
  />
@@ -12,11 +12,14 @@ import {
12
12
  } from "semantic-ui-react";
13
13
  import { connect } from "react-redux";
14
14
  import { FormattedMessage } from "react-intl";
15
- import { ConfirmModal, HistoryBackButton } from "@truedat/core/components";
16
- import { selectTemplate, selectDomain } from "@truedat/df/routines";
15
+ import {
16
+ ConfirmModal,
17
+ DomainSelector,
18
+ HistoryBackButton,
19
+ } from "@truedat/core/components";
20
+ import { selectTemplate } from "@truedat/df/routines";
17
21
  import { applyTemplateWithoutDefaults } from "@truedat/df/utils";
18
22
  import { bulkUpdate } from "../routines";
19
- import DomainDropdownSelector from "./../../taxonomy/components/DomainDropdownSelector";
20
23
 
21
24
  const DynamicForm = React.lazy(() =>
22
25
  import("@truedat/df/components/DynamicForm")
@@ -27,6 +30,9 @@ const TemplateLoader = React.lazy(() =>
27
30
 
28
31
  const initialState = {
29
32
  content: {},
33
+ domainsLoading: true,
34
+ domains: [],
35
+ selectedDomain: null,
30
36
  };
31
37
 
32
38
  const isValid = _.conforms({
@@ -51,7 +57,6 @@ const actions = (handleSubmit) => [
51
57
  export class ConceptsBulkUpdate extends React.Component {
52
58
  static propTypes = {
53
59
  loading: PropTypes.bool,
54
- selectDomain: PropTypes.func,
55
60
  selectTemplate: PropTypes.func,
56
61
  conceptCount: PropTypes.number,
57
62
  concepts: PropTypes.array,
@@ -59,7 +64,6 @@ export class ConceptsBulkUpdate extends React.Component {
59
64
  template: PropTypes.object,
60
65
  applyTemplate: PropTypes.func,
61
66
  bulkUpdate: PropTypes.func,
62
- selectedDomain: PropTypes.object,
63
67
  };
64
68
 
65
69
  state = initialState;
@@ -69,22 +73,17 @@ export class ConceptsBulkUpdate extends React.Component {
69
73
  selectTemplate({ id: templateId });
70
74
  }
71
75
 
72
- componentDidUpdate(prevProps) {
73
- const { selectedDomain: prevSelectedDomain } = prevProps;
74
- const { applyTemplate, selectedDomain } = this.props;
75
- const { content } = this.state;
76
- if (selectedDomain && selectedDomain !== prevSelectedDomain) {
77
- this.setState({ content: applyTemplate(content, selectedDomain) });
78
- }
79
- }
76
+ handleDomainsLoaded = (data) => {
77
+ this.setState({ domains: data.domains, domainsLoading: false });
78
+ };
80
79
 
81
80
  handleDomainSelected = (e, { value }) => {
82
- const domain_id = value;
83
-
84
- const { selectDomain } = this.props;
85
- selectDomain({ id: domain_id });
86
-
87
- this.setState({ domain_id });
81
+ const selectedDomain = _.find({ id: value })(this.state.domains);
82
+ if (selectedDomain && selectedDomain !== this.state.selectedDomain) {
83
+ const domain_id = selectedDomain ? _.toInteger(selectedDomain.id) : null;
84
+ const content = this.props.applyTemplate(this.state.content, domain_id);
85
+ this.setState({ selectedDomain, content, domain_id });
86
+ }
88
87
  };
89
88
 
90
89
  handleContentChange = (content) => this.setState({ content });
@@ -109,15 +108,9 @@ export class ConceptsBulkUpdate extends React.Component {
109
108
  };
110
109
 
111
110
  render() {
112
- const {
113
- loading,
114
- template,
115
- templateId,
116
- conceptCount,
117
- concepts,
118
- selectedDomain,
119
- } = this.props;
120
- const { content } = this.state;
111
+ const { loading, template, templateId, conceptCount, concepts } =
112
+ this.props;
113
+ const { content, domainsLoading, selectedDomain, domain_id } = this.state;
121
114
  const validConcepts = _.size(_.uniq(_.map(_.prop("type"))(concepts))) == 1;
122
115
 
123
116
  return (
@@ -145,21 +138,23 @@ export class ConceptsBulkUpdate extends React.Component {
145
138
  <FormattedMessage id="concepts.header.edit.bulk.info_message" />
146
139
  </Header.Content>
147
140
  </Header>
148
- <Form loading={loading}>
149
- <DomainDropdownSelector
141
+ <Form loading={loading || domainsLoading}>
142
+ <DomainSelector
143
+ action="manageConcept"
150
144
  onChange={this.handleDomainSelected}
151
- invalid={!_.isFinite(this.state.domain_id)}
145
+ onLoad={this.handleDomainsLoaded}
146
+ required
147
+ value={domain_id}
148
+ labels
152
149
  />
153
- {template &&
154
- templateId &&
155
- _.negate(_.isEmpty)(selectedDomain) && (
156
- <DynamicForm
157
- onChange={this.handleContentChange}
158
- content={content}
159
- fieldsToOmit={fieldsToOmit}
160
- applyTemplate={applyTemplateWithoutDefaults}
161
- />
162
- )}
150
+ {template && templateId && !_.isEmpty(selectedDomain) ? (
151
+ <DynamicForm
152
+ onChange={this.handleContentChange}
153
+ content={content}
154
+ fieldsToOmit={fieldsToOmit}
155
+ applyTemplate={applyTemplateWithoutDefaults}
156
+ />
157
+ ) : null}
163
158
  <ConfirmModal
164
159
  actions={actions(this.handleSubmit)}
165
160
  trigger={
@@ -200,15 +195,17 @@ export class ConceptsBulkUpdate extends React.Component {
200
195
  }
201
196
  }
202
197
 
203
- const mapStateToProps = ({
204
- bulkUpdateLoading,
205
- templateLoading,
206
- conceptCount,
207
- templates,
208
- template,
209
- concepts,
210
- selectedDomain,
211
- }) => {
198
+ const mapStateToProps = (
199
+ {
200
+ bulkUpdateLoading,
201
+ templateLoading,
202
+ conceptCount,
203
+ templates,
204
+ template,
205
+ concepts,
206
+ },
207
+ { applyTemplate } // ownProps only used for testing
208
+ ) => {
212
209
  const concept = _.head(concepts);
213
210
  const templateId =
214
211
  templates && concept?.type
@@ -218,8 +215,7 @@ const mapStateToProps = ({
218
215
  loading: templateLoading || bulkUpdateLoading,
219
216
  template,
220
217
  templateId,
221
- applyTemplate: applyTemplateWithoutDefaults(template),
222
- selectedDomain,
218
+ applyTemplate: applyTemplate || applyTemplateWithoutDefaults(template),
223
219
  concepts,
224
220
  conceptCount,
225
221
  };
@@ -228,5 +224,4 @@ const mapStateToProps = ({
228
224
  export default connect(mapStateToProps, {
229
225
  bulkUpdate,
230
226
  selectTemplate,
231
- selectDomain,
232
227
  })(ConceptsBulkUpdate);
@@ -5,18 +5,12 @@ import { useForm, Controller } from "react-hook-form";
5
5
  import { Button, Container, Form, Header } from "semantic-ui-react";
6
6
  import PropTypes from "prop-types";
7
7
  import { useIntl } from "react-intl";
8
+ import { DomainSelector } from "@truedat/core/components";
8
9
  import { saveSharedTo } from "../routines";
9
- import { getDomainSelectorOptions } from "../../taxonomy/selectors";
10
- import DomainMenuSelector from "../../taxonomy/components/DomainMenuSelector";
11
10
 
12
- export const SharedToForm = ({
13
- domainOptions,
14
- id,
15
- saveSharedTo,
16
- saving,
17
- sharedTo,
18
- }) => {
11
+ export const SharedToForm = ({ id, saveSharedTo, saving, sharedTo }) => {
19
12
  const { formatMessage } = useIntl();
13
+ const [loading, setLoading] = React.useState(true);
20
14
  const { handleSubmit, control, formState } = useForm({
21
15
  mode: "all",
22
16
  defaultValues: {
@@ -30,27 +24,23 @@ export const SharedToForm = ({
30
24
  <Container style={{ width: "400px" }}>
31
25
  <Header
32
26
  as="h2"
33
- content={formatMessage({
34
- id: "concept.sharedTo.header",
35
- })}
27
+ content={formatMessage({ id: "concept.sharedTo.header" })}
36
28
  />
37
- <Form onSubmit={handleSubmit(onSubmit)}>
29
+ <Form loading={loading} onSubmit={handleSubmit(onSubmit)}>
38
30
  <Controller
39
31
  control={control}
40
32
  name="sharedTo"
41
- rules={{ validate: (v) => !_.isEmpty(v) }}
42
- render={({
43
- field: { onBlur, onChange, value },
44
- fieldState: { error },
45
- }) => (
46
- <DomainMenuSelector
47
- domainOptions={domainOptions}
48
- name="sharedTo"
49
- error={!!error}
50
- label={formatMessage({ id: "concept.sharedTo.dropdown.label" })}
51
- onBlur={onBlur}
33
+ render={({ field: { onBlur, onChange, value } }) => (
34
+ <DomainSelector
35
+ action="shareConcept"
36
+ placeholder={formatMessage({
37
+ id: "concept.sharedTo.dropdown.label",
38
+ })}
39
+ labels
40
+ multiple
52
41
  onChange={(_e, { value }) => onChange(value)}
53
- required
42
+ onBlur={onBlur}
43
+ onLoad={() => setLoading(false)}
54
44
  value={value}
55
45
  />
56
46
  )}
@@ -70,7 +60,6 @@ export const SharedToForm = ({
70
60
  };
71
61
 
72
62
  SharedToForm.propTypes = {
73
- domainOptions: PropTypes.array,
74
63
  id: PropTypes.number,
75
64
  saveSharedTo: PropTypes.func,
76
65
  saving: PropTypes.bool,
@@ -78,7 +67,6 @@ SharedToForm.propTypes = {
78
67
  };
79
68
 
80
69
  const mapStateToProps = (state) => ({
81
- domainOptions: getDomainSelectorOptions(state),
82
70
  id: state.concept.business_concept_id,
83
71
  saving: state.savingSharedTo,
84
72
  sharedTo: state.sharedToDomains,
@@ -2,7 +2,11 @@ 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 { multipleTemplatesMock, singleTemplateMock } from "@truedat/test/mocks";
5
+ import {
6
+ domainsMock,
7
+ multipleTemplatesMock,
8
+ singleTemplateMock,
9
+ } from "@truedat/test/mocks";
6
10
  import ConceptForm from "../ConceptForm";
7
11
 
8
12
  const state = {
@@ -10,12 +14,16 @@ const state = {
10
14
  conceptActionLoading: "",
11
15
  domains: [{ id: 1, name: "domain1" }],
12
16
  };
13
- const variables = { scope: "bg", domainIds: [1] };
17
+ const templateVariables = { scope: "bg", domainIds: [1] };
18
+ const domainVariables = { action: "createBusinessConcept" };
14
19
 
15
20
  describe("<ConceptForm />", () => {
16
21
  describe("with multiple templates", () => {
17
22
  const renderOpts = {
18
- mocks: [multipleTemplatesMock(variables)],
23
+ mocks: [
24
+ multipleTemplatesMock(templateVariables),
25
+ domainsMock(domainVariables),
26
+ ],
19
27
  state,
20
28
  fallback: "lazy",
21
29
  };
@@ -26,6 +34,7 @@ describe("<ConceptForm />", () => {
26
34
  await waitFor(() =>
27
35
  expect(queryByText(/loading/i)).not.toBeInTheDocument()
28
36
  );
37
+ await waitFor(() => expect(queryByText(/fooDomain/)).toBeInTheDocument());
29
38
  expect(container).toMatchSnapshot();
30
39
  });
31
40
 
@@ -35,6 +44,8 @@ describe("<ConceptForm />", () => {
35
44
  renderOpts
36
45
  );
37
46
  await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
47
+ await waitFor(() => expect(queryByText(/fooDomain/)).toBeInTheDocument());
48
+ userEvent.click(await findByText("fooDomain"));
38
49
  userEvent.click(await findByText("template1"));
39
50
  expect(getByText("field1")).toBeInTheDocument();
40
51
  });
@@ -42,7 +53,7 @@ describe("<ConceptForm />", () => {
42
53
 
43
54
  describe("with a single template", () => {
44
55
  const renderOpts = {
45
- mocks: [singleTemplateMock(variables)],
56
+ mocks: [singleTemplateMock(templateVariables)],
46
57
  state,
47
58
  fallback: "lazy",
48
59
  };
@@ -53,6 +64,9 @@ describe("<ConceptForm />", () => {
53
64
  await waitFor(() =>
54
65
  expect(queryByText(/loading/i)).not.toBeInTheDocument()
55
66
  );
67
+ await waitFor(() =>
68
+ expect(queryByText(/fooDomain/)).not.toBeInTheDocument()
69
+ );
56
70
  expect(container).toMatchSnapshot();
57
71
  });
58
72