@truedat/dq 7.12.7 → 7.13.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dq",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.13.0",
|
|
4
4
|
"description": "Truedat Web Data Quality Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
87
87
|
"swr": "^2.3.3"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "fce3d82fdde98cdd99f6fe5a8a0a0a52a7de9669"
|
|
90
90
|
}
|
package/src/api.js
CHANGED
|
@@ -22,8 +22,7 @@ const API_RULE_IMPLEMENTATIONS_XLSX_UPLOAD_JOBS =
|
|
|
22
22
|
"/api/rule_implementations/xlsx/upload_jobs";
|
|
23
23
|
const API_RULE_IMPLEMENTATIONS_XLSX_UPLOAD_JOB =
|
|
24
24
|
"/api/rule_implementations/xlsx/upload_jobs/:id";
|
|
25
|
-
const API_RULE_IMPLEMENTATIONS_FROM_RULE =
|
|
26
|
-
"/api/rules/:id/rule_implementations";
|
|
25
|
+
const API_RULE_IMPLEMENTATIONS_FROM_RULE = "/api/rules/rule_implementations";
|
|
27
26
|
const API_RULE_IMPLEMENTATIONS_SEARCH = "/api/rule_implementations/search";
|
|
28
27
|
const API_RULE_IMPLEMENTATION_FILTERS_SEARCH =
|
|
29
28
|
"/api/rule_implementation_filters/search";
|
|
@@ -4,7 +4,7 @@ import { connect } from "react-redux";
|
|
|
4
4
|
import { Container } from "semantic-ui-react";
|
|
5
5
|
import { getLinkedImplementationsToRulesColumns } from "../selectors";
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
useRuleImplementationFromRulesSearch,
|
|
8
8
|
useRuleImplementationFilters,
|
|
9
9
|
} from "../hooks/useImplementations";
|
|
10
10
|
import RuleImplementationsTable from "./RuleImplementationsTable";
|
|
@@ -15,7 +15,7 @@ export const RuleFormImplementations = ({ rule, columns }) => {
|
|
|
15
15
|
const searchProps = {
|
|
16
16
|
initialSortColumn: "implementation_key.raw",
|
|
17
17
|
initialSortDirection: "ascending",
|
|
18
|
-
useSearch:
|
|
18
|
+
useSearch: useRuleImplementationFromRulesSearch,
|
|
19
19
|
useFilters: useRuleImplementationFilters,
|
|
20
20
|
pageSize: 20,
|
|
21
21
|
defaultFilters: {
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import { useSearchContext } from "@truedat/core/search/SearchContext";
|
|
3
|
+
import {
|
|
4
|
+
useRuleImplementationFromRulesSearch,
|
|
5
|
+
useRuleImplementationFilters,
|
|
6
|
+
} from "../../hooks/useImplementations";
|
|
2
7
|
import { RuleFormImplementations } from "../RuleFormImplementations";
|
|
3
8
|
|
|
9
|
+
jest.mock("@truedat/core/search/SearchContext", () => {
|
|
10
|
+
const originalModule = jest.requireActual(
|
|
11
|
+
"@truedat/core/search/SearchContext"
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
__esModule: true,
|
|
16
|
+
...originalModule,
|
|
17
|
+
useSearchContext: jest.fn(),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
jest.mock("../../hooks/useImplementations", () => ({
|
|
22
|
+
useRuleImplementationFromRulesSearch: jest.fn(),
|
|
23
|
+
useRuleImplementationFilters: jest.fn(),
|
|
24
|
+
}));
|
|
25
|
+
|
|
4
26
|
describe("<RuleFormImplementations />", () => {
|
|
5
27
|
const rule = { id: 1, name: "rule name" };
|
|
6
28
|
const updateDeletionQuery = jest.fn();
|
|
@@ -10,6 +32,24 @@ describe("<RuleFormImplementations />", () => {
|
|
|
10
32
|
deletedRender: false,
|
|
11
33
|
};
|
|
12
34
|
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
jest.clearAllMocks();
|
|
37
|
+
useRuleImplementationFromRulesSearch.mockReturnValue({
|
|
38
|
+
trigger: jest.fn(),
|
|
39
|
+
});
|
|
40
|
+
useRuleImplementationFilters.mockReturnValue({
|
|
41
|
+
trigger: jest.fn(),
|
|
42
|
+
});
|
|
43
|
+
useSearchContext.mockReturnValue({
|
|
44
|
+
searchData: {
|
|
45
|
+
data: [],
|
|
46
|
+
scroll_id: null,
|
|
47
|
+
},
|
|
48
|
+
searchMust: { status: ["pending"] },
|
|
49
|
+
setOnSearchChange: jest.fn(),
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
13
53
|
it("matches the latest snapshot", async () => {
|
|
14
54
|
const rendered = render(<RuleFormImplementations {...props} />);
|
|
15
55
|
await waitForLoad(rendered);
|
|
@@ -31,4 +71,11 @@ describe("<RuleFormImplementations />", () => {
|
|
|
31
71
|
rendered.container.querySelector(".implementation-actions")
|
|
32
72
|
).toBeInTheDocument();
|
|
33
73
|
});
|
|
74
|
+
|
|
75
|
+
it("uses useRuleImplementationFromRulesSearch hook", async () => {
|
|
76
|
+
const rendered = render(<RuleFormImplementations {...props} />);
|
|
77
|
+
await waitForLoad(rendered);
|
|
78
|
+
|
|
79
|
+
expect(useRuleImplementationFromRulesSearch).toHaveBeenCalled();
|
|
80
|
+
});
|
|
34
81
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import useSWRMutations from "swr/mutation";
|
|
3
|
+
import { renderHook } from "@testing-library/react";
|
|
4
|
+
import { apiJsonPost } from "@truedat/core/services/api";
|
|
5
|
+
import { API_RULE_IMPLEMENTATIONS_FROM_RULE } from "../../api";
|
|
6
|
+
import { useRuleImplementationFromRulesSearch } from "../useImplementations";
|
|
7
|
+
|
|
8
|
+
jest.mock("swr/mutation", () => ({
|
|
9
|
+
__esModule: true,
|
|
10
|
+
...jest.requireActual("swr/mutation"),
|
|
11
|
+
default: jest.fn(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock("@truedat/core/services/api", () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
...jest.requireActual("@truedat/core/services/api"),
|
|
17
|
+
apiJsonPost: jest.fn(),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
describe("useRuleImplementationFromRulesSearch", () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("calls useSWRMutations with correct api route", () => {
|
|
26
|
+
renderHook(() => useRuleImplementationFromRulesSearch());
|
|
27
|
+
const [url, func] = _.last(useSWRMutations.mock.calls);
|
|
28
|
+
const arg = { rule_id: 1, page: 1 };
|
|
29
|
+
expect(url).toBe(API_RULE_IMPLEMENTATIONS_FROM_RULE);
|
|
30
|
+
func(url, { arg });
|
|
31
|
+
|
|
32
|
+
expect(apiJsonPost).toHaveBeenCalledWith(url, arg);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
API_RULE_IMPLEMENTATIONS_SEARCH,
|
|
13
13
|
API_RULE_IMPLEMENTATION_FILTERS_SEARCH,
|
|
14
|
+
API_RULE_IMPLEMENTATIONS_FROM_RULE,
|
|
14
15
|
API_RULE_IMPLEMENTATIONS_XLSX_DOWNLOAD,
|
|
15
16
|
API_RULE_IMPLEMENTATIONS_XLSX_UPLOAD,
|
|
16
17
|
API_RULE_IMPLEMENTATIONS_XLSX_UPLOAD_JOBS,
|
|
@@ -41,6 +42,12 @@ export const useRuleImplementationSearch = () => {
|
|
|
41
42
|
});
|
|
42
43
|
};
|
|
43
44
|
|
|
45
|
+
export const useRuleImplementationFromRulesSearch = () => {
|
|
46
|
+
return useSWRMutations(API_RULE_IMPLEMENTATIONS_FROM_RULE, (url, { arg }) => {
|
|
47
|
+
return apiJsonPost(url, arg);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
44
51
|
export const useImplementationsDownload = () => {
|
|
45
52
|
return useSWRMutations(
|
|
46
53
|
API_RULE_IMPLEMENTATIONS_XLSX_DOWNLOAD,
|