@truedat/qx 8.5.1 → 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,11 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { waitFor } from "@testing-library/react";
|
|
1
|
+
import { fireEvent } from "@testing-library/react";
|
|
3
2
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
3
|
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
5
4
|
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
6
5
|
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
7
6
|
import ControlProperties, { defaultForMode } from "../ControlProperties";
|
|
8
7
|
|
|
8
|
+
jest.mock("@truedat/cx/sources/components/SourceSelector", () => ({
|
|
9
|
+
__esModule: true,
|
|
10
|
+
default: ({ onChange, value, disabled }) => (
|
|
11
|
+
<button
|
|
12
|
+
data-testid="mock-source-selector"
|
|
13
|
+
disabled={disabled}
|
|
14
|
+
onClick={() => onChange(null, { value: "999" })}
|
|
15
|
+
type="button"
|
|
16
|
+
>
|
|
17
|
+
{value}
|
|
18
|
+
</button>
|
|
19
|
+
),
|
|
20
|
+
}));
|
|
21
|
+
|
|
9
22
|
const dataSet = {
|
|
10
23
|
id: "7",
|
|
11
24
|
name: "dataset1",
|
|
@@ -39,43 +52,61 @@ describe("<ControlProperties />", () => {
|
|
|
39
52
|
<TestFormWrapper defaultValues={defaultValues}>
|
|
40
53
|
<ControlProperties />
|
|
41
54
|
</TestFormWrapper>,
|
|
42
|
-
renderOpts
|
|
55
|
+
renderOpts,
|
|
43
56
|
);
|
|
44
57
|
await waitForLoad(rendered);
|
|
45
58
|
expect(rendered.container).toMatchSnapshot();
|
|
46
59
|
});
|
|
47
60
|
|
|
48
|
-
it("matches the latest snapshot with
|
|
49
|
-
const
|
|
61
|
+
it("matches the latest snapshot with error_count", async () => {
|
|
62
|
+
const errorCountDefaultValues = {
|
|
50
63
|
...defaultValues,
|
|
51
|
-
control_mode: "
|
|
64
|
+
control_mode: "error_count",
|
|
52
65
|
};
|
|
53
66
|
const rendered = render(
|
|
54
|
-
<TestFormWrapper defaultValues={
|
|
67
|
+
<TestFormWrapper defaultValues={errorCountDefaultValues}>
|
|
55
68
|
<ControlProperties />
|
|
56
69
|
</TestFormWrapper>,
|
|
57
|
-
renderOpts
|
|
70
|
+
renderOpts,
|
|
58
71
|
);
|
|
59
72
|
await waitForLoad(rendered);
|
|
60
73
|
expect(rendered.container).toMatchSnapshot();
|
|
61
74
|
});
|
|
75
|
+
|
|
76
|
+
it("updates source field when source selector changes", async () => {
|
|
77
|
+
const rendered = render(
|
|
78
|
+
<TestFormWrapper defaultValues={defaultValues}>
|
|
79
|
+
<ControlProperties />
|
|
80
|
+
</TestFormWrapper>,
|
|
81
|
+
renderOpts,
|
|
82
|
+
);
|
|
83
|
+
await waitForLoad(rendered);
|
|
84
|
+
expect(rendered.getByTestId("mock-source-selector")).toHaveTextContent("181");
|
|
85
|
+
fireEvent.click(rendered.getByTestId("mock-source-selector"));
|
|
86
|
+
expect(rendered.getByTestId("mock-source-selector")).toHaveTextContent("999");
|
|
87
|
+
});
|
|
62
88
|
});
|
|
63
89
|
|
|
90
|
+
const defaultValidation = [
|
|
91
|
+
{
|
|
92
|
+
expressions: [{ shape: "function", value: { isCondition: true } }],
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
|
|
64
96
|
describe("defaultForMode", () => {
|
|
65
|
-
it("returns correct default for '
|
|
66
|
-
const result = defaultForMode("
|
|
67
|
-
expect(result).toEqual({
|
|
97
|
+
it("returns correct default for 'error_count' control mode", () => {
|
|
98
|
+
const result = defaultForMode("error_count");
|
|
99
|
+
expect(result).toEqual({
|
|
100
|
+
errors_resource: null,
|
|
101
|
+
validation: defaultValidation,
|
|
102
|
+
});
|
|
68
103
|
});
|
|
69
104
|
|
|
70
105
|
it("returns correct default for other control modes", () => {
|
|
71
106
|
const result = defaultForMode("some_other_mode");
|
|
72
107
|
expect(result).toEqual({
|
|
73
108
|
resource: null,
|
|
74
|
-
validation:
|
|
75
|
-
{
|
|
76
|
-
expressions: [{ shape: "function", value: { isCondition: true } }],
|
|
77
|
-
},
|
|
78
|
-
],
|
|
109
|
+
validation: defaultValidation,
|
|
79
110
|
});
|
|
80
111
|
});
|
|
81
112
|
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useFormContext } from "react-hook-form";
|
|
2
|
+
import { render } from "@truedat/test/render";
|
|
3
|
+
import ControlPropertiesForm from "../ControlPropertiesForm";
|
|
4
|
+
|
|
5
|
+
jest.mock("react-hook-form", () => ({
|
|
6
|
+
useFormContext: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock("../ControlProperties", () => {
|
|
10
|
+
const MockControlProperties = ({ isModification }) => (
|
|
11
|
+
<div>{`control-properties-${isModification}`}</div>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
return MockControlProperties;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const fieldNames = [
|
|
18
|
+
"source_id",
|
|
19
|
+
"control_properties.resource",
|
|
20
|
+
"control_properties.errors_resource",
|
|
21
|
+
"control_properties.validation",
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
describe("<ControlPropertiesForm />", () => {
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
jest.clearAllMocks();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("renders control properties when control mode exists", () => {
|
|
30
|
+
useFormContext.mockReturnValue({
|
|
31
|
+
watch: () => ({ control_mode: "error_count" }),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const rendered = render(
|
|
35
|
+
<ControlPropertiesForm
|
|
36
|
+
isModification
|
|
37
|
+
setStepInformation={jest.fn()}
|
|
38
|
+
stepInformation={{}}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(
|
|
43
|
+
rendered.queryByText(/control-properties-true/i)
|
|
44
|
+
).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("does not render control properties when control mode is missing", () => {
|
|
48
|
+
useFormContext.mockReturnValue({
|
|
49
|
+
watch: () => ({ control_mode: null }),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const rendered = render(
|
|
53
|
+
<ControlPropertiesForm
|
|
54
|
+
isModification={false}
|
|
55
|
+
setStepInformation={jest.fn()}
|
|
56
|
+
stepInformation={{}}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect(
|
|
61
|
+
rendered.queryByText(/control-properties-false/i)
|
|
62
|
+
).not.toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("updates step information when field names differ", () => {
|
|
66
|
+
const setStepInformation = jest.fn();
|
|
67
|
+
useFormContext.mockReturnValue({
|
|
68
|
+
watch: () => ({ control_mode: "deviation" }),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
render(
|
|
72
|
+
<ControlPropertiesForm
|
|
73
|
+
isModification={false}
|
|
74
|
+
setStepInformation={setStepInformation}
|
|
75
|
+
stepInformation={{ fieldNames: ["source_id"] }}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(setStepInformation).toHaveBeenCalledWith(1, {
|
|
80
|
+
fieldNames,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("does not update step information when field names are equal", () => {
|
|
85
|
+
const setStepInformation = jest.fn();
|
|
86
|
+
useFormContext.mockReturnValue({
|
|
87
|
+
watch: () => ({ control_mode: "percentage" }),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
render(
|
|
91
|
+
<ControlPropertiesForm
|
|
92
|
+
isModification
|
|
93
|
+
setStepInformation={setStepInformation}
|
|
94
|
+
stepInformation={{ fieldNames }}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(setStepInformation).not.toHaveBeenCalled();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { render } from "@truedat/test/render";
|
|
2
|
+
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
3
|
+
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
4
|
+
import ControlPropertiesSummary from "../ControlPropertiesSummary";
|
|
5
|
+
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
6
|
+
|
|
7
|
+
jest.mock("@truedat/qx/components/common/ClauseViewer", () =>
|
|
8
|
+
jest.fn(({ clause }) => (
|
|
9
|
+
<div>{`clause-viewer-${Array.isArray(clause) ? clause.length : 0}`}</div>
|
|
10
|
+
))
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const renderOpts = { messages };
|
|
14
|
+
|
|
15
|
+
describe("<ControlPropertiesSummary />", () => {
|
|
16
|
+
it("does not render summary when there are no resources ids", () => {
|
|
17
|
+
const rendered = render(
|
|
18
|
+
<TestFormWrapper>
|
|
19
|
+
<ControlPropertiesSummary
|
|
20
|
+
qualityControl={{
|
|
21
|
+
...qualityControlData(),
|
|
22
|
+
control_properties: { resource: null, errors_resource: null },
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
</TestFormWrapper>,
|
|
26
|
+
renderOpts
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(rendered.queryByText(/implementation/i)).not.toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("renders ratio summary for percentage mode", () => {
|
|
33
|
+
const rendered = render(
|
|
34
|
+
<TestFormWrapper>
|
|
35
|
+
<ControlPropertiesSummary
|
|
36
|
+
qualityControl={qualityControlData({ control_mode: "percentage" })}
|
|
37
|
+
/>
|
|
38
|
+
</TestFormWrapper>,
|
|
39
|
+
renderOpts
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(rendered.getByText(/implementation/i)).toBeInTheDocument();
|
|
43
|
+
expect(rendered.getByText(/data structure/i)).toBeInTheDocument();
|
|
44
|
+
expect(rendered.getByText(/dataset/i)).toBeInTheDocument();
|
|
45
|
+
expect(rendered.getByText(/accounting_rules/i)).toBeInTheDocument();
|
|
46
|
+
expect(rendered.getByText(/validation/i)).toBeInTheDocument();
|
|
47
|
+
expect(rendered.getByText(/clause-viewer-1/i)).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("renders count summary for error_count mode", () => {
|
|
51
|
+
const rendered = render(
|
|
52
|
+
<TestFormWrapper>
|
|
53
|
+
<ControlPropertiesSummary
|
|
54
|
+
qualityControl={qualityControlData({
|
|
55
|
+
control_mode: "error_count",
|
|
56
|
+
control_properties: {
|
|
57
|
+
errors_resource: {
|
|
58
|
+
id: 999,
|
|
59
|
+
type: "data_structure",
|
|
60
|
+
embedded: { name: "ERRORS_DS" },
|
|
61
|
+
},
|
|
62
|
+
validation: [{ expressions: [] }],
|
|
63
|
+
},
|
|
64
|
+
})}
|
|
65
|
+
/>
|
|
66
|
+
</TestFormWrapper>,
|
|
67
|
+
renderOpts
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(rendered.getByText(/dataset/i)).toBeInTheDocument();
|
|
71
|
+
expect(rendered.getByText(/data structure/i)).toBeInTheDocument();
|
|
72
|
+
expect(rendered.getByText(/errors_ds/i)).toBeInTheDocument();
|
|
73
|
+
expect(rendered.getByText(/validation/i)).toBeInTheDocument();
|
|
74
|
+
expect(rendered.getByText(/clause-viewer-1/i)).toBeInTheDocument();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("renders empty ratio labels when resource and validation are missing", () => {
|
|
78
|
+
const rendered = render(
|
|
79
|
+
<TestFormWrapper>
|
|
80
|
+
<ControlPropertiesSummary
|
|
81
|
+
qualityControl={qualityControlData({
|
|
82
|
+
control_mode: "percentage",
|
|
83
|
+
control_properties: {
|
|
84
|
+
resource: null,
|
|
85
|
+
errors_resource: {
|
|
86
|
+
id: 123,
|
|
87
|
+
type: "data_structure",
|
|
88
|
+
embedded: { name: "FALLBACK_DS" },
|
|
89
|
+
},
|
|
90
|
+
validation: null,
|
|
91
|
+
},
|
|
92
|
+
})}
|
|
93
|
+
/>
|
|
94
|
+
</TestFormWrapper>,
|
|
95
|
+
renderOpts
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(rendered.getByText(/empty resource/i)).toBeInTheDocument();
|
|
99
|
+
expect(rendered.getByText(/empty validation/i)).toBeInTheDocument();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("renders empty count labels when errors resource and validation are missing", () => {
|
|
103
|
+
const rendered = render(
|
|
104
|
+
<TestFormWrapper>
|
|
105
|
+
<ControlPropertiesSummary
|
|
106
|
+
qualityControl={qualityControlData({
|
|
107
|
+
control_mode: "error_count",
|
|
108
|
+
control_properties: {
|
|
109
|
+
resource: {
|
|
110
|
+
id: 321,
|
|
111
|
+
type: "data_structure",
|
|
112
|
+
embedded: { name: "FALLBACK_DS" },
|
|
113
|
+
},
|
|
114
|
+
errors_resource: null,
|
|
115
|
+
validation: null,
|
|
116
|
+
},
|
|
117
|
+
})}
|
|
118
|
+
/>
|
|
119
|
+
</TestFormWrapper>,
|
|
120
|
+
renderOpts
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
expect(rendered.getByText(/empty dataset/i)).toBeInTheDocument();
|
|
124
|
+
expect(rendered.getByText(/empty validation/i)).toBeInTheDocument();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("renders empty content when mode is unsupported", () => {
|
|
128
|
+
const rendered = render(
|
|
129
|
+
<TestFormWrapper>
|
|
130
|
+
<ControlPropertiesSummary
|
|
131
|
+
qualityControl={qualityControlData({
|
|
132
|
+
control_mode: "unsupported_mode",
|
|
133
|
+
})}
|
|
134
|
+
/>
|
|
135
|
+
</TestFormWrapper>,
|
|
136
|
+
renderOpts
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(rendered.getByText(/empty control properties/i)).toBeInTheDocument();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -1,28 +1,43 @@
|
|
|
1
|
-
import { render } from "@truedat/test/render";
|
|
1
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
|
+
import { Loading } from "@truedat/core/components";
|
|
2
3
|
import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
|
|
3
4
|
import { messages } from "@truedat/qx/components/__tests__/__fixtures__/helper";
|
|
5
|
+
import * as dataViewsHooks from "@truedat/qx/hooks/useDataViews";
|
|
4
6
|
import ControlPropertiesView from "../ControlPropertiesView";
|
|
5
7
|
import { qualityControlData } from "./__fixtures__/qualityControlHelper";
|
|
6
8
|
|
|
9
|
+
jest.mock("@truedat/core/components", () => ({
|
|
10
|
+
Loading: jest.fn(() => <div>loading-mock</div>),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
jest.mock("@truedat/qx/components/dataViews/DataViewSummary", () =>
|
|
14
|
+
jest.fn(() => <div>data-view-summary-mock</div>),
|
|
15
|
+
);
|
|
16
|
+
|
|
7
17
|
const renderOpts = { messages };
|
|
8
18
|
|
|
9
19
|
const qualityControl = qualityControlData();
|
|
20
|
+
const useDataViewFetchMock = jest.spyOn(dataViewsHooks, "useDataViewFetch");
|
|
10
21
|
|
|
11
22
|
describe("<ControlPropertiesView />", () => {
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
useDataViewFetchMock.mockReturnValue({ dataView: null, loading: false });
|
|
25
|
+
});
|
|
26
|
+
|
|
12
27
|
it("matches the latest snapshot for ratio", async () => {
|
|
13
28
|
const { container } = render(
|
|
14
29
|
<TestFormWrapper>
|
|
15
30
|
<ControlPropertiesView qualityControl={qualityControl} />
|
|
16
31
|
</TestFormWrapper>,
|
|
17
|
-
renderOpts
|
|
32
|
+
renderOpts,
|
|
18
33
|
);
|
|
19
34
|
expect(container).toMatchSnapshot();
|
|
20
35
|
});
|
|
21
36
|
|
|
22
|
-
it("matches the latest snapshot for
|
|
23
|
-
const
|
|
37
|
+
it("matches the latest snapshot for error_count", async () => {
|
|
38
|
+
const errorCountQualityControl = {
|
|
24
39
|
...qualityControl,
|
|
25
|
-
control_mode: "
|
|
40
|
+
control_mode: "error_count",
|
|
26
41
|
control_properties: {
|
|
27
42
|
errors_resource: {
|
|
28
43
|
id: 11859650,
|
|
@@ -32,9 +47,9 @@ describe("<ControlPropertiesView />", () => {
|
|
|
32
47
|
};
|
|
33
48
|
const { container } = render(
|
|
34
49
|
<TestFormWrapper>
|
|
35
|
-
<ControlPropertiesView qualityControl={
|
|
50
|
+
<ControlPropertiesView qualityControl={errorCountQualityControl} />
|
|
36
51
|
</TestFormWrapper>,
|
|
37
|
-
renderOpts
|
|
52
|
+
renderOpts,
|
|
38
53
|
);
|
|
39
54
|
expect(container).toMatchSnapshot();
|
|
40
55
|
});
|
|
@@ -46,7 +61,7 @@ describe("<ControlPropertiesView />", () => {
|
|
|
46
61
|
qualityControl={{ ...qualityControl, control_properties: null }}
|
|
47
62
|
/>
|
|
48
63
|
</TestFormWrapper>,
|
|
49
|
-
renderOpts
|
|
64
|
+
renderOpts,
|
|
50
65
|
);
|
|
51
66
|
expect(container).toMatchSnapshot();
|
|
52
67
|
});
|
|
@@ -57,12 +72,12 @@ describe("<ControlPropertiesView />", () => {
|
|
|
57
72
|
<ControlPropertiesView
|
|
58
73
|
qualityControl={{
|
|
59
74
|
...qualityControl,
|
|
60
|
-
control_mode: "
|
|
75
|
+
control_mode: "error_count",
|
|
61
76
|
control_properties: { errors_resource: null },
|
|
62
77
|
}}
|
|
63
78
|
/>
|
|
64
79
|
</TestFormWrapper>,
|
|
65
|
-
renderOpts
|
|
80
|
+
renderOpts,
|
|
66
81
|
);
|
|
67
82
|
expect(container).toMatchSnapshot();
|
|
68
83
|
});
|
|
@@ -78,8 +93,84 @@ describe("<ControlPropertiesView />", () => {
|
|
|
78
93
|
}}
|
|
79
94
|
/>
|
|
80
95
|
</TestFormWrapper>,
|
|
81
|
-
renderOpts
|
|
96
|
+
renderOpts,
|
|
82
97
|
);
|
|
83
98
|
expect(container).toMatchSnapshot();
|
|
84
99
|
});
|
|
100
|
+
|
|
101
|
+
it("renders loading while data view is being fetched", async () => {
|
|
102
|
+
useDataViewFetchMock.mockReturnValueOnce({ dataView: null, loading: true });
|
|
103
|
+
const dataViewQualityControl = qualityControlData({
|
|
104
|
+
control_properties: {
|
|
105
|
+
...qualityControl.control_properties,
|
|
106
|
+
resource: {
|
|
107
|
+
id: 123,
|
|
108
|
+
type: "data_view",
|
|
109
|
+
embedded: { name: "MY_DV" },
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const rendered = render(
|
|
115
|
+
<TestFormWrapper>
|
|
116
|
+
<ControlPropertiesView qualityControl={dataViewQualityControl} />
|
|
117
|
+
</TestFormWrapper>,
|
|
118
|
+
renderOpts,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(Loading).toHaveBeenCalled();
|
|
122
|
+
expect(rendered.getByText(/loading-mock/i)).toBeInTheDocument();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("renders data view summary when fetch returns data", async () => {
|
|
126
|
+
useDataViewFetchMock.mockReturnValueOnce({
|
|
127
|
+
dataView: { queryables: [] },
|
|
128
|
+
loading: false,
|
|
129
|
+
});
|
|
130
|
+
const dataViewQualityControl = qualityControlData({
|
|
131
|
+
control_properties: {
|
|
132
|
+
...qualityControl.control_properties,
|
|
133
|
+
resource: {
|
|
134
|
+
id: 456,
|
|
135
|
+
type: "data_view",
|
|
136
|
+
embedded: { name: "MY_DV" },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const rendered = render(
|
|
142
|
+
<TestFormWrapper>
|
|
143
|
+
<ControlPropertiesView qualityControl={dataViewQualityControl} />
|
|
144
|
+
</TestFormWrapper>,
|
|
145
|
+
renderOpts,
|
|
146
|
+
);
|
|
147
|
+
await waitForLoad(rendered);
|
|
148
|
+
|
|
149
|
+
expect(rendered.getByText(/data-view-summary-mock/i)).toBeInTheDocument();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("does not render loading or summary when fetch returns no data", async () => {
|
|
153
|
+
useDataViewFetchMock.mockReturnValueOnce({ dataView: null, loading: false });
|
|
154
|
+
const dataViewQualityControl = qualityControlData({
|
|
155
|
+
control_properties: {
|
|
156
|
+
...qualityControl.control_properties,
|
|
157
|
+
resource: {
|
|
158
|
+
id: 789,
|
|
159
|
+
type: "data_view",
|
|
160
|
+
embedded: { name: "MY_DV" },
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const rendered = render(
|
|
166
|
+
<TestFormWrapper>
|
|
167
|
+
<ControlPropertiesView qualityControl={dataViewQualityControl} />
|
|
168
|
+
</TestFormWrapper>,
|
|
169
|
+
renderOpts,
|
|
170
|
+
);
|
|
171
|
+
await waitForLoad(rendered);
|
|
172
|
+
|
|
173
|
+
expect(rendered.queryByText(/loading-mock/i)).not.toBeInTheDocument();
|
|
174
|
+
expect(rendered.queryByText(/data-view-summary-mock/i)).not.toBeInTheDocument();
|
|
175
|
+
});
|
|
85
176
|
});
|
|
@@ -3,6 +3,7 @@ import { waitFor } from "@testing-library/react";
|
|
|
3
3
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
4
|
import { singleTemplateMock, templateByNameMock } from "@truedat/test/mocks";
|
|
5
5
|
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
6
|
+
import { linkTo } from "@truedat/core/routes";
|
|
6
7
|
import { SOURCE_OPTIONS_QUERY } from "@truedat/cx/sources/api/queries";
|
|
7
8
|
import { REFERENCE_DATASETS_HEADERS_QUERY } from "@truedat/dd/api/queries";
|
|
8
9
|
import {
|
|
@@ -174,7 +175,9 @@ describe("<EditQualityControl />", () => {
|
|
|
174
175
|
});
|
|
175
176
|
|
|
176
177
|
// Save button only appears on step 2 (last step)
|
|
177
|
-
expect(
|
|
178
|
+
expect(
|
|
179
|
+
rendered.queryByRole("button", { name: /save/i })
|
|
180
|
+
).not.toBeInTheDocument();
|
|
178
181
|
|
|
179
182
|
const user = userEvent.setup({ delay: null });
|
|
180
183
|
// Fill step 0 (Information) - make a change to enable save later
|
|
@@ -183,13 +186,17 @@ describe("<EditQualityControl />", () => {
|
|
|
183
186
|
// Navigate to step 1
|
|
184
187
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
185
188
|
await waitFor(() =>
|
|
186
|
-
expect(
|
|
189
|
+
expect(
|
|
190
|
+
rendered.getByRole("button", { name: /back/i })
|
|
191
|
+
).toBeInTheDocument()
|
|
187
192
|
);
|
|
188
193
|
|
|
189
194
|
// Navigate to step 2
|
|
190
195
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
191
196
|
await waitFor(() =>
|
|
192
|
-
expect(
|
|
197
|
+
expect(
|
|
198
|
+
rendered.getByRole("button", { name: /save/i })
|
|
199
|
+
).toBeInTheDocument()
|
|
193
200
|
);
|
|
194
201
|
|
|
195
202
|
await waitFor(() =>
|
|
@@ -205,5 +212,22 @@ describe("<EditQualityControl />", () => {
|
|
|
205
212
|
await waitFor(() =>
|
|
206
213
|
expect(trigger).toHaveBeenCalledWith({ quality_control: qualityControl })
|
|
207
214
|
);
|
|
215
|
+
expect(mockNavigate).toHaveBeenCalledWith(
|
|
216
|
+
linkTo.QUALITY_CONTROL({ id: "9", version: "1" })
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("shows loading state while update is mutating", async () => {
|
|
221
|
+
useQualityControlUpdateDraft.mockImplementationOnce(() => ({
|
|
222
|
+
trigger: jest.fn(() => Promise.resolve({ data: { data: {} } })),
|
|
223
|
+
isMutating: true,
|
|
224
|
+
}));
|
|
225
|
+
|
|
226
|
+
const rendered = render(<EditQualityControl />, renderOpts);
|
|
227
|
+
await waitFor(() =>
|
|
228
|
+
expect(
|
|
229
|
+
rendered.container.querySelector(".ui.loading.segment")
|
|
230
|
+
).toBeInTheDocument()
|
|
231
|
+
);
|
|
208
232
|
});
|
|
209
233
|
});
|