@truedat/bg 7.10.4 → 7.11.0

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 (25) hide show
  1. package/package.json +3 -3
  2. package/src/concepts/components/ConceptLinksUploadButton.js +0 -4
  3. package/src/concepts/components/ConceptRoutes.js +28 -46
  4. package/src/concepts/components/__tests__/ConceptRoutes.spec.js +201 -0
  5. package/src/concepts/components/__tests__/__snapshots__/ConceptRoutes.spec.js.snap +165 -0
  6. package/src/concepts/relations/api.js +9 -1
  7. package/src/concepts/relations/components/ConceptLinksApprovalResults.js +91 -0
  8. package/src/concepts/relations/components/ConceptLinksApprovals.js +225 -0
  9. package/src/concepts/relations/components/ConceptLinksApprovalsLabelResults.js +42 -0
  10. package/src/concepts/relations/components/ConceptLinksApprovalsRow.js +43 -0
  11. package/src/concepts/relations/components/ConceptLinksApprovalsTable.js +104 -0
  12. package/src/concepts/relations/components/__tests__/ConceptLinksApprovalResults.spec.js +123 -0
  13. package/src/concepts/relations/components/__tests__/ConceptLinksApprovals.spec.js +77 -0
  14. package/src/concepts/relations/components/__tests__/ConceptLinksApprovalsLabelResults.spec.js +47 -0
  15. package/src/concepts/relations/components/__tests__/ConceptLinksApprovalsRow.spec.js +68 -0
  16. package/src/concepts/relations/components/__tests__/ConceptLinksApprovalsTable.spec.js +107 -0
  17. package/src/concepts/relations/components/__tests__/__snapshots__/ConceptLinksApprovalResults.spec.js.snap +217 -0
  18. package/src/concepts/relations/components/__tests__/__snapshots__/ConceptLinksApprovals.spec.js.snap +559 -0
  19. package/src/concepts/relations/components/__tests__/__snapshots__/ConceptLinksApprovalsLabelResults.spec.js.snap +34 -0
  20. package/src/concepts/relations/components/__tests__/__snapshots__/ConceptLinksApprovalsRow.spec.js.snap +47 -0
  21. package/src/concepts/relations/components/__tests__/__snapshots__/ConceptLinksApprovalsTable.spec.js.snap +132 -0
  22. package/src/concepts/relations/hooks/useLinks.js +25 -0
  23. package/src/concepts/relations/selectors/getLinksSearchColumns.js +106 -0
  24. package/src/concepts/relations/selectors/index.js +2 -0
  25. package/src/concepts/relations/styles/ConceptLinksApprovals.less +15 -0
@@ -0,0 +1,68 @@
1
+ import { render, waitForLoad } from "@truedat/test/render";
2
+ import { ConceptLinksApprovalsRow } from "../ConceptLinksApprovalsRow";
3
+
4
+ describe("ConceptLinksApprovalsRow", () => {
5
+ const defaultProps = {
6
+ checked: false,
7
+ columns: [
8
+ {
9
+ key: "name",
10
+ textAlign: "left",
11
+ },
12
+ ],
13
+ onCheckboxChange: jest.fn(),
14
+ link: {
15
+ id: "123",
16
+ name: "Test Link",
17
+ },
18
+ approveView: false,
19
+ };
20
+
21
+ it("renders null when columns are empty", async () => {
22
+ const rendered = render(
23
+ <ConceptLinksApprovalsRow {...defaultProps} columns={[]} />
24
+ );
25
+ await waitForLoad(rendered);
26
+ expect(rendered.container).toMatchSnapshot();
27
+ });
28
+
29
+ it("renders null when link is empty", async () => {
30
+ const rendered = render(
31
+ <ConceptLinksApprovalsRow {...defaultProps} link={{}} />
32
+ );
33
+ await waitForLoad(rendered);
34
+ expect(rendered.container).toMatchSnapshot();
35
+ });
36
+
37
+ it("renders row with checkbox when approveView is true", async () => {
38
+ const rendered = render(
39
+ <ConceptLinksApprovalsRow {...defaultProps} approveView={true} />
40
+ );
41
+ await waitForLoad(rendered);
42
+ expect(rendered.container).toMatchSnapshot();
43
+ });
44
+
45
+ it("renders row without checkbox when approveView is false", async () => {
46
+ const rendered = render(
47
+ <ConceptLinksApprovalsRow {...defaultProps} approveView={false} />
48
+ );
49
+ await waitForLoad(rendered);
50
+ expect(rendered.container).toMatchSnapshot();
51
+ });
52
+
53
+ it("calls onCheckboxChange when checkbox is clicked", async () => {
54
+ const onCheckboxChange = jest.fn();
55
+ const rendered = render(
56
+ <ConceptLinksApprovalsRow
57
+ {...defaultProps}
58
+ approveView={true}
59
+ onCheckboxChange={onCheckboxChange}
60
+ />
61
+ );
62
+ await waitForLoad(rendered);
63
+
64
+ const checkbox = rendered.container.querySelector("input[type='checkbox']");
65
+ checkbox.click();
66
+ expect(onCheckboxChange).toHaveBeenCalled();
67
+ });
68
+ });
@@ -0,0 +1,107 @@
1
+ import { render, waitForLoad } from "@truedat/test/render";
2
+ import { useSearchContext } from "@truedat/core/search/SearchContext";
3
+ import { ConceptLinksApprovalsTable } from "../ConceptLinksApprovalsTable";
4
+
5
+ jest.mock("@truedat/core/search/SearchContext", () => {
6
+ const originalModule = jest.requireActual(
7
+ "@truedat/core/search/SearchContext"
8
+ );
9
+
10
+ return {
11
+ __esModule: true,
12
+ ...originalModule,
13
+ useSearchContext: jest.fn(),
14
+ };
15
+ });
16
+
17
+ describe("ConceptLinksApprovalsTable", () => {
18
+ const mockColumns = [
19
+ { name: "source_name", width: 4 },
20
+ { name: "target_name", width: 4 },
21
+ { name: "tag_type", width: 2 },
22
+ { name: "status", width: 2 },
23
+ { name: "updated_at", width: 2 },
24
+ ];
25
+
26
+ beforeEach(() => {
27
+ useSearchContext.mockReturnValue({
28
+ searchData: {
29
+ data: [
30
+ {
31
+ id: 1,
32
+ source_name: "Concept 1",
33
+ target_name: "Structure 1",
34
+ tag_type: "relates_to",
35
+ status: "pending",
36
+ updated_at: "2023-01-01",
37
+ },
38
+ ],
39
+ },
40
+ loading: false,
41
+ sortColumn: null,
42
+ sortDirection: null,
43
+ handleSortSelection: jest.fn(),
44
+ });
45
+ });
46
+
47
+ it("matches the latest snapshot with data", async () => {
48
+ const props = {
49
+ columns: mockColumns,
50
+ approveView: true,
51
+ checkedAll: false,
52
+ addAll: jest.fn(),
53
+ checkRow: jest.fn(),
54
+ isRowChecked: jest.fn(),
55
+ };
56
+
57
+ const rendered = render(<ConceptLinksApprovalsTable {...props} />);
58
+ await waitForLoad(rendered);
59
+ expect(rendered.container).toMatchSnapshot();
60
+ });
61
+
62
+ it("matches the latest snapshot with empty data", async () => {
63
+ useSearchContext.mockReturnValue({
64
+ searchData: { data: [] },
65
+ loading: false,
66
+ sortColumn: null,
67
+ sortDirection: null,
68
+ handleSortSelection: jest.fn(),
69
+ });
70
+
71
+ const props = {
72
+ columns: mockColumns,
73
+ approveView: true,
74
+ checkedAll: false,
75
+ addAll: jest.fn(),
76
+ checkRow: jest.fn(),
77
+ isRowChecked: jest.fn(),
78
+ };
79
+
80
+ const rendered = render(<ConceptLinksApprovalsTable {...props} />);
81
+ await waitForLoad(rendered);
82
+ expect(rendered.container).toMatchSnapshot();
83
+ });
84
+
85
+ it("matches the latest snapshot while loading", async () => {
86
+ useSearchContext.mockReturnValue({
87
+ searchData: { data: [] },
88
+ loading: true,
89
+ sortColumn: null,
90
+ sortDirection: null,
91
+ handleSortSelection: jest.fn(),
92
+ });
93
+
94
+ const props = {
95
+ columns: mockColumns,
96
+ approveView: true,
97
+ checkedAll: false,
98
+ addAll: jest.fn(),
99
+ checkRow: jest.fn(),
100
+ isRowChecked: jest.fn(),
101
+ };
102
+
103
+ const rendered = render(<ConceptLinksApprovalsTable {...props} />);
104
+ await waitForLoad(rendered);
105
+ expect(rendered.container).toMatchSnapshot();
106
+ });
107
+ });
@@ -0,0 +1,217 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<LinksApprovalResults /> renders approval results with relations and errors 1`] = `
4
+ <div>
5
+ <div
6
+ class="ui breadcrumb"
7
+ >
8
+ <a
9
+ class="section"
10
+ data-discover="true"
11
+ href="/concepts/management/approvals"
12
+ >
13
+ conceptRelations.approvals.header
14
+ </a>
15
+ <i
16
+ aria-hidden="true"
17
+ class="right angle icon divider"
18
+ />
19
+ <div
20
+ class="active section"
21
+ >
22
+ conceptRelations.approvals.results.header
23
+ </div>
24
+ </div>
25
+ <div
26
+ class="ui positive message"
27
+ >
28
+ <div
29
+ class="header"
30
+ >
31
+ conceptRelations.approvals.results.approved.header
32
+ </div>
33
+ <li
34
+ class="content"
35
+ >
36
+ conceptRelations.approvals.results.message.source_name
37
+ <a
38
+ data-discover="true"
39
+ href="/concepts/10/versions/current"
40
+ target="_blank"
41
+ >
42
+ Source 1
43
+ </a>
44
+ conceptRelations.approvals.results.message.target_name
45
+ <a
46
+ data-discover="true"
47
+ href="/structures/20"
48
+ target="_blank"
49
+ >
50
+ Target 1
51
+ </a>
52
+ </li>
53
+ </div>
54
+ <div
55
+ class="ui error message"
56
+ >
57
+ <div
58
+ class="header"
59
+ >
60
+ conceptRelations.approvals.results.errors.permissions.header
61
+ </div>
62
+ <li
63
+ class="content"
64
+ >
65
+ conceptRelations.approvals.results.message.source_name
66
+ <a
67
+ data-discover="true"
68
+ href="/concepts/11/versions/current"
69
+ target="_blank"
70
+ >
71
+ Source 2
72
+ </a>
73
+ conceptRelations.approvals.results.message.target_name
74
+ <a
75
+ data-discover="true"
76
+ href="/structures/21"
77
+ target="_blank"
78
+ >
79
+ Target 2
80
+ </a>
81
+ </li>
82
+ </div>
83
+ </div>
84
+ `;
85
+
86
+ exports[`<LinksApprovalResults /> renders rejection results 1`] = `
87
+ <div>
88
+ <div
89
+ class="ui breadcrumb"
90
+ >
91
+ <a
92
+ class="section"
93
+ data-discover="true"
94
+ href="/concepts/management/approvals"
95
+ >
96
+ conceptRelations.approvals.header
97
+ </a>
98
+ <i
99
+ aria-hidden="true"
100
+ class="right angle icon divider"
101
+ />
102
+ <div
103
+ class="active section"
104
+ >
105
+ conceptRelations.approvals.results.header
106
+ </div>
107
+ </div>
108
+ <div
109
+ class="ui warning message"
110
+ >
111
+ <div
112
+ class="header"
113
+ >
114
+ conceptRelations.approvals.results.rejected.header
115
+ </div>
116
+ <li
117
+ class="content"
118
+ >
119
+ conceptRelations.approvals.results.message.source_name
120
+ <a
121
+ data-discover="true"
122
+ href="/concepts/12/versions/current"
123
+ target="_blank"
124
+ >
125
+ Source 3
126
+ </a>
127
+ conceptRelations.approvals.results.message.target_name
128
+ <a
129
+ data-discover="true"
130
+ href="/structures/22"
131
+ target="_blank"
132
+ >
133
+ Target 3
134
+ </a>
135
+ </li>
136
+ </div>
137
+ </div>
138
+ `;
139
+
140
+ exports[`<LinksApprovalResults /> renders with empty relations and errors 1`] = `
141
+ <div>
142
+ <div
143
+ class="ui breadcrumb"
144
+ >
145
+ <a
146
+ class="section"
147
+ data-discover="true"
148
+ href="/concepts/management/approvals"
149
+ >
150
+ conceptRelations.approvals.header
151
+ </a>
152
+ <i
153
+ aria-hidden="true"
154
+ class="right angle icon divider"
155
+ />
156
+ <div
157
+ class="active section"
158
+ >
159
+ conceptRelations.approvals.results.header
160
+ </div>
161
+ </div>
162
+ </div>
163
+ `;
164
+
165
+ exports[`<LinksApprovalResults /> renders with no errors 1`] = `
166
+ <div>
167
+ <div
168
+ class="ui breadcrumb"
169
+ >
170
+ <a
171
+ class="section"
172
+ data-discover="true"
173
+ href="/concepts/management/approvals"
174
+ >
175
+ conceptRelations.approvals.header
176
+ </a>
177
+ <i
178
+ aria-hidden="true"
179
+ class="right angle icon divider"
180
+ />
181
+ <div
182
+ class="active section"
183
+ >
184
+ conceptRelations.approvals.results.header
185
+ </div>
186
+ </div>
187
+ <div
188
+ class="ui positive message"
189
+ >
190
+ <div
191
+ class="header"
192
+ >
193
+ conceptRelations.approvals.results.approved.header
194
+ </div>
195
+ <li
196
+ class="content"
197
+ >
198
+ conceptRelations.approvals.results.message.source_name
199
+ <a
200
+ data-discover="true"
201
+ href="/concepts/13/versions/current"
202
+ target="_blank"
203
+ >
204
+ Source 4
205
+ </a>
206
+ conceptRelations.approvals.results.message.target_name
207
+ <a
208
+ data-discover="true"
209
+ href="/structures/23"
210
+ target="_blank"
211
+ >
212
+ Target 4
213
+ </a>
214
+ </li>
215
+ </div>
216
+ </div>
217
+ `;