@truedat/qx 7.0.8 → 7.1.1
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 +189 -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 +10 -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 +113 -134
- 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,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { waitFor } from "@testing-library/react";
|
|
4
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
5
|
+
import { templateByNameMock } from "@truedat/test/mocks";
|
|
6
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
7
|
+
import QualityControl from "../QualityControl";
|
|
8
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
9
|
+
|
|
10
|
+
const renderOpts = {
|
|
11
|
+
mocks: [templateByNameMock({ name: "template1", domainIds: [2] })],
|
|
12
|
+
messages,
|
|
13
|
+
fallback: "loading",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe("<QualityControl />", () => {
|
|
17
|
+
it("matches the latest snapshot", async () => {
|
|
18
|
+
const context = { qualityControl: qualityControlData() };
|
|
19
|
+
const { container, queryByText } = render(
|
|
20
|
+
<TestFormWrapper context={context}>
|
|
21
|
+
<QualityControl />
|
|
22
|
+
</TestFormWrapper>,
|
|
23
|
+
renderOpts
|
|
24
|
+
);
|
|
25
|
+
await waitFor(() => {
|
|
26
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument();
|
|
27
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(container).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("matches the latest snapshot without df_type", async () => {
|
|
34
|
+
const context = {
|
|
35
|
+
qualityControl: qualityControlData({ df_type: undefined }),
|
|
36
|
+
};
|
|
37
|
+
const { queryByText } = render(
|
|
38
|
+
<TestFormWrapper context={context}>
|
|
39
|
+
<QualityControl />
|
|
40
|
+
</TestFormWrapper>,
|
|
41
|
+
renderOpts
|
|
42
|
+
);
|
|
43
|
+
await waitFor(() =>
|
|
44
|
+
expect(queryByText(/Information/i)).not.toBeInTheDocument()
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { waitFor } from "@testing-library/react";
|
|
4
|
+
import { render } from "@truedat/test/render";
|
|
5
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
6
|
+
import { singleTemplateMock } from "@truedat/test/mocks";
|
|
7
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
8
|
+
import QualityControlActions from "../QualityControlActions";
|
|
9
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
10
|
+
|
|
11
|
+
const mockHistory = { push: jest.fn() };
|
|
12
|
+
|
|
13
|
+
jest.mock("react-router-dom", () => ({
|
|
14
|
+
...jest.requireActual("react-router-dom"),
|
|
15
|
+
useHistory: () => mockHistory,
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
jest.mock("@truedat/core/hooks", () => ({
|
|
19
|
+
useAuthorized: jest.fn(() => true),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
jest.mock("@truedat/qx/hooks/useQualityControls", () => {
|
|
23
|
+
const { qualityControlData } = jest.requireActual(
|
|
24
|
+
"./__fixtures__/qualityControlHelper"
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
useQualityControlUpdateMain: jest.fn(() => ({
|
|
29
|
+
trigger: jest.fn(() => Promise.resolve()),
|
|
30
|
+
data: qualityControlData(),
|
|
31
|
+
isMutating: false,
|
|
32
|
+
loading: false,
|
|
33
|
+
})),
|
|
34
|
+
useQualityControlUpdateStatus: jest.fn(() => ({
|
|
35
|
+
trigger: jest.fn(() => Promise.resolve()),
|
|
36
|
+
data: { ...qualityControlData(), status: "published" },
|
|
37
|
+
isMutating: false,
|
|
38
|
+
loading: false,
|
|
39
|
+
})),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
jest.mock("@truedat/qx/hooks/useScoreGroups", () => {
|
|
44
|
+
const { scoreGroup } = jest.requireActual(
|
|
45
|
+
"@truedat/qx/components/scores/__tests__/__fixtures__/scoreHelper"
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
useScoreGroupCreate: jest.fn(() => ({
|
|
50
|
+
trigger: jest.fn(() => Promise.resolve({ data: { data: scoreGroup } })),
|
|
51
|
+
loading: false,
|
|
52
|
+
})),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const actions = ["deprecate", "create_draft", "toggle_active"];
|
|
57
|
+
const mutate = jest.fn();
|
|
58
|
+
const qualityControl = qualityControlData();
|
|
59
|
+
|
|
60
|
+
const context = {
|
|
61
|
+
actions,
|
|
62
|
+
qualityControl,
|
|
63
|
+
mutate,
|
|
64
|
+
};
|
|
65
|
+
const variables = { scope: "qe" };
|
|
66
|
+
const renderOpts = {
|
|
67
|
+
mocks: [singleTemplateMock(variables)],
|
|
68
|
+
messages,
|
|
69
|
+
fallback: "loading",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
describe("<QualityControlActions />", () => {
|
|
73
|
+
it("matches the latest snapshot with actions for published status", async () => {
|
|
74
|
+
const { container, queryByText } = render(
|
|
75
|
+
<TestFormWrapper context={{ ...context }}>
|
|
76
|
+
<QualityControlActions />
|
|
77
|
+
</TestFormWrapper>,
|
|
78
|
+
renderOpts
|
|
79
|
+
);
|
|
80
|
+
await waitFor(() =>
|
|
81
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
82
|
+
);
|
|
83
|
+
expect(container).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("render actions for dratf status", () => {
|
|
87
|
+
const newContext = {
|
|
88
|
+
...context,
|
|
89
|
+
actions: ["send_to_approval", "publish", "edit", "toggle_active"],
|
|
90
|
+
};
|
|
91
|
+
const { queryByText } = render(
|
|
92
|
+
<TestFormWrapper context={{ ...newContext }}>
|
|
93
|
+
<QualityControlActions />
|
|
94
|
+
</TestFormWrapper>,
|
|
95
|
+
renderOpts
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(queryByText(/Edit/i)).toBeInTheDocument();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("renders the correct actions", async () => {
|
|
102
|
+
const { getByText, queryByText } = render(
|
|
103
|
+
<TestFormWrapper context={{ ...context }}>
|
|
104
|
+
<QualityControlActions />
|
|
105
|
+
</TestFormWrapper>,
|
|
106
|
+
renderOpts
|
|
107
|
+
);
|
|
108
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
109
|
+
expect(getByText(/Create Draft/i)).toBeInTheDocument();
|
|
110
|
+
expect(getByText(/Disable/i)).toBeInTheDocument();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("render the correct actions when is disabled", async () => {
|
|
114
|
+
const disableQualityControl = qualityControlData({ active: false });
|
|
115
|
+
const { getByText, queryByText } = render(
|
|
116
|
+
<TestFormWrapper
|
|
117
|
+
context={{ ...context, qualityControl: disableQualityControl }}
|
|
118
|
+
>
|
|
119
|
+
<QualityControlActions />
|
|
120
|
+
</TestFormWrapper>,
|
|
121
|
+
renderOpts
|
|
122
|
+
);
|
|
123
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
124
|
+
expect(getByText(/Enable/i)).toBeInTheDocument();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("render onConfirm when toggle_active button is clicked", async () => {
|
|
128
|
+
const { getByText, queryByText } = render(
|
|
129
|
+
<TestFormWrapper context={{ ...context }}>
|
|
130
|
+
<QualityControlActions />
|
|
131
|
+
</TestFormWrapper>,
|
|
132
|
+
renderOpts
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
userEvent.click(getByText(/Enable|Disable/i));
|
|
136
|
+
await waitFor(() =>
|
|
137
|
+
expect(queryByText(/confirm_yes/i)).toBeInTheDocument()
|
|
138
|
+
);
|
|
139
|
+
userEvent.click(getByText(/confirm_yes/i));
|
|
140
|
+
await waitFor(() => expect(mutate).toHaveBeenCalledTimes(1));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("renders correct Link components for create_draft and edit actions", () => {
|
|
144
|
+
const actions = ["create_draft", "edit"];
|
|
145
|
+
const { getByText } = render(
|
|
146
|
+
<TestFormWrapper context={{ ...context, actions }}>
|
|
147
|
+
<QualityControlActions />
|
|
148
|
+
</TestFormWrapper>,
|
|
149
|
+
renderOpts
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
expect(getByText(/Create Draft/i).closest("a")).toHaveAttribute(
|
|
153
|
+
"href",
|
|
154
|
+
`/qualityControls/${qualityControl.id}/new_draft`
|
|
155
|
+
);
|
|
156
|
+
expect(getByText(/Edit/i).closest("a")).toHaveAttribute(
|
|
157
|
+
"href",
|
|
158
|
+
`/qualityControls/${qualityControl.id}/edit`
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("calls updateStatus when default action button is clicked", async () => {
|
|
163
|
+
const { getByText, queryByText } = render(
|
|
164
|
+
<TestFormWrapper context={{ ...context, actions: ["publish"] }}>
|
|
165
|
+
<QualityControlActions />
|
|
166
|
+
</TestFormWrapper>,
|
|
167
|
+
renderOpts
|
|
168
|
+
);
|
|
169
|
+
userEvent.click(getByText(/Publish/i));
|
|
170
|
+
await waitFor(() => expect(queryByText(/Publish/i)).toBeInTheDocument());
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("calls onCreateScoreGroup when ScoreGroupPopup is submitted", async () => {
|
|
174
|
+
const { getByText, queryByText } = render(
|
|
175
|
+
<TestFormWrapper context={{ ...context }}>
|
|
176
|
+
<QualityControlActions />
|
|
177
|
+
</TestFormWrapper>,
|
|
178
|
+
renderOpts
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
await waitFor(() =>
|
|
182
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
userEvent.click(getByText(/Execute quality control/i));
|
|
186
|
+
|
|
187
|
+
await waitFor(() => expect(queryByText("Create")).toBeInTheDocument());
|
|
188
|
+
userEvent.click(getByText("Create"));
|
|
189
|
+
await waitFor(() => expect(mockHistory.push.mock.calls.length).toBe(1));
|
|
190
|
+
expect(mockHistory.push.mock.calls[0][0]).toBe("/scoreGroups/36");
|
|
191
|
+
});
|
|
192
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
4
|
+
import QualityControlCrumbs from "../QualityControlCrumbs";
|
|
5
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
6
|
+
|
|
7
|
+
const renderOpts = { messages };
|
|
8
|
+
|
|
9
|
+
describe("<QualityControlCrumbs />", () => {
|
|
10
|
+
it("matches the latest snapshot", () => {
|
|
11
|
+
const { container } = render(
|
|
12
|
+
<QualityControlCrumbs qualityControl={qualityControlData()} />,
|
|
13
|
+
renderOpts
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(container).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { waitFor, fireEvent } from "@testing-library/react";
|
|
4
|
+
import { act } from "@testing-library/react";
|
|
5
|
+
import userEvent from "@testing-library/user-event";
|
|
6
|
+
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
7
|
+
import { singleTemplateMock } from "@truedat/test/mocks";
|
|
8
|
+
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
9
|
+
import { SOURCE_OPTIONS_QUERY } from "@truedat/cx/sources/api/queries";
|
|
10
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
11
|
+
import { defaultQualityControl } from "../NewQualityControl";
|
|
12
|
+
import QualityControlEditor from "../QualityControlEditor";
|
|
13
|
+
import {
|
|
14
|
+
sources,
|
|
15
|
+
domains,
|
|
16
|
+
qualityControlData,
|
|
17
|
+
} from "./__fixtures__/qualityControlHelper";
|
|
18
|
+
|
|
19
|
+
jest.mock("@truedat/core/hooks/useUserFilters", () => {
|
|
20
|
+
const originalModule = jest.requireActual(
|
|
21
|
+
"@truedat/core/hooks/useUserFilters"
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
__esModule: true,
|
|
26
|
+
...originalModule,
|
|
27
|
+
useUserFilters: jest.fn(() => ({})),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
jest.mock("@truedat/qx/hooks/useFunctions", () => {
|
|
31
|
+
const originalModule = jest.requireActual("@truedat/qx/hooks/useFunctions");
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
__esModule: true,
|
|
35
|
+
...originalModule,
|
|
36
|
+
useFunctions: jest.fn(() => ({})),
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
40
|
+
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
__esModule: true,
|
|
44
|
+
...originalModule,
|
|
45
|
+
useDataViews: jest.fn(() => ({})),
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const sourcesMock = {
|
|
50
|
+
request: { query: SOURCE_OPTIONS_QUERY },
|
|
51
|
+
result: { data: { sources } },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const referenceDatasetsMock = {
|
|
55
|
+
request: { query: REFERENCE_DATASETS_HEADERS_QUERY },
|
|
56
|
+
result: {
|
|
57
|
+
data: {
|
|
58
|
+
referenceDatasets: [
|
|
59
|
+
{
|
|
60
|
+
id: "7",
|
|
61
|
+
name: "dataset1",
|
|
62
|
+
headers: ["campo1", "campo2"],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
loading: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const createDomainsMock = {
|
|
71
|
+
request: {
|
|
72
|
+
query: DOMAINS_QUERY,
|
|
73
|
+
variables: { action: "createQualityControls" },
|
|
74
|
+
},
|
|
75
|
+
result: { data: { domains } },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const publishDomainsMock = {
|
|
79
|
+
request: {
|
|
80
|
+
query: DOMAINS_QUERY,
|
|
81
|
+
variables: { action: "publishQualityControls" },
|
|
82
|
+
},
|
|
83
|
+
result: { data: { domains } },
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const mocks = [
|
|
87
|
+
publishDomainsMock,
|
|
88
|
+
createDomainsMock,
|
|
89
|
+
sourcesMock,
|
|
90
|
+
referenceDatasetsMock,
|
|
91
|
+
singleTemplateMock({ scope: "quality_control", domainIds: ["2"] }),
|
|
92
|
+
singleTemplateMock({ scope: "quality_control", domainIds: [2] }),
|
|
93
|
+
singleTemplateMock({ scope: "quality_control", domainIds: [] }),
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const renderOpts = {
|
|
97
|
+
mocks,
|
|
98
|
+
messages,
|
|
99
|
+
fallback: "lazy",
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const props = {
|
|
103
|
+
value: qualityControlData(),
|
|
104
|
+
isModification: true,
|
|
105
|
+
onPublish: jest.fn(),
|
|
106
|
+
onSave: jest.fn(),
|
|
107
|
+
onCancel: jest.fn(),
|
|
108
|
+
isSubmitting: false,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
describe("<QualityControlEditor />", () => {
|
|
112
|
+
it("matches the latest snapshot for edition", async () => {
|
|
113
|
+
const { container, queryByText } = render(
|
|
114
|
+
<QualityControlEditor {...props} />,
|
|
115
|
+
renderOpts
|
|
116
|
+
);
|
|
117
|
+
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
118
|
+
await waitFor(() =>
|
|
119
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
120
|
+
);
|
|
121
|
+
expect(container).toMatchSnapshot();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("matches the latest snapshot for creation", async () => {
|
|
125
|
+
const { getByRole, container, queryByText } = render(
|
|
126
|
+
<QualityControlEditor
|
|
127
|
+
{...props}
|
|
128
|
+
isModification={false}
|
|
129
|
+
value={defaultQualityControl}
|
|
130
|
+
/>,
|
|
131
|
+
renderOpts
|
|
132
|
+
);
|
|
133
|
+
await waitFor(() =>
|
|
134
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
135
|
+
);
|
|
136
|
+
await waitFor(() =>
|
|
137
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
138
|
+
);
|
|
139
|
+
await waitFor(() =>
|
|
140
|
+
expect(getByRole("button", { name: /Save/ })).toBeDisabled()
|
|
141
|
+
);
|
|
142
|
+
expect(container).toMatchSnapshot();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("test cancel button with out modal confirmation", async () => {
|
|
146
|
+
const onCancel = jest.fn();
|
|
147
|
+
const newProps = { ...props, onCancel };
|
|
148
|
+
const { getByRole, queryByText } = render(
|
|
149
|
+
<QualityControlEditor {...newProps} />,
|
|
150
|
+
renderOpts
|
|
151
|
+
);
|
|
152
|
+
await waitFor(() =>
|
|
153
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
154
|
+
);
|
|
155
|
+
userEvent.click(getByRole("button", { name: /Cancel/i }));
|
|
156
|
+
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("test cancel button with modal confirmation", async () => {
|
|
160
|
+
const onCancel = jest.fn();
|
|
161
|
+
const newProps = { ...props, onCancel };
|
|
162
|
+
const { getByRole, queryByText, getByPlaceholderText, getByText } = render(
|
|
163
|
+
<QualityControlEditor {...newProps} />,
|
|
164
|
+
renderOpts
|
|
165
|
+
);
|
|
166
|
+
await waitFor(() =>
|
|
167
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
168
|
+
);
|
|
169
|
+
const nameInput = getByPlaceholderText("Name");
|
|
170
|
+
fireEvent.change(nameInput, { target: { value: "test_modified" } });
|
|
171
|
+
await act(async () =>
|
|
172
|
+
userEvent.click(getByRole("button", { name: /Cancel/i }))
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
await waitFor(() =>
|
|
176
|
+
expect(queryByText(/confirm_yes/i)).toBeInTheDocument()
|
|
177
|
+
);
|
|
178
|
+
userEvent.click(getByText(/confirm_yes/));
|
|
179
|
+
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("test onSave", async () => {
|
|
183
|
+
const onSave = jest.fn();
|
|
184
|
+
const { getByRole, getByPlaceholderText, queryByText } = render(
|
|
185
|
+
<QualityControlEditor {...props} onSave={onSave} />,
|
|
186
|
+
renderOpts
|
|
187
|
+
);
|
|
188
|
+
await waitFor(() =>
|
|
189
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
190
|
+
);
|
|
191
|
+
expect(getByRole("button", { name: /Save/i })).toBeDisabled();
|
|
192
|
+
|
|
193
|
+
userEvent.type(getByPlaceholderText("Name"), "_modified");
|
|
194
|
+
|
|
195
|
+
await waitFor(() =>
|
|
196
|
+
expect(getByRole("button", { name: /Save/i })).toBeEnabled()
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const expectedQualityControl = qualityControlData({
|
|
200
|
+
name: "test_modified",
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
userEvent.click(getByRole("button", { name: /Save/i }));
|
|
204
|
+
|
|
205
|
+
await waitFor(() =>
|
|
206
|
+
expect(onSave).toHaveBeenCalledWith(expectedQualityControl)
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
it("test onPublish", async () => {
|
|
210
|
+
const onPublish = jest.fn();
|
|
211
|
+
const { getByRole, getByPlaceholderText, queryByText } = render(
|
|
212
|
+
<QualityControlEditor {...props} onPublish={onPublish} />,
|
|
213
|
+
renderOpts
|
|
214
|
+
);
|
|
215
|
+
await waitFor(() =>
|
|
216
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
217
|
+
);
|
|
218
|
+
expect(getByRole("button", { name: /Publish/i })).toBeDisabled();
|
|
219
|
+
|
|
220
|
+
userEvent.type(getByPlaceholderText("Name"), "_modified");
|
|
221
|
+
|
|
222
|
+
await waitFor(() =>
|
|
223
|
+
expect(getByRole("button", { name: /Publish/i })).toBeEnabled()
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const expectedQualityControl = qualityControlData({
|
|
227
|
+
name: "test_modified",
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
userEvent.click(getByRole("button", { name: /Publish/i }));
|
|
231
|
+
|
|
232
|
+
await waitFor(() =>
|
|
233
|
+
expect(onPublish).toHaveBeenCalledWith(expectedQualityControl)
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("test fill form", async () => {
|
|
238
|
+
const {
|
|
239
|
+
container,
|
|
240
|
+
getByText,
|
|
241
|
+
getByPlaceholderText,
|
|
242
|
+
queryByText,
|
|
243
|
+
getByRole,
|
|
244
|
+
} = render(
|
|
245
|
+
<QualityControlEditor
|
|
246
|
+
{...props}
|
|
247
|
+
value={defaultQualityControl}
|
|
248
|
+
isModification={false}
|
|
249
|
+
/>,
|
|
250
|
+
renderOpts
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
await waitFor(() =>
|
|
254
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
255
|
+
);
|
|
256
|
+
await waitFor(() =>
|
|
257
|
+
expect(getByRole("button", { name: /Publish/i })).toBeDisabled()
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
userEvent.click(getByText(/Enable/));
|
|
261
|
+
|
|
262
|
+
// Fill in the 'Name' field
|
|
263
|
+
userEvent.type(getByPlaceholderText("Name"), "test_modified");
|
|
264
|
+
|
|
265
|
+
// Select a domain
|
|
266
|
+
userEvent.click(getByText(/Select domains/));
|
|
267
|
+
userEvent.click(getByText(/barDomain/));
|
|
268
|
+
|
|
269
|
+
// Select a source
|
|
270
|
+
userEvent.click(getByText(/Select source/));
|
|
271
|
+
userEvent.click(getByRole("option", { name: /external_source_id/i }));
|
|
272
|
+
|
|
273
|
+
userEvent.click(getByRole("option", { name: /Error count/i }));
|
|
274
|
+
|
|
275
|
+
// Fill in the 'Goal' field
|
|
276
|
+
userEvent.type(getByPlaceholderText("Goal"), "25");
|
|
277
|
+
// Fill in the 'Threshold' field
|
|
278
|
+
userEvent.type(getByPlaceholderText("Threshold"), "50");
|
|
279
|
+
|
|
280
|
+
await waitFor(() =>
|
|
281
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
282
|
+
);
|
|
283
|
+
await waitFor(() =>
|
|
284
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
// Select the 'Reference datasets' for the resource type
|
|
288
|
+
userEvent.click(getByText(/Resource type/));
|
|
289
|
+
userEvent.click(getByText(/Reference datasets/));
|
|
290
|
+
userEvent.click(getByRole("option", { name: /dataset1/i }));
|
|
291
|
+
|
|
292
|
+
await waitFor(() =>
|
|
293
|
+
expect(getByRole("button", { name: /Publish/i })).toBeEnabled()
|
|
294
|
+
);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
4
|
+
import { useQualityControl } from "@truedat/qx/hooks/useQualityControls";
|
|
5
|
+
import QualityControlHeader from "../QualityControlHeader";
|
|
6
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
7
|
+
|
|
8
|
+
jest.mock("react-router-dom", () => ({
|
|
9
|
+
...jest.requireActual("react-router-dom"),
|
|
10
|
+
useParams: () => ({ id: "8" }),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
jest.mock("@truedat/qx/hooks/useQualityControls", () => {
|
|
14
|
+
const { qualityControlData } = jest.requireActual(
|
|
15
|
+
"@truedat/qx/components/qualityControls/__tests__/__fixtures__/qualityControlHelper"
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
useQualityControl: jest.fn(() => ({
|
|
20
|
+
data: { data: qualityControlData() },
|
|
21
|
+
loading: false,
|
|
22
|
+
mutate: jest.fn(),
|
|
23
|
+
})),
|
|
24
|
+
useQualityControlUpdateMain: jest.fn(() => ({
|
|
25
|
+
trigger: jest.fn(() => Promise.resolve()),
|
|
26
|
+
data: qualityControlData(),
|
|
27
|
+
loading: false,
|
|
28
|
+
})),
|
|
29
|
+
useQualityControlUpdateStatus: jest.fn(() => ({
|
|
30
|
+
trigger: jest.fn(() => Promise.resolve()),
|
|
31
|
+
data: { ...qualityControlData(), status: "published" },
|
|
32
|
+
loading: false,
|
|
33
|
+
})),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const renderOpts = { messages };
|
|
38
|
+
|
|
39
|
+
describe("<QualityControlHeader />", () => {
|
|
40
|
+
it("matches the latest snapshot with control quality active", () => {
|
|
41
|
+
const { container, queryByText } = render(
|
|
42
|
+
<QualityControlHeader />,
|
|
43
|
+
renderOpts
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(container).toMatchSnapshot();
|
|
47
|
+
expect(queryByText(/Enabled/i)).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("render control quality active = false", () => {
|
|
51
|
+
useQualityControl.mockImplementation(() => ({
|
|
52
|
+
data: { data: { ...qualityControlData(), active: false } },
|
|
53
|
+
loading: true,
|
|
54
|
+
}));
|
|
55
|
+
const { queryByText } = render(<QualityControlHeader />, renderOpts);
|
|
56
|
+
|
|
57
|
+
expect(queryByText(/Disabled/i)).toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("renders nothing when quality control is empty", () => {
|
|
61
|
+
useQualityControl.mockImplementation(() => ({
|
|
62
|
+
data: { data: {} },
|
|
63
|
+
loading: true,
|
|
64
|
+
}));
|
|
65
|
+
const { queryByText } = render(<QualityControlHeader />, renderOpts);
|
|
66
|
+
expect(queryByText(".header")).not.toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
4
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
5
|
+
import QualityControlsHistory from "../QualityControlHistory";
|
|
6
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
7
|
+
|
|
8
|
+
const renderOpts = { messages };
|
|
9
|
+
|
|
10
|
+
describe("<QualityControlsHistory />", () => {
|
|
11
|
+
it("matches the latest snapshot", async () => {
|
|
12
|
+
const context = { qualityControl: qualityControlData() };
|
|
13
|
+
const { container } = render(
|
|
14
|
+
<TestFormWrapper context={context}>
|
|
15
|
+
<QualityControlsHistory />
|
|
16
|
+
</TestFormWrapper>,
|
|
17
|
+
renderOpts
|
|
18
|
+
);
|
|
19
|
+
expect(container).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
});
|