@truedat/qx 7.0.8 → 7.1.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 +13 -4
- package/src/api.js +29 -20
- package/src/components/QxRoutes.js +18 -16
- package/src/components/__tests__/__fixtures__/helper.js +187 -0
- package/src/components/common/TestFormWrapper.js +38 -0
- package/src/components/common/__tests__/ResourceSelector.spec.js +18 -7
- package/src/components/common/__tests__/__snapshots__/ResourceSelector.spec.js.snap +0 -12
- package/src/components/common/expressions/__tests__/Condition.spec.js +4 -1
- package/src/components/common/expressions/__tests__/FunctionArgs.spec.js +18 -5
- package/src/components/common/expressions/__tests__/ShapeSelector.spec.js +4 -4
- package/src/components/common/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +10 -2
- package/src/components/common/resourceSelectors/__tests__/DataStructureSelector.spec.js +6 -3
- package/src/components/common/resourceSelectors/__tests__/__snapshots__/DataStructureSelector.spec.js.snap +0 -12
- package/src/components/dataViews/__tests__/DataViewEditor.spec.js +83 -53
- package/src/components/dataViews/__tests__/DataViews.spec.js +14 -1
- package/src/components/dataViews/__tests__/__snapshots__/DataViewEditor.spec.js.snap +93 -4
- package/src/components/dataViews/queryableProperties/__tests__/SelectField.spec.js +13 -6
- package/src/components/functions/__tests__/FunctionEditor.spec.js +2 -34
- package/src/components/functions/__tests__/FunctionParams.spec.js +4 -17
- package/src/components/functions/__tests__/Functions.spec.js +2 -34
- package/src/components/functions/__tests__/__snapshots__/FunctionEditor.spec.js.snap +48 -48
- package/src/components/functions/__tests__/__snapshots__/FunctionParams.spec.js.snap +4 -4
- package/src/components/functions/__tests__/__snapshots__/Functions.spec.js.snap +4 -4
- package/src/components/qualityControls/ControlProperties.js +43 -0
- package/src/components/qualityControls/ControlPropertiesView.js +109 -0
- package/src/components/qualityControls/EditQualityControl.js +5 -21
- package/src/components/qualityControls/IconPopup.js +28 -0
- package/src/components/qualityControls/NewDraftQualityControl.js +4 -13
- package/src/components/qualityControls/NewQualityControl.js +10 -25
- package/src/components/qualityControls/QualityBadge.js +33 -0
- package/src/components/qualityControls/QualityControl.js +11 -53
- package/src/components/qualityControls/QualityControlActions.js +133 -46
- package/src/components/qualityControls/QualityControlEditor.js +114 -135
- package/src/components/qualityControls/QualityControlHeader.js +29 -7
- package/src/components/qualityControls/QualityControlHistory.js +6 -12
- package/src/components/qualityControls/QualityControlQueryModal.js +8 -5
- package/src/components/qualityControls/QualityControlRoutes.js +51 -96
- package/src/components/qualityControls/QualityControlRow.js +21 -2
- package/src/components/qualityControls/QualityControlScores.js +140 -0
- package/src/components/qualityControls/QualityControlTabs.js +24 -23
- package/src/components/qualityControls/QualityControls.js +142 -59
- package/src/components/qualityControls/QualityControlsLabelResults.js +51 -0
- package/src/components/qualityControls/QualityControlsTable.js +69 -43
- package/src/components/qualityControls/ScoreCriteria.js +40 -0
- package/src/components/qualityControls/{ResultCriteria.js → ScoreCriteriaView.js} +26 -42
- package/src/components/qualityControls/__tests__/ControlProperties.spec.js +86 -0
- package/src/components/qualityControls/__tests__/ControlPropertiesView.spec.js +86 -0
- package/src/components/qualityControls/__tests__/EditQualityControl.spec.js +219 -0
- package/src/components/qualityControls/__tests__/IconPopup.spec.js +33 -0
- package/src/components/qualityControls/__tests__/NewDraftQualityControl.spec.js +253 -0
- package/src/components/qualityControls/__tests__/NewQualityControl.spec.js +384 -0
- package/src/components/qualityControls/__tests__/QualityBadge.spec.js +30 -0
- package/src/components/qualityControls/__tests__/QualityControl.spec.js +47 -0
- package/src/components/qualityControls/__tests__/QualityControlActions.spec.js +192 -0
- package/src/components/qualityControls/__tests__/QualityControlCrumbs.spec.js +18 -0
- package/src/components/qualityControls/__tests__/QualityControlEditor.spec.js +296 -0
- package/src/components/qualityControls/__tests__/QualityControlHeader.spec.js +68 -0
- package/src/components/qualityControls/__tests__/QualityControlHistory.spec.js +21 -0
- package/src/components/qualityControls/__tests__/QualityControlQueryModal.spec.js +77 -0
- package/src/components/qualityControls/__tests__/QualityControlRow.spec.js +91 -0
- package/src/components/qualityControls/__tests__/QualityControlScores.spec.js +139 -0
- package/src/components/qualityControls/__tests__/QualityControlTabs.spec.js +20 -0
- package/src/components/qualityControls/__tests__/QualityControls.spec.js +202 -0
- package/src/components/qualityControls/__tests__/QualityControlsLabelResults.spec.js +83 -0
- package/src/components/qualityControls/__tests__/QualityControlsTable.spec.js +38 -0
- package/src/components/qualityControls/__tests__/ScoreCriteria.spec.js +77 -0
- package/src/components/qualityControls/__tests__/ScoreCriteriaView.spec.js +62 -0
- package/src/components/qualityControls/__tests__/__fixtures__/qualityControlHelper.js +281 -0
- package/src/components/qualityControls/__tests__/__snapshots__/ControlProperties.spec.js.snap +151 -0
- package/src/components/qualityControls/__tests__/__snapshots__/ControlPropertiesView.spec.js.snap +290 -0
- package/src/components/qualityControls/__tests__/__snapshots__/EditQualityControl.spec.js.snap +672 -0
- package/src/components/qualityControls/__tests__/__snapshots__/IconPopup.spec.js.snap +10 -0
- package/src/components/qualityControls/__tests__/__snapshots__/NewDraftQualityControl.spec.js.snap +648 -0
- package/src/components/qualityControls/__tests__/__snapshots__/NewQualityControl.spec.js.snap +336 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityBadge.spec.js.snap +11 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControl.spec.js.snap +255 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlActions.spec.js.snap +85 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlCrumbs.spec.js.snap +25 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlEditor.spec.js.snap +930 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlHeader.spec.js.snap +127 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlHistory.spec.js.snap +75 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlQueryModal.spec.js.snap +27 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlRow.spec.js.snap +113 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlScores.spec.js.snap +161 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlTabs.spec.js.snap +28 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControls.spec.js.snap +219 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlsLabelResults.spec.js.snap +11 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlsTable.spec.js.snap +121 -0
- package/src/components/qualityControls/__tests__/__snapshots__/ScoreCriteria.spec.js.snap +186 -0
- package/src/components/qualityControls/__tests__/__snapshots__/ScoreCriteriaView.spec.js.snap +76 -0
- package/src/components/qualityControls/__tests__/qualityByControlMode.spec.js +248 -0
- package/src/components/qualityControls/controlProperties/ErrorCount.js +56 -0
- package/src/components/qualityControls/controlProperties/Ratio.js +79 -0
- package/src/components/qualityControls/controlProperties/__tests__/ErrorCount.spec.js +82 -0
- package/src/components/qualityControls/controlProperties/__tests__/Ratio.spec.js +115 -0
- package/src/components/qualityControls/controlProperties/__tests__/__snapshots__/ErrorCount.spec.js.snap +62 -0
- package/src/components/qualityControls/controlProperties/__tests__/__snapshots__/Ratio.spec.js.snap +143 -0
- package/src/components/qualityControls/qualityByControlMode.js +62 -0
- package/src/components/qualityControls/qualityControlScoresColumns.js +52 -0
- package/src/components/qualityControls/{resultCriterias → scoreCriterias}/Deviation.js +6 -6
- package/src/components/qualityControls/{resultCriterias/ErrorsNumber.js → scoreCriterias/ErrorCount.js} +7 -7
- package/src/components/qualityControls/{resultCriterias → scoreCriterias}/Percentage.js +6 -6
- package/src/components/qualityControls/scoreCriterias/__tests__/Deviation.spec.js +75 -0
- package/src/components/qualityControls/scoreCriterias/__tests__/ErrorCount.spec.js +63 -0
- package/src/components/qualityControls/scoreCriterias/__tests__/Percentage.spec.js +61 -0
- package/src/components/qualityControls/scoreCriterias/__tests__/__snapshots__/Deviation.spec.js.snap +58 -0
- package/src/components/qualityControls/scoreCriterias/__tests__/__snapshots__/ErrorCount.spec.js.snap +58 -0
- package/src/components/qualityControls/scoreCriterias/__tests__/__snapshots__/Percentage.spec.js.snap +58 -0
- package/src/components/{executions/ExecutionGroupsHeader.js → scores/MyScoreGroups.js} +5 -3
- package/src/components/scores/QualityBar.js +73 -0
- package/src/components/scores/Score.js +32 -0
- package/src/components/scores/ScoreContext.js +3 -0
- package/src/components/scores/ScoreCrumbs.js +40 -0
- package/src/components/scores/ScoreDetails.js +67 -0
- package/src/components/scores/ScoreEvents.js +59 -0
- package/src/components/scores/ScoreGroup.js +83 -0
- package/src/components/scores/ScoreGroupBreadcrumbs.js +25 -0
- package/src/components/{qualityControls/ExecutionForm.js → scores/ScoreGroupForm.js} +11 -13
- package/src/components/scores/ScoreGroupLink.js +18 -0
- package/src/components/scores/ScoreGroupMessage.js +25 -0
- package/src/components/{qualityControls/ExecutionPopup.js → scores/ScoreGroupPopup.js} +13 -22
- package/src/components/scores/ScoreGroupsTable.js +113 -0
- package/src/components/scores/ScoreRoutes.js +32 -0
- package/src/components/{executions/ExecutionStatusDecorator.js → scores/ScoreStatusDecorator.js} +10 -8
- package/src/components/scores/ScoreTabs.js +32 -0
- package/src/components/scores/__tests__/MyScoreGroups.spec.js +31 -0
- package/src/components/scores/__tests__/QualityBar.spec.js +55 -0
- package/src/components/scores/__tests__/Score.spec.js +41 -0
- package/src/components/scores/__tests__/ScoreCrumbs.spec.js +39 -0
- package/src/components/scores/__tests__/ScoreDetails.spec.js +38 -0
- package/src/components/scores/__tests__/ScoreEvents.spec.js +24 -0
- package/src/components/scores/__tests__/ScoreGroup.spec.js +43 -0
- package/src/components/scores/__tests__/ScoreGroupBreadcrumbs.spec.js +16 -0
- package/src/components/scores/__tests__/ScoreGroupForm.spec.js +78 -0
- package/src/components/scores/__tests__/ScoreGroupLink.spec.js +16 -0
- package/src/components/scores/__tests__/ScoreGroupMessage.spec.js +20 -0
- package/src/components/scores/__tests__/ScoreGroupPopup.spec.js +59 -0
- package/src/components/scores/__tests__/ScoreGroupsTable.spec.js +40 -0
- package/src/components/scores/__tests__/ScoreStatusDecorator.spec.js +21 -0
- package/src/components/scores/__tests__/ScoreTabs.spec.js +27 -0
- package/src/components/scores/__tests__/__fixtures__/scoreHelper.js +182 -0
- package/src/components/scores/__tests__/__snapshots__/MyScoreGroups.spec.js.snap +154 -0
- package/src/components/scores/__tests__/__snapshots__/QualityBar.spec.js.snap +24 -0
- package/src/components/scores/__tests__/__snapshots__/Score.spec.js.snap +92 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreCrumbs.spec.js.snap +39 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreDetails.spec.js.snap +156 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreEvents.spec.js.snap +167 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreGroup.spec.js.snap +103 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreGroupBreadcrumbs.spec.js.snap +29 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreGroupForm.spec.js.snap +145 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreGroupLink.spec.js.snap +15 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreGroupMessage.spec.js.snap +43 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreGroupPopup.spec.js.snap +11 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreGroupsTable.spec.js.snap +147 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreStatusDecorator.spec.js.snap +71 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreTabs.spec.js.snap +43 -0
- package/src/components/scores/index.js +15 -0
- package/src/hooks/useQualityControls.js +3 -9
- package/src/hooks/useScoreGroups.js +23 -0
- package/src/hooks/useScores.js +22 -0
- package/src/styles/Expression.less +16 -0
- package/src/styles/scores.less +63 -0
- package/src/components/executions/ExecutionGroupBreadcrumbs.js +0 -25
- package/src/components/executions/ExecutionGroupContent.js +0 -42
- package/src/components/executions/ExecutionGroupLink.js +0 -18
- package/src/components/executions/ExecutionGroupMessage.js +0 -27
- package/src/components/executions/ExecutionGroupsTable.js +0 -101
- package/src/components/executions/executionGroupDetail.js +0 -87
- package/src/components/qualityControls/ResultType.js +0 -57
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { fireEvent } from "@testing-library/react";
|
|
4
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
5
|
+
import QualityControlQueryModal from "../QualityControlQueryModal";
|
|
6
|
+
|
|
7
|
+
const data = {
|
|
8
|
+
data: {
|
|
9
|
+
queries: [
|
|
10
|
+
{
|
|
11
|
+
resource: {
|
|
12
|
+
select: null,
|
|
13
|
+
queryables: [
|
|
14
|
+
{
|
|
15
|
+
resource: null,
|
|
16
|
+
__type__: "from",
|
|
17
|
+
resource_ref: 0,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
__type__: "data_view",
|
|
21
|
+
resource_refs: {
|
|
22
|
+
0: {
|
|
23
|
+
alias: null,
|
|
24
|
+
id: 11859650,
|
|
25
|
+
type: "data_structure",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
action: "count",
|
|
30
|
+
__type__: "query",
|
|
31
|
+
query_ref: "error_count",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
resources_lookup: {
|
|
35
|
+
"data_structure:11859650": {
|
|
36
|
+
id: 11859650,
|
|
37
|
+
name: "ACCOUNTING_RULES",
|
|
38
|
+
metadata: {
|
|
39
|
+
database: "SECURITYDBO",
|
|
40
|
+
table: "ACCOUNTING_RULES",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
jest.mock("@truedat/qx/hooks/useQualityControls", () => {
|
|
48
|
+
return {
|
|
49
|
+
useQualityControlQueries: jest.fn(() => ({
|
|
50
|
+
data,
|
|
51
|
+
loading: false,
|
|
52
|
+
})),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const renderOpts = { messages };
|
|
57
|
+
|
|
58
|
+
describe("<QualityControlQueryModal />", () => {
|
|
59
|
+
it("matches the latest snapshot", () => {
|
|
60
|
+
const { container } = render(
|
|
61
|
+
<QualityControlQueryModal qualityControlId={8} />,
|
|
62
|
+
renderOpts
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(container).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("open modal", () => {
|
|
69
|
+
const { container, getByRole } = render(
|
|
70
|
+
<QualityControlQueryModal qualityControlId={8} />,
|
|
71
|
+
renderOpts
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
fireEvent.click(getByRole("button"));
|
|
75
|
+
expect(container).toMatchSnapshot();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { waitFor } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
6
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
7
|
+
import { columns } from "../QualityControlsTable";
|
|
8
|
+
import QualityControlRow from "../QualityControlRow";
|
|
9
|
+
|
|
10
|
+
const mockHistory = {
|
|
11
|
+
push: jest.fn(),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
jest.mock("react-router-dom", () => ({
|
|
15
|
+
...jest.requireActual("react-router-dom"),
|
|
16
|
+
useHistory: () => mockHistory,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const renderOpts = {
|
|
20
|
+
messages,
|
|
21
|
+
fallback: "lazy",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const props = {
|
|
25
|
+
onChange: jest.fn(),
|
|
26
|
+
qualityControl: qualityControlData(),
|
|
27
|
+
columns: columns,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe("<QualityControlRow />", () => {
|
|
31
|
+
it("matches the latest snapshot", () => {
|
|
32
|
+
const { container } = render(
|
|
33
|
+
<table>
|
|
34
|
+
<tbody>
|
|
35
|
+
<QualityControlRow {...props} />
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>,
|
|
38
|
+
|
|
39
|
+
renderOpts
|
|
40
|
+
);
|
|
41
|
+
expect(container).toMatchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("withCheck set to true", async () => {
|
|
45
|
+
const newProps = {
|
|
46
|
+
...props,
|
|
47
|
+
withCheck: true,
|
|
48
|
+
checked: true,
|
|
49
|
+
};
|
|
50
|
+
const { container } = render(
|
|
51
|
+
<table>
|
|
52
|
+
<tbody>
|
|
53
|
+
<QualityControlRow {...newProps} />
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>,
|
|
56
|
+
renderOpts
|
|
57
|
+
);
|
|
58
|
+
expect(container).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("render Quality control route", () => {
|
|
62
|
+
const { queryByText } = render(
|
|
63
|
+
<table>
|
|
64
|
+
<tbody>
|
|
65
|
+
<QualityControlRow {...props} />
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>,
|
|
68
|
+
renderOpts
|
|
69
|
+
);
|
|
70
|
+
const link = queryByText("test");
|
|
71
|
+
expect(link).toHaveAttribute("href", "/qualityControls/8");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("renders empty table columns are empty", () => {
|
|
75
|
+
const newProps = {
|
|
76
|
+
...props,
|
|
77
|
+
columns: [],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { queryByText } = render(
|
|
81
|
+
<table>
|
|
82
|
+
<tbody>
|
|
83
|
+
<QualityControlRow {...newProps} />
|
|
84
|
+
</tbody>
|
|
85
|
+
</table>,
|
|
86
|
+
renderOpts
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(queryByText("test")).not.toBeInTheDocument();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@truedat/test/render";
|
|
4
|
+
import { waitFor } from "@testing-library/react";
|
|
5
|
+
import userEvent from "@testing-library/user-event";
|
|
6
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
7
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
8
|
+
import {
|
|
9
|
+
useQualityControlScores,
|
|
10
|
+
useScoreDelete,
|
|
11
|
+
} from "@truedat/qx/hooks/useScores";
|
|
12
|
+
import QualityControlScores from "../QualityControlScores";
|
|
13
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
14
|
+
|
|
15
|
+
jest.mock("react-router-dom", () => ({
|
|
16
|
+
...jest.requireActual("react-router-dom"),
|
|
17
|
+
useParams: () => ({ id: "8" }),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
jest.mock("@truedat/qx/hooks/useScores", () => {
|
|
21
|
+
const { scoreData } = jest.requireActual(
|
|
22
|
+
"@truedat/qx/components/scores/__tests__/__fixtures__/scoreHelper"
|
|
23
|
+
);
|
|
24
|
+
const data = [scoreData(), scoreData({ id: 16, status: "QUEUED" })];
|
|
25
|
+
const mutate = jest.fn();
|
|
26
|
+
return {
|
|
27
|
+
useQualityControlScores: jest.fn(() => ({
|
|
28
|
+
data: { data: data },
|
|
29
|
+
loading: false,
|
|
30
|
+
mutate,
|
|
31
|
+
})),
|
|
32
|
+
useScoreDelete: jest.fn(() => ({
|
|
33
|
+
trigger: () => ({
|
|
34
|
+
then: (callback) =>
|
|
35
|
+
callback({
|
|
36
|
+
data: {},
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
})),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const renderOpts = { messages };
|
|
44
|
+
const mutate = jest.fn();
|
|
45
|
+
|
|
46
|
+
const context = {
|
|
47
|
+
qualityControl: qualityControlData(),
|
|
48
|
+
loading: false,
|
|
49
|
+
actions: ["delete_score"],
|
|
50
|
+
mutate,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
describe("<QualityControlScores />", () => {
|
|
54
|
+
it("matches the latest snapshot", () => {
|
|
55
|
+
const { container } = render(
|
|
56
|
+
<TestFormWrapper context={context}>
|
|
57
|
+
<QualityControlScores />
|
|
58
|
+
</TestFormWrapper>,
|
|
59
|
+
renderOpts
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect(container).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("shows a message when there are no scores", () => {
|
|
66
|
+
useQualityControlScores.mockReturnValueOnce({
|
|
67
|
+
data: { data: [] },
|
|
68
|
+
loading: false,
|
|
69
|
+
mutate,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const context = {
|
|
73
|
+
qualityControl: qualityControlData(),
|
|
74
|
+
loading: false,
|
|
75
|
+
actions: ["delete_score"],
|
|
76
|
+
mutate,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const { getByText } = render(
|
|
80
|
+
<TestFormWrapper context={context}>
|
|
81
|
+
<QualityControlScores />
|
|
82
|
+
</TestFormWrapper>,
|
|
83
|
+
renderOpts
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(getByText("No scores found")).toBeInTheDocument();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("does not show delete button when user does not have delete_score action", () => {
|
|
90
|
+
const context = {
|
|
91
|
+
qualityControl: qualityControlData(),
|
|
92
|
+
loading: false,
|
|
93
|
+
actions: [],
|
|
94
|
+
mutate,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const { container } = render(
|
|
98
|
+
<TestFormWrapper context={context}>
|
|
99
|
+
<QualityControlScores />
|
|
100
|
+
</TestFormWrapper>,
|
|
101
|
+
renderOpts
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const deleteButtons = container.querySelectorAll(
|
|
105
|
+
".ui.red.basic.icon.button"
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
expect(deleteButtons.length).toBe(0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("deletes a score when the delete button is clicked", async () => {
|
|
112
|
+
const trigger = jest.fn(() =>
|
|
113
|
+
Promise.resolve({
|
|
114
|
+
data: {},
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
useScoreDelete.mockImplementation(() => ({
|
|
119
|
+
trigger,
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
const { container, getByText } = render(
|
|
123
|
+
<TestFormWrapper context={context}>
|
|
124
|
+
<QualityControlScores />
|
|
125
|
+
</TestFormWrapper>,
|
|
126
|
+
renderOpts
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const deleteButtons = container.querySelectorAll(
|
|
130
|
+
".ui.red.basic.icon.button"
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
userEvent.click(deleteButtons[0]);
|
|
134
|
+
userEvent.click(getByText(/confirm_yes/));
|
|
135
|
+
await waitFor(() => {
|
|
136
|
+
expect(trigger).toHaveBeenCalled();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
4
|
+
import QualityControlTabs from "../QualityControlTabs";
|
|
5
|
+
|
|
6
|
+
jest.mock("react-router-dom", () => ({
|
|
7
|
+
...jest.requireActual("react-router-dom"),
|
|
8
|
+
useParams: () => ({ id: "8" }),
|
|
9
|
+
useLocation: () => ({ pathname: "/qualityControls/8" }),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const renderOpts = { messages };
|
|
13
|
+
|
|
14
|
+
describe("<QualityControlTabs />", () => {
|
|
15
|
+
it("matches the latest snapshot", () => {
|
|
16
|
+
const { container } = render(<QualityControlTabs />, renderOpts);
|
|
17
|
+
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { waitFor } from "@testing-library/react";
|
|
4
|
+
import { within } from "@testing-library/dom";
|
|
5
|
+
import userEvent from "@testing-library/user-event";
|
|
6
|
+
import { singleTemplateMock } from "@truedat/test/mocks";
|
|
7
|
+
import SearchContext from "@truedat/core/search/SearchContext";
|
|
8
|
+
import { useScoreGroupCreate } from "@truedat/qx/hooks/useScoreGroups";
|
|
9
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
10
|
+
import QualityControls from "../QualityControls";
|
|
11
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
12
|
+
|
|
13
|
+
jest.mock("@truedat/core/hooks/useAuthorizedAction", () => ({
|
|
14
|
+
...jest.requireActual("@truedat/core/hooks/useAuthorizedAction"),
|
|
15
|
+
__esModule: true,
|
|
16
|
+
default: () => ({
|
|
17
|
+
data: { has_any_domain: true },
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock("@truedat/qx/hooks/useScoreGroups", () => ({
|
|
22
|
+
useScoreGroupCreate: jest.fn(() => ({})),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const renderOpts = {
|
|
26
|
+
mocks: [singleTemplateMock({ scope: "qe", domainIds: undefined })],
|
|
27
|
+
messages,
|
|
28
|
+
fallback: "loading",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const searchProps = {
|
|
32
|
+
count: 1,
|
|
33
|
+
query: "",
|
|
34
|
+
searchMust: "",
|
|
35
|
+
hiddenFilters: "",
|
|
36
|
+
searchData: {
|
|
37
|
+
data: [qualityControlData({ status: "published" })],
|
|
38
|
+
actions: { execute: true },
|
|
39
|
+
},
|
|
40
|
+
defaultFilters: { status: "published" },
|
|
41
|
+
toggleHiddenFilterValue: jest.fn(),
|
|
42
|
+
loading: false,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
describe("<QualityControls />", () => {
|
|
46
|
+
it("matches the latest snapshot", () => {
|
|
47
|
+
const { container } = render(
|
|
48
|
+
<SearchContext.Provider value={searchProps}>
|
|
49
|
+
<QualityControls />
|
|
50
|
+
</SearchContext.Provider>,
|
|
51
|
+
renderOpts
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
expect(container).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("activate/desactivate execution", async () => {
|
|
58
|
+
const toggleHiddenFilterValue = jest.fn();
|
|
59
|
+
const removeHiddenFilter = jest.fn();
|
|
60
|
+
|
|
61
|
+
const thisSearchProps = {
|
|
62
|
+
...searchProps,
|
|
63
|
+
toggleHiddenFilterValue,
|
|
64
|
+
removeHiddenFilter,
|
|
65
|
+
};
|
|
66
|
+
const { container, getByRole } = render(
|
|
67
|
+
<SearchContext.Provider value={thisSearchProps}>
|
|
68
|
+
<QualityControls />
|
|
69
|
+
</SearchContext.Provider>,
|
|
70
|
+
renderOpts
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(
|
|
74
|
+
getByRole("button", { name: /Execute quality control/i })
|
|
75
|
+
).toBeDisabled();
|
|
76
|
+
|
|
77
|
+
userEvent.click(container.querySelector("#execute_checkbox"));
|
|
78
|
+
|
|
79
|
+
expect(toggleHiddenFilterValue).toHaveBeenCalledWith({
|
|
80
|
+
filter: "for_execution",
|
|
81
|
+
value: true,
|
|
82
|
+
});
|
|
83
|
+
expect(
|
|
84
|
+
getByRole("button", { name: /Execute quality control/i })
|
|
85
|
+
).toBeEnabled();
|
|
86
|
+
|
|
87
|
+
expect(
|
|
88
|
+
container.querySelector("#row-checkbox-8").parentElement
|
|
89
|
+
).not.toHaveClass("checked");
|
|
90
|
+
|
|
91
|
+
userEvent.click(container.querySelector("#selectQualityControl"));
|
|
92
|
+
|
|
93
|
+
expect(
|
|
94
|
+
container.querySelector("#row-checkbox-8").parentElement
|
|
95
|
+
).toHaveClass("checked");
|
|
96
|
+
|
|
97
|
+
userEvent.click(container.querySelector("#row-checkbox-8"));
|
|
98
|
+
|
|
99
|
+
expect(
|
|
100
|
+
container.querySelector("#row-checkbox-8").parentElement
|
|
101
|
+
).not.toHaveClass("checked");
|
|
102
|
+
|
|
103
|
+
userEvent.click(container.querySelector("#execute_checkbox"));
|
|
104
|
+
|
|
105
|
+
expect(removeHiddenFilter).toHaveBeenCalledWith({
|
|
106
|
+
filter: "for_execution",
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
expect(container.querySelector("#row-checkbox-8")).not.toBeInTheDocument();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("submit execution with search", async () => {
|
|
113
|
+
const trigger = jest.fn(() =>
|
|
114
|
+
Promise.resolve({ data: { data: { id: "9" } } })
|
|
115
|
+
);
|
|
116
|
+
useScoreGroupCreate.mockImplementation(() => ({
|
|
117
|
+
trigger,
|
|
118
|
+
loading: false,
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
const { container, getByRole, queryByText } = render(
|
|
122
|
+
<SearchContext.Provider value={searchProps}>
|
|
123
|
+
<QualityControls />
|
|
124
|
+
</SearchContext.Provider>,
|
|
125
|
+
renderOpts
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
userEvent.click(container.querySelector("#execute_checkbox"));
|
|
129
|
+
|
|
130
|
+
expect(
|
|
131
|
+
getByRole("button", { name: /Execute quality control/i })
|
|
132
|
+
).toBeEnabled();
|
|
133
|
+
|
|
134
|
+
userEvent.click(getByRole("button", { name: /Execute quality control/i }));
|
|
135
|
+
|
|
136
|
+
await waitFor(() =>
|
|
137
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
138
|
+
);
|
|
139
|
+
await waitFor(() => expect(queryByText(/loader/i)).not.toBeInTheDocument());
|
|
140
|
+
|
|
141
|
+
const modal = queryByText(/Quality controls execution/i).parentElement;
|
|
142
|
+
userEvent.click(within(modal).getByRole("button", { name: /Create/i }));
|
|
143
|
+
|
|
144
|
+
expect(trigger).toHaveBeenCalledWith({
|
|
145
|
+
score_group: {
|
|
146
|
+
df_type: "template1",
|
|
147
|
+
dynamic_content: {},
|
|
148
|
+
},
|
|
149
|
+
search: {
|
|
150
|
+
must: "",
|
|
151
|
+
query: "",
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("submit execution with select", async () => {
|
|
157
|
+
const trigger = jest.fn(() =>
|
|
158
|
+
Promise.resolve({ data: { data: { id: "9" } } })
|
|
159
|
+
);
|
|
160
|
+
useScoreGroupCreate.mockImplementation(() => ({
|
|
161
|
+
trigger,
|
|
162
|
+
loading: false,
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
const { container, getByRole, queryByText } = render(
|
|
166
|
+
<SearchContext.Provider value={searchProps}>
|
|
167
|
+
<QualityControls />
|
|
168
|
+
</SearchContext.Provider>,
|
|
169
|
+
renderOpts
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
userEvent.click(container.querySelector("#execute_checkbox"));
|
|
173
|
+
|
|
174
|
+
expect(
|
|
175
|
+
getByRole("button", { name: /Execute quality control/i })
|
|
176
|
+
).toBeEnabled();
|
|
177
|
+
|
|
178
|
+
userEvent.click(container.querySelector("#selectQualityControl"));
|
|
179
|
+
|
|
180
|
+
expect(
|
|
181
|
+
container.querySelector("#row-checkbox-8").parentElement
|
|
182
|
+
).toHaveClass("checked");
|
|
183
|
+
|
|
184
|
+
userEvent.click(getByRole("button", { name: /Execute quality control/i }));
|
|
185
|
+
|
|
186
|
+
await waitFor(() =>
|
|
187
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
188
|
+
);
|
|
189
|
+
await waitFor(() => expect(queryByText(/loader/i)).not.toBeInTheDocument());
|
|
190
|
+
|
|
191
|
+
const modal = queryByText(/Quality controls execution/i).parentElement;
|
|
192
|
+
userEvent.click(within(modal).getByRole("button", { name: /Create/i }));
|
|
193
|
+
|
|
194
|
+
expect(trigger).toHaveBeenCalledWith({
|
|
195
|
+
score_group: {
|
|
196
|
+
df_type: "template1",
|
|
197
|
+
dynamic_content: {},
|
|
198
|
+
},
|
|
199
|
+
ids: [13],
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { SearchContextProvider } from "@truedat/core/search/SearchContext";
|
|
4
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
5
|
+
import QualityControlsLabelResults from "../QualityControlsLabelResults";
|
|
6
|
+
|
|
7
|
+
const useFilters = jest.fn(() => ({
|
|
8
|
+
trigger: jest.fn(() => new Promise(() => {})),
|
|
9
|
+
isMutating: false,
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const useSearch = () => ({
|
|
13
|
+
trigger: () => ({
|
|
14
|
+
then: (callback) =>
|
|
15
|
+
callback({
|
|
16
|
+
data: [],
|
|
17
|
+
headers: { "x-total-count": 22 },
|
|
18
|
+
}),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const searchProps = {
|
|
23
|
+
initialSortColumn: "updated_at",
|
|
24
|
+
initialSortDirection: "descending",
|
|
25
|
+
useSearch: useSearch,
|
|
26
|
+
useFilters: useFilters,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const renderOpts = { messages };
|
|
30
|
+
|
|
31
|
+
describe("<QualityControlsLabelResults />", () => {
|
|
32
|
+
it("matches the latest snapshot", async () => {
|
|
33
|
+
const executeQualityControlOn = false;
|
|
34
|
+
const qualityControlsToExecute = 0;
|
|
35
|
+
const { container, findByText } = render(
|
|
36
|
+
<SearchContextProvider {...searchProps}>
|
|
37
|
+
<QualityControlsLabelResults
|
|
38
|
+
executeQualityControlOn={executeQualityControlOn}
|
|
39
|
+
qualityControlsToExecute={qualityControlsToExecute}
|
|
40
|
+
/>
|
|
41
|
+
</SearchContextProvider>,
|
|
42
|
+
renderOpts
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(await findByText("22 quality controls found")).toBeInTheDocument();
|
|
46
|
+
|
|
47
|
+
expect(container).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("show number of specific executions", async () => {
|
|
51
|
+
const executeQualityControlOn = true;
|
|
52
|
+
const qualityControlsToExecute = 10;
|
|
53
|
+
const { findByText } = render(
|
|
54
|
+
<SearchContextProvider {...searchProps}>
|
|
55
|
+
<QualityControlsLabelResults
|
|
56
|
+
executeQualityControlOn={executeQualityControlOn}
|
|
57
|
+
qualityControlsToExecute={qualityControlsToExecute}
|
|
58
|
+
/>
|
|
59
|
+
</SearchContextProvider>,
|
|
60
|
+
renderOpts
|
|
61
|
+
);
|
|
62
|
+
expect(
|
|
63
|
+
await findByText("10 quality controls to execute")
|
|
64
|
+
).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("show all quality controls to execute ", async () => {
|
|
68
|
+
const executeQualityControlOn = true;
|
|
69
|
+
const qualityControlsToExecute = 0;
|
|
70
|
+
const { findByText } = render(
|
|
71
|
+
<SearchContextProvider {...searchProps}>
|
|
72
|
+
<QualityControlsLabelResults
|
|
73
|
+
executeQualityControlOn={executeQualityControlOn}
|
|
74
|
+
qualityControlsToExecute={qualityControlsToExecute}
|
|
75
|
+
/>
|
|
76
|
+
</SearchContextProvider>,
|
|
77
|
+
renderOpts
|
|
78
|
+
);
|
|
79
|
+
expect(
|
|
80
|
+
await findByText("22 quality controls to execute")
|
|
81
|
+
).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
4
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
5
|
+
import SearchContext from "@truedat/core/search/SearchContext";
|
|
6
|
+
import QualityControlsTable from "../QualityControlsTable";
|
|
7
|
+
|
|
8
|
+
const data = [qualityControlData(), qualityControlData({ id: 9, name: "Foo" })];
|
|
9
|
+
|
|
10
|
+
const searchProps = {
|
|
11
|
+
sortColumn: "updated_at",
|
|
12
|
+
sortDirection: "descending",
|
|
13
|
+
handleSortSelection: jest.fn(),
|
|
14
|
+
searchData: { data },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const renderOpts = { messages };
|
|
18
|
+
|
|
19
|
+
const props = {
|
|
20
|
+
addAll: jest.fn(),
|
|
21
|
+
checkedAll: false,
|
|
22
|
+
checkRow: jest.fn(),
|
|
23
|
+
executeQualityControlOn: false,
|
|
24
|
+
isRowChecked: jest.fn(),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe("<QualityControlsTable />", () => {
|
|
28
|
+
it("matches the latest snapshot", () => {
|
|
29
|
+
const { container } = render(
|
|
30
|
+
<SearchContext.Provider value={searchProps}>
|
|
31
|
+
<QualityControlsTable {...props} />
|
|
32
|
+
</SearchContext.Provider>,
|
|
33
|
+
renderOpts
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(container).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
});
|