@truedat/dq 4.58.3 → 4.58.5

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.
@@ -0,0 +1,136 @@
1
+ import _ from "lodash/fp";
2
+ import React from "react";
3
+ import { waitFor } from "@testing-library/react";
4
+ import userEvent from "@testing-library/user-event";
5
+ import { render } from "@truedat/test/render";
6
+ import { DOMAIN_QUERY, DOMAINS_QUERY } from "@truedat/core/api/queries";
7
+ import { multipleTemplatesMock } from "@truedat/test/mocks";
8
+ import { RuleImplementationBasicForm } from "../RuleImplementationBasicForm";
9
+
10
+ jest.setTimeout(30000);
11
+
12
+ const domains = [
13
+ { id: 1, name: "domain1", actions: ["publishImplementation"] },
14
+ ];
15
+ const domainsMock = {
16
+ request: { query: DOMAINS_QUERY },
17
+ result: { data: { domains: domains } },
18
+ };
19
+
20
+ const domainMock = {
21
+ request: { query: DOMAIN_QUERY },
22
+ result: { data: { domain: domains } },
23
+ };
24
+
25
+ const renderOpts = {
26
+ mocks: [
27
+ multipleTemplatesMock({ scope: "ri", domainIds: [1] }),
28
+ domainMock,
29
+ domainsMock,
30
+ ],
31
+ state: {
32
+ rule: { domain_id: 1 },
33
+ ruleImplementationCreating: false,
34
+ },
35
+ fallback: "lazy",
36
+ };
37
+
38
+ const props = {
39
+ onChange: jest.fn(),
40
+ onSubmit: jest.fn(),
41
+ implementationKey: "",
42
+ isSubmitting: false,
43
+ ruleImplementation: {
44
+ id: 1,
45
+ goal: "10",
46
+ minimum: "1",
47
+ result_type: "percentage",
48
+ },
49
+ };
50
+
51
+ describe("<RuleImplementationBasicForm />", () => {
52
+ it("matches the latest snapshot", async () => {
53
+ const updatedProps = _.flow(_.set("ruleImplementation.domain_id", 1))(
54
+ props
55
+ );
56
+ const { container, queryByText } = render(
57
+ <RuleImplementationBasicForm {...updatedProps} />,
58
+ renderOpts
59
+ );
60
+ await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument(), {
61
+ timeout: 10000,
62
+ });
63
+ await waitFor(() =>
64
+ expect(queryByText(/loading/i)).not.toBeInTheDocument()
65
+ );
66
+ expect(container).toMatchSnapshot();
67
+ });
68
+
69
+ it("Implementation_key field is editable with status published", () => {
70
+ const updatedProps = _.flow(
71
+ _.set("ruleImplementation.domain_id", 1),
72
+ _.set("ruleImplementation.status", "published"),
73
+ _.set("ruleImplementation.implementation_key", "implementation_test")
74
+ )(props);
75
+ const { queryByPlaceholderText } = render(
76
+ <RuleImplementationBasicForm {...updatedProps} />,
77
+ renderOpts
78
+ );
79
+ expect(
80
+ queryByPlaceholderText("Rule Implementation Key")
81
+ ).not.toBeDisabled();
82
+ });
83
+
84
+ it("submit button enabled if there is valid content in form without rule", async () => {
85
+ const updatedProps = _.flow(
86
+ _.set("ruleImplementation.domain_id", 1),
87
+ _.set("ruleImplementation.dfName", "template1"),
88
+ _.set("ruleImplementation.dfContent", { field1: "foo" })
89
+ )(props);
90
+ const customProps = {
91
+ ...updatedProps,
92
+ };
93
+
94
+ const { getByRole } = render(
95
+ <RuleImplementationBasicForm {...customProps} />,
96
+ renderOpts
97
+ );
98
+ await waitFor(() => {
99
+ expect(getByRole("button", { name: "Save" })).toBeEnabled();
100
+ });
101
+ });
102
+
103
+ it("submit button enabled if there is valid content in form with rule", async () => {
104
+ const updatedProps = _.flow(
105
+ _.set("ruleImplementation.domain_id", 1),
106
+ _.set("ruleImplementation.dfName", "template1"),
107
+ _.set("ruleImplementation.dfContent", { field1: "foo" })
108
+ )(props);
109
+ const customProps = {
110
+ ...updatedProps,
111
+ rule: { id: 5, name: "regla" },
112
+ };
113
+
114
+ const { findByRole } = render(
115
+ <RuleImplementationBasicForm {...customProps} />,
116
+ renderOpts
117
+ );
118
+ expect(await findByRole("button", { name: /save/i })).toBeEnabled();
119
+ });
120
+
121
+ it("submit button disabled if there is invalid content in form", async () => {
122
+ const updatedProps = _.flow(
123
+ _.set("ruleImplementation.domain_id", 1),
124
+ _.set("ruleImplementation.dfName", "template1"),
125
+ _.set("ruleImplementation.dfContent", {})
126
+ )(props);
127
+ const customProps = {
128
+ ...updatedProps,
129
+ };
130
+ const { queryByRole } = render(
131
+ <RuleImplementationBasicForm {...customProps} />,
132
+ renderOpts
133
+ );
134
+ expect(queryByRole("button", { name: /save/i })).toBeDisabled();
135
+ });
136
+ });
@@ -0,0 +1,273 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<RuleImplementationBasicForm /> matches the latest snapshot 1`] = `
4
+ <div>
5
+ <form
6
+ class="ui form rule"
7
+ style=""
8
+ >
9
+ <div
10
+ class="field"
11
+ >
12
+ <label>
13
+ Implementation Key
14
+ <i
15
+ aria-hidden="true"
16
+ class="question circle outline icon rule-form-popup"
17
+ />
18
+ </label>
19
+ <div
20
+ class="required field"
21
+ >
22
+ <div
23
+ class="ui input"
24
+ >
25
+ <input
26
+ autocomplete="off"
27
+ name="implementation_key"
28
+ placeholder="Rule Implementation Key"
29
+ required=""
30
+ type="text"
31
+ value=""
32
+ />
33
+ </div>
34
+ </div>
35
+ </div>
36
+ <div
37
+ class="field"
38
+ />
39
+ <div
40
+ class="ui segment"
41
+ >
42
+ <div
43
+ class="field"
44
+ >
45
+ <label
46
+ class="rule-form-label"
47
+ >
48
+ Result Type
49
+ <span>
50
+ *
51
+ </span>
52
+ <i
53
+ aria-hidden="true"
54
+ class="question circle outline icon rule-form-popup"
55
+ />
56
+ </label>
57
+ <div
58
+ class="inline fields"
59
+ >
60
+ <div
61
+ class="field"
62
+ >
63
+ <div
64
+ class="ui checked radio checkbox"
65
+ >
66
+ <input
67
+ checked=""
68
+ class="hidden"
69
+ name="result_type"
70
+ readonly=""
71
+ tabindex="0"
72
+ type="radio"
73
+ value="percentage"
74
+ />
75
+ <label>
76
+ Percentage
77
+ </label>
78
+ </div>
79
+ </div>
80
+ <div
81
+ class="field"
82
+ >
83
+ <div
84
+ class="ui radio checkbox"
85
+ >
86
+ <input
87
+ class="hidden"
88
+ name="result_type"
89
+ readonly=""
90
+ tabindex="0"
91
+ type="radio"
92
+ value="deviation"
93
+ />
94
+ <label>
95
+ Deviation
96
+ </label>
97
+ </div>
98
+ </div>
99
+ <div
100
+ class="field"
101
+ >
102
+ <div
103
+ class="ui radio checkbox"
104
+ >
105
+ <input
106
+ class="hidden"
107
+ name="result_type"
108
+ readonly=""
109
+ tabindex="0"
110
+ type="radio"
111
+ value="errors_number"
112
+ />
113
+ <label>
114
+ Error count
115
+ </label>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ <div
121
+ class="field"
122
+ >
123
+ <label
124
+ class="rule-form-label"
125
+ >
126
+ Threshold
127
+ <span>
128
+ *
129
+ </span>
130
+ <i
131
+ aria-hidden="true"
132
+ class="question circle outline icon rule-form-popup"
133
+ />
134
+ </label>
135
+ <div
136
+ class="field"
137
+ >
138
+ <div
139
+ class="ui input"
140
+ >
141
+ <input
142
+ autocomplete="off"
143
+ name="minimum"
144
+ placeholder="Threshold value"
145
+ type="text"
146
+ value="1"
147
+ />
148
+ </div>
149
+ </div>
150
+ </div>
151
+ <div
152
+ class="field"
153
+ >
154
+ <label
155
+ class="rule-form-label"
156
+ >
157
+ Goal
158
+ <span>
159
+ *
160
+ </span>
161
+ <i
162
+ aria-hidden="true"
163
+ class="question circle outline icon rule-form-popup"
164
+ />
165
+ </label>
166
+ <div
167
+ class="field"
168
+ >
169
+ <div
170
+ class="ui input"
171
+ >
172
+ <input
173
+ autocomplete="off"
174
+ name="goal"
175
+ placeholder="Goal value"
176
+ type="text"
177
+ value="10"
178
+ />
179
+ </div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+ <div
184
+ class="required field"
185
+ >
186
+ <label>
187
+ Template
188
+ <div
189
+ class="ui left pointing label"
190
+ >
191
+ Empty required field
192
+ </div>
193
+ </label>
194
+ <div
195
+ class="field"
196
+ >
197
+ <div
198
+ aria-busy="false"
199
+ aria-expanded="false"
200
+ class="ui search selection dropdown"
201
+ name="template"
202
+ role="combobox"
203
+ >
204
+ <input
205
+ aria-autocomplete="list"
206
+ autocomplete="off"
207
+ class="search"
208
+ tabindex="0"
209
+ type="text"
210
+ value=""
211
+ />
212
+ <div
213
+ aria-atomic="true"
214
+ aria-live="polite"
215
+ class="divider default text"
216
+ role="alert"
217
+ >
218
+ Select a template...
219
+ </div>
220
+ <i
221
+ aria-hidden="true"
222
+ class="dropdown icon"
223
+ />
224
+ <div
225
+ class="menu transition"
226
+ role="listbox"
227
+ >
228
+ <div
229
+ aria-checked="false"
230
+ aria-selected="true"
231
+ class="selected item"
232
+ role="option"
233
+ style="pointer-events: all;"
234
+ >
235
+ <span
236
+ class="text"
237
+ >
238
+ template1
239
+ </span>
240
+ </div>
241
+ <div
242
+ aria-checked="false"
243
+ aria-selected="false"
244
+ class="item"
245
+ role="option"
246
+ style="pointer-events: all;"
247
+ >
248
+ <span
249
+ class="text"
250
+ >
251
+ template2
252
+ </span>
253
+ </div>
254
+ </div>
255
+ </div>
256
+ </div>
257
+ </div>
258
+ <button
259
+ class="ui primary disabled right floated button"
260
+ disabled=""
261
+ tabindex="-1"
262
+ type="submit"
263
+ >
264
+ Save
265
+ </button>
266
+ <button
267
+ class="ui secondary right floated button"
268
+ >
269
+ Cancel
270
+ </button>
271
+ </form>
272
+ </div>
273
+ `;
@@ -72,6 +72,7 @@ export default {
72
72
  "This implementation will be executed. Are you sure?",
73
73
  "implementationStructures.empty": "No structures found",
74
74
  "implementations.actions.create": "Create implementation",
75
+ "implementations.actions.create_basic": "Create basic implementation",
75
76
  "implementations.actions.create_raw": "Create raw implementation",
76
77
  "implementations.actions.do_execution": "Execute implementations",
77
78
  "implementations.actions.download.empty":
@@ -141,6 +142,7 @@ export default {
141
142
  "quality.result.percentage.description": "{result}%",
142
143
  "quality.result_type": "Result Type",
143
144
  "quality.rule.actions.create": "New Implementation",
145
+ "quality.rule.actions.create_basic": "New basic Implementation",
144
146
  "quality.rule.actions.create_raw": "New raw Implementation",
145
147
  "quality.rule.description": "Description",
146
148
  "quality.rule.failed": "Failed",
@@ -72,7 +72,8 @@ export default {
72
72
  "Se va a solicitar la ejecución de esta implementación. ¿Estás seguro?",
73
73
  "implementationStructures.empty": "Ningúna estructura encontrada",
74
74
  "implementations.actions.create": "Crear implementación",
75
- "implementations.actions.create_raw": "Crear implementacion nativa",
75
+ "implementations.actions.create_basic": "Crear implementación básica",
76
+ "implementations.actions.create_raw": "Crear implementación nativa",
76
77
  "implementations.actions.do_execution": "Ejecutar implementaciones",
77
78
  "implementations.actions.download.empty":
78
79
  "No hay implementaciones para descargar",
@@ -145,6 +146,7 @@ export default {
145
146
  "quality.result.percentage.description": "{result}%",
146
147
  "quality.result_type": "Tipo resultado",
147
148
  "quality.rule.actions.create": "Nueva Implementación",
149
+ "quality.rule.actions.create_basic": "Nueva implementación básica",
148
150
  "quality.rule.actions.create_raw": "Nueva implementación nativa",
149
151
  "quality.rule.description": "Descripción",
150
152
  "quality.rule.failed": "Failed",