@truedat/qx 7.6.0 → 7.6.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 +3 -3
- package/src/components/index.js +2 -1
- package/src/components/qualityControls/QualityControlEditor.js +2 -0
- package/src/components/qualityControls/QualityControlRoutes.js +13 -4
- package/src/components/qualityControls/QualityControlScores.js +141 -91
- package/src/components/qualityControls/ScoreCriteriaView.js +2 -2
- package/src/components/qualityControls/__tests__/NewQualityControl.spec.js +12 -4
- package/src/components/qualityControls/__tests__/QualityBadge.spec.js +3 -3
- package/src/components/qualityControls/__tests__/QualityControlEditor.spec.js +42 -14
- package/src/components/qualityControls/__tests__/QualityControlRoutes.spec.js +128 -0
- package/src/components/qualityControls/__tests__/QualityControlScores.spec.js +154 -48
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlRoutes.spec.js.snap +27 -0
- package/src/components/qualityControls/__tests__/__snapshots__/QualityControlScores.spec.js.snap +71 -0
- package/src/components/qualityControls/qualityByControlMode.js +6 -6
- package/src/components/qualityControls/scoreCriterias/Count.js +2 -2
- package/src/components/qualityControls/scoreCriterias/ErrorCount.js +2 -2
- package/src/components/qualityControls/scoreCriterias/__tests__/ErrorCount.spec.js +7 -7
- package/src/components/qualityControls/scoreCriterias/__tests__/__snapshots__/ErrorCount.spec.js.snap +3 -0
- package/src/components/scores/ScoreContext.js +64 -2
- package/src/components/scores/ScoreDetails.js +13 -2
- package/src/components/scores/ScoreGroupsTable.js +55 -50
- package/src/components/scores/ScorePagination.js +28 -0
- package/src/components/scores/__tests__/ScoreContext.spec.js +64 -0
- package/src/components/scores/__tests__/ScorePagination.spec.js +66 -0
- package/src/components/scores/__tests__/__snapshots__/ScoreDetails.spec.js.snap +13 -0
- package/src/components/scores/__tests__/__snapshots__/ScorePagination.spec.js.snap +220 -0
- package/src/components/scores/index.js +4 -2
- package/src/components/selectors/__tests__/__snapshots__/getMyScoreGroupsColumns.spec.js.snap +54 -0
- package/src/components/selectors/__tests__/__snapshots__/getQualityControlScoresColumns.spec.js.snap +34 -0
- package/src/components/selectors/__tests__/getMyScoreGroupsColumns.spec.js +59 -0
- package/src/components/selectors/__tests__/getQualityControlScoresColumns.spec.js +43 -0
- package/src/components/selectors/getMyScoreGroupsColumns.js +50 -0
- package/src/components/{qualityControls/qualityControlScoresColumns.js → selectors/getQualityControlScoresColumns.js} +19 -4
- package/src/components/selectors/index.js +2 -0
- package/src/hooks/useScores.js +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/qx",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.1",
|
|
4
4
|
"description": "Truedat Web Quality Experience package",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@testing-library/jest-dom": "^6.6.3",
|
|
54
54
|
"@testing-library/react": "^16.3.0",
|
|
55
55
|
"@testing-library/user-event": "^14.6.1",
|
|
56
|
-
"@truedat/test": "7.6.
|
|
56
|
+
"@truedat/test": "7.6.1",
|
|
57
57
|
"identity-obj-proxy": "^3.0.0",
|
|
58
58
|
"jest": "^29.7.0",
|
|
59
59
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"semantic-ui-react": "^3.0.0-beta.2",
|
|
87
87
|
"swr": "^2.3.3"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "da40cd48fee6be123cdb2fad700e16cdf9f69319"
|
|
90
90
|
}
|
package/src/components/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import ControlProperties, {
|
|
|
20
20
|
const SelectableDynamicForm = lazy(
|
|
21
21
|
() => import("@truedat/df/components/SelectableDynamicForm")
|
|
22
22
|
);
|
|
23
|
+
|
|
23
24
|
const SourceSelector = lazy(
|
|
24
25
|
() => import("@truedat/cx/sources/components/SourceSelector")
|
|
25
26
|
);
|
|
@@ -63,6 +64,7 @@ export default function QualityControlEditor({
|
|
|
63
64
|
shouldValidate: true,
|
|
64
65
|
shouldDirty: true,
|
|
65
66
|
});
|
|
67
|
+
|
|
66
68
|
setValidDfContent(_.isEmpty(valid));
|
|
67
69
|
};
|
|
68
70
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Route, Routes } from "react-router";
|
|
1
|
+
import { Route, Routes, useParams } from "react-router";
|
|
2
2
|
import {
|
|
3
3
|
QUALITY_CONTROLS_DEPRECATED,
|
|
4
4
|
QUALITY_CONTROLS_DRAFTS,
|
|
@@ -23,6 +23,17 @@ import QualityControlScores from "./QualityControlScores";
|
|
|
23
23
|
import NewQualityControl from "./NewQualityControl";
|
|
24
24
|
import EditQualityControl from "./EditQualityControl";
|
|
25
25
|
import NewDraftQualityControl from "./NewDraftQualityControl";
|
|
26
|
+
import { ScoreContextProvider } from "../scores/ScoreContext";
|
|
27
|
+
|
|
28
|
+
const LoaderQualityControlScores = () => {
|
|
29
|
+
const { id } = useParams();
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<ScoreContextProvider qualityControlId={id}>
|
|
33
|
+
<QualityControlScores />
|
|
34
|
+
</ScoreContextProvider>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
26
37
|
|
|
27
38
|
export default function QualityControlRoutes() {
|
|
28
39
|
const searchProps = {
|
|
@@ -80,10 +91,8 @@ export default function QualityControlRoutes() {
|
|
|
80
91
|
|
|
81
92
|
<Route path=":id/version/:version" element={<QualityControlHeader />}>
|
|
82
93
|
<Route index element={<QualityControl />} />
|
|
83
|
-
|
|
84
94
|
<Route path="history" element={<QualityControlHistory />} />
|
|
85
|
-
|
|
86
|
-
<Route path="scores" element={<QualityControlScores />} />
|
|
95
|
+
<Route path="scores" element={<LoaderQualityControlScores />} />
|
|
87
96
|
</Route>
|
|
88
97
|
</Routes>
|
|
89
98
|
);
|
|
@@ -1,37 +1,72 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import { Fragment,
|
|
2
|
+
import { Fragment, use } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { connect } from "react-redux";
|
|
3
5
|
import { useIntl } from "react-intl";
|
|
4
6
|
import { useParams, Link } from "react-router";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
+
import {
|
|
8
|
+
Button,
|
|
9
|
+
Divider,
|
|
10
|
+
Icon,
|
|
11
|
+
Label,
|
|
12
|
+
Message,
|
|
13
|
+
Table,
|
|
14
|
+
} from "semantic-ui-react";
|
|
15
|
+
import { ConfirmModal, DateTime, Loading } from "@truedat/core/components";
|
|
7
16
|
import { columnDecorator } from "@truedat/core/services";
|
|
8
17
|
import { linkTo } from "@truedat/core/routes";
|
|
9
|
-
import {
|
|
18
|
+
import { getQualityControlScoresColumns } from "@truedat/qx/components/selectors/getQualityControlScoresColumns";
|
|
19
|
+
import { useScoreContext } from "../scores/ScoreContext";
|
|
20
|
+
import ScorePagination from "../scores/ScorePagination";
|
|
10
21
|
import QxContext from "../QxContext";
|
|
11
|
-
import columns from "./qualityControlScoresColumns";
|
|
12
22
|
|
|
13
23
|
const VALID_DELETE_STATUSES = ["PENDING", "SUCCEEDED", "FAILED"];
|
|
14
24
|
|
|
15
|
-
export
|
|
25
|
+
export function LastExecutionResult({ lastExecutionResult }) {
|
|
26
|
+
const { formatMessage, locale } = useIntl();
|
|
27
|
+
|
|
28
|
+
return lastExecutionResult?.status === "FAILED" ? (
|
|
29
|
+
<Message negative style={{ marginTop: "14px" }}>
|
|
30
|
+
<Message.Header content={formatMessage({ id: "quality.error" })} />
|
|
31
|
+
<Divider />
|
|
32
|
+
<span
|
|
33
|
+
style={{
|
|
34
|
+
position: "absolute",
|
|
35
|
+
top: "14px",
|
|
36
|
+
right: "21px",
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<DateTime
|
|
40
|
+
value={lastExecutionResult.execution_timestamp}
|
|
41
|
+
locale={locale}
|
|
42
|
+
/>
|
|
43
|
+
</span>
|
|
44
|
+
<p style={{ whiteSpace: "pre-wrap" }}>
|
|
45
|
+
{lastExecutionResult.details?.error}
|
|
46
|
+
</p>
|
|
47
|
+
<p style={{ whiteSpace: "pre-wrap" }}>
|
|
48
|
+
{lastExecutionResult.latest_event_message}
|
|
49
|
+
</p>
|
|
50
|
+
</Message>
|
|
51
|
+
) : null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function QualityControlScores({ columns }) {
|
|
16
55
|
const { id } = useParams();
|
|
17
56
|
const { formatMessage } = useIntl();
|
|
18
|
-
|
|
19
|
-
data,
|
|
20
|
-
loading: loadingQualityScores,
|
|
21
|
-
mutate,
|
|
22
|
-
} = useQualityControlScores(id);
|
|
23
|
-
const { trigger: deleteScore, loading: deletingScore } = useScoreDelete();
|
|
57
|
+
|
|
24
58
|
const {
|
|
25
59
|
qualityControl,
|
|
26
60
|
actions,
|
|
27
61
|
loading: loadingQualityControl,
|
|
28
|
-
} =
|
|
62
|
+
} = use(QxContext);
|
|
29
63
|
|
|
30
|
-
const
|
|
64
|
+
const scoreContext = useScoreContext();
|
|
65
|
+
const { scores, lastExecutionResult, loadingQualityScores, handleDelete } =
|
|
66
|
+
scoreContext;
|
|
31
67
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const scores = data?.data;
|
|
68
|
+
const canDeleteScore = _.includes("delete_score")(actions);
|
|
69
|
+
const loading = loadingQualityControl || loadingQualityScores;
|
|
35
70
|
|
|
36
71
|
const versionsMap = _.flow(
|
|
37
72
|
_.prop("versions"),
|
|
@@ -63,80 +98,95 @@ export default function QualityControlScores() {
|
|
|
63
98
|
})}
|
|
64
99
|
/>
|
|
65
100
|
) : (
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{columns.map((column, key) => (
|
|
105
|
-
<Table.Cell
|
|
106
|
-
key={key}
|
|
107
|
-
textAlign={column.textAlign}
|
|
108
|
-
content={columnDecorator(column)(score)}
|
|
109
|
-
/>
|
|
110
|
-
))}
|
|
111
|
-
|
|
112
|
-
{canDeleteScore ? (
|
|
113
|
-
<Table.Cell onClick={(e) => e.stopPropagation()}>
|
|
114
|
-
{_.includes(score.status)(VALID_DELETE_STATUSES) ? (
|
|
115
|
-
<ConfirmModal
|
|
116
|
-
icon="trash"
|
|
117
|
-
trigger={
|
|
118
|
-
<Button icon basic color="red" size="mini">
|
|
119
|
-
<Icon name="trash alternate outline" color="red" />
|
|
120
|
-
</Button>
|
|
121
|
-
}
|
|
122
|
-
header={formatMessage({
|
|
123
|
-
id: "score.actions.delete.confirmation.header",
|
|
124
|
-
})}
|
|
125
|
-
content={formatMessage({
|
|
126
|
-
id: "score.actions.delete.confirmation.content",
|
|
127
|
-
})}
|
|
128
|
-
onConfirm={() =>
|
|
129
|
-
deleteScore({ id: `${score.id}` }).then(mutate)
|
|
130
|
-
}
|
|
131
|
-
/>
|
|
132
|
-
) : null}
|
|
133
|
-
</Table.Cell>
|
|
101
|
+
<>
|
|
102
|
+
<LastExecutionResult lastExecutionResult={lastExecutionResult} />
|
|
103
|
+
<Table>
|
|
104
|
+
<Table.Header>
|
|
105
|
+
<Table.Row>
|
|
106
|
+
{columns.map(({ name }, idx) => (
|
|
107
|
+
<Table.HeaderCell
|
|
108
|
+
key={idx}
|
|
109
|
+
content={formatMessage({ id: `scores.props.${name}` })}
|
|
110
|
+
/>
|
|
111
|
+
))}
|
|
112
|
+
{canDeleteScore ? <Table.HeaderCell /> : null}
|
|
113
|
+
</Table.Row>
|
|
114
|
+
</Table.Header>
|
|
115
|
+
<Table.Body>
|
|
116
|
+
{scoreRows.map((score, key) => {
|
|
117
|
+
const version = score.quality_control.version;
|
|
118
|
+
const active = version === qualityControl.version;
|
|
119
|
+
const tagLabel = score.firstInVersion
|
|
120
|
+
? `${formatMessage({
|
|
121
|
+
id: "quality_control.props.version",
|
|
122
|
+
})}: ${version}`
|
|
123
|
+
: null;
|
|
124
|
+
return (
|
|
125
|
+
<Fragment key={key}>
|
|
126
|
+
{tagLabel ? (
|
|
127
|
+
<Table.Row>
|
|
128
|
+
<Table.Cell>
|
|
129
|
+
<Label
|
|
130
|
+
as={Link}
|
|
131
|
+
to={linkTo.QUALITY_CONTROL_HISTORY({ id, version })}
|
|
132
|
+
active={active}
|
|
133
|
+
ribbon
|
|
134
|
+
>
|
|
135
|
+
{tagLabel}
|
|
136
|
+
</Label>
|
|
137
|
+
</Table.Cell>
|
|
138
|
+
</Table.Row>
|
|
134
139
|
) : null}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
<Table.Row warning={active}>
|
|
141
|
+
{columns.map((column, key) => (
|
|
142
|
+
<Table.Cell
|
|
143
|
+
key={key}
|
|
144
|
+
textAlign={column.textAlign}
|
|
145
|
+
content={columnDecorator(column)(score)}
|
|
146
|
+
/>
|
|
147
|
+
))}
|
|
148
|
+
|
|
149
|
+
{canDeleteScore ? (
|
|
150
|
+
<Table.Cell onClick={(e) => e.stopPropagation()}>
|
|
151
|
+
{_.includes(score.status)(VALID_DELETE_STATUSES) ? (
|
|
152
|
+
<ConfirmModal
|
|
153
|
+
icon="trash"
|
|
154
|
+
trigger={
|
|
155
|
+
<Button icon basic color="red" size="mini">
|
|
156
|
+
<Icon
|
|
157
|
+
name="trash alternate outline"
|
|
158
|
+
color="red"
|
|
159
|
+
/>
|
|
160
|
+
</Button>
|
|
161
|
+
}
|
|
162
|
+
header={formatMessage({
|
|
163
|
+
id: "score.actions.delete.confirmation.header",
|
|
164
|
+
})}
|
|
165
|
+
content={formatMessage({
|
|
166
|
+
id: "score.actions.delete.confirmation.content",
|
|
167
|
+
})}
|
|
168
|
+
onConfirm={() => handleDelete({ id: `${score.id}` })}
|
|
169
|
+
/>
|
|
170
|
+
) : null}
|
|
171
|
+
</Table.Cell>
|
|
172
|
+
) : null}
|
|
173
|
+
</Table.Row>
|
|
174
|
+
</Fragment>
|
|
175
|
+
);
|
|
176
|
+
})}
|
|
177
|
+
</Table.Body>
|
|
178
|
+
</Table>
|
|
179
|
+
<ScorePagination />
|
|
180
|
+
</>
|
|
141
181
|
);
|
|
142
182
|
}
|
|
183
|
+
|
|
184
|
+
QualityControlScores.propTypes = {
|
|
185
|
+
columns: PropTypes.array,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const mapStateToProps = (state) => ({
|
|
189
|
+
columns: getQualityControlScoresColumns(state),
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
export default connect(mapStateToProps)(QualityControlScores);
|
|
@@ -20,8 +20,8 @@ export default function ScoreCriteriaView({ qualityControl }) {
|
|
|
20
20
|
),
|
|
21
21
|
error_count: (
|
|
22
22
|
<ScoreCriteriaContent
|
|
23
|
-
goal={score_criteria?.goal}
|
|
24
|
-
threshold={score_criteria?.maximum}
|
|
23
|
+
goal={`${score_criteria?.goal}%`}
|
|
24
|
+
threshold={`${score_criteria?.maximum}%`}
|
|
25
25
|
/>
|
|
26
26
|
),
|
|
27
27
|
count: (
|
|
@@ -265,7 +265,7 @@ describe("<NewQualityControl />", () => {
|
|
|
265
265
|
);
|
|
266
266
|
});
|
|
267
267
|
|
|
268
|
-
it
|
|
268
|
+
it("test publish submit ", async () => {
|
|
269
269
|
const user = userEvent.setup({ delay: null });
|
|
270
270
|
const trigger = jest.fn(() =>
|
|
271
271
|
Promise.resolve({ data: { data: { id: "9", version: "1" } } })
|
|
@@ -295,16 +295,24 @@ describe("<NewQualityControl />", () => {
|
|
|
295
295
|
rendered.getByRole("option", { name: /external_source_id/i })
|
|
296
296
|
);
|
|
297
297
|
|
|
298
|
-
await user.click(
|
|
298
|
+
await user.click(
|
|
299
|
+
rendered.getByRole("option", {
|
|
300
|
+
name: /quality_control.control_mode.count/i,
|
|
301
|
+
})
|
|
302
|
+
);
|
|
299
303
|
|
|
300
304
|
// Fill in the 'Goal' field
|
|
301
305
|
await user.type(
|
|
302
|
-
rendered.getByPlaceholderText(
|
|
306
|
+
rendered.getByPlaceholderText(
|
|
307
|
+
/quality_control.score_criteria.count.goal/i
|
|
308
|
+
),
|
|
303
309
|
"25"
|
|
304
310
|
);
|
|
305
311
|
// Fill in the 'Threshold' field
|
|
306
312
|
await user.type(
|
|
307
|
-
rendered.getByPlaceholderText(
|
|
313
|
+
rendered.getByPlaceholderText(
|
|
314
|
+
/quality_control.score_criteria.count.maximum/i
|
|
315
|
+
),
|
|
308
316
|
"50"
|
|
309
317
|
);
|
|
310
318
|
await waitForLoad(rendered);
|
|
@@ -21,7 +21,7 @@ describe("<QualityBadge />", () => {
|
|
|
21
21
|
const score = scoreData({ score_content: undefined });
|
|
22
22
|
const rendered = render(<QualityBadge score={score} />);
|
|
23
23
|
await waitForLoad(rendered);
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
expect(rendered.queryByText(/score.not_executed/i)).toBeInTheDocument();
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ describe("<QualityBadge />", () => {
|
|
|
34
34
|
const score = scoreData({ score_content });
|
|
35
35
|
const rendered = render(<QualityBadge score={score} />);
|
|
36
36
|
await waitForLoad(rendered);
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
expect(rendered.queryByText(/score.no_results/i)).toBeInTheDocument();
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -187,7 +187,7 @@ describe("<QualityBadgeForSearch />", () => {
|
|
|
187
187
|
/>
|
|
188
188
|
);
|
|
189
189
|
await waitForLoad(rendered);
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
expect(rendered.queryByText(/score.no_results/i)).toBeInTheDocument();
|
|
192
192
|
});
|
|
193
193
|
});
|
|
@@ -204,11 +204,15 @@ describe("<QualityControlEditor />", () => {
|
|
|
204
204
|
);
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
-
it
|
|
207
|
+
it("test fill form for creation", async () => {
|
|
208
208
|
const user = userEvent.setup({ delay: null });
|
|
209
|
+
const newProps = {
|
|
210
|
+
...props,
|
|
211
|
+
value: undefined,
|
|
212
|
+
};
|
|
209
213
|
const rendered = render(
|
|
210
214
|
<QualityControlEditor
|
|
211
|
-
{...
|
|
215
|
+
{...newProps}
|
|
212
216
|
value={defaultQualityControl}
|
|
213
217
|
isModification={false}
|
|
214
218
|
/>,
|
|
@@ -216,14 +220,19 @@ describe("<QualityControlEditor />", () => {
|
|
|
216
220
|
);
|
|
217
221
|
await waitForLoad(rendered);
|
|
218
222
|
|
|
219
|
-
await waitFor(() =>
|
|
220
|
-
expect(rendered.getByRole("button", { name: /publish/i })).toBeDisabled()
|
|
221
|
-
|
|
223
|
+
await waitFor(() => {
|
|
224
|
+
expect(rendered.getByRole("button", { name: /publish/i })).toBeDisabled();
|
|
225
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeDisabled();
|
|
226
|
+
});
|
|
222
227
|
|
|
223
228
|
await user.click(rendered.getByText(/enable/i));
|
|
224
|
-
|
|
225
229
|
await user.type(rendered.getByPlaceholderText(/name/i), "test_modified");
|
|
226
230
|
|
|
231
|
+
await user.type(
|
|
232
|
+
rendered.getByPlaceholderText(/field1/i),
|
|
233
|
+
"field_template_modified"
|
|
234
|
+
);
|
|
235
|
+
|
|
227
236
|
await user.click(rendered.getByText(/select domains/i));
|
|
228
237
|
await user.click(rendered.getByText(/bardomain/i));
|
|
229
238
|
|
|
@@ -234,17 +243,12 @@ describe("<QualityControlEditor />", () => {
|
|
|
234
243
|
|
|
235
244
|
await user.click(
|
|
236
245
|
rendered.getByRole("option", {
|
|
237
|
-
name:
|
|
246
|
+
name: "count",
|
|
238
247
|
})
|
|
239
248
|
);
|
|
240
249
|
|
|
241
|
-
await user.type(rendered.getByPlaceholderText(
|
|
242
|
-
await user.type(
|
|
243
|
-
rendered.getByPlaceholderText(
|
|
244
|
-
/quality_control.score_criteria.error_count.maximum/i
|
|
245
|
-
),
|
|
246
|
-
"50"
|
|
247
|
-
);
|
|
250
|
+
await user.type(rendered.getByPlaceholderText("Goal"), "25");
|
|
251
|
+
await user.type(rendered.getByPlaceholderText("Threshold"), "50");
|
|
248
252
|
|
|
249
253
|
await user.click(rendered.getByText(/resource type/i));
|
|
250
254
|
await user.click(rendered.getByText(/reference datasets/i));
|
|
@@ -254,4 +258,28 @@ describe("<QualityControlEditor />", () => {
|
|
|
254
258
|
expect(rendered.getByRole("button", { name: /Publish/i })).toBeEnabled()
|
|
255
259
|
);
|
|
256
260
|
});
|
|
261
|
+
|
|
262
|
+
it("test fill form for edition", async () => {
|
|
263
|
+
const user = userEvent.setup({ delay: null });
|
|
264
|
+
const newProps = {
|
|
265
|
+
...props,
|
|
266
|
+
onPublish: undefined,
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const rendered = render(<QualityControlEditor {...newProps} />, renderOpts);
|
|
270
|
+
|
|
271
|
+
await waitForLoad(rendered);
|
|
272
|
+
|
|
273
|
+
await waitFor(() => {
|
|
274
|
+
expect(rendered.queryByText(/publish/i)).not.toBeInTheDocument();
|
|
275
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeDisabled();
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
await user.click(rendered.getByText(/enable/i));
|
|
279
|
+
await user.type(rendered.getByPlaceholderText(/name/i), "test_modified");
|
|
280
|
+
|
|
281
|
+
await waitFor(() =>
|
|
282
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled()
|
|
283
|
+
);
|
|
284
|
+
});
|
|
257
285
|
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, waitForLoad } from "@truedat/test/render";
|
|
3
|
+
import QualityControlRoutes from "../QualityControlRoutes";
|
|
4
|
+
import { useAuthorized } from "@truedat/core/hooks/useAuthorized";
|
|
5
|
+
import {
|
|
6
|
+
QUALITY_CONTROLS_DEPRECATED,
|
|
7
|
+
QUALITY_CONTROLS_DRAFTS,
|
|
8
|
+
QUALITY_CONTROLS_PUBLISHED,
|
|
9
|
+
QUALITY_CONTROL_NEW,
|
|
10
|
+
QUALITY_CONTROL_EDIT,
|
|
11
|
+
QUALITY_CONTROL_NEW_DRAFT,
|
|
12
|
+
QUALITY_CONTROL,
|
|
13
|
+
QUALITY_CONTROL_HISTORY,
|
|
14
|
+
QUALITY_CONTROL_SCORES,
|
|
15
|
+
} from "@truedat/core/routes";
|
|
16
|
+
|
|
17
|
+
jest.mock("@truedat/core/hooks/useAuthorized", () => ({
|
|
18
|
+
useAuthorized: jest.fn(() => true),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock("../QualityControls", () => () => <div>QualityControls</div>);
|
|
22
|
+
jest.mock("../QualityControl", () => () => <div>QualityControl</div>);
|
|
23
|
+
jest.mock("../QualityControlHeader", () => () => (
|
|
24
|
+
<div>QualityControlHeader</div>
|
|
25
|
+
));
|
|
26
|
+
jest.mock("../QualityControlHistory", () => () => (
|
|
27
|
+
<div>QualityControlHistory</div>
|
|
28
|
+
));
|
|
29
|
+
jest.mock("../QualityControlScores", () => () => (
|
|
30
|
+
<div>QualityControlScores</div>
|
|
31
|
+
));
|
|
32
|
+
jest.mock("../NewQualityControl", () => () => <div>NewQualityControl</div>);
|
|
33
|
+
jest.mock("../EditQualityControl", () => () => <div>EditQualityControl</div>);
|
|
34
|
+
jest.mock("../NewDraftQualityControl", () => () => (
|
|
35
|
+
<div>NewDraftQualityControl</div>
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
describe("<QualityControlRoutes />", () => {
|
|
39
|
+
it("renders correctly with default route", async () => {
|
|
40
|
+
const rendered = render(<QualityControlRoutes />);
|
|
41
|
+
await waitForLoad(rendered);
|
|
42
|
+
expect(rendered.container).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("renders correctly with deprecated route", async () => {
|
|
46
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
47
|
+
routes: [QUALITY_CONTROLS_DEPRECATED],
|
|
48
|
+
});
|
|
49
|
+
await waitForLoad(rendered);
|
|
50
|
+
expect(rendered.container).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("renders correctly with drafts route", async () => {
|
|
54
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
55
|
+
routes: [QUALITY_CONTROLS_DRAFTS],
|
|
56
|
+
});
|
|
57
|
+
await waitForLoad(rendered);
|
|
58
|
+
expect(rendered.container).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("renders correctly with new route", async () => {
|
|
62
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
63
|
+
routes: [QUALITY_CONTROL_NEW],
|
|
64
|
+
});
|
|
65
|
+
await waitForLoad(rendered);
|
|
66
|
+
expect(rendered.container).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("renders correctly with edit route", async () => {
|
|
70
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
71
|
+
routes: [
|
|
72
|
+
QUALITY_CONTROL_EDIT.replace(":id", "123").replace(":version", "1"),
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
await waitForLoad(rendered);
|
|
76
|
+
expect(rendered.container).toMatchSnapshot();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("renders correctly with new draft route", async () => {
|
|
80
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
81
|
+
routes: [
|
|
82
|
+
QUALITY_CONTROL_NEW_DRAFT.replace(":id", "123").replace(
|
|
83
|
+
":version",
|
|
84
|
+
"1"
|
|
85
|
+
),
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
await waitForLoad(rendered);
|
|
89
|
+
expect(rendered.container).toMatchSnapshot();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("renders correctly with quality control route", async () => {
|
|
93
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
94
|
+
routes: [QUALITY_CONTROL.replace(":id", "123").replace(":version", "1")],
|
|
95
|
+
});
|
|
96
|
+
await waitForLoad(rendered);
|
|
97
|
+
expect(rendered.container).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("renders correctly with history route", async () => {
|
|
101
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
102
|
+
routes: [
|
|
103
|
+
QUALITY_CONTROL_HISTORY.replace(":id", "123").replace(":version", "1"),
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
await waitForLoad(rendered);
|
|
107
|
+
expect(rendered.container).toMatchSnapshot();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("renders correctly with scores route", async () => {
|
|
111
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
112
|
+
routes: [
|
|
113
|
+
QUALITY_CONTROL_SCORES.replace(":id", "123").replace(":version", "1"),
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
await waitForLoad(rendered);
|
|
117
|
+
expect(rendered.container).toMatchSnapshot();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("renders unauthorized component when not authorized", async () => {
|
|
121
|
+
useAuthorized.mockReturnValueOnce(false);
|
|
122
|
+
const rendered = render(<QualityControlRoutes />, {
|
|
123
|
+
routes: [QUALITY_CONTROLS_PUBLISHED],
|
|
124
|
+
});
|
|
125
|
+
await waitForLoad(rendered);
|
|
126
|
+
expect(rendered.container).toMatchSnapshot();
|
|
127
|
+
});
|
|
128
|
+
});
|