@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,248 @@
|
|
|
1
|
+
import { scoreData } from "@truedat/qx/components/scores/__tests__/__fixtures__/scoreHelper";
|
|
2
|
+
|
|
3
|
+
import qualityByControlMode from "../qualityByControlMode";
|
|
4
|
+
|
|
5
|
+
describe("qualityByControlMode", () => {
|
|
6
|
+
it("returns isFailed when score status is FAILED", () => {
|
|
7
|
+
const score = scoreData({ status: "FAILED" });
|
|
8
|
+
expect(qualityByControlMode(score)).toEqual({ isFailed: true });
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("returns isEmpty when scoreContent is null", () => {
|
|
12
|
+
const score = scoreData({ score_content: null });
|
|
13
|
+
expect(qualityByControlMode(score)).toEqual({ isEmpty: true });
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("returns correct object when controlMode is deviation with red", () => {
|
|
17
|
+
const score = scoreData();
|
|
18
|
+
const result = {
|
|
19
|
+
color: "red",
|
|
20
|
+
label1: "quality_control.score_criteria.deviation.goal",
|
|
21
|
+
label2: "quality_control.score_criteria.deviation.maximum",
|
|
22
|
+
text: "50%",
|
|
23
|
+
value1: 10,
|
|
24
|
+
value2: 30,
|
|
25
|
+
};
|
|
26
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("returns correct object when controlMode is deviation with yellow", () => {
|
|
30
|
+
const score = scoreData({
|
|
31
|
+
quality_control: {
|
|
32
|
+
control_mode: "deviation",
|
|
33
|
+
score_criteria: {
|
|
34
|
+
maximum: 80,
|
|
35
|
+
goal: 50,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
score_content: {
|
|
39
|
+
total_count: 50,
|
|
40
|
+
validation_count: 30,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const result = {
|
|
44
|
+
color: "yellow",
|
|
45
|
+
label1: "quality_control.score_criteria.deviation.goal",
|
|
46
|
+
label2: "quality_control.score_criteria.deviation.maximum",
|
|
47
|
+
text: "60%",
|
|
48
|
+
value1: 50,
|
|
49
|
+
value2: 80,
|
|
50
|
+
};
|
|
51
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("returns correct object when controlMode is deviation with green", () => {
|
|
55
|
+
const score = scoreData({
|
|
56
|
+
quality_control: {
|
|
57
|
+
control_mode: "deviation",
|
|
58
|
+
score_criteria: {
|
|
59
|
+
maximum: 80,
|
|
60
|
+
goal: 70,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
score_content: {
|
|
64
|
+
total_count: 50,
|
|
65
|
+
validation_count: 30,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
const result = {
|
|
69
|
+
color: "green",
|
|
70
|
+
label1: "quality_control.score_criteria.deviation.goal",
|
|
71
|
+
label2: "quality_control.score_criteria.deviation.maximum",
|
|
72
|
+
text: "60%",
|
|
73
|
+
value1: 70,
|
|
74
|
+
value2: 80,
|
|
75
|
+
};
|
|
76
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("returns correct object when controlMode is percentage with yellow", () => {
|
|
80
|
+
const score = scoreData({
|
|
81
|
+
score_type: "ratio",
|
|
82
|
+
score_content: {
|
|
83
|
+
total_count: 100,
|
|
84
|
+
validation_count: 25,
|
|
85
|
+
},
|
|
86
|
+
quality_control: {
|
|
87
|
+
control_mode: "percentage",
|
|
88
|
+
score_criteria: {
|
|
89
|
+
goal: 30,
|
|
90
|
+
minimum: 20,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const result = {
|
|
95
|
+
color: "yellow",
|
|
96
|
+
label1: "quality_control.score_criteria.percentage.minimum",
|
|
97
|
+
label2: "quality_control.score_criteria.percentage.goal",
|
|
98
|
+
text: "25%",
|
|
99
|
+
value1: 20,
|
|
100
|
+
value2: 30,
|
|
101
|
+
};
|
|
102
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("returns correct object when controlMode is percentage with green", () => {
|
|
106
|
+
const score = scoreData({
|
|
107
|
+
score_type: "ratio",
|
|
108
|
+
score_content: {
|
|
109
|
+
total_count: 100,
|
|
110
|
+
validation_count: 25,
|
|
111
|
+
},
|
|
112
|
+
quality_control: {
|
|
113
|
+
control_mode: "percentage",
|
|
114
|
+
score_criteria: {
|
|
115
|
+
goal: 10,
|
|
116
|
+
minimum: 5,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
const result = {
|
|
121
|
+
color: "green",
|
|
122
|
+
label1: "quality_control.score_criteria.percentage.minimum",
|
|
123
|
+
label2: "quality_control.score_criteria.percentage.goal",
|
|
124
|
+
text: "25%",
|
|
125
|
+
value1: 5,
|
|
126
|
+
value2: 10,
|
|
127
|
+
};
|
|
128
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("returns correct object when controlMode is percentage with red", () => {
|
|
132
|
+
const score = scoreData({
|
|
133
|
+
score_type: "ratio",
|
|
134
|
+
score_content: {
|
|
135
|
+
total_count: 100,
|
|
136
|
+
validation_count: 25,
|
|
137
|
+
},
|
|
138
|
+
quality_control: {
|
|
139
|
+
control_mode: "percentage",
|
|
140
|
+
score_criteria: {
|
|
141
|
+
goal: 50,
|
|
142
|
+
minimum: 30,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
const result = {
|
|
147
|
+
color: "red",
|
|
148
|
+
label1: "quality_control.score_criteria.percentage.minimum",
|
|
149
|
+
label2: "quality_control.score_criteria.percentage.goal",
|
|
150
|
+
text: "25%",
|
|
151
|
+
value1: 30,
|
|
152
|
+
value2: 50,
|
|
153
|
+
};
|
|
154
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("returns correct object when controlMode is error_count with green", () => {
|
|
158
|
+
const score = scoreData({
|
|
159
|
+
score_content: {
|
|
160
|
+
error_count: 10,
|
|
161
|
+
},
|
|
162
|
+
quality_control: {
|
|
163
|
+
control_mode: "error_count",
|
|
164
|
+
score_criteria: {
|
|
165
|
+
maximum: 30,
|
|
166
|
+
goal: 20,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
const result = {
|
|
171
|
+
color: "green",
|
|
172
|
+
label1: "quality_control.score_criteria.error_count.goal",
|
|
173
|
+
label2: "quality_control.score_criteria.error_count.maximum",
|
|
174
|
+
text: 10,
|
|
175
|
+
value1: 20,
|
|
176
|
+
value2: 30,
|
|
177
|
+
};
|
|
178
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("returns correct object when controlMode is error_count with yellow", () => {
|
|
182
|
+
const score = scoreData({
|
|
183
|
+
score_content: {
|
|
184
|
+
error_count: 20,
|
|
185
|
+
},
|
|
186
|
+
quality_control: {
|
|
187
|
+
control_mode: "error_count",
|
|
188
|
+
|
|
189
|
+
score_criteria: {
|
|
190
|
+
maximum: 30,
|
|
191
|
+
goal: 20,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
const result = {
|
|
196
|
+
color: "yellow",
|
|
197
|
+
label1: "quality_control.score_criteria.error_count.goal",
|
|
198
|
+
label2: "quality_control.score_criteria.error_count.maximum",
|
|
199
|
+
text: 20,
|
|
200
|
+
value1: 20,
|
|
201
|
+
value2: 30,
|
|
202
|
+
};
|
|
203
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("returns correct object when controlMode is error_count with red", () => {
|
|
207
|
+
const score = scoreData({
|
|
208
|
+
score_content: {
|
|
209
|
+
error_count: 40,
|
|
210
|
+
},
|
|
211
|
+
quality_control: {
|
|
212
|
+
control_mode: "error_count",
|
|
213
|
+
|
|
214
|
+
score_criteria: {
|
|
215
|
+
maximum: 30,
|
|
216
|
+
goal: 20,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
const result = {
|
|
221
|
+
color: "red",
|
|
222
|
+
label1: "quality_control.score_criteria.error_count.goal",
|
|
223
|
+
label2: "quality_control.score_criteria.error_count.maximum",
|
|
224
|
+
text: 40,
|
|
225
|
+
value1: 20,
|
|
226
|
+
value2: 30,
|
|
227
|
+
};
|
|
228
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("returns correct object when controlMode is not defined", () => {
|
|
232
|
+
const score = scoreData({
|
|
233
|
+
score_content: {
|
|
234
|
+
error_count: 10,
|
|
235
|
+
},
|
|
236
|
+
quality_control: {
|
|
237
|
+
control_mode: "foo",
|
|
238
|
+
|
|
239
|
+
score_criteria: {
|
|
240
|
+
maximum: 30,
|
|
241
|
+
goal: 20,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
const result = {};
|
|
246
|
+
expect(qualityByControlMode(score)).toEqual(result);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { useQuery } from "@apollo/client";
|
|
4
|
+
import { useFormContext } from "react-hook-form";
|
|
5
|
+
import { Loading } from "@truedat/core/components";
|
|
6
|
+
import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
7
|
+
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
8
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
9
|
+
import { useDataViews } from "@truedat/qx/hooks/useDataViews";
|
|
10
|
+
import { useFunctions } from "@truedat/qx/hooks/useFunctions";
|
|
11
|
+
import ResourceSelector from "@truedat/qx/components/common/ResourceSelector";
|
|
12
|
+
|
|
13
|
+
export default function ErrorCount() {
|
|
14
|
+
const { field } = useContext(QxContext);
|
|
15
|
+
const { watch } = useFormContext();
|
|
16
|
+
|
|
17
|
+
const formData = watch();
|
|
18
|
+
|
|
19
|
+
const { source_id: sourceId } = formData;
|
|
20
|
+
|
|
21
|
+
const { data, loading: dataViewsLoading } = useDataViews();
|
|
22
|
+
const { data: functionsData, loading: functionsLoading } = useFunctions();
|
|
23
|
+
const { data: referenceDatasetsData, loading: referenceDatasetsLoading } =
|
|
24
|
+
useQuery(REFERENCE_DATASETS_HEADERS_QUERY);
|
|
25
|
+
|
|
26
|
+
const loading =
|
|
27
|
+
dataViewsLoading || functionsLoading || referenceDatasetsLoading;
|
|
28
|
+
|
|
29
|
+
const dataViews = _.orderBy(["id"], ["asc"])(data?.data);
|
|
30
|
+
const functions = functionsData?.data;
|
|
31
|
+
const referenceDatasets = _.flow(
|
|
32
|
+
_.getOr([], "referenceDatasets"),
|
|
33
|
+
_.sortBy([({ name }) => lowerDeburrTrim(name), "name"]),
|
|
34
|
+
_.map((row) => ({ ...row, id: Number(row?.id) }))
|
|
35
|
+
)(referenceDatasetsData);
|
|
36
|
+
const context = {
|
|
37
|
+
dataViews,
|
|
38
|
+
referenceDatasets,
|
|
39
|
+
functions,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return loading ? (
|
|
43
|
+
<Loading />
|
|
44
|
+
) : (
|
|
45
|
+
<>
|
|
46
|
+
<QxContext.Provider
|
|
47
|
+
value={{ ...context, sourceId, field: `${field}.errors_resource` }}
|
|
48
|
+
>
|
|
49
|
+
<ResourceSelector
|
|
50
|
+
required
|
|
51
|
+
labelId="quality_control.form.control_properties.error_count.errors_resource"
|
|
52
|
+
/>
|
|
53
|
+
</QxContext.Provider>
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { useQuery } from "@apollo/client";
|
|
4
|
+
import { useFormContext } from "react-hook-form";
|
|
5
|
+
import { Loading } from "@truedat/core/components";
|
|
6
|
+
import { lowerDeburrTrim } from "@truedat/core/services/sort";
|
|
7
|
+
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
8
|
+
import QxContext from "@truedat/qx/components/QxContext";
|
|
9
|
+
import { useDataViews } from "@truedat/qx/hooks/useDataViews";
|
|
10
|
+
import { useFunctions } from "@truedat/qx/hooks/useFunctions";
|
|
11
|
+
import { fieldsFromResource } from "@truedat/qx/components/dataViews/queryableFunctions";
|
|
12
|
+
import ResourceSelector from "@truedat/qx/components/common/ResourceSelector";
|
|
13
|
+
import { Clauses } from "@truedat/qx/components/common/expressions";
|
|
14
|
+
|
|
15
|
+
export default function Ratio() {
|
|
16
|
+
const { field } = useContext(QxContext);
|
|
17
|
+
const { watch } = useFormContext();
|
|
18
|
+
|
|
19
|
+
const formData = watch();
|
|
20
|
+
|
|
21
|
+
const { control_properties: controlProperties, source_id: sourceId } =
|
|
22
|
+
formData;
|
|
23
|
+
|
|
24
|
+
const resource = _.prop("resource")(controlProperties);
|
|
25
|
+
|
|
26
|
+
const { data, loading: dataViewsLoading } = useDataViews();
|
|
27
|
+
const { data: functionsData, loading: functionsLoading } = useFunctions();
|
|
28
|
+
const { data: referenceDatasetsData, loading: referenceDatasetsLoading } =
|
|
29
|
+
useQuery(REFERENCE_DATASETS_HEADERS_QUERY);
|
|
30
|
+
|
|
31
|
+
const loading =
|
|
32
|
+
dataViewsLoading || functionsLoading || referenceDatasetsLoading;
|
|
33
|
+
|
|
34
|
+
const dataViews = _.orderBy(["id"], ["asc"])(data?.data);
|
|
35
|
+
const functions = functionsData?.data;
|
|
36
|
+
const referenceDatasets = _.flow(
|
|
37
|
+
_.getOr([], "referenceDatasets"),
|
|
38
|
+
_.sortBy([({ name }) => lowerDeburrTrim(name), "name"]),
|
|
39
|
+
_.map((row) => ({ ...row, id: Number(row?.id) }))
|
|
40
|
+
)(referenceDatasetsData);
|
|
41
|
+
const context = {
|
|
42
|
+
dataViews,
|
|
43
|
+
referenceDatasets,
|
|
44
|
+
functions,
|
|
45
|
+
};
|
|
46
|
+
const fields = fieldsFromResource(
|
|
47
|
+
_.prop("embedded.name")(resource),
|
|
48
|
+
0
|
|
49
|
+
)({ resource });
|
|
50
|
+
|
|
51
|
+
return loading ? (
|
|
52
|
+
<Loading />
|
|
53
|
+
) : (
|
|
54
|
+
<>
|
|
55
|
+
<QxContext.Provider
|
|
56
|
+
value={{ ...context, sourceId, field: `${field}.resource` }}
|
|
57
|
+
>
|
|
58
|
+
<ResourceSelector
|
|
59
|
+
required
|
|
60
|
+
labelId="quality_control.form.control_properties.ratio.resource"
|
|
61
|
+
/>
|
|
62
|
+
</QxContext.Provider>
|
|
63
|
+
{resource?.id ? (
|
|
64
|
+
<div className="vertical-space">
|
|
65
|
+
<QxContext.Provider
|
|
66
|
+
value={{
|
|
67
|
+
...context,
|
|
68
|
+
sourceId,
|
|
69
|
+
fields,
|
|
70
|
+
field: `${field}.validation`,
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<Clauses labelId="quality_control.form.control_properties.ratio.validation" />
|
|
74
|
+
</QxContext.Provider>
|
|
75
|
+
</div>
|
|
76
|
+
) : null}
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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 TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
6
|
+
import ErrorCount from "../ErrorCount";
|
|
7
|
+
|
|
8
|
+
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
9
|
+
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
__esModule: true,
|
|
13
|
+
...originalModule,
|
|
14
|
+
useDataViews: jest.fn(() => ({
|
|
15
|
+
data: {
|
|
16
|
+
data: [
|
|
17
|
+
{
|
|
18
|
+
id: 4,
|
|
19
|
+
description: "Description",
|
|
20
|
+
name: "StructureView",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
loading: false,
|
|
25
|
+
})),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const dataSet = {
|
|
30
|
+
id: "7",
|
|
31
|
+
name: "dataset1",
|
|
32
|
+
headers: ["campo1", "campo2"],
|
|
33
|
+
};
|
|
34
|
+
const referenceDatasetsMock = {
|
|
35
|
+
request: { query: REFERENCE_DATASETS_HEADERS_QUERY },
|
|
36
|
+
result: { data: { referenceDatasets: [dataSet], loading: false } },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const messages = {
|
|
40
|
+
en: {
|
|
41
|
+
"quality_control.form.control_properties.error_count.errors_resource":
|
|
42
|
+
"Dataset",
|
|
43
|
+
"queryables.resource.type": "Resource type",
|
|
44
|
+
"queryables.resource.type.data_structure": "Data structures",
|
|
45
|
+
"queryables.resource.type.reference_dataset": "Reference datasets",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const renderOpts = {
|
|
50
|
+
mocks: [referenceDatasetsMock],
|
|
51
|
+
fallback: "lazy",
|
|
52
|
+
messages,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const context = {
|
|
56
|
+
functions: [
|
|
57
|
+
{
|
|
58
|
+
name: "eq",
|
|
59
|
+
type: "boolean",
|
|
60
|
+
params: [
|
|
61
|
+
{ name: "arg1", type: "any" },
|
|
62
|
+
{ name: "arg2", type: "any" },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
describe("<ErrorCount />", () => {
|
|
69
|
+
it("matches the latest snapshot", async () => {
|
|
70
|
+
const { container, queryByText } = render(
|
|
71
|
+
<TestFormWrapper context={context}>
|
|
72
|
+
<ErrorCount />
|
|
73
|
+
</TestFormWrapper>,
|
|
74
|
+
renderOpts
|
|
75
|
+
);
|
|
76
|
+
await waitFor(() => {
|
|
77
|
+
expect(queryByText(/lazy/i)).not.toBeInTheDocument();
|
|
78
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
expect(container).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
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 TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
6
|
+
import Ratio from "../Ratio";
|
|
7
|
+
|
|
8
|
+
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
9
|
+
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
__esModule: true,
|
|
13
|
+
...originalModule,
|
|
14
|
+
useDataViews: jest.fn(() => ({
|
|
15
|
+
data: {
|
|
16
|
+
data: [
|
|
17
|
+
{
|
|
18
|
+
id: 4,
|
|
19
|
+
description: "Description",
|
|
20
|
+
name: "StructureView",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
loading: false,
|
|
25
|
+
})),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const dataSet = {
|
|
30
|
+
id: "7",
|
|
31
|
+
name: "dataset1",
|
|
32
|
+
headers: ["campo1", "campo2"],
|
|
33
|
+
};
|
|
34
|
+
const referenceDatasetsMock = {
|
|
35
|
+
request: { query: REFERENCE_DATASETS_HEADERS_QUERY },
|
|
36
|
+
result: { data: { referenceDatasets: [dataSet], loading: false } },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const messages = {
|
|
40
|
+
en: {
|
|
41
|
+
"quality_control.form.control_properties.ratio.resource": "Dataset",
|
|
42
|
+
"queryables.resource.type": "Resource type",
|
|
43
|
+
"queryables.resource.type.data_structure": "Data structures",
|
|
44
|
+
"queryables.resource.type.reference_dataset": "Reference datasets",
|
|
45
|
+
"expression.clause.action.addGroup": "Add group",
|
|
46
|
+
"quality_control.form.control_properties.ratio.validation": "Validation",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const renderOpts = {
|
|
51
|
+
mocks: [referenceDatasetsMock],
|
|
52
|
+
fallback: "lazy",
|
|
53
|
+
messages,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const defaultValues = {
|
|
57
|
+
source_id: "181",
|
|
58
|
+
control_properties: {
|
|
59
|
+
resource: {
|
|
60
|
+
id: 11859650,
|
|
61
|
+
embedded: { fields: [{ id: 11859651 }] },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const context = {
|
|
67
|
+
functions: [
|
|
68
|
+
{
|
|
69
|
+
name: "eq",
|
|
70
|
+
type: "boolean",
|
|
71
|
+
params: [
|
|
72
|
+
{ name: "arg1", type: "any" },
|
|
73
|
+
{ name: "arg2", type: "any" },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
describe("<Ratio />", () => {
|
|
80
|
+
it("matches the latest snapshot", async () => {
|
|
81
|
+
const { container, queryByText } = render(
|
|
82
|
+
<TestFormWrapper context={context} defaultValues={defaultValues}>
|
|
83
|
+
<Ratio />
|
|
84
|
+
</TestFormWrapper>,
|
|
85
|
+
renderOpts
|
|
86
|
+
);
|
|
87
|
+
await waitFor(() => {
|
|
88
|
+
expect(queryByText(/lazy/i)).not.toBeInTheDocument();
|
|
89
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(container).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("matches the latest snapshot when there is not resource", async () => {
|
|
96
|
+
const newDefaultValues = {
|
|
97
|
+
...defaultValues,
|
|
98
|
+
control_properties: {
|
|
99
|
+
resource: {},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const { container, queryByText } = render(
|
|
103
|
+
<TestFormWrapper context={context} defaultValues={newDefaultValues}>
|
|
104
|
+
<Ratio />
|
|
105
|
+
</TestFormWrapper>,
|
|
106
|
+
renderOpts
|
|
107
|
+
);
|
|
108
|
+
await waitFor(() => {
|
|
109
|
+
expect(queryByText(/lazy/i)).not.toBeInTheDocument();
|
|
110
|
+
expect(container.querySelector(".loader")).not.toBeInTheDocument();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(container).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<ErrorCount /> matches the latest snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="required field"
|
|
7
|
+
>
|
|
8
|
+
<label>
|
|
9
|
+
Dataset
|
|
10
|
+
</label>
|
|
11
|
+
<div
|
|
12
|
+
aria-expanded="false"
|
|
13
|
+
class="ui selection dropdown"
|
|
14
|
+
role="listbox"
|
|
15
|
+
tabindex="0"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
aria-atomic="true"
|
|
19
|
+
aria-live="polite"
|
|
20
|
+
class="divider default text"
|
|
21
|
+
role="alert"
|
|
22
|
+
>
|
|
23
|
+
Resource type
|
|
24
|
+
</div>
|
|
25
|
+
<i
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
class="dropdown icon"
|
|
28
|
+
/>
|
|
29
|
+
<div
|
|
30
|
+
class="menu transition"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
aria-checked="false"
|
|
34
|
+
aria-selected="true"
|
|
35
|
+
class="selected item"
|
|
36
|
+
role="option"
|
|
37
|
+
style="pointer-events: all;"
|
|
38
|
+
>
|
|
39
|
+
<span
|
|
40
|
+
class="text"
|
|
41
|
+
>
|
|
42
|
+
Data structures
|
|
43
|
+
</span>
|
|
44
|
+
</div>
|
|
45
|
+
<div
|
|
46
|
+
aria-checked="false"
|
|
47
|
+
aria-selected="false"
|
|
48
|
+
class="item"
|
|
49
|
+
role="option"
|
|
50
|
+
style="pointer-events: all;"
|
|
51
|
+
>
|
|
52
|
+
<span
|
|
53
|
+
class="text"
|
|
54
|
+
>
|
|
55
|
+
Reference datasets
|
|
56
|
+
</span>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
`;
|