@truedat/qx 8.4.9 → 8.5.2
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 +3 -3
- package/src/components/common/expressions/Clauses.js +5 -9
- package/src/components/common/expressions/Condition.js +36 -37
- package/src/components/common/expressions/__tests__/Clauses.spec.js +87 -0
- package/src/components/common/expressions/__tests__/Condition.spec.js +220 -1
- package/src/components/common/expressions/__tests__/__snapshots__/Clauses.spec.js.snap +22 -21
- package/src/components/common/expressions/__tests__/__snapshots__/Condition.spec.js.snap +212 -214
- package/src/components/dataViews/queryableProperties/GroupBy.js +4 -2
- package/src/components/dataViews/queryableProperties/__tests__/GroupBy.spec.js +134 -28
- package/src/components/qualityControls/ControlProperties.js +32 -16
- package/src/components/qualityControls/ControlPropertiesForm.js +3 -3
- package/src/components/qualityControls/ControlPropertiesSummary.js +127 -104
- package/src/components/qualityControls/ControlPropertiesView.js +48 -74
- package/src/components/qualityControls/InformationForm.js +181 -180
- package/src/components/qualityControls/ScoreCriteria.js +0 -4
- package/src/components/qualityControls/ScoreCriteriaView.js +6 -9
- package/src/components/qualityControls/__tests__/ControlProperties.spec.js +47 -16
- package/src/components/qualityControls/__tests__/ControlPropertiesForm.spec.js +100 -0
- package/src/components/qualityControls/__tests__/ControlPropertiesSummary.spec.js +141 -0
- package/src/components/qualityControls/__tests__/ControlPropertiesView.spec.js +102 -11
- package/src/components/qualityControls/__tests__/EditQualityControl.spec.js +27 -3
- package/src/components/qualityControls/__tests__/InformationForm.spec.js +342 -0
- package/src/components/qualityControls/__tests__/NewDraftQualityControl.spec.js +26 -6
- package/src/components/qualityControls/__tests__/NewQualityControl.spec.js +66 -20
- package/src/components/qualityControls/__tests__/QualityBadge.spec.js +30 -3
- package/src/components/qualityControls/__tests__/QualityControlEditor.spec.js +282 -45
- package/src/components/qualityControls/__tests__/ScoreCriteria.spec.js +25 -3
- package/src/components/qualityControls/__tests__/ScoreCriteriaView.spec.js +19 -3
- package/src/components/qualityControls/__tests__/__fixtures__/qualityControlHelper.js +1 -1
- package/src/components/qualityControls/__tests__/__snapshots__/ControlProperties.spec.js.snap +13 -1
- package/src/components/qualityControls/__tests__/__snapshots__/ControlPropertiesView.spec.js.snap +70 -40
- package/src/components/qualityControls/__tests__/__snapshots__/EditQualityControl.spec.js.snap +118 -132
- package/src/components/qualityControls/__tests__/__snapshots__/NewDraftQualityControl.spec.js.snap +118 -132
- package/src/components/qualityControls/__tests__/__snapshots__/NewQualityControl.spec.js.snap +0 -13
- package/src/components/qualityControls/__tests__/__snapshots__/QualityBadge.spec.js.snap +15 -5
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlEditor.spec.js.snap +488 -125
- package/src/components/qualityControls/__tests__/__snapshots__/ScoreCriteria.spec.js.snap +13 -5
- package/src/components/qualityControls/__tests__/qualityByControlMode.spec.js +65 -14
- package/src/components/qualityControls/controlProperties/{Ratio.js → ResourceWithValidation.js} +19 -10
- package/src/components/qualityControls/controlProperties/__tests__/ResourceWithValidation.spec.js +192 -0
- package/src/components/qualityControls/qualityByControlMode.js +6 -30
- package/src/components/qualityControls/scoreCriterias/ErrorCount.js +0 -1
- package/src/components/qualityControls/scoreCriterias/__tests__/ErrorCount.spec.js +4 -4
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/GroupBy.spec.js.snap +0 -604
- package/src/components/qualityControls/controlProperties/Count.js +0 -56
- package/src/components/qualityControls/controlProperties/__tests__/Count.spec.js +0 -66
- package/src/components/qualityControls/controlProperties/__tests__/Ratio.spec.js +0 -95
- package/src/components/qualityControls/controlProperties/__tests__/__snapshots__/Count.spec.js.snap +0 -67
- package/src/components/qualityControls/controlProperties/__tests__/__snapshots__/Ratio.spec.js.snap +0 -161
- package/src/components/qualityControls/scoreCriterias/Count.js +0 -88
- package/src/components/qualityControls/scoreCriterias/__tests__/Count.spec.js +0 -62
- package/src/components/qualityControls/scoreCriterias/__tests__/__snapshots__/Count.spec.js.snap +0 -58
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
-
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
3
|
-
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
4
|
-
import Count from "../Count";
|
|
5
|
-
|
|
6
|
-
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
7
|
-
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
__esModule: true,
|
|
11
|
-
...originalModule,
|
|
12
|
-
useDataViews: jest.fn(() => ({
|
|
13
|
-
data: {
|
|
14
|
-
data: [
|
|
15
|
-
{
|
|
16
|
-
id: 4,
|
|
17
|
-
description: "Description",
|
|
18
|
-
name: "StructureView",
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
loading: false,
|
|
23
|
-
})),
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const dataSet = {
|
|
28
|
-
id: "7",
|
|
29
|
-
name: "dataset1",
|
|
30
|
-
headers: ["campo1", "campo2"],
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const referenceDatasetsMock = {
|
|
34
|
-
request: { query: REFERENCE_DATASETS_HEADERS_QUERY },
|
|
35
|
-
result: { data: { referenceDatasets: [dataSet], loading: false } },
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const renderOpts = {
|
|
39
|
-
mocks: [referenceDatasetsMock],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const context = {
|
|
43
|
-
functions: [
|
|
44
|
-
{
|
|
45
|
-
name: "eq",
|
|
46
|
-
type: "boolean",
|
|
47
|
-
params: [
|
|
48
|
-
{ name: "arg1", type: "any" },
|
|
49
|
-
{ name: "arg2", type: "any" },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
describe("<Count />", () => {
|
|
56
|
-
it("matches the latest snapshot", async () => {
|
|
57
|
-
const rendered = render(
|
|
58
|
-
<TestFormWrapper context={context}>
|
|
59
|
-
<Count />
|
|
60
|
-
</TestFormWrapper>,
|
|
61
|
-
renderOpts
|
|
62
|
-
);
|
|
63
|
-
await waitForLoad(rendered);
|
|
64
|
-
expect(rendered.container).toMatchSnapshot();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
-
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
3
|
-
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
4
|
-
import Ratio from "../Ratio";
|
|
5
|
-
|
|
6
|
-
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
7
|
-
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
__esModule: true,
|
|
11
|
-
...originalModule,
|
|
12
|
-
useDataViews: jest.fn(() => ({
|
|
13
|
-
data: {
|
|
14
|
-
data: [
|
|
15
|
-
{
|
|
16
|
-
id: 4,
|
|
17
|
-
description: "Description",
|
|
18
|
-
name: "StructureView",
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
loading: false,
|
|
23
|
-
})),
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const dataSet = {
|
|
28
|
-
id: "7",
|
|
29
|
-
name: "dataset1",
|
|
30
|
-
headers: ["campo1", "campo2"],
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const referenceDatasetsMock = {
|
|
34
|
-
request: { query: REFERENCE_DATASETS_HEADERS_QUERY },
|
|
35
|
-
result: { data: { referenceDatasets: [dataSet], loading: false } },
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const renderOpts = {
|
|
39
|
-
mocks: [referenceDatasetsMock],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const defaultValues = {
|
|
43
|
-
source_id: "181",
|
|
44
|
-
control_properties: {
|
|
45
|
-
resource: {
|
|
46
|
-
id: 11859650,
|
|
47
|
-
embedded: { fields: [{ id: 11859651 }] },
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const context = {
|
|
53
|
-
functions: [
|
|
54
|
-
{
|
|
55
|
-
name: "eq",
|
|
56
|
-
type: "boolean",
|
|
57
|
-
params: [
|
|
58
|
-
{ name: "arg1", type: "any" },
|
|
59
|
-
{ name: "arg2", type: "any" },
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
describe("<Ratio />", () => {
|
|
66
|
-
it("matches the latest snapshot", async () => {
|
|
67
|
-
const rendered = render(
|
|
68
|
-
<TestFormWrapper context={context} defaultValues={defaultValues}>
|
|
69
|
-
<Ratio />
|
|
70
|
-
</TestFormWrapper>,
|
|
71
|
-
renderOpts
|
|
72
|
-
);
|
|
73
|
-
await waitForLoad(rendered);
|
|
74
|
-
|
|
75
|
-
expect(rendered.container).toMatchSnapshot();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("matches the latest snapshot when there is not resource", async () => {
|
|
79
|
-
const newDefaultValues = {
|
|
80
|
-
...defaultValues,
|
|
81
|
-
control_properties: {
|
|
82
|
-
resource: {},
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
const rendered = render(
|
|
86
|
-
<TestFormWrapper context={context} defaultValues={newDefaultValues}>
|
|
87
|
-
<Ratio />
|
|
88
|
-
</TestFormWrapper>,
|
|
89
|
-
renderOpts
|
|
90
|
-
);
|
|
91
|
-
await waitForLoad(rendered);
|
|
92
|
-
|
|
93
|
-
expect(rendered.container).toMatchSnapshot();
|
|
94
|
-
});
|
|
95
|
-
});
|
package/src/components/qualityControls/controlProperties/__tests__/__snapshots__/Count.spec.js.snap
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<Count /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="required field"
|
|
7
|
-
>
|
|
8
|
-
<label>
|
|
9
|
-
quality_control.form.control_properties.count.errors_resource
|
|
10
|
-
</label>
|
|
11
|
-
<div
|
|
12
|
-
class="disabled field"
|
|
13
|
-
>
|
|
14
|
-
<div
|
|
15
|
-
aria-disabled="true"
|
|
16
|
-
aria-expanded="false"
|
|
17
|
-
class="ui disabled selection dropdown"
|
|
18
|
-
role="listbox"
|
|
19
|
-
tabindex="-1"
|
|
20
|
-
>
|
|
21
|
-
<div
|
|
22
|
-
aria-atomic="true"
|
|
23
|
-
aria-live="polite"
|
|
24
|
-
class="divider default text"
|
|
25
|
-
role="alert"
|
|
26
|
-
>
|
|
27
|
-
queryables.resource.type
|
|
28
|
-
</div>
|
|
29
|
-
<i
|
|
30
|
-
aria-hidden="true"
|
|
31
|
-
class="dropdown icon"
|
|
32
|
-
/>
|
|
33
|
-
<div
|
|
34
|
-
class="menu transition"
|
|
35
|
-
>
|
|
36
|
-
<div
|
|
37
|
-
aria-checked="false"
|
|
38
|
-
aria-selected="true"
|
|
39
|
-
class="selected item"
|
|
40
|
-
role="option"
|
|
41
|
-
style="pointer-events: all;"
|
|
42
|
-
>
|
|
43
|
-
<span
|
|
44
|
-
class="text"
|
|
45
|
-
>
|
|
46
|
-
queryables.resource.type.data_structure
|
|
47
|
-
</span>
|
|
48
|
-
</div>
|
|
49
|
-
<div
|
|
50
|
-
aria-checked="false"
|
|
51
|
-
aria-selected="false"
|
|
52
|
-
class="item"
|
|
53
|
-
role="option"
|
|
54
|
-
style="pointer-events: all;"
|
|
55
|
-
>
|
|
56
|
-
<span
|
|
57
|
-
class="text"
|
|
58
|
-
>
|
|
59
|
-
queryables.resource.type.reference_dataset
|
|
60
|
-
</span>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
`;
|
package/src/components/qualityControls/controlProperties/__tests__/__snapshots__/Ratio.spec.js.snap
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<Ratio /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="required field"
|
|
7
|
-
>
|
|
8
|
-
<label>
|
|
9
|
-
quality_control.form.control_properties.ratio.resource
|
|
10
|
-
</label>
|
|
11
|
-
<div
|
|
12
|
-
class="field"
|
|
13
|
-
>
|
|
14
|
-
<div
|
|
15
|
-
aria-disabled="false"
|
|
16
|
-
aria-expanded="false"
|
|
17
|
-
class="ui selection dropdown"
|
|
18
|
-
role="listbox"
|
|
19
|
-
tabindex="0"
|
|
20
|
-
>
|
|
21
|
-
<div
|
|
22
|
-
aria-atomic="true"
|
|
23
|
-
aria-live="polite"
|
|
24
|
-
class="divider default text"
|
|
25
|
-
role="alert"
|
|
26
|
-
>
|
|
27
|
-
queryables.resource.type
|
|
28
|
-
</div>
|
|
29
|
-
<i
|
|
30
|
-
aria-hidden="true"
|
|
31
|
-
class="dropdown icon"
|
|
32
|
-
/>
|
|
33
|
-
<div
|
|
34
|
-
class="menu transition"
|
|
35
|
-
>
|
|
36
|
-
<div
|
|
37
|
-
aria-checked="false"
|
|
38
|
-
aria-selected="true"
|
|
39
|
-
class="selected item"
|
|
40
|
-
role="option"
|
|
41
|
-
style="pointer-events: all;"
|
|
42
|
-
>
|
|
43
|
-
<span
|
|
44
|
-
class="text"
|
|
45
|
-
>
|
|
46
|
-
queryables.resource.type.data_structure
|
|
47
|
-
</span>
|
|
48
|
-
</div>
|
|
49
|
-
<div
|
|
50
|
-
aria-checked="false"
|
|
51
|
-
aria-selected="false"
|
|
52
|
-
class="item"
|
|
53
|
-
role="option"
|
|
54
|
-
style="pointer-events: all;"
|
|
55
|
-
>
|
|
56
|
-
<span
|
|
57
|
-
class="text"
|
|
58
|
-
>
|
|
59
|
-
queryables.resource.type.reference_dataset
|
|
60
|
-
</span>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
<div
|
|
67
|
-
class="vertical-space"
|
|
68
|
-
>
|
|
69
|
-
<div
|
|
70
|
-
class="field"
|
|
71
|
-
>
|
|
72
|
-
<label>
|
|
73
|
-
quality_control.form.control_properties.ratio.validation
|
|
74
|
-
</label>
|
|
75
|
-
<div
|
|
76
|
-
class="ui horizontal divider"
|
|
77
|
-
>
|
|
78
|
-
<div
|
|
79
|
-
class="ui medium basic buttons"
|
|
80
|
-
>
|
|
81
|
-
<button
|
|
82
|
-
class="ui button"
|
|
83
|
-
>
|
|
84
|
-
<i
|
|
85
|
-
aria-hidden="true"
|
|
86
|
-
class="plus icon"
|
|
87
|
-
/>
|
|
88
|
-
expression.clause.action.addGroup
|
|
89
|
-
</button>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
exports[`<Ratio /> matches the latest snapshot when there is not resource 1`] = `
|
|
98
|
-
<div>
|
|
99
|
-
<div
|
|
100
|
-
class="required field"
|
|
101
|
-
>
|
|
102
|
-
<label>
|
|
103
|
-
quality_control.form.control_properties.ratio.resource
|
|
104
|
-
</label>
|
|
105
|
-
<div
|
|
106
|
-
class="field"
|
|
107
|
-
>
|
|
108
|
-
<div
|
|
109
|
-
aria-disabled="false"
|
|
110
|
-
aria-expanded="false"
|
|
111
|
-
class="ui selection dropdown"
|
|
112
|
-
role="listbox"
|
|
113
|
-
tabindex="0"
|
|
114
|
-
>
|
|
115
|
-
<div
|
|
116
|
-
aria-atomic="true"
|
|
117
|
-
aria-live="polite"
|
|
118
|
-
class="divider default text"
|
|
119
|
-
role="alert"
|
|
120
|
-
>
|
|
121
|
-
queryables.resource.type
|
|
122
|
-
</div>
|
|
123
|
-
<i
|
|
124
|
-
aria-hidden="true"
|
|
125
|
-
class="dropdown icon"
|
|
126
|
-
/>
|
|
127
|
-
<div
|
|
128
|
-
class="menu transition"
|
|
129
|
-
>
|
|
130
|
-
<div
|
|
131
|
-
aria-checked="false"
|
|
132
|
-
aria-selected="true"
|
|
133
|
-
class="selected item"
|
|
134
|
-
role="option"
|
|
135
|
-
style="pointer-events: all;"
|
|
136
|
-
>
|
|
137
|
-
<span
|
|
138
|
-
class="text"
|
|
139
|
-
>
|
|
140
|
-
queryables.resource.type.data_structure
|
|
141
|
-
</span>
|
|
142
|
-
</div>
|
|
143
|
-
<div
|
|
144
|
-
aria-checked="false"
|
|
145
|
-
aria-selected="false"
|
|
146
|
-
class="item"
|
|
147
|
-
role="option"
|
|
148
|
-
style="pointer-events: all;"
|
|
149
|
-
>
|
|
150
|
-
<span
|
|
151
|
-
class="text"
|
|
152
|
-
>
|
|
153
|
-
queryables.resource.type.reference_dataset
|
|
154
|
-
</span>
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
`;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, { use } from "react";
|
|
2
|
-
import { useIntl } from "react-intl";
|
|
3
|
-
import { Controller, useFormContext } from "react-hook-form";
|
|
4
|
-
import { Form } from "semantic-ui-react";
|
|
5
|
-
import QxContext from "@truedat/qx/components/QxContext";
|
|
6
|
-
import { FieldLabel } from "@truedat/core/components";
|
|
7
|
-
import { numberRules } from "@truedat/core/services/formRules";
|
|
8
|
-
|
|
9
|
-
export default function Count() {
|
|
10
|
-
const { formatMessage } = useIntl();
|
|
11
|
-
const { field } = use(QxContext);
|
|
12
|
-
const { control, watch } = useFormContext();
|
|
13
|
-
|
|
14
|
-
const maximumField = `${field}.maximum`;
|
|
15
|
-
const goalField = `${field}.goal`;
|
|
16
|
-
const maximum = watch(maximumField);
|
|
17
|
-
const goal = watch(goalField);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<Controller
|
|
22
|
-
name={goalField}
|
|
23
|
-
control={control}
|
|
24
|
-
rules={numberRules({
|
|
25
|
-
formatMessage,
|
|
26
|
-
minValue: 0,
|
|
27
|
-
maxValue: maximum,
|
|
28
|
-
required: true,
|
|
29
|
-
})}
|
|
30
|
-
render={({
|
|
31
|
-
field: { onBlur, onChange, value },
|
|
32
|
-
fieldState: { error },
|
|
33
|
-
}) => (
|
|
34
|
-
<FieldLabel
|
|
35
|
-
label={formatMessage({
|
|
36
|
-
id: "quality_control.score_criteria.count.goal",
|
|
37
|
-
})}
|
|
38
|
-
required
|
|
39
|
-
error={error?.message}
|
|
40
|
-
>
|
|
41
|
-
<Form.Input
|
|
42
|
-
autoComplete="off"
|
|
43
|
-
placeholder={formatMessage({
|
|
44
|
-
id: "quality_control.score_criteria.count.goal",
|
|
45
|
-
})}
|
|
46
|
-
error={!!error}
|
|
47
|
-
onBlur={onBlur}
|
|
48
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
49
|
-
value={value || ""}
|
|
50
|
-
/>
|
|
51
|
-
</FieldLabel>
|
|
52
|
-
)}
|
|
53
|
-
/>
|
|
54
|
-
<Controller
|
|
55
|
-
name={maximumField}
|
|
56
|
-
control={control}
|
|
57
|
-
rules={numberRules({
|
|
58
|
-
formatMessage,
|
|
59
|
-
minValue: goal,
|
|
60
|
-
required: true,
|
|
61
|
-
})}
|
|
62
|
-
render={({
|
|
63
|
-
field: { onBlur, onChange, value },
|
|
64
|
-
fieldState: { error },
|
|
65
|
-
}) => (
|
|
66
|
-
<FieldLabel
|
|
67
|
-
label={formatMessage({
|
|
68
|
-
id: "quality_control.score_criteria.count.maximum",
|
|
69
|
-
})}
|
|
70
|
-
required
|
|
71
|
-
error={error?.message}
|
|
72
|
-
>
|
|
73
|
-
<Form.Input
|
|
74
|
-
autoComplete="off"
|
|
75
|
-
placeholder={formatMessage({
|
|
76
|
-
id: "quality_control.score_criteria.count.maximum",
|
|
77
|
-
})}
|
|
78
|
-
error={!!error}
|
|
79
|
-
onBlur={onBlur}
|
|
80
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
81
|
-
value={value || ""}
|
|
82
|
-
/>
|
|
83
|
-
</FieldLabel>
|
|
84
|
-
)}
|
|
85
|
-
/>
|
|
86
|
-
</>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
-
import { waitFor } from "@testing-library/react";
|
|
4
|
-
import { fireEvent } from "@testing-library/react";
|
|
5
|
-
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
6
|
-
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
7
|
-
import Count from "../Count";
|
|
8
|
-
|
|
9
|
-
const renderOpts = { messages };
|
|
10
|
-
|
|
11
|
-
describe("<Count />", () => {
|
|
12
|
-
it("matches the latest snapshot", async () => {
|
|
13
|
-
const { container } = render(
|
|
14
|
-
<TestFormWrapper>
|
|
15
|
-
<Count />
|
|
16
|
-
</TestFormWrapper>,
|
|
17
|
-
renderOpts
|
|
18
|
-
);
|
|
19
|
-
expect(container).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should update the goal and maximum fields correctly", async () => {
|
|
23
|
-
const defaultValues = { "testField.goal": "", "testField.maximum": "" };
|
|
24
|
-
|
|
25
|
-
const { getByPlaceholderText, queryByText } = render(
|
|
26
|
-
<TestFormWrapper defaultValues={defaultValues}>
|
|
27
|
-
<Count />
|
|
28
|
-
</TestFormWrapper>,
|
|
29
|
-
renderOpts
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const goalInput = getByPlaceholderText("Goal");
|
|
33
|
-
|
|
34
|
-
const thresholdInput = getByPlaceholderText("Threshold");
|
|
35
|
-
|
|
36
|
-
fireEvent.change(goalInput, { target: { value: "10" } });
|
|
37
|
-
fireEvent.change(thresholdInput, { target: { value: "20" } });
|
|
38
|
-
|
|
39
|
-
await waitFor(() =>
|
|
40
|
-
expect(queryByText(/Must be greater than y/i)).not.toBeInTheDocument()
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("Show alert if thresholdInput is less than goal", async () => {
|
|
45
|
-
const { getByPlaceholderText, queryByText } = render(
|
|
46
|
-
<TestFormWrapper>
|
|
47
|
-
<Count />
|
|
48
|
-
</TestFormWrapper>,
|
|
49
|
-
renderOpts
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const goalInput = getByPlaceholderText("Goal");
|
|
53
|
-
const thresholdInput = getByPlaceholderText("Threshold");
|
|
54
|
-
|
|
55
|
-
fireEvent.change(goalInput, { target: { value: "10" } });
|
|
56
|
-
fireEvent.change(thresholdInput, { target: { value: "1" } });
|
|
57
|
-
|
|
58
|
-
await waitFor(() =>
|
|
59
|
-
expect(queryByText(/Must be greater than 10/i)).toBeInTheDocument()
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
});
|
package/src/components/qualityControls/scoreCriterias/__tests__/__snapshots__/Count.spec.js.snap
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<Count /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="field"
|
|
7
|
-
>
|
|
8
|
-
<label
|
|
9
|
-
class="field-label"
|
|
10
|
-
>
|
|
11
|
-
Goal
|
|
12
|
-
<span>
|
|
13
|
-
*
|
|
14
|
-
</span>
|
|
15
|
-
</label>
|
|
16
|
-
<div
|
|
17
|
-
class="field"
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
class="ui input"
|
|
21
|
-
>
|
|
22
|
-
<input
|
|
23
|
-
autocomplete="off"
|
|
24
|
-
placeholder="Goal"
|
|
25
|
-
type="text"
|
|
26
|
-
value=""
|
|
27
|
-
/>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
<div
|
|
32
|
-
class="field"
|
|
33
|
-
>
|
|
34
|
-
<label
|
|
35
|
-
class="field-label"
|
|
36
|
-
>
|
|
37
|
-
Threshold
|
|
38
|
-
<span>
|
|
39
|
-
*
|
|
40
|
-
</span>
|
|
41
|
-
</label>
|
|
42
|
-
<div
|
|
43
|
-
class="field"
|
|
44
|
-
>
|
|
45
|
-
<div
|
|
46
|
-
class="ui input"
|
|
47
|
-
>
|
|
48
|
-
<input
|
|
49
|
-
autocomplete="off"
|
|
50
|
-
placeholder="Threshold"
|
|
51
|
-
type="text"
|
|
52
|
-
value=""
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
`;
|