@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,4 +1,4 @@
|
|
|
1
|
-
import { waitFor, fireEvent } from "@testing-library/react";
|
|
1
|
+
import { act, waitFor, fireEvent } from "@testing-library/react";
|
|
2
2
|
import userEvent from "@testing-library/user-event";
|
|
3
3
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
4
4
|
import { DOMAINS_QUERY } from "@truedat/core/api/queries";
|
|
@@ -15,15 +15,23 @@ import {
|
|
|
15
15
|
} from "./__fixtures__/qualityControlHelper";
|
|
16
16
|
|
|
17
17
|
jest.mock("@truedat/core/hooks/useUserFilters");
|
|
18
|
-
jest.mock("@truedat/qx/hooks/useFunctions", () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
18
|
+
jest.mock("@truedat/qx/hooks/useFunctions", () => ({
|
|
19
|
+
useFunctions: jest.fn(() => ({
|
|
20
|
+
data: {
|
|
21
|
+
data: [
|
|
22
|
+
{
|
|
23
|
+
name: "eq",
|
|
24
|
+
type: "boolean",
|
|
25
|
+
params: [
|
|
26
|
+
{ name: "arg1", type: "any" },
|
|
27
|
+
{ name: "arg2", type: "any" },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
loading: false,
|
|
33
|
+
})),
|
|
34
|
+
}));
|
|
27
35
|
jest.mock("@truedat/qx/hooks/useDataViews", () => {
|
|
28
36
|
const originalModule = jest.requireActual("@truedat/qx/hooks/useDataViews");
|
|
29
37
|
|
|
@@ -117,7 +125,7 @@ describe("<QualityControlEditor />", () => {
|
|
|
117
125
|
isModification={false}
|
|
118
126
|
value={defaultQualityControl}
|
|
119
127
|
/>,
|
|
120
|
-
renderOpts
|
|
128
|
+
renderOpts,
|
|
121
129
|
);
|
|
122
130
|
await waitForLoad(rendered);
|
|
123
131
|
// Wait for async state updates from GraphQL queries to complete
|
|
@@ -126,7 +134,9 @@ describe("<QualityControlEditor />", () => {
|
|
|
126
134
|
});
|
|
127
135
|
// Save/Publish buttons only appear on step 2 (last step)
|
|
128
136
|
await waitFor(() =>
|
|
129
|
-
expect(
|
|
137
|
+
expect(
|
|
138
|
+
rendered.queryByRole("button", { name: /save/i }),
|
|
139
|
+
).not.toBeInTheDocument(),
|
|
130
140
|
);
|
|
131
141
|
expect(rendered.container).toMatchSnapshot();
|
|
132
142
|
});
|
|
@@ -163,7 +173,7 @@ describe("<QualityControlEditor />", () => {
|
|
|
163
173
|
await user.click(rendered.getByRole("button", { name: /cancel/i }));
|
|
164
174
|
|
|
165
175
|
await waitFor(() =>
|
|
166
|
-
expect(rendered.queryByText(/confirm_yes/i)).toBeInTheDocument()
|
|
176
|
+
expect(rendered.queryByText(/confirm_yes/i)).toBeInTheDocument(),
|
|
167
177
|
);
|
|
168
178
|
await user.click(rendered.getByText(/confirm_yes/i));
|
|
169
179
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
@@ -174,7 +184,7 @@ describe("<QualityControlEditor />", () => {
|
|
|
174
184
|
const onSave = jest.fn();
|
|
175
185
|
const rendered = render(
|
|
176
186
|
<QualityControlEditor {...props} onSave={onSave} />,
|
|
177
|
-
renderOpts
|
|
187
|
+
renderOpts,
|
|
178
188
|
);
|
|
179
189
|
await waitForLoad(rendered);
|
|
180
190
|
// Wait for async state updates from GraphQL queries to complete
|
|
@@ -183,7 +193,9 @@ describe("<QualityControlEditor />", () => {
|
|
|
183
193
|
});
|
|
184
194
|
|
|
185
195
|
// Save button only appears on step 2 (last step)
|
|
186
|
-
expect(
|
|
196
|
+
expect(
|
|
197
|
+
rendered.queryByRole("button", { name: /save/i }),
|
|
198
|
+
).not.toBeInTheDocument();
|
|
187
199
|
|
|
188
200
|
// Make a change on step 0 to enable save later
|
|
189
201
|
await user.type(rendered.getByPlaceholderText(/name/i), "_modified");
|
|
@@ -191,13 +203,17 @@ describe("<QualityControlEditor />", () => {
|
|
|
191
203
|
// Navigate to step 1
|
|
192
204
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
193
205
|
await waitFor(() =>
|
|
194
|
-
expect(
|
|
206
|
+
expect(
|
|
207
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
208
|
+
).toBeInTheDocument(),
|
|
195
209
|
);
|
|
196
210
|
|
|
197
211
|
// Navigate to step 2
|
|
198
212
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
199
213
|
await waitFor(() =>
|
|
200
|
-
expect(
|
|
214
|
+
expect(
|
|
215
|
+
rendered.getByRole("button", { name: /save/i }),
|
|
216
|
+
).toBeInTheDocument(),
|
|
201
217
|
);
|
|
202
218
|
|
|
203
219
|
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled();
|
|
@@ -209,7 +225,7 @@ describe("<QualityControlEditor />", () => {
|
|
|
209
225
|
await user.click(rendered.getByRole("button", { name: /save/i }));
|
|
210
226
|
|
|
211
227
|
await waitFor(() =>
|
|
212
|
-
expect(onSave).toHaveBeenCalledWith(expectedQualityControl)
|
|
228
|
+
expect(onSave).toHaveBeenCalledWith(expectedQualityControl),
|
|
213
229
|
);
|
|
214
230
|
});
|
|
215
231
|
|
|
@@ -218,7 +234,7 @@ describe("<QualityControlEditor />", () => {
|
|
|
218
234
|
const onPublish = jest.fn();
|
|
219
235
|
const rendered = render(
|
|
220
236
|
<QualityControlEditor {...props} onPublish={onPublish} />,
|
|
221
|
-
renderOpts
|
|
237
|
+
renderOpts,
|
|
222
238
|
);
|
|
223
239
|
await waitForLoad(rendered);
|
|
224
240
|
// Wait for async state updates from GraphQL queries to complete
|
|
@@ -227,7 +243,9 @@ describe("<QualityControlEditor />", () => {
|
|
|
227
243
|
});
|
|
228
244
|
|
|
229
245
|
// Publish button only appears on step 2 (last step)
|
|
230
|
-
expect(
|
|
246
|
+
expect(
|
|
247
|
+
rendered.queryByRole("button", { name: /publish/i }),
|
|
248
|
+
).not.toBeInTheDocument();
|
|
231
249
|
|
|
232
250
|
// Make a change on step 0 to enable publish later
|
|
233
251
|
await user.type(rendered.getByPlaceholderText(/name/i), "_modified");
|
|
@@ -235,13 +253,17 @@ describe("<QualityControlEditor />", () => {
|
|
|
235
253
|
// Navigate to step 1
|
|
236
254
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
237
255
|
await waitFor(() =>
|
|
238
|
-
expect(
|
|
256
|
+
expect(
|
|
257
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
258
|
+
).toBeInTheDocument(),
|
|
239
259
|
);
|
|
240
260
|
|
|
241
261
|
// Navigate to step 2
|
|
242
262
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
243
263
|
await waitFor(() =>
|
|
244
|
-
expect(
|
|
264
|
+
expect(
|
|
265
|
+
rendered.getByRole("button", { name: /publish/i }),
|
|
266
|
+
).toBeInTheDocument(),
|
|
245
267
|
);
|
|
246
268
|
|
|
247
269
|
expect(rendered.getByRole("button", { name: /publish/i })).toBeEnabled();
|
|
@@ -253,7 +275,7 @@ describe("<QualityControlEditor />", () => {
|
|
|
253
275
|
await user.click(rendered.getByRole("button", { name: /publish/i }));
|
|
254
276
|
|
|
255
277
|
await waitFor(() =>
|
|
256
|
-
expect(onPublish).toHaveBeenCalledWith(expectedQualityControl)
|
|
278
|
+
expect(onPublish).toHaveBeenCalledWith(expectedQualityControl),
|
|
257
279
|
);
|
|
258
280
|
});
|
|
259
281
|
|
|
@@ -269,7 +291,7 @@ describe("<QualityControlEditor />", () => {
|
|
|
269
291
|
value={defaultQualityControl}
|
|
270
292
|
isModification={false}
|
|
271
293
|
/>,
|
|
272
|
-
renderOpts
|
|
294
|
+
renderOpts,
|
|
273
295
|
);
|
|
274
296
|
await waitForLoad(rendered);
|
|
275
297
|
// Wait for async state updates from GraphQL queries to complete
|
|
@@ -279,8 +301,12 @@ describe("<QualityControlEditor />", () => {
|
|
|
279
301
|
|
|
280
302
|
// Save/Publish buttons only appear on step 2
|
|
281
303
|
await waitFor(() => {
|
|
282
|
-
expect(
|
|
283
|
-
|
|
304
|
+
expect(
|
|
305
|
+
rendered.queryByRole("button", { name: /publish/i }),
|
|
306
|
+
).not.toBeInTheDocument();
|
|
307
|
+
expect(
|
|
308
|
+
rendered.queryByRole("button", { name: /save/i }),
|
|
309
|
+
).not.toBeInTheDocument();
|
|
284
310
|
});
|
|
285
311
|
|
|
286
312
|
// Fill step 0 (Information)
|
|
@@ -289,53 +315,90 @@ describe("<QualityControlEditor />", () => {
|
|
|
289
315
|
|
|
290
316
|
await user.type(
|
|
291
317
|
rendered.getByPlaceholderText(/field1/i),
|
|
292
|
-
"field_template_modified"
|
|
318
|
+
"field_template_modified",
|
|
293
319
|
);
|
|
294
320
|
// Wait for SelectableDynamicForm to finish updating state (prevents act() warning)
|
|
295
|
-
await waitFor(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
321
|
+
await waitFor(
|
|
322
|
+
() => {
|
|
323
|
+
const input = rendered.getByPlaceholderText(/field1/i);
|
|
324
|
+
expect(input).toHaveValue("field_template_modified");
|
|
325
|
+
},
|
|
326
|
+
{ timeout: 2000 },
|
|
327
|
+
);
|
|
299
328
|
|
|
300
329
|
await user.click(rendered.getByText(/select domains/i));
|
|
301
330
|
await user.click(rendered.getByText(/bardomain/i));
|
|
302
331
|
|
|
303
332
|
await user.click(
|
|
304
333
|
rendered.getByRole("option", {
|
|
305
|
-
name:
|
|
306
|
-
})
|
|
334
|
+
name: /quality_control.control_mode.error_count/i,
|
|
335
|
+
}),
|
|
307
336
|
);
|
|
308
337
|
|
|
309
|
-
await user.type(
|
|
310
|
-
|
|
338
|
+
await user.type(
|
|
339
|
+
rendered.getByPlaceholderText(
|
|
340
|
+
/quality_control.score_criteria.error_count.goal/i,
|
|
341
|
+
),
|
|
342
|
+
"25",
|
|
343
|
+
);
|
|
344
|
+
await user.type(
|
|
345
|
+
rendered.getByPlaceholderText(
|
|
346
|
+
/quality_control.score_criteria.error_count.maximum/i,
|
|
347
|
+
),
|
|
348
|
+
"50",
|
|
349
|
+
);
|
|
311
350
|
|
|
312
351
|
// Navigate to step 1 (Control Properties)
|
|
313
352
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
314
353
|
await waitFor(() =>
|
|
315
|
-
expect(
|
|
354
|
+
expect(
|
|
355
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
356
|
+
).toBeInTheDocument(),
|
|
316
357
|
);
|
|
317
358
|
|
|
318
359
|
// Fill step 1 - Source selector is now in step 1
|
|
319
360
|
await user.click(rendered.getByText(/select source/i));
|
|
320
361
|
await user.click(
|
|
321
|
-
rendered.getByRole("option", { name: /external_source_id/i })
|
|
362
|
+
rendered.getByRole("option", { name: /external_source_id/i }),
|
|
322
363
|
);
|
|
323
364
|
|
|
324
365
|
await user.click(rendered.getByText(/resource type/i));
|
|
325
366
|
await user.click(rendered.getByText(/reference datasets/i));
|
|
326
367
|
await user.click(rendered.getByRole("option", { name: /dataset1/i }));
|
|
327
368
|
|
|
369
|
+
await waitFor(() =>
|
|
370
|
+
expect(
|
|
371
|
+
rendered.getAllByRole("option", { name: /campo1/ }).length,
|
|
372
|
+
).toBeGreaterThan(0),
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
await act(async () => {
|
|
376
|
+
await user.click(rendered.getAllByRole("option", { name: /campo1/ })[0]);
|
|
377
|
+
await user.click(rendered.getByRole("option", { name: /eq/i }));
|
|
378
|
+
await user.click(rendered.getAllByRole("option", { name: /campo2/ })[1]);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
await waitFor(() =>
|
|
382
|
+
expect(rendered.getByRole("button", { name: /forward/i })).toBeEnabled(),
|
|
383
|
+
);
|
|
384
|
+
|
|
328
385
|
// Navigate to step 2 (Segmentation)
|
|
329
386
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
387
|
+
|
|
330
388
|
await waitFor(() =>
|
|
331
|
-
expect(
|
|
389
|
+
expect(
|
|
390
|
+
rendered.queryByRole("button", { name: /forward/i }),
|
|
391
|
+
).not.toBeInTheDocument(),
|
|
332
392
|
);
|
|
393
|
+
|
|
333
394
|
await waitFor(() =>
|
|
334
|
-
expect(
|
|
395
|
+
expect(
|
|
396
|
+
rendered.getByRole("button", { name: /publish/i }),
|
|
397
|
+
).toBeInTheDocument(),
|
|
335
398
|
);
|
|
336
399
|
|
|
337
400
|
await waitFor(() =>
|
|
338
|
-
expect(rendered.getByRole("button", { name: /publish/i })).toBeEnabled()
|
|
401
|
+
expect(rendered.getByRole("button", { name: /publish/i })).toBeEnabled(),
|
|
339
402
|
);
|
|
340
403
|
});
|
|
341
404
|
|
|
@@ -357,7 +420,9 @@ describe("<QualityControlEditor />", () => {
|
|
|
357
420
|
await waitFor(() => {
|
|
358
421
|
expect(rendered.queryByText(/publish/i)).not.toBeInTheDocument();
|
|
359
422
|
// Save button only appears on step 2
|
|
360
|
-
expect(
|
|
423
|
+
expect(
|
|
424
|
+
rendered.queryByRole("button", { name: /save/i }),
|
|
425
|
+
).not.toBeInTheDocument();
|
|
361
426
|
});
|
|
362
427
|
|
|
363
428
|
// Make a change on step 0
|
|
@@ -367,20 +432,192 @@ describe("<QualityControlEditor />", () => {
|
|
|
367
432
|
// Navigate to step 1
|
|
368
433
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
369
434
|
await waitFor(() =>
|
|
370
|
-
expect(
|
|
435
|
+
expect(
|
|
436
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
437
|
+
).toBeInTheDocument(),
|
|
371
438
|
);
|
|
372
439
|
|
|
373
440
|
// Navigate to step 2 to see save button
|
|
374
441
|
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
375
442
|
await waitFor(() =>
|
|
376
|
-
expect(
|
|
443
|
+
expect(
|
|
444
|
+
rendered.queryByRole("button", { name: /forward/i }),
|
|
445
|
+
).not.toBeInTheDocument(),
|
|
446
|
+
);
|
|
447
|
+
await waitFor(() =>
|
|
448
|
+
expect(
|
|
449
|
+
rendered.getByRole("button", { name: /save/i }),
|
|
450
|
+
).toBeInTheDocument(),
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
await waitFor(() =>
|
|
454
|
+
expect(rendered.getByRole("button", { name: /save/i })).toBeEnabled(),
|
|
455
|
+
);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it("shows error status icon when first step is invalid", async () => {
|
|
459
|
+
const user = userEvent.setup({ delay: null });
|
|
460
|
+
const rendered = render(
|
|
461
|
+
<QualityControlEditor
|
|
462
|
+
{...props}
|
|
463
|
+
isModification={false}
|
|
464
|
+
value={defaultQualityControl}
|
|
465
|
+
/>,
|
|
466
|
+
renderOpts,
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
await waitForLoad(rendered);
|
|
470
|
+
await waitFor(() => {
|
|
471
|
+
expect(rendered.getByPlaceholderText(/name/i)).toBeInTheDocument();
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
475
|
+
|
|
476
|
+
await waitFor(() => {
|
|
477
|
+
expect(
|
|
478
|
+
rendered.queryByRole("button", { name: /back/i }),
|
|
479
|
+
).not.toBeInTheDocument();
|
|
480
|
+
expect(rendered.container.querySelector("i.red.x.icon")).toBeInTheDocument();
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it("test back button returns to previous step", async () => {
|
|
485
|
+
const user = userEvent.setup({ delay: null });
|
|
486
|
+
const rendered = render(<QualityControlEditor {...props} />, renderOpts);
|
|
487
|
+
|
|
488
|
+
await waitForLoad(rendered);
|
|
489
|
+
await waitFor(() => {
|
|
490
|
+
expect(rendered.getByPlaceholderText(/name/i)).toBeInTheDocument();
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
494
|
+
|
|
495
|
+
await waitFor(() =>
|
|
496
|
+
expect(
|
|
497
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
498
|
+
).toBeInTheDocument(),
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
await user.click(rendered.getByRole("button", { name: /back/i }));
|
|
502
|
+
|
|
503
|
+
await waitFor(() => {
|
|
504
|
+
expect(
|
|
505
|
+
rendered.queryByRole("button", { name: /back/i }),
|
|
506
|
+
).not.toBeInTheDocument();
|
|
507
|
+
expect(rendered.getByRole("button", { name: /forward/i })).toBeInTheDocument();
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("renders nothing when value is not provided", () => {
|
|
512
|
+
const newProps = {
|
|
513
|
+
...props,
|
|
514
|
+
value: undefined,
|
|
515
|
+
};
|
|
516
|
+
const rendered = render(<QualityControlEditor {...newProps} />, renderOpts);
|
|
517
|
+
expect(rendered.container.firstChild).toBeNull();
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it("does not render save button when onSave is undefined on last step", async () => {
|
|
521
|
+
const user = userEvent.setup({ delay: null });
|
|
522
|
+
const newProps = {
|
|
523
|
+
...props,
|
|
524
|
+
onSave: undefined,
|
|
525
|
+
};
|
|
526
|
+
const rendered = render(<QualityControlEditor {...newProps} />, renderOpts);
|
|
527
|
+
|
|
528
|
+
await waitForLoad(rendered);
|
|
529
|
+
await waitFor(() => {
|
|
530
|
+
expect(rendered.getByPlaceholderText(/name/i)).toBeInTheDocument();
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
534
|
+
await waitFor(() =>
|
|
535
|
+
expect(
|
|
536
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
537
|
+
).toBeInTheDocument(),
|
|
538
|
+
);
|
|
539
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
540
|
+
|
|
541
|
+
await waitFor(() =>
|
|
542
|
+
expect(
|
|
543
|
+
rendered.queryByRole("button", { name: /forward/i }),
|
|
544
|
+
).not.toBeInTheDocument(),
|
|
545
|
+
);
|
|
546
|
+
|
|
547
|
+
await waitFor(() =>
|
|
548
|
+
expect(
|
|
549
|
+
rendered.queryByRole("button", { name: /save/i }),
|
|
550
|
+
).not.toBeInTheDocument(),
|
|
551
|
+
);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it("does not render publish button when onPublish is undefined on last step", async () => {
|
|
555
|
+
const user = userEvent.setup({ delay: null });
|
|
556
|
+
const newProps = {
|
|
557
|
+
...props,
|
|
558
|
+
onPublish: undefined,
|
|
559
|
+
};
|
|
560
|
+
const rendered = render(<QualityControlEditor {...newProps} />, renderOpts);
|
|
561
|
+
|
|
562
|
+
await waitForLoad(rendered);
|
|
563
|
+
await waitFor(() => {
|
|
564
|
+
expect(rendered.getByPlaceholderText(/name/i)).toBeInTheDocument();
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
568
|
+
await waitFor(() =>
|
|
569
|
+
expect(
|
|
570
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
571
|
+
).toBeInTheDocument(),
|
|
572
|
+
);
|
|
573
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
574
|
+
|
|
575
|
+
await waitFor(() =>
|
|
576
|
+
expect(
|
|
577
|
+
rendered.queryByRole("button", { name: /forward/i }),
|
|
578
|
+
).not.toBeInTheDocument(),
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
await waitFor(() =>
|
|
582
|
+
expect(
|
|
583
|
+
rendered.queryByRole("button", { name: /publish/i }),
|
|
584
|
+
).not.toBeInTheDocument(),
|
|
585
|
+
);
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
it("does not call onSave when full form validation fails", async () => {
|
|
589
|
+
const user = userEvent.setup({ delay: null });
|
|
590
|
+
const onSave = jest.fn();
|
|
591
|
+
const rendered = render(
|
|
592
|
+
<QualityControlEditor {...props} onSave={onSave} />,
|
|
593
|
+
renderOpts,
|
|
377
594
|
);
|
|
595
|
+
|
|
596
|
+
await waitForLoad(rendered);
|
|
597
|
+
await waitFor(() => {
|
|
598
|
+
expect(rendered.getByPlaceholderText(/name/i)).toBeInTheDocument();
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
await user.type(rendered.getByPlaceholderText(/name/i), "_modified");
|
|
602
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
378
603
|
await waitFor(() =>
|
|
379
|
-
expect(
|
|
604
|
+
expect(
|
|
605
|
+
rendered.getByRole("button", { name: /back/i }),
|
|
606
|
+
).toBeInTheDocument(),
|
|
380
607
|
);
|
|
608
|
+
await user.click(rendered.getByRole("button", { name: /forward/i }));
|
|
381
609
|
|
|
382
610
|
await waitFor(() =>
|
|
383
|
-
expect(
|
|
611
|
+
expect(
|
|
612
|
+
rendered.getByRole("button", { name: /save/i }),
|
|
613
|
+
).toBeInTheDocument(),
|
|
384
614
|
);
|
|
615
|
+
|
|
616
|
+
fireEvent.change(rendered.getByPlaceholderText(/name/i), {
|
|
617
|
+
target: { value: "" },
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
await user.click(rendered.getByRole("button", { name: /save/i }));
|
|
621
|
+
await waitFor(() => expect(onSave).not.toHaveBeenCalled());
|
|
385
622
|
});
|
|
386
623
|
});
|
|
@@ -20,9 +20,9 @@ describe("<ScoreCriteria />", () => {
|
|
|
20
20
|
expect(container).toMatchSnapshot();
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it("matches the latest snapshot for
|
|
23
|
+
it("matches the latest snapshot for error_count", () => {
|
|
24
24
|
const defaultValues = {
|
|
25
|
-
control_mode: "
|
|
25
|
+
control_mode: "error_count",
|
|
26
26
|
};
|
|
27
27
|
const { container } = render(
|
|
28
28
|
<TestFormWrapper defaultValues={defaultValues}>
|
|
@@ -62,7 +62,7 @@ describe("<ScoreCriteria />", () => {
|
|
|
62
62
|
[
|
|
63
63
|
{ controlMode: "deviation", expectedValue: { goal: null, maximum: null } },
|
|
64
64
|
{
|
|
65
|
-
controlMode: "
|
|
65
|
+
controlMode: "error_count",
|
|
66
66
|
expectedValue: { goal: null, maximum: null },
|
|
67
67
|
},
|
|
68
68
|
{ controlMode: "percentage", expectedValue: { goal: null, minimum: null } },
|
|
@@ -73,4 +73,26 @@ describe("<ScoreCriteria />", () => {
|
|
|
73
73
|
expect(defaultForMode(controlMode)).toEqual(expectedValue);
|
|
74
74
|
})
|
|
75
75
|
);
|
|
76
|
+
|
|
77
|
+
it("matches the latest snapshot for unsupported controlMode", () => {
|
|
78
|
+
const defaultValues = {
|
|
79
|
+
control_mode: "unsupported",
|
|
80
|
+
};
|
|
81
|
+
const rendered = render(
|
|
82
|
+
<TestFormWrapper defaultValues={defaultValues}>
|
|
83
|
+
<ScoreCriteria />
|
|
84
|
+
</TestFormWrapper>,
|
|
85
|
+
renderOpts
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
expect(rendered.container).toMatchSnapshot();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("returns undefined for unsupported controlMode", () => {
|
|
92
|
+
expect(defaultForMode("unsupported")).toBeUndefined();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("returns undefined when controlMode is not provided", () => {
|
|
96
|
+
expect(defaultForMode()).toBeUndefined();
|
|
97
|
+
});
|
|
76
98
|
});
|
|
@@ -47,9 +47,9 @@ describe("<ScoreCriteriaView />", () => {
|
|
|
47
47
|
expect(queryByText(/5/i)).toBeInTheDocument();
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
it("view for
|
|
50
|
+
it("view for error_count with goal and maximum", () => {
|
|
51
51
|
const qc = qualityControlData({
|
|
52
|
-
control_mode: "
|
|
52
|
+
control_mode: "error_count",
|
|
53
53
|
score_criteria: {
|
|
54
54
|
goal: 15,
|
|
55
55
|
maximum: 40,
|
|
@@ -64,7 +64,7 @@ describe("<ScoreCriteriaView />", () => {
|
|
|
64
64
|
|
|
65
65
|
it("view for empty score_criteria", () => {
|
|
66
66
|
const qc = qualityControlData({
|
|
67
|
-
control_mode: "
|
|
67
|
+
control_mode: "error_count",
|
|
68
68
|
score_criteria: undefined,
|
|
69
69
|
});
|
|
70
70
|
const { queryByText } = render(
|
|
@@ -74,4 +74,20 @@ describe("<ScoreCriteriaView />", () => {
|
|
|
74
74
|
|
|
75
75
|
expect(queryByText(/No result criteria defined/i)).toBeInTheDocument();
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
it("view for unsupported control_mode", () => {
|
|
79
|
+
const qc = qualityControlData({
|
|
80
|
+
control_mode: "unsupported",
|
|
81
|
+
score_criteria: {
|
|
82
|
+
goal: 10,
|
|
83
|
+
minimum: 5,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
const { queryByText } = render(
|
|
87
|
+
<ScoreCriteriaView qualityControl={qc} />,
|
|
88
|
+
renderOpts
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
expect(queryByText(/No result criteria defined/i)).toBeInTheDocument();
|
|
92
|
+
});
|
|
77
93
|
});
|
package/src/components/qualityControls/__tests__/__snapshots__/ControlProperties.spec.js.snap
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`<ControlProperties /> matches the latest snapshot with
|
|
3
|
+
exports[`<ControlProperties /> matches the latest snapshot with error_count 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
6
|
class="ui segment"
|
|
@@ -11,6 +11,12 @@ exports[`<ControlProperties /> matches the latest snapshot with count 1`] = `
|
|
|
11
11
|
<label>
|
|
12
12
|
Source
|
|
13
13
|
</label>
|
|
14
|
+
<button
|
|
15
|
+
data-testid="mock-source-selector"
|
|
16
|
+
type="button"
|
|
17
|
+
>
|
|
18
|
+
181
|
|
19
|
+
</button>
|
|
14
20
|
</div>
|
|
15
21
|
<div
|
|
16
22
|
class="required field"
|
|
@@ -88,6 +94,12 @@ exports[`<ControlProperties /> matches the latest snapshot with ratio 1`] = `
|
|
|
88
94
|
<label>
|
|
89
95
|
Source
|
|
90
96
|
</label>
|
|
97
|
+
<button
|
|
98
|
+
data-testid="mock-source-selector"
|
|
99
|
+
type="button"
|
|
100
|
+
>
|
|
101
|
+
181
|
|
102
|
+
</button>
|
|
91
103
|
</div>
|
|
92
104
|
<div
|
|
93
105
|
class="required field"
|