@truedat/bg 7.2.4 → 7.2.6

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.
@@ -1,21 +1,11 @@
1
1
  import React from "react";
2
2
  import { render } from "@truedat/test/render";
3
- import { LangProviderWrapper } from "@truedat/core/i18n";
4
3
  import { ConceptDetails } from "../ConceptDetails";
5
4
 
6
5
  const renderOpts = {
7
6
  fallback: "lazy",
8
- messages: {},
9
7
  };
10
8
 
11
- const renderComponent = (props) =>
12
- render(
13
- <LangProviderWrapper langs={["es"]}>
14
- <ConceptDetails {...props} />
15
- </LangProviderWrapper>,
16
- renderOpts
17
- );
18
-
19
9
  describe("<ConceptDetails />", () => {
20
10
  const props = {
21
11
  concept: {
@@ -36,10 +26,15 @@ describe("<ConceptDetails />", () => {
36
26
  field: { value: "value1", origin: "user" },
37
27
  },
38
28
  },
29
+ selectedContent: { field: { value: "value1", origin: "user" } },
30
+ lang: "en",
39
31
  };
40
32
 
41
33
  it("matches the latest snapshot", async () => {
42
- const { container, findByText } = renderComponent(props);
34
+ const { container, findByText } = render(
35
+ <ConceptDetails {...props} />,
36
+ renderOpts
37
+ );
43
38
 
44
39
  await findByText("field_label");
45
40
  expect(container).toMatchSnapshot();
@@ -1,62 +1,209 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { intl } from "@truedat/test/intl-stub";
4
- import { ConceptHeader } from "../ConceptHeader";
2
+ import { render } from "@truedat/test/render";
3
+ import userEvent from "@testing-library/user-event";
4
+ import ConceptHeader from "../ConceptHeader";
5
5
 
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);
6
+ const template = {
7
+ label: "Template Label",
8
+ content: [
9
+ {
10
+ name: "foo_group",
11
+ fields: [{ name: "field", label: "field_label", values: ["value1"] }],
12
+ },
13
+ ],
14
+ };
9
15
 
10
- describe("<ConceptHeader />", () => {
11
- const props = {
12
- concept: {
13
- name: "Concept1",
14
- business_concept_id: "42"
16
+ const contentEs = {
17
+ values: ["value1"],
18
+ };
19
+ const contentEn = {
20
+ values: ["value1"],
21
+ };
22
+
23
+ const concept = {
24
+ id: 1,
25
+ business_concept_id: 1,
26
+ name: "Concept_en",
27
+ type: "type",
28
+ version: 1,
29
+ status: "draft",
30
+ last_change_at: "2025-01-01T10:00:00Z",
31
+ template,
32
+ i18n_content: {
33
+ es: {
34
+ field: "field_label",
35
+ content: contentEs,
36
+ completeness: 1.0,
37
+ name: "Concept_es",
15
38
  },
16
- domain: {
17
- name: "Domain name"
39
+ en: {
40
+ field: "field_label",
41
+ content: contentEn,
42
+ completeness: 1.0,
43
+ name: "Concept_en",
18
44
  },
19
- template: {
20
- label: "Template1"
21
- }
22
- };
45
+ },
46
+ dynamic_content: {
47
+ field: { value: "value1", origin: "user" },
48
+ },
49
+ };
50
+
51
+ const props = {
52
+ selectedLang: "en",
53
+ setSelectedLang: jest.fn(),
54
+ i18nConcept: {
55
+ en: { id: 1, lang: "en", name: "Concept_en", content: contentEn },
56
+ es: { id: 2, lang: "es", name: "Concept_es", content: contentEs },
57
+ },
58
+ };
23
59
 
24
- const setConfidentialConcept = {
25
- href: "/api/business_concept_versions/29/set_confidential",
26
- input: {},
27
- method: "POST"
28
- };
60
+ const setConfidentialConcept = {
61
+ href: "/api/business_concept_versions/1/set_confidential",
62
+ input: {},
63
+ method: "POST",
64
+ };
29
65
 
66
+ const share = {
67
+ input: {},
68
+ method: "PATCH",
69
+ href: "/api/business_concepts/1/shared_domains",
70
+ };
71
+
72
+ const renderOpts = {
73
+ messages: {
74
+ en: {
75
+ "i18n.messages.lang.es": "Es",
76
+ "i18n.messages.lang.en": "En",
77
+ },
78
+ },
79
+ state: {
80
+ concept,
81
+ conceptPermissions: { share },
82
+ conceptActions: { set_confidential: setConfidentialConcept },
83
+ },
84
+ };
85
+
86
+ describe("<ConceptHeader />", () => {
30
87
  it("matches the latest snapshot", () => {
31
88
  const customProps = {
32
89
  ...props,
33
- setConfidentialConcept: setConfidentialConcept
90
+ setConfidentialConcept: setConfidentialConcept,
34
91
  };
35
- const wrapper = shallow(<ConceptHeader {...customProps} />);
36
- expect(wrapper).toMatchSnapshot();
92
+ const { container } = render(
93
+ <ConceptHeader {...customProps} />,
94
+ renderOpts
95
+ );
96
+
97
+ expect(container).toMatchSnapshot();
37
98
  });
38
99
 
39
100
  it("does not render ConceptConfidentialButton if no permission for managing confidential concepts", () => {
40
- const wrapper = shallow(<ConceptHeader {...props} />);
41
- expect(wrapper.find("Connect(ConceptConfidentialButton)")).toHaveLength(0);
101
+ const customRenderOpts = {
102
+ ...renderOpts,
103
+ state: {
104
+ concept,
105
+ conceptPermissions: { share },
106
+ conceptActions: {},
107
+ },
108
+ };
109
+
110
+ const { queryByText } = render(
111
+ <ConceptHeader {...props} />,
112
+ customRenderOpts
113
+ );
114
+ expect(queryByText("ConceptConfidentialButton")).toBeNull();
115
+ });
116
+
117
+ it("does not render SharedToDomainsPopup if no permission for updating concepts", () => {
118
+ const customRenderOpts = {
119
+ ...renderOpts,
120
+ state: {
121
+ concept,
122
+ conceptPermissions: {},
123
+ conceptActions: {},
124
+ },
125
+ };
126
+
127
+ const { queryByText } = render(
128
+ <ConceptHeader {...props} />,
129
+ customRenderOpts
130
+ );
131
+ expect(queryByText("SharedToDomainsPopup")).toBeNull();
42
132
  });
43
133
 
44
- it("does render ConceptConfidentialButton if permission for managing confidential concepts", () => {
134
+ it("change languaje when click on button", async () => {
135
+ const { getByText, queryByText } = render(
136
+ <ConceptHeader {...props} />,
137
+ renderOpts
138
+ );
139
+ expect(queryByText("Concept_en")).toBeInTheDocument();
140
+ const button = getByText("Es");
141
+
142
+ userEvent.click(button);
143
+
144
+ expect(props.setSelectedLang).toHaveBeenCalledWith("es");
145
+ });
146
+
147
+ it("does not render lang buttons if concept is published", () => {
148
+ const customRenderOpts = {
149
+ ...renderOpts,
150
+ state: {
151
+ concept: { ...concept, status: "published" },
152
+ conceptPermissions: { share },
153
+ conceptActions: { set_confidential: setConfidentialConcept },
154
+ },
155
+ };
156
+
157
+ const { queryByText } = render(
158
+ <ConceptHeader {...props} />,
159
+ customRenderOpts
160
+ );
161
+ expect(queryByText("En")).toBeNull();
162
+ });
163
+
164
+ it("does not render lang buttons if concept has only one language", () => {
45
165
  const customProps = {
46
166
  ...props,
47
- setConfidentialConcept: setConfidentialConcept
167
+ i18nConcept: {
168
+ en: { id: 1, lang: "en", name: "Concept_en", content: contentEn },
169
+ },
48
170
  };
49
- const wrapper = shallow(<ConceptHeader {...customProps} />);
50
- expect(wrapper.find("Connect(ConceptConfidentialButton)")).toHaveLength(1);
171
+
172
+ const { queryByText } = render(
173
+ <ConceptHeader {...customProps} />,
174
+ renderOpts
175
+ );
176
+ expect(queryByText("En")).toBeNull();
51
177
  });
52
178
 
53
- it("does not render SharedToDomainsPopup if no permission for updating concepts", () => {
54
- const wrapper = shallow(<ConceptHeader {...props} />);
55
- expect(wrapper.find("Connect(SharedToDomainsPopup)")).toHaveLength(0);
179
+ it("does not render lang buttons if i18nConcept has no content", () => {
180
+ const customProps = {
181
+ ...props,
182
+ i18nConcept: {
183
+ en: { id: 1, lang: "en", name: "Concept_en", content: {} },
184
+ es: { id: 2, lang: "es", name: "Concept_es", content: {} },
185
+ },
186
+ };
187
+
188
+ const { queryByText } = render(
189
+ <ConceptHeader {...customProps} />,
190
+ renderOpts
191
+ );
192
+ expect(queryByText("En")).toBeNull();
56
193
  });
57
194
 
58
- it("renders SharedToDomainsPopup if no permission for updating concepts", () => {
59
- const wrapper = shallow(<ConceptHeader {...{ ...props, share: true }} />);
60
- expect(wrapper.find("Connect(SharedToDomainsPopup)")).toHaveLength(1);
195
+ it("set content name when i18ncontent is undefined", () => {
196
+ const customRenderOpts = {
197
+ ...renderOpts,
198
+ state: {
199
+ concept: { ...concept, i18n_content: undefined },
200
+ },
201
+ };
202
+
203
+ const { queryByText } = render(
204
+ <ConceptHeader {...props} />,
205
+ customRenderOpts
206
+ );
207
+ expect(queryByText("Concept_en")).toBeInTheDocument();
61
208
  });
62
209
  });
@@ -1,54 +1,309 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<Concept /> matches the latest snapshot 1`] = `
4
- <Fragment>
5
- <Connect(ConceptCrumbs) />
6
- <Connect(ConceptArchiveLoader) />
7
- <Connect(CommentsLoader)
8
- resource_id={1}
9
- resource_type="business_concept"
10
- />
11
- <lazy
12
- resource_id={1}
13
- resource_type="concept"
14
- />
15
- <lazy />
16
- <lazy
17
- resource_id={1}
18
- resource_type="business_concept"
19
- target_type="business_concept"
20
- />
21
- <Grid
22
- columns="equal"
23
- style={
24
- {
25
- "marginTop": 0,
26
- }
27
- }
4
+ <div>
5
+ <div
6
+ class="ui breadcrumb"
7
+ style=""
28
8
  >
29
- <GridColumn
30
- width={12}
9
+ <a
10
+ class="section"
11
+ href="/concepts"
31
12
  >
32
- <Segment>
33
- <Connect(ConceptHeader) />
34
- <Connect(ConceptTabs) />
35
- <ConceptTabPane />
36
- </Segment>
37
- <Route
38
- exact={true}
39
- path="/concepts/:business_concept_id/versions/:id"
40
- render={[Function]}
41
- />
42
- </GridColumn>
43
- <GridColumn
44
- width={4}
13
+ Business Glossary
14
+ </a>
15
+ <i
16
+ aria-hidden="true"
17
+ class="right angle icon divider"
18
+ />
19
+ <a
20
+ class="section"
21
+ href="/concepts/pending"
45
22
  >
46
- <Connect(ConceptSummary) />
47
- <injectIntl(Connect(ConceptRelationsSummary)) />
48
- <Connect(ConceptTaxonomy) />
49
- <Connect(SharedToDomains) />
50
- <Connect(ConceptCompleteness) />
51
- </GridColumn>
52
- </Grid>
53
- </Fragment>
23
+ Draft
24
+ </a>
25
+ <i
26
+ aria-hidden="true"
27
+ class="right angle icon divider"
28
+ />
29
+ <span
30
+ class="active section"
31
+ style="cursor: default;"
32
+ >
33
+ Concept_en
34
+ </span>
35
+ </div>
36
+ <div
37
+ class="ui equal width grid"
38
+ style="margin-top: 0px;"
39
+ >
40
+ <div
41
+ class="twelve wide column"
42
+ >
43
+ <div
44
+ class="ui segment"
45
+ >
46
+ <div
47
+ class="ui grid"
48
+ >
49
+ <div
50
+ class="row"
51
+ >
52
+ <div
53
+ class="eight wide column"
54
+ >
55
+ <h2
56
+ class="ui header"
57
+ >
58
+ <i
59
+ aria-hidden="true"
60
+ class="book circular icon"
61
+ />
62
+ <div
63
+ class="content"
64
+ >
65
+ Concept_es
66
+ <div
67
+ class="sub header"
68
+ >
69
+ templates.undefined
70
+ </div>
71
+ </div>
72
+ </h2>
73
+ </div>
74
+ <div
75
+ class="right aligned eight wide column"
76
+ >
77
+ <button
78
+ class="ui basic icon button button icon group-actions"
79
+ data-tooltip="Sharing"
80
+ >
81
+ <i
82
+ aria-hidden="true"
83
+ class="share alternate icon"
84
+ />
85
+ </button>
86
+ <button
87
+ class="ui basic icon button button icon group-actions structureButton"
88
+ >
89
+ <i
90
+ aria-hidden="true"
91
+ class="eye icon"
92
+ />
93
+ </button>
94
+ </div>
95
+ </div>
96
+ <div
97
+ class="row"
98
+ >
99
+ <div
100
+ class="eight wide column"
101
+ >
102
+ <div
103
+ class="ui left floated buttons"
104
+ >
105
+ <button
106
+ class="ui mini active button"
107
+ >
108
+ Spanish
109
+ </button>
110
+ <button
111
+ class="ui mini button"
112
+ >
113
+ English
114
+ </button>
115
+ </div>
116
+ </div>
117
+ <div
118
+ class="right aligned eight wide column"
119
+ />
120
+ </div>
121
+ </div>
122
+ <div
123
+ class="ui pointing secondary top attached tabular menu"
124
+ >
125
+ <a
126
+ class="item"
127
+ href="/concepts/1/versions/1"
128
+ >
129
+ Concept
130
+ </a>
131
+ <a
132
+ class="item"
133
+ href="/concepts/1/versions/1/links/structures"
134
+ >
135
+ Linkage
136
+ </a>
137
+ <a
138
+ class="item"
139
+ href="/concepts/1/versions/1/rules"
140
+ >
141
+ Quality Rules
142
+ </a>
143
+ <a
144
+ class="item"
145
+ href="/concepts/1/versions/1/archive"
146
+ >
147
+ History
148
+ </a>
149
+ <a
150
+ class="item"
151
+ href="/concepts/1/versions/1/events"
152
+ >
153
+ Audit
154
+ </a>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ <div
159
+ class="four wide column"
160
+ >
161
+ <div
162
+ class="ui segment"
163
+ >
164
+ <h3
165
+ class="ui dividing header"
166
+ >
167
+ Resumen
168
+ </h3>
169
+ <div
170
+ class="item concept-summary"
171
+ role="listitem"
172
+ >
173
+ <div
174
+ class="content concept-summary__content"
175
+ >
176
+ <div
177
+ class="concept-summary__content-bold"
178
+ >
179
+ Status
180
+ :
181
+ </div>
182
+ <div
183
+ class="ui olive label"
184
+ >
185
+ draft
186
+ </div>
187
+ </div>
188
+ </div>
189
+ <div
190
+ class="item concept-summary"
191
+ role="listitem"
192
+ >
193
+ <div
194
+ class="content concept-summary__content"
195
+ >
196
+ <div
197
+ class="concept-summary__content-bold"
198
+ >
199
+ Version
200
+ :
201
+ </div>
202
+ <div
203
+ class="ui label"
204
+ >
205
+ <i
206
+ aria-hidden="true"
207
+ class="grey ellipsis vertical icon"
208
+ />
209
+ </div>
210
+ </div>
211
+ </div>
212
+ <div
213
+ class="item concept-summary"
214
+ role="listitem"
215
+ >
216
+ <div
217
+ class="content concept-summary__content"
218
+ >
219
+ <div
220
+ class="concept-summary__content-bold"
221
+ >
222
+ Update
223
+ :
224
+ </div>
225
+ <div
226
+ class="ui label"
227
+ >
228
+ <time
229
+ datetime="1735725600000"
230
+ >
231
+ 2025-01-01 10:00
232
+ </time>
233
+ </div>
234
+ </div>
235
+ </div>
236
+ <div
237
+ class="item concept-summary"
238
+ role="listitem"
239
+ >
240
+ <div
241
+ class="content concept-summary__content"
242
+ >
243
+ <div
244
+ class="concept-summary__content-bold"
245
+ >
246
+ User
247
+ :
248
+ </div>
249
+ <div
250
+ class="ui label"
251
+ >
252
+ <i
253
+ aria-hidden="true"
254
+ class="grey ellipsis vertical icon"
255
+ />
256
+ </div>
257
+ </div>
258
+ </div>
259
+ </div>
260
+ <div
261
+ class="ui segment completeness"
262
+ >
263
+ <h3
264
+ class="ui dividing header"
265
+ >
266
+ Completeness
267
+
268
+ </h3>
269
+ <div
270
+ class="ui progress"
271
+ data-percent="0"
272
+ >
273
+ <div
274
+ class="bar"
275
+ style="width: 0%;"
276
+ >
277
+ <div
278
+ class="progress"
279
+ >
280
+ 0%
281
+ </div>
282
+ </div>
283
+ </div>
284
+ <h3
285
+ class="ui dividing header"
286
+ >
287
+ Completeness
288
+
289
+ </h3>
290
+ <div
291
+ class="ui error progress"
292
+ data-percent="1"
293
+ >
294
+ <div
295
+ class="bar"
296
+ style="width: 1%;"
297
+ >
298
+ <div
299
+ class="progress"
300
+ >
301
+ 1%
302
+ </div>
303
+ </div>
304
+ </div>
305
+ </div>
306
+ </div>
307
+ </div>
308
+ </div>
54
309
  `;