@truedat/qx 7.0.7 → 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,40 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { useFormContext } from "react-hook-form";
|
|
3
|
+
import { Segment } from "semantic-ui-react";
|
|
4
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
5
|
+
|
|
6
|
+
import Deviation from "./scoreCriterias/Deviation";
|
|
7
|
+
import ErrorCount from "./scoreCriterias/ErrorCount";
|
|
8
|
+
import Percentage from "./scoreCriterias/Percentage";
|
|
9
|
+
|
|
10
|
+
export default function ScoreCriteria() {
|
|
11
|
+
const { watch } = useFormContext();
|
|
12
|
+
const context = useContext(QxContext);
|
|
13
|
+
|
|
14
|
+
const controlMode = watch("control_mode");
|
|
15
|
+
|
|
16
|
+
const scoreCriteriaForMode = {
|
|
17
|
+
deviation: <Deviation />,
|
|
18
|
+
error_count: <ErrorCount />,
|
|
19
|
+
percentage: <Percentage />,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return controlMode ? (
|
|
23
|
+
<Segment>
|
|
24
|
+
<QxContext.Provider value={{ ...context, field: "score_criteria" }}>
|
|
25
|
+
{scoreCriteriaForMode[controlMode]}
|
|
26
|
+
</QxContext.Provider>
|
|
27
|
+
</Segment>
|
|
28
|
+
) : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const defaultForMode = (controlMode) => {
|
|
32
|
+
switch (controlMode) {
|
|
33
|
+
case "deviation":
|
|
34
|
+
return { goal: null, maximum: null };
|
|
35
|
+
case "error_count":
|
|
36
|
+
return { goal: null, maximum: null };
|
|
37
|
+
case "percentage":
|
|
38
|
+
return { goal: null, minimum: null };
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -3,14 +3,12 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import { FormattedMessage } from "react-intl";
|
|
4
4
|
import { Header, Icon, Segment, List } from "semantic-ui-react";
|
|
5
5
|
|
|
6
|
-
export default function
|
|
7
|
-
const {
|
|
8
|
-
const
|
|
9
|
-
percentage: <
|
|
10
|
-
deviation: <
|
|
11
|
-
|
|
12
|
-
<ResultCriteriaErrorsNumber resultCriteria={result_criteria} />
|
|
13
|
-
),
|
|
6
|
+
export default function ScoreCriteriaView({ qualityControl }) {
|
|
7
|
+
const { score_criteria, control_mode } = qualityControl;
|
|
8
|
+
const scoreCriteriaForMode = {
|
|
9
|
+
percentage: <ScoreCriteriaPercentage scoreCriteria={score_criteria} />,
|
|
10
|
+
deviation: <ScoreCriteriaDeviation scoreCriteria={score_criteria} />,
|
|
11
|
+
error_count: <ScoreCriteriaErrorCount scoreCriteria={score_criteria} />,
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
return (
|
|
@@ -18,43 +16,29 @@ export default function ResultCriteria({ qualityControl }) {
|
|
|
18
16
|
<Header as="h3">
|
|
19
17
|
<Icon name="flag checkered" size="small" />
|
|
20
18
|
<Header.Content>
|
|
21
|
-
<FormattedMessage id="quality_control.
|
|
19
|
+
<FormattedMessage id="quality_control.score_criteria" />
|
|
22
20
|
</Header.Content>
|
|
23
21
|
</Header>
|
|
24
22
|
<Segment>
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
<List.Item>
|
|
28
|
-
<List.Header>
|
|
29
|
-
<FormattedMessage id="quality.thresholds" />
|
|
30
|
-
</List.Header>
|
|
31
|
-
<List.Content>
|
|
32
|
-
<List.Description>
|
|
33
|
-
<FormattedMessage
|
|
34
|
-
id={`quality_control.result_type.${result_type}`}
|
|
35
|
-
/>
|
|
36
|
-
</List.Description>
|
|
37
|
-
</List.Content>
|
|
38
|
-
</List.Item>
|
|
39
|
-
{resultCriteriaForType[result_type]}
|
|
40
|
-
</List>
|
|
23
|
+
{score_criteria ? (
|
|
24
|
+
scoreCriteriaForMode[control_mode]
|
|
41
25
|
) : (
|
|
42
|
-
<FormattedMessage id="quality_control.
|
|
26
|
+
<FormattedMessage id="quality_control.score_criteria.empty" />
|
|
43
27
|
)}
|
|
44
28
|
</Segment>
|
|
45
29
|
</>
|
|
46
30
|
);
|
|
47
31
|
}
|
|
48
32
|
|
|
49
|
-
const
|
|
50
|
-
|
|
33
|
+
const ScoreCriteriaPercentage = ({ scoreCriteria }) => (
|
|
34
|
+
<List>
|
|
51
35
|
<List.Item>
|
|
52
36
|
<Icon name="circle" color="green" />
|
|
53
37
|
<List.Content>
|
|
54
38
|
<List.Header>
|
|
55
39
|
<FormattedMessage id="quality.goal" />
|
|
56
40
|
</List.Header>
|
|
57
|
-
<List.Description>{
|
|
41
|
+
<List.Description>{scoreCriteria.goal}%</List.Description>
|
|
58
42
|
</List.Content>
|
|
59
43
|
</List.Item>
|
|
60
44
|
<List.Item>
|
|
@@ -63,21 +47,21 @@ const ResultCriteriaPercentage = ({ resultCriteria }) => (
|
|
|
63
47
|
<List.Header>
|
|
64
48
|
<FormattedMessage id="quality.threshold" />
|
|
65
49
|
</List.Header>
|
|
66
|
-
<List.Description>{
|
|
50
|
+
<List.Description>{scoreCriteria.minimum}%</List.Description>
|
|
67
51
|
</List.Content>
|
|
68
52
|
</List.Item>
|
|
69
|
-
|
|
53
|
+
</List>
|
|
70
54
|
);
|
|
71
55
|
|
|
72
|
-
const
|
|
73
|
-
|
|
56
|
+
const ScoreCriteriaDeviation = ({ scoreCriteria }) => (
|
|
57
|
+
<List>
|
|
74
58
|
<List.Item>
|
|
75
59
|
<Icon name="circle" color="green" />
|
|
76
60
|
<List.Content>
|
|
77
61
|
<List.Header>
|
|
78
62
|
<FormattedMessage id="quality.goal" />
|
|
79
63
|
</List.Header>
|
|
80
|
-
<List.Description>{
|
|
64
|
+
<List.Description>{scoreCriteria.goal}%</List.Description>
|
|
81
65
|
</List.Content>
|
|
82
66
|
</List.Item>
|
|
83
67
|
<List.Item>
|
|
@@ -86,21 +70,21 @@ const ResultCriteriaDeviation = ({ resultCriteria }) => (
|
|
|
86
70
|
<List.Header>
|
|
87
71
|
<FormattedMessage id="quality.threshold" />
|
|
88
72
|
</List.Header>
|
|
89
|
-
<List.Description>{
|
|
73
|
+
<List.Description>{scoreCriteria.maximum}%</List.Description>
|
|
90
74
|
</List.Content>
|
|
91
75
|
</List.Item>
|
|
92
|
-
|
|
76
|
+
</List>
|
|
93
77
|
);
|
|
94
78
|
|
|
95
|
-
const
|
|
96
|
-
|
|
79
|
+
const ScoreCriteriaErrorCount = ({ scoreCriteria }) => (
|
|
80
|
+
<List>
|
|
97
81
|
<List.Item>
|
|
98
82
|
<Icon name="circle" color="green" />
|
|
99
83
|
<List.Content>
|
|
100
84
|
<List.Header>
|
|
101
85
|
<FormattedMessage id="quality.goal" />
|
|
102
86
|
</List.Header>
|
|
103
|
-
<List.Description>{
|
|
87
|
+
<List.Description>{scoreCriteria.goal}</List.Description>
|
|
104
88
|
</List.Content>
|
|
105
89
|
</List.Item>
|
|
106
90
|
<List.Item>
|
|
@@ -109,12 +93,12 @@ const ResultCriteriaErrorsNumber = ({ resultCriteria }) => (
|
|
|
109
93
|
<List.Header>
|
|
110
94
|
<FormattedMessage id="quality.threshold" />
|
|
111
95
|
</List.Header>
|
|
112
|
-
<List.Description>{
|
|
96
|
+
<List.Description>{scoreCriteria.maximum}</List.Description>
|
|
113
97
|
</List.Content>
|
|
114
98
|
</List.Item>
|
|
115
|
-
|
|
99
|
+
</List>
|
|
116
100
|
);
|
|
117
101
|
|
|
118
|
-
|
|
102
|
+
ScoreCriteriaView.propTypes = {
|
|
119
103
|
qualityControl: PropTypes.object,
|
|
120
104
|
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import { waitFor } from "@testing-library/react";
|
|
4
|
+
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
5
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
6
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
7
|
+
import ControlProperties, { defaultForMode } from "../ControlProperties";
|
|
8
|
+
|
|
9
|
+
const dataSet = {
|
|
10
|
+
id: "7",
|
|
11
|
+
name: "dataset1",
|
|
12
|
+
headers: ["campo1", "campo2"],
|
|
13
|
+
};
|
|
14
|
+
const referenceDatasetsMock = {
|
|
15
|
+
request: { query: REFERENCE_DATASETS_HEADERS_QUERY },
|
|
16
|
+
result: { data: { referenceDatasets: [dataSet], loading: false } },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const renderOpts = {
|
|
20
|
+
mocks: [referenceDatasetsMock],
|
|
21
|
+
messages,
|
|
22
|
+
fallback: "lazy",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const defaultValues = {
|
|
26
|
+
control_mode: "percentage",
|
|
27
|
+
source_id: "181",
|
|
28
|
+
control_properties: {
|
|
29
|
+
resource: {
|
|
30
|
+
id: 11859650,
|
|
31
|
+
embedded: { fields: [{ id: 11859651 }] },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe("<ControlProperties />", () => {
|
|
37
|
+
it("matches the latest snapshot with ratio", async () => {
|
|
38
|
+
const { container } = render(
|
|
39
|
+
<TestFormWrapper defaultValues={defaultValues}>
|
|
40
|
+
<ControlProperties />
|
|
41
|
+
</TestFormWrapper>,
|
|
42
|
+
renderOpts
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
await waitFor(() =>
|
|
46
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
47
|
+
);
|
|
48
|
+
expect(container).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("matches the latest snapshot with error count", async () => {
|
|
52
|
+
const errorCountDefaultValues = {
|
|
53
|
+
...defaultValues,
|
|
54
|
+
control_mode: "error_count",
|
|
55
|
+
};
|
|
56
|
+
const { container } = render(
|
|
57
|
+
<TestFormWrapper defaultValues={errorCountDefaultValues}>
|
|
58
|
+
<ControlProperties />
|
|
59
|
+
</TestFormWrapper>,
|
|
60
|
+
renderOpts
|
|
61
|
+
);
|
|
62
|
+
await waitFor(() =>
|
|
63
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
64
|
+
);
|
|
65
|
+
expect(container).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("defaultForMode", () => {
|
|
70
|
+
it("returns correct default for 'error_count' control mode", () => {
|
|
71
|
+
const result = defaultForMode("error_count");
|
|
72
|
+
expect(result).toEqual({ errors_resource: null });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("returns correct default for other control modes", () => {
|
|
76
|
+
const result = defaultForMode("some_other_mode");
|
|
77
|
+
expect(result).toEqual({
|
|
78
|
+
resource: null,
|
|
79
|
+
validation: [
|
|
80
|
+
{
|
|
81
|
+
expressions: [{ shape: "function", value: { isCondition: true } }],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
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 ControlPropertiesView from "../ControlPropertiesView";
|
|
6
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
7
|
+
|
|
8
|
+
const renderOpts = { messages };
|
|
9
|
+
|
|
10
|
+
const qualityControl = qualityControlData();
|
|
11
|
+
|
|
12
|
+
describe("<ControlPropertiesView />", () => {
|
|
13
|
+
it("matches the latest snapshot for ratio", async () => {
|
|
14
|
+
const { container } = render(
|
|
15
|
+
<TestFormWrapper>
|
|
16
|
+
<ControlPropertiesView qualityControl={qualityControl} />
|
|
17
|
+
</TestFormWrapper>,
|
|
18
|
+
renderOpts
|
|
19
|
+
);
|
|
20
|
+
expect(container).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("matches the latest snapshot for error count", async () => {
|
|
24
|
+
const errorCountQualityControl = {
|
|
25
|
+
...qualityControl,
|
|
26
|
+
control_mode: "error_count",
|
|
27
|
+
control_properties: {
|
|
28
|
+
errors_resource: {
|
|
29
|
+
id: 11859650,
|
|
30
|
+
type: "data_structure",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<TestFormWrapper>
|
|
36
|
+
<ControlPropertiesView qualityControl={errorCountQualityControl} />
|
|
37
|
+
</TestFormWrapper>,
|
|
38
|
+
renderOpts
|
|
39
|
+
);
|
|
40
|
+
expect(container).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("matches the latest snapshot for empty control properties", async () => {
|
|
44
|
+
const { container } = render(
|
|
45
|
+
<TestFormWrapper>
|
|
46
|
+
<ControlPropertiesView
|
|
47
|
+
qualityControl={{ ...qualityControl, control_properties: null }}
|
|
48
|
+
/>
|
|
49
|
+
</TestFormWrapper>,
|
|
50
|
+
renderOpts
|
|
51
|
+
);
|
|
52
|
+
expect(container).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("matches the latest snapshot for empty errors_resource", async () => {
|
|
56
|
+
const { container } = render(
|
|
57
|
+
<TestFormWrapper>
|
|
58
|
+
<ControlPropertiesView
|
|
59
|
+
qualityControl={{
|
|
60
|
+
...qualityControl,
|
|
61
|
+
control_mode: "error_count",
|
|
62
|
+
control_properties: { errors_resource: null },
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
</TestFormWrapper>,
|
|
66
|
+
renderOpts
|
|
67
|
+
);
|
|
68
|
+
expect(container).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("matches the latest snapshot for empty ratio validation and resource", async () => {
|
|
72
|
+
const { container } = render(
|
|
73
|
+
<TestFormWrapper>
|
|
74
|
+
<ControlPropertiesView
|
|
75
|
+
qualityControl={{
|
|
76
|
+
...qualityControl,
|
|
77
|
+
control_mode: "percentage",
|
|
78
|
+
control_properties: { resource: null, validation: null },
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
</TestFormWrapper>,
|
|
82
|
+
renderOpts
|
|
83
|
+
);
|
|
84
|
+
expect(container).toMatchSnapshot();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,219 @@
|
|
|
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 { SOURCE_OPTIONS_QUERY } from "@truedat/cx/sources/api/queries";
|
|
6
|
+
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
7
|
+
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
8
|
+
import { singleTemplateMock } from "@truedat/test/mocks";
|
|
9
|
+
import {
|
|
10
|
+
useQualityControlUpdateDraft,
|
|
11
|
+
useQualityControl,
|
|
12
|
+
} from "@truedat/qx/hooks/useQualityControls";
|
|
13
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
14
|
+
import {
|
|
15
|
+
sources,
|
|
16
|
+
domains,
|
|
17
|
+
qualityControlData,
|
|
18
|
+
} from "./__fixtures__/qualityControlHelper";
|
|
19
|
+
import EditQualityControl from "../EditQualityControl";
|
|
20
|
+
|
|
21
|
+
const mockHistory = { push: jest.fn() };
|
|
22
|
+
|
|
23
|
+
jest.mock("react-router-dom", () => ({
|
|
24
|
+
...jest.requireActual("react-router-dom"),
|
|
25
|
+
useParams: () => ({ id: "8" }),
|
|
26
|
+
useHistory: () => mockHistory,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.mock("@truedat/qx/hooks/useQualityControls", () => {
|
|
30
|
+
const { qualityControlData } = jest.requireActual(
|
|
31
|
+
"./__fixtures__/qualityControlHelper"
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
useQualityControl: jest.fn(() => ({
|
|
36
|
+
data: {
|
|
37
|
+
data: qualityControlData({
|
|
38
|
+
versions: [],
|
|
39
|
+
status: "draft",
|
|
40
|
+
}),
|
|
41
|
+
_actions: ["send_to_approval", "publish", "edit", "toggle_active"],
|
|
42
|
+
},
|
|
43
|
+
loading: false,
|
|
44
|
+
})),
|
|
45
|
+
useQualityControlUpdateDraft: jest.fn(() => ({
|
|
46
|
+
trigger: jest.fn(() => Promise.resolve()),
|
|
47
|
+
isMutating: false,
|
|
48
|
+
})),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
jest.mock("@truedat/core/hooks/useUserFilters", () => {
|
|
53
|
+
const originalModule = jest.requireActual(
|
|
54
|
+
"@truedat/core/hooks/useUserFilters"
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
__esModule: true,
|
|
59
|
+
...originalModule,
|
|
60
|
+
useUserFilters: jest.fn(() => ({})),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
jest.mock("@truedat/qx/hooks/useFunctions", () => {
|
|
64
|
+
const originalModule = jest.requireActual("@truedat/qx/hooks/useFunctions");
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
__esModule: true,
|
|
68
|
+
...originalModule,
|
|
69
|
+
useFunctions: jest.fn(() => ({})),
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
73
|
+
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
__esModule: true,
|
|
77
|
+
...originalModule,
|
|
78
|
+
useDataViews: jest.fn(() => ({})),
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const sourcesMock = {
|
|
83
|
+
request: { query: SOURCE_OPTIONS_QUERY },
|
|
84
|
+
result: { data: { sources } },
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const referenceDatasetsMock = {
|
|
88
|
+
request: { query: REFERENCE_DATASETS_HEADERS_QUERY },
|
|
89
|
+
result: {
|
|
90
|
+
data: {
|
|
91
|
+
referenceDatasets: [
|
|
92
|
+
{
|
|
93
|
+
id: "7",
|
|
94
|
+
name: "dataset1",
|
|
95
|
+
headers: ["campo1", "campo2"],
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
loading: false,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const publishDomainsMock = {
|
|
104
|
+
request: {
|
|
105
|
+
query: DOMAINS_QUERY,
|
|
106
|
+
variables: { action: "publishQualityControls" },
|
|
107
|
+
},
|
|
108
|
+
result: { data: { domains } },
|
|
109
|
+
};
|
|
110
|
+
const createDomainsMock = {
|
|
111
|
+
request: {
|
|
112
|
+
query: DOMAINS_QUERY,
|
|
113
|
+
variables: { action: "createQualityControls" },
|
|
114
|
+
},
|
|
115
|
+
result: { data: { domains } },
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const renderOpts = {
|
|
119
|
+
mocks: [
|
|
120
|
+
singleTemplateMock({ scope: "quality_control", domainIds: [2] }),
|
|
121
|
+
singleTemplateMock({ scope: "quality_control", domainIds: undefined }),
|
|
122
|
+
sourcesMock,
|
|
123
|
+
referenceDatasetsMock,
|
|
124
|
+
publishDomainsMock,
|
|
125
|
+
createDomainsMock,
|
|
126
|
+
],
|
|
127
|
+
messages,
|
|
128
|
+
fallback: "loading",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
describe("<EditQualityControl />", () => {
|
|
132
|
+
it("matches the latest snapshot", async () => {
|
|
133
|
+
const { container, queryByText } = render(
|
|
134
|
+
<EditQualityControl />,
|
|
135
|
+
renderOpts
|
|
136
|
+
);
|
|
137
|
+
await waitFor(() =>
|
|
138
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
139
|
+
);
|
|
140
|
+
await waitFor(() =>
|
|
141
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
142
|
+
);
|
|
143
|
+
expect(container).toMatchSnapshot();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("matches the latest snapshot with empty qualityControl", async () => {
|
|
147
|
+
useQualityControl.mockImplementationOnce(() => ({
|
|
148
|
+
data: {},
|
|
149
|
+
loading: false,
|
|
150
|
+
}));
|
|
151
|
+
|
|
152
|
+
const { container, queryByText } = render(
|
|
153
|
+
<EditQualityControl />,
|
|
154
|
+
renderOpts
|
|
155
|
+
);
|
|
156
|
+
await waitFor(() =>
|
|
157
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
158
|
+
);
|
|
159
|
+
await waitFor(() =>
|
|
160
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
161
|
+
);
|
|
162
|
+
expect(container).toMatchSnapshot();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("navigates to qulity controls when cancel button is cliked", async () => {
|
|
166
|
+
const { container, getByText, queryByText } = render(
|
|
167
|
+
<EditQualityControl />,
|
|
168
|
+
renderOpts
|
|
169
|
+
);
|
|
170
|
+
await waitFor(() =>
|
|
171
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
172
|
+
);
|
|
173
|
+
await waitFor(() =>
|
|
174
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument()
|
|
175
|
+
);
|
|
176
|
+
userEvent.click(getByText(/Cancel/));
|
|
177
|
+
|
|
178
|
+
expect(mockHistory.push.mock.calls.length).toBe(1);
|
|
179
|
+
expect(mockHistory.push.mock.calls[0][0]).toBe("/qualityControls");
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("test save submit ", async () => {
|
|
183
|
+
const trigger = jest.fn(() =>
|
|
184
|
+
Promise.resolve({ data: { data: { id: "9" } } })
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
useQualityControlUpdateDraft.mockImplementation(() => ({
|
|
188
|
+
trigger,
|
|
189
|
+
}));
|
|
190
|
+
|
|
191
|
+
const { getByText, getByPlaceholderText, queryByText, getByRole } = render(
|
|
192
|
+
<EditQualityControl />,
|
|
193
|
+
renderOpts
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
await waitFor(() =>
|
|
197
|
+
expect(queryByText(/loading/i)).not.toBeInTheDocument()
|
|
198
|
+
);
|
|
199
|
+
await waitFor(() =>
|
|
200
|
+
expect(getByRole("button", { name: /Save/ })).toBeDisabled()
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
userEvent.type(getByPlaceholderText("Name"), "_modified");
|
|
204
|
+
|
|
205
|
+
await waitFor(() =>
|
|
206
|
+
expect(getByRole("button", { name: /Save/ })).toBeEnabled()
|
|
207
|
+
);
|
|
208
|
+
userEvent.click(getByText(/Save/));
|
|
209
|
+
|
|
210
|
+
const qualityControl = qualityControlData({
|
|
211
|
+
versions: [],
|
|
212
|
+
status: "draft",
|
|
213
|
+
name: "test_modified",
|
|
214
|
+
});
|
|
215
|
+
await waitFor(() =>
|
|
216
|
+
expect(trigger).toHaveBeenCalledWith({ quality_control: qualityControl })
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
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 IconPopup from "../IconPopup";
|
|
6
|
+
|
|
7
|
+
const renderOpts = { messages };
|
|
8
|
+
|
|
9
|
+
const props = {
|
|
10
|
+
color: "red",
|
|
11
|
+
label1: "quality_control.score_criteria.deviation.goal",
|
|
12
|
+
value1: 10,
|
|
13
|
+
label2: "quality_control.score_criteria.deviation.maximum",
|
|
14
|
+
value2: 30,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe("<IconPopup />", () => {
|
|
18
|
+
it("matches the latest snapshot", () => {
|
|
19
|
+
const { container } = render(<IconPopup {...props} />, renderOpts);
|
|
20
|
+
expect(container).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("show popup information with mouse over", async () => {
|
|
24
|
+
const { container, findByText } = render(
|
|
25
|
+
<IconPopup {...props} />,
|
|
26
|
+
renderOpts
|
|
27
|
+
);
|
|
28
|
+
const icon = container.querySelector(".red.circle.icon");
|
|
29
|
+
fireEvent.mouseOver(icon);
|
|
30
|
+
|
|
31
|
+
expect(await findByText("Result criteria")).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
});
|