@truedat/dq 7.11.0 → 7.11.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 (52) hide show
  1. package/package.json +3 -3
  2. package/src/api.js +12 -0
  3. package/src/components/ImplementationSearchResults.js +24 -42
  4. package/src/components/ImplementationUploadJobBreadcrumbs.js +25 -0
  5. package/src/components/Implementations.js +31 -17
  6. package/src/components/ImplementationsRoutes.js +9 -0
  7. package/src/components/ImplementationsUploadButton.js +38 -50
  8. package/src/components/ImplementationsUploadJob.js +217 -0
  9. package/src/components/ImplementationsUploadJobs.js +128 -0
  10. package/src/components/RuleFormImplementations.js +29 -10
  11. package/src/components/RuleImplementationActions.js +10 -20
  12. package/src/components/RuleImplementationsActions.js +15 -37
  13. package/src/components/RuleImplementationsDownload.js +26 -31
  14. package/src/components/RuleImplementationsDownloadXlsx.js +47 -0
  15. package/src/components/RuleImplementationsLabelResults.js +30 -39
  16. package/src/components/RuleImplementationsOptions.js +5 -3
  17. package/src/components/RuleImplementationsTable.js +7 -3
  18. package/src/components/RuleRoutes.js +1 -4
  19. package/src/components/SimpleRuleImplementationsTable.js +68 -0
  20. package/src/components/__tests__/ImplementationSearchResults.spec.js +32 -4
  21. package/src/components/__tests__/ImplementationUploadJobBreadcrumbs.spec.js +28 -0
  22. package/src/components/__tests__/Implementations.spec.js +43 -0
  23. package/src/components/__tests__/ImplementationsUploadButton.spec.js +67 -40
  24. package/src/components/__tests__/ImplementationsUploadJob.spec.js +112 -0
  25. package/src/components/__tests__/ImplementationsUploadJobs.spec.js +60 -0
  26. package/src/components/__tests__/RuleImplementationsActions.spec.js +71 -56
  27. package/src/components/__tests__/RuleImplementationsOptions.spec.js +28 -3
  28. package/src/components/__tests__/RuleImplementationsTable.spec.js +24 -0
  29. package/src/components/__tests__/__snapshots__/ImplementationSearchResults.spec.js.snap +113 -46
  30. package/src/components/__tests__/__snapshots__/ImplementationUploadJobBreadcrumbs.spec.js.snap +42 -0
  31. package/src/components/__tests__/__snapshots__/Implementations.spec.js.snap +125 -24
  32. package/src/components/__tests__/__snapshots__/RuleImplementationsActions.spec.js.snap +4 -8
  33. package/src/components/__tests__/__snapshots__/RuleImplementationsOptions.spec.js.snap +5 -8
  34. package/src/components/__tests__/implementationsUploadJobParser.spec.js +105 -0
  35. package/src/components/implementationsUploadJobParser.js +276 -0
  36. package/src/components/index.js +0 -2
  37. package/src/hooks/useImplementations.js +80 -0
  38. package/src/reducers/index.js +2 -0
  39. package/src/reducers/ruleImplementationSelectedFilter.js +1 -1
  40. package/src/reducers/ruleImplementationsDownloadingXlsx.js +14 -0
  41. package/src/routines.js +3 -0
  42. package/src/sagas/downloadRuleImplementationsXlsx.js +52 -0
  43. package/src/sagas/index.js +3 -0
  44. package/src/components/RuleImplementationFilters.js +0 -25
  45. package/src/components/RuleImplementationSelectedFilters.js +0 -99
  46. package/src/components/RuleImplementationsFromRuleLoader.js +0 -60
  47. package/src/components/RuleImplementationsPagination.js +0 -18
  48. package/src/components/RuleImplementationsSearch.js +0 -39
  49. package/src/components/__tests__/RuleImplementationsFromRuleLoader.spec.js +0 -63
  50. package/src/components/__tests__/RuleImplementationsSearch.spec.js +0 -29
  51. package/src/components/__tests__/__snapshots__/RuleImplementationsFromRuleLoader.spec.js.snap +0 -3
  52. package/src/components/__tests__/__snapshots__/RuleImplementationsSearch.spec.js.snap +0 -50
@@ -1,31 +1,49 @@
1
- import { render, waitForLoad } from "@truedat/test/render";
2
1
  import userEvent from "@testing-library/user-event";
2
+ import { render, waitForLoad } from "@truedat/test/render";
3
+ import { useSearchContext } from "@truedat/core/search/SearchContext";
3
4
  import { RuleImplementationsActions } from "../RuleImplementationsActions";
4
5
 
6
+ jest.mock("@truedat/core/search/SearchContext", () => {
7
+ const originalModule = jest.requireActual(
8
+ "@truedat/core/search/SearchContext"
9
+ );
10
+
11
+ return {
12
+ __esModule: true,
13
+ ...originalModule,
14
+ useSearchContext: jest.fn(),
15
+ };
16
+ });
17
+
5
18
  describe("<RuleImplementationsActions />", () => {
6
- const addImplementationFilter = jest.fn();
7
- const toggleImplementationFilterValue = jest.fn();
8
19
  const setMode = jest.fn();
9
- const removeImplementationFilter = jest.fn();
10
20
  const props = {
11
- actions: {
12
- uploadResults: {},
13
- createRuleLess: {},
14
- createRawRuleLess: {},
15
- download: {},
16
- execute: {},
17
- },
18
- executionGroupLoading: false,
19
- ruleImplementationCount: 12,
20
- implementationsExecution: true,
21
- ruleImplementationsLoading: false,
22
- toggleImplementationFilterValue,
23
- addImplementationFilter,
24
21
  executeImplementationsOn: false,
22
+ implementationQuery: {},
23
+ selectedImplementations: [],
25
24
  setMode,
26
- removeImplementationFilter,
27
25
  };
28
26
 
27
+ const mockSearchContext = {
28
+ searchData: {
29
+ data: [{ id: 1 }],
30
+ _actions: {
31
+ uploadResults: {},
32
+ createRuleLess: {},
33
+ createRawRuleLess: {},
34
+ download: {},
35
+ execute: {},
36
+ },
37
+ },
38
+ count: 12,
39
+ loading: false,
40
+ };
41
+
42
+ beforeEach(() => {
43
+ jest.clearAllMocks();
44
+ useSearchContext.mockReturnValue(mockSearchContext);
45
+ });
46
+
29
47
  it("matches the latest snapshot", async () => {
30
48
  const rendered = render(<RuleImplementationsActions {...props} />);
31
49
  await waitForLoad(rendered);
@@ -33,14 +51,15 @@ describe("<RuleImplementationsActions />", () => {
33
51
  });
34
52
 
35
53
  it("as user with permissions I see execute implementations button and checkbox", async () => {
36
- const userProps = {
37
- actions: { execute: {} },
38
- executionGroupLoading: false,
39
- ruleImplementationCount: 12,
40
- implementationsExecution: true,
41
- role: "user",
42
- };
43
- const rendered = render(<RuleImplementationsActions {...userProps} />);
54
+ useSearchContext.mockReturnValue({
55
+ searchData: {
56
+ _actions: { execute: {} },
57
+ },
58
+ count: 12,
59
+ loading: false,
60
+ });
61
+
62
+ const rendered = render(<RuleImplementationsActions {...props} />);
44
63
  await waitForLoad(rendered);
45
64
  expect(
46
65
  rendered.container.querySelector("#execute_checkbox")
@@ -51,13 +70,15 @@ describe("<RuleImplementationsActions />", () => {
51
70
  });
52
71
 
53
72
  it("as user I do not see execute rules actions if I have no permission", async () => {
54
- const noPermProps = {
55
- actions: {},
56
- executionGroupLoading: false,
57
- ruleImplementationCount: 12,
58
- implementationsExecution: true,
59
- };
60
- const rendered = render(<RuleImplementationsActions {...noPermProps} />);
73
+ useSearchContext.mockReturnValue({
74
+ searchData: {
75
+ _actions: {},
76
+ },
77
+ count: 12,
78
+ loading: false,
79
+ });
80
+
81
+ const rendered = render(<RuleImplementationsActions {...props} />);
61
82
  await waitForLoad(rendered);
62
83
  expect(
63
84
  rendered.container.querySelector("#execute_checkbox")
@@ -66,25 +87,29 @@ describe("<RuleImplementationsActions />", () => {
66
87
  });
67
88
 
68
89
  it("as non admin user I can see an active checkbox if executeImplementationsOn", async () => {
90
+ useSearchContext.mockReturnValue({
91
+ searchData: {
92
+ data: [{ id: 1 }],
93
+ _actions: { execute: {} },
94
+ },
95
+ count: 12,
96
+ loading: false,
97
+ });
98
+
69
99
  const activeProps = {
70
- actions: { execute: {} },
71
- executionGroupLoading: false,
72
- ruleImplementationCount: 12,
73
- implementationsExecution: true,
100
+ ...props,
74
101
  executeImplementationsOn: true,
75
102
  };
103
+
76
104
  const rendered = render(<RuleImplementationsActions {...activeProps} />);
77
105
  await waitForLoad(rendered);
78
106
  const checkbox = rendered.container.querySelector("#execute_checkbox");
79
107
  expect(checkbox).toBeInTheDocument();
80
108
  expect(checkbox).toBeChecked();
81
- expect(
82
- rendered.getByText(/implementations.actions.download.tooltip/i)
83
- ).toBeInTheDocument();
84
109
  });
85
110
 
86
111
  it("handles checkbox onChange", async () => {
87
- const user = userEvent.setup({ delay: null }); // Asynchronous userEvent setup
112
+ const user = userEvent.setup({ delay: null });
88
113
  const rendered = render(<RuleImplementationsActions {...props} />);
89
114
  await waitForLoad(rendered);
90
115
 
@@ -94,21 +119,14 @@ describe("<RuleImplementationsActions />", () => {
94
119
 
95
120
  await user.click(checkbox);
96
121
  expect(setMode).toHaveBeenCalledWith(true);
97
- expect(addImplementationFilter).toHaveBeenCalledWith({
98
- filter: "executable",
99
- });
100
- expect(toggleImplementationFilterValue).toHaveBeenCalledWith({
101
- filter: "executable",
102
- value: true,
103
- });
104
122
 
123
+ const thisProps = {
124
+ ...props,
125
+ executeImplementationsOn: true,
126
+ };
105
127
  // Reset and test unchecking
106
128
  setMode.mockReset();
107
- rendered.rerender(
108
- <RuleImplementationsActions
109
- {...{ ...props, executeImplementationsOn: true }}
110
- />
111
- );
129
+ rendered.rerender(<RuleImplementationsActions {...thisProps} />);
112
130
  await waitForLoad(rendered);
113
131
 
114
132
  const updatedCheckbox =
@@ -117,8 +135,5 @@ describe("<RuleImplementationsActions />", () => {
117
135
 
118
136
  await user.click(updatedCheckbox);
119
137
  expect(setMode).toHaveBeenCalledWith(false);
120
- expect(removeImplementationFilter).toHaveBeenCalledWith({
121
- filter: "executable",
122
- });
123
138
  });
124
139
  });
@@ -1,12 +1,37 @@
1
1
  import { waitFor } from "@testing-library/react";
2
- import { render } from "@truedat/test/render";
2
+ import { render, waitForLoad } from "@truedat/test/render";
3
3
  import RuleImplementationsOptions from "../RuleImplementationsOptions";
4
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
+ const { useSearchContext } = require("@truedat/core/search/SearchContext");
18
+
5
19
  const props = { canUploadResults: true };
6
20
 
7
21
  describe("<RuleImplementationsOptions />", () => {
22
+ beforeEach(() => {
23
+ useSearchContext.mockReturnValue({
24
+ searchData: {
25
+ data: [{ id: 1 }],
26
+ scroll_id: null,
27
+ },
28
+ setOnSearchChange: jest.fn(),
29
+ });
30
+ });
31
+
8
32
  it("matches the latest snapshot", async () => {
9
- const { container } = render(<RuleImplementationsOptions {...props} />);
10
- await waitFor(() => expect(container).toMatchSnapshot());
33
+ const rendered = render(<RuleImplementationsOptions {...props} />);
34
+ await waitForLoad(rendered);
35
+ expect(rendered.container).toMatchSnapshot();
11
36
  });
12
37
  });
@@ -1,7 +1,20 @@
1
1
  import userEvent from "@testing-library/user-event";
2
2
  import { render, waitForLoad } from "@truedat/test/render";
3
+ import { useSearchContext } from "@truedat/core/search/SearchContext";
3
4
  import { RuleImplementationsTable } from "../RuleImplementationsTable";
4
5
 
6
+ jest.mock("@truedat/core/search/SearchContext", () => {
7
+ const originalModule = jest.requireActual(
8
+ "@truedat/core/search/SearchContext"
9
+ );
10
+
11
+ return {
12
+ __esModule: true,
13
+ ...originalModule,
14
+ useSearchContext: jest.fn(),
15
+ };
16
+ });
17
+
5
18
  describe("<RuleImplementationsTable />", () => {
6
19
  const ruleImplementations = [1, 2, 3].map((id) => ({ id }));
7
20
  const columns = [
@@ -19,6 +32,17 @@ describe("<RuleImplementationsTable />", () => {
19
32
  sortImplementations,
20
33
  };
21
34
 
35
+ beforeEach(() => {
36
+ useSearchContext.mockReturnValue({
37
+ searchData: {
38
+ data: ruleImplementations,
39
+ scroll_id: null,
40
+ },
41
+ searchMust: {},
42
+ setOnSearchChange: jest.fn(),
43
+ });
44
+ });
45
+
22
46
  it("matches the latest snapshot", async () => {
23
47
  const rendered = render(<RuleImplementationsTable {...props} />);
24
48
  await waitForLoad(rendered);
@@ -3,12 +3,36 @@
3
3
  exports[`<ImplementationSearchResults /> matches the latest snapshot 1`] = `
4
4
  <div>
5
5
  <div
6
+ border="1px red"
6
7
  class="ui bottom attached segment"
7
8
  >
8
9
  <div
9
10
  style="float: right;"
10
11
  >
11
12
  <div
13
+ class="ui fitted toggle checkbox bgOrange"
14
+ style="top: 6px; margin-right: 7.5px;"
15
+ >
16
+ <input
17
+ class="hidden"
18
+ id="execute_checkbox"
19
+ readonly=""
20
+ tabindex="0"
21
+ type="checkbox"
22
+ />
23
+ <label
24
+ for="execute_checkbox"
25
+ />
26
+ </div>
27
+ <button
28
+ class="ui secondary disabled button"
29
+ disabled=""
30
+ tabindex="-1"
31
+ >
32
+ implementation.actions.do_execution
33
+ </button>
34
+ <div
35
+ aria-disabled="false"
12
36
  aria-expanded="false"
13
37
  class="ui floating dropdown button icon group-actions button-update"
14
38
  role="listbox"
@@ -22,8 +46,8 @@ exports[`<ImplementationSearchResults /> matches the latest snapshot 1`] = `
22
46
  class="menu transition left"
23
47
  >
24
48
  <div
25
- aria-disabled="true"
26
- class="disabled item"
49
+ aria-disabled="false"
50
+ class="item"
27
51
  role="option"
28
52
  >
29
53
  <i
@@ -31,15 +55,11 @@ exports[`<ImplementationSearchResults /> matches the latest snapshot 1`] = `
31
55
  class="download icon"
32
56
  />
33
57
  <span>
34
- implementations.actions.download.tooltip
58
+ implementations.actions.downloadXlsx.tooltip
35
59
  </span>
36
- <p
37
- class="menu-item-description"
38
- >
39
- implementations.actions.download.empty
40
- </p>
41
60
  </div>
42
61
  <div
62
+ aria-disabled="false"
43
63
  class="item"
44
64
  role="option"
45
65
  >
@@ -59,14 +79,14 @@ exports[`<ImplementationSearchResults /> matches the latest snapshot 1`] = `
59
79
  <div
60
80
  class="ui action left icon input"
61
81
  >
62
- <input
63
- placeholder="implementations.search.placeholder"
64
- type="text"
65
- />
66
82
  <i
67
83
  aria-hidden="true"
68
84
  class="search link icon"
69
85
  />
86
+ <input
87
+ placeholder="search.placeholder"
88
+ type="text"
89
+ />
70
90
  <div
71
91
  aria-expanded="false"
72
92
  class="ui button floating labeled scrolling dropdown icon"
@@ -110,19 +130,24 @@ exports[`<ImplementationSearchResults /> matches the latest snapshot 1`] = `
110
130
  >
111
131
  ruleImplementations.retrieved.results
112
132
  </div>
113
- <h4
114
- class="ui header"
133
+ <div
134
+ class="implementations-table-overflow"
115
135
  >
116
- <i
117
- aria-hidden="true"
118
- class="search icon"
119
- />
120
- <div
121
- class="content"
136
+ <table
137
+ class="ui sortable table"
122
138
  >
123
- ruleImplementations.search.results.empty
124
- </div>
125
- </h4>
139
+ <thead
140
+ class=""
141
+ >
142
+ <tr
143
+ class=""
144
+ />
145
+ </thead>
146
+ <tbody
147
+ class=""
148
+ />
149
+ </table>
150
+ </div>
126
151
  </div>
127
152
  </div>
128
153
  </div>
@@ -131,12 +156,34 @@ exports[`<ImplementationSearchResults /> matches the latest snapshot 1`] = `
131
156
  exports[`<ImplementationSearchResults /> renders executions on when executionEnabled is true 1`] = `
132
157
  <div>
133
158
  <div
159
+ border="1px red"
134
160
  class="ui bottom attached segment"
135
161
  >
136
162
  <div
137
163
  style="float: right;"
138
164
  >
139
165
  <div
166
+ class="ui checked fitted toggle checkbox bgOrange"
167
+ style="top: 6px; margin-right: 7.5px;"
168
+ >
169
+ <input
170
+ class="hidden"
171
+ id="execute_checkbox"
172
+ readonly=""
173
+ tabindex="0"
174
+ type="checkbox"
175
+ />
176
+ <label
177
+ for="execute_checkbox"
178
+ />
179
+ </div>
180
+ <button
181
+ class="ui secondary button"
182
+ >
183
+ implementation.actions.do_execution
184
+ </button>
185
+ <div
186
+ aria-disabled="false"
140
187
  aria-expanded="false"
141
188
  class="ui floating dropdown button icon group-actions button-update"
142
189
  role="listbox"
@@ -150,8 +197,8 @@ exports[`<ImplementationSearchResults /> renders executions on when executionEna
150
197
  class="menu transition left"
151
198
  >
152
199
  <div
153
- aria-disabled="true"
154
- class="disabled item"
200
+ aria-disabled="false"
201
+ class="item"
155
202
  role="option"
156
203
  >
157
204
  <i
@@ -159,15 +206,11 @@ exports[`<ImplementationSearchResults /> renders executions on when executionEna
159
206
  class="download icon"
160
207
  />
161
208
  <span>
162
- implementations.actions.download.tooltip
209
+ implementations.actions.downloadXlsx.tooltip
163
210
  </span>
164
- <p
165
- class="menu-item-description"
166
- >
167
- implementations.actions.download.empty
168
- </p>
169
211
  </div>
170
212
  <div
213
+ aria-disabled="false"
171
214
  class="item"
172
215
  role="option"
173
216
  >
@@ -187,14 +230,14 @@ exports[`<ImplementationSearchResults /> renders executions on when executionEna
187
230
  <div
188
231
  class="ui action left icon input"
189
232
  >
190
- <input
191
- placeholder="implementations.search.placeholder"
192
- type="text"
193
- />
194
233
  <i
195
234
  aria-hidden="true"
196
235
  class="search link icon"
197
236
  />
237
+ <input
238
+ placeholder="search.placeholder"
239
+ type="text"
240
+ />
198
241
  <div
199
242
  aria-expanded="false"
200
243
  class="ui button floating labeled scrolling dropdown icon"
@@ -243,19 +286,43 @@ exports[`<ImplementationSearchResults /> renders executions on when executionEna
243
286
  >
244
287
  implementations.execute.filtered
245
288
  </div>
246
- <h4
247
- class="ui header"
289
+ <div
290
+ class="implementations-table-overflow"
248
291
  >
249
- <i
250
- aria-hidden="true"
251
- class="search icon"
252
- />
253
- <div
254
- class="content"
292
+ <table
293
+ class="ui sortable table"
255
294
  >
256
- ruleImplementations.search.results.empty
257
- </div>
258
- </h4>
295
+ <thead
296
+ class=""
297
+ >
298
+ <tr
299
+ class=""
300
+ >
301
+ <th
302
+ class="center aligned"
303
+ >
304
+ <div
305
+ class="ui fitted checkbox"
306
+ >
307
+ <input
308
+ class="hidden"
309
+ id="selectImplementation"
310
+ readonly=""
311
+ tabindex="0"
312
+ type="checkbox"
313
+ />
314
+ <label
315
+ for="selectImplementation"
316
+ />
317
+ </div>
318
+ </th>
319
+ </tr>
320
+ </thead>
321
+ <tbody
322
+ class=""
323
+ />
324
+ </table>
325
+ </div>
259
326
  </div>
260
327
  </div>
261
328
  </div>
@@ -0,0 +1,42 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ImplementationUploadJobBreadcrumbs renders breadcrumbs with filename 1`] = `
4
+ <div>
5
+ <div
6
+ class="ui breadcrumb"
7
+ >
8
+ <a
9
+ class="section"
10
+ data-discover="true"
11
+ href="/implementations/uploadJobs"
12
+ >
13
+ sidemenu.implementations_upload_jobs
14
+ </a>
15
+ <i
16
+ aria-hidden="true"
17
+ class="right angle icon divider"
18
+ />
19
+ <div
20
+ class="active section"
21
+ >
22
+ test.csv
23
+ </div>
24
+ </div>
25
+ </div>
26
+ `;
27
+
28
+ exports[`ImplementationUploadJobBreadcrumbs renders breadcrumbs without filename 1`] = `
29
+ <div>
30
+ <div
31
+ class="ui breadcrumb"
32
+ >
33
+ <a
34
+ class="section"
35
+ data-discover="true"
36
+ href="/implementations/uploadJobs"
37
+ >
38
+ sidemenu.implementations_upload_jobs
39
+ </a>
40
+ </div>
41
+ </div>
42
+ `;