@truedat/dq 4.36.9 → 4.37.3
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/CHANGELOG.md +26 -0
- package/package.json +4 -4
- package/src/components/ImplementationsRoutes.js +4 -0
- package/src/components/RuleEventRow.js +47 -0
- package/src/components/RuleEvents.js +31 -0
- package/src/components/RuleImplementationSelectedFilters.js +18 -0
- package/src/components/RuleImplementationsDownload.js +2 -1
- package/src/components/RuleRoutes.js +24 -0
- package/src/components/RuleSelectedFilters.js +18 -0
- package/src/components/RuleTabs.js +16 -2
- package/src/components/RulesRoutes.js +13 -1
- package/src/components/__tests__/RuleEventRow.spec.js +33 -0
- package/src/components/__tests__/RuleEvents.spec.js +64 -0
- package/src/components/__tests__/RuleImplementationEvents.spec.js +2 -3
- package/src/components/__tests__/__snapshots__/RuleEventRow.spec.js.snap +38 -0
- package/src/components/__tests__/__snapshots__/RuleEvents.spec.js.snap +78 -0
- package/src/components/__tests__/__snapshots__/RuleImplementationEvents.spec.js.snap +2 -2
- package/src/components/ruleImplementationForm/DatasetForm.js +9 -26
- package/src/components/ruleImplementationForm/FiltersField.js +2 -12
- package/src/components/ruleImplementationForm/__tests__/DataSetForm.spec.js +19 -59
- package/src/components/ruleImplementationForm/__tests__/FiltersField.spec.js +4 -18
- package/src/components/ruleImplementationForm/__tests__/__snapshots__/DataSetForm.spec.js.snap +7 -147
- package/src/components/ruleImplementationForm/__tests__/__snapshots__/FiltersField.spec.js.snap +7 -12
- package/src/messages/en.js +8 -0
- package/src/messages/es.js +11 -0
- package/src/reducers/__tests__/ruleActiveFilters.spec.js +19 -7
- package/src/reducers/__tests__/ruleImplementationActiveFilters.spec.js +19 -7
- package/src/reducers/index.js +0 -2
- package/src/reducers/ruleActiveFilters.js +5 -0
- package/src/reducers/ruleImplementationActiveFilters.js +7 -0
- package/src/routines.js +0 -3
- package/src/selectors/__tests__/datasetDefaultFiltersSelector.spec.js +17 -0
- package/src/selectors/__tests__/getParsedEvents.spec.js +173 -0
- package/src/selectors/datasetDefaultFiltersSelector.js +8 -0
- package/src/selectors/getParsedEvents.js +55 -0
- package/src/selectors/index.js +1 -1
- package/src/reducers/__tests__/ruleImplementationFilterValues.spec.js +0 -36
- package/src/reducers/ruleImplementationFilterValues.js +0 -20
- package/src/selectors/__tests__/getRuleImplementationFormFilters.spec.js +0 -22
- package/src/selectors/getRuleImplementationFormFilters.js +0 -19
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { applyUserSearchFilter } from "@truedat/dd/routines";
|
|
1
2
|
import { initialState } from "../ruleImplementationActiveFilters";
|
|
2
3
|
import {
|
|
3
4
|
addImplementationFilter,
|
|
4
5
|
closeImplementationFilter,
|
|
5
6
|
removeImplementationFilter,
|
|
6
7
|
resetImplementationFilters,
|
|
7
|
-
toggleImplementationFilterValue
|
|
8
|
+
toggleImplementationFilterValue,
|
|
8
9
|
} from "../../routines";
|
|
9
10
|
import { ruleImplementationActiveFilters } from "..";
|
|
10
11
|
|
|
@@ -17,13 +18,24 @@ describe("reducers: ruleImplementationActiveFilters", () => {
|
|
|
17
18
|
);
|
|
18
19
|
});
|
|
19
20
|
|
|
21
|
+
it("should handle the applyUserSearchFilter.TRIGGER action", () => {
|
|
22
|
+
const filters = { country: ["Sp"] };
|
|
23
|
+
const payload = { userFilter: { filters }, scope: "rule_implementation" };
|
|
24
|
+
expect(
|
|
25
|
+
ruleImplementationActiveFilters(fooState, {
|
|
26
|
+
type: applyUserSearchFilter.TRIGGER,
|
|
27
|
+
payload,
|
|
28
|
+
})
|
|
29
|
+
).toEqual({ ...filters });
|
|
30
|
+
});
|
|
31
|
+
|
|
20
32
|
it("should handle the addImplementationFilter.TRIGGER action", () => {
|
|
21
33
|
const filter = "baz";
|
|
22
34
|
const payload = { filter };
|
|
23
35
|
expect(
|
|
24
36
|
ruleImplementationActiveFilters(fooState, {
|
|
25
37
|
type: addImplementationFilter.TRIGGER,
|
|
26
|
-
payload
|
|
38
|
+
payload,
|
|
27
39
|
})
|
|
28
40
|
).toEqual({ ...fooState, baz: [] });
|
|
29
41
|
});
|
|
@@ -36,7 +48,7 @@ describe("reducers: ruleImplementationActiveFilters", () => {
|
|
|
36
48
|
expect(
|
|
37
49
|
ruleImplementationActiveFilters(state, {
|
|
38
50
|
type: closeImplementationFilter.TRIGGER,
|
|
39
|
-
payload
|
|
51
|
+
payload,
|
|
40
52
|
})
|
|
41
53
|
).toEqual({ foo });
|
|
42
54
|
});
|
|
@@ -49,7 +61,7 @@ describe("reducers: ruleImplementationActiveFilters", () => {
|
|
|
49
61
|
expect(
|
|
50
62
|
ruleImplementationActiveFilters(state, {
|
|
51
63
|
type: removeImplementationFilter.TRIGGER,
|
|
52
|
-
payload
|
|
64
|
+
payload,
|
|
53
65
|
})
|
|
54
66
|
).toEqual({ bar });
|
|
55
67
|
});
|
|
@@ -57,7 +69,7 @@ describe("reducers: ruleImplementationActiveFilters", () => {
|
|
|
57
69
|
it("should handle the resetImplementationFilters.TRIGGER action", () => {
|
|
58
70
|
expect(
|
|
59
71
|
ruleImplementationActiveFilters(fooState, {
|
|
60
|
-
type: resetImplementationFilters.TRIGGER
|
|
72
|
+
type: resetImplementationFilters.TRIGGER,
|
|
61
73
|
})
|
|
62
74
|
).toEqual(initialState);
|
|
63
75
|
});
|
|
@@ -67,7 +79,7 @@ describe("reducers: ruleImplementationActiveFilters", () => {
|
|
|
67
79
|
ruleImplementationActiveFilters(
|
|
68
80
|
{ ...fooState, executable: [true] },
|
|
69
81
|
{
|
|
70
|
-
type: resetImplementationFilters.TRIGGER
|
|
82
|
+
type: resetImplementationFilters.TRIGGER,
|
|
71
83
|
}
|
|
72
84
|
)
|
|
73
85
|
).toEqual({ executable: [true] });
|
|
@@ -81,7 +93,7 @@ describe("reducers: ruleImplementationActiveFilters", () => {
|
|
|
81
93
|
expect(
|
|
82
94
|
ruleImplementationActiveFilters(state, {
|
|
83
95
|
type: toggleImplementationFilterValue.TRIGGER,
|
|
84
|
-
payload
|
|
96
|
+
payload,
|
|
85
97
|
})
|
|
86
98
|
).toEqual({ foo: ["foo1", "foo3"], bar });
|
|
87
99
|
});
|
package/src/reducers/index.js
CHANGED
|
@@ -17,7 +17,6 @@ import { ruleImplementation } from "./ruleImplementation";
|
|
|
17
17
|
import { ruleImplementationCount } from "./ruleImplementationCount";
|
|
18
18
|
import { ruleImplementationCreating } from "./ruleImplementationCreating";
|
|
19
19
|
import { ruleImplementationFilters } from "./ruleImplementationFilters";
|
|
20
|
-
import { ruleImplementationFilterValues } from "./ruleImplementationFilterValues";
|
|
21
20
|
import { ruleImplementationLoading } from "./ruleImplementationLoading";
|
|
22
21
|
import { ruleImplementationQuery } from "./ruleImplementationQuery";
|
|
23
22
|
import { ruleImplementationRaw } from "./ruleImplementationRaw";
|
|
@@ -65,7 +64,6 @@ export {
|
|
|
65
64
|
ruleImplementationCount,
|
|
66
65
|
ruleImplementationCreating,
|
|
67
66
|
ruleImplementationFilters,
|
|
68
|
-
ruleImplementationFilterValues,
|
|
69
67
|
ruleImplementationLoading,
|
|
70
68
|
ruleImplementationQuery,
|
|
71
69
|
ruleImplementationRaw,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
+
import { applyUserSearchFilter } from "@truedat/dd/routines";
|
|
2
3
|
import {
|
|
3
4
|
addRuleFilter,
|
|
4
5
|
closeRuleFilter,
|
|
@@ -15,6 +16,10 @@ export const ruleActiveFilters = (state = initialState, { type, payload }) => {
|
|
|
15
16
|
const { filter } = payload;
|
|
16
17
|
return { ...state, [filter]: [] };
|
|
17
18
|
}
|
|
19
|
+
case applyUserSearchFilter.TRIGGER: {
|
|
20
|
+
const { userFilter, scope } = payload;
|
|
21
|
+
return scope === "rule" ? _.prop("filters")(userFilter) : state;
|
|
22
|
+
}
|
|
18
23
|
case closeRuleFilter.TRIGGER: {
|
|
19
24
|
const { filter } = payload;
|
|
20
25
|
const values = _.propOr([], filter)(state);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
+
import { applyUserSearchFilter } from "@truedat/dd/routines";
|
|
2
3
|
import {
|
|
3
4
|
addImplementationFilter,
|
|
4
5
|
closeImplementationFilter,
|
|
@@ -18,6 +19,12 @@ export const ruleImplementationActiveFilters = (
|
|
|
18
19
|
const { filter } = payload;
|
|
19
20
|
return { ...state, [filter]: [] };
|
|
20
21
|
}
|
|
22
|
+
case applyUserSearchFilter.TRIGGER: {
|
|
23
|
+
const { userFilter, scope } = payload;
|
|
24
|
+
return scope === "rule_implementation"
|
|
25
|
+
? _.prop("filters")(userFilter)
|
|
26
|
+
: state;
|
|
27
|
+
}
|
|
21
28
|
case closeImplementationFilter.TRIGGER: {
|
|
22
29
|
const { filter } = payload;
|
|
23
30
|
const values = _.propOr([], filter)(state);
|
package/src/routines.js
CHANGED
|
@@ -48,9 +48,6 @@ export const updateDeletionQuery = createRoutine("UPDATE_DELETION_QUERY");
|
|
|
48
48
|
export const uploadRules = createRoutine("UPLOAD_RULES");
|
|
49
49
|
export const uploadImplementations = createRoutine("UPLOAD_IMPLEMENTATIONS");
|
|
50
50
|
export const clearStructure = createRoutine("CLEAR_STRUCTURE");
|
|
51
|
-
export const setImplementationFilterValues = createRoutine(
|
|
52
|
-
"SET_IMPLEMENTATION_FILTER_VALUES"
|
|
53
|
-
);
|
|
54
51
|
export const searchRuleImplementations = createRoutine(
|
|
55
52
|
"SEARCH_RULE_IMPLEMENTATIONS"
|
|
56
53
|
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
datasetDefaultFiltersSelector,
|
|
3
|
+
defaultFilters,
|
|
4
|
+
} from "../datasetDefaultFiltersSelector";
|
|
5
|
+
|
|
6
|
+
describe("datasetDefaultFiltersSelector", () => {
|
|
7
|
+
it("returns datasetDefaultFilters if present the state", () => {
|
|
8
|
+
const datasetDefaultFilters = { "class.raw": ["foo", "bar"] };
|
|
9
|
+
const state = { datasetDefaultFilters };
|
|
10
|
+
expect(datasetDefaultFiltersSelector(state)).toBe(datasetDefaultFilters);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("returns the default value if datasetDefaultFilters is not present in the state", () => {
|
|
14
|
+
const state = {};
|
|
15
|
+
expect(datasetDefaultFiltersSelector(state)).toBe(defaultFilters);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { getParsedEvents } from "..";
|
|
2
|
+
|
|
3
|
+
describe("selectors: getParsedEvents", () => {
|
|
4
|
+
const events = [
|
|
5
|
+
{
|
|
6
|
+
id: 52351,
|
|
7
|
+
service: "td_dd",
|
|
8
|
+
resource_id: 777,
|
|
9
|
+
resource_type: "rule",
|
|
10
|
+
event: "rule_created",
|
|
11
|
+
payload: {
|
|
12
|
+
active: true,
|
|
13
|
+
content: {
|
|
14
|
+
added: {
|
|
15
|
+
data_owner: null,
|
|
16
|
+
proyecto: ["P1"],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
description: {},
|
|
20
|
+
df_name: "dq_default_template",
|
|
21
|
+
domain_id: 2,
|
|
22
|
+
goal: 20,
|
|
23
|
+
minimum: 80,
|
|
24
|
+
name: "des01",
|
|
25
|
+
result_type: "deviation",
|
|
26
|
+
updated_by: 398,
|
|
27
|
+
},
|
|
28
|
+
user_id: 398,
|
|
29
|
+
user_name: null,
|
|
30
|
+
user: {
|
|
31
|
+
email: "some.user@domain.tld",
|
|
32
|
+
full_name: "Some User",
|
|
33
|
+
id: 398,
|
|
34
|
+
user_name: "some.user@domain.tld",
|
|
35
|
+
},
|
|
36
|
+
ts: "2021-08-12T12:11:26.908147Z",
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
id: 100217,
|
|
41
|
+
service: "td_dd",
|
|
42
|
+
resource_id: 777,
|
|
43
|
+
resource_type: "rule",
|
|
44
|
+
event: "rule_updated",
|
|
45
|
+
payload: {
|
|
46
|
+
domain_id: 140,
|
|
47
|
+
},
|
|
48
|
+
user_id: 142,
|
|
49
|
+
user_name: null,
|
|
50
|
+
user: {
|
|
51
|
+
email: "some.user@domain.tld",
|
|
52
|
+
full_name: "Some User",
|
|
53
|
+
id: 142,
|
|
54
|
+
user_name: "some.user@domain.tld",
|
|
55
|
+
},
|
|
56
|
+
ts: "2021-09-16T07:36:32.848603Z",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 100435,
|
|
60
|
+
service: "td_dd",
|
|
61
|
+
resource_id: 777,
|
|
62
|
+
resource_type: "rule",
|
|
63
|
+
event: "rule_updated",
|
|
64
|
+
payload: {
|
|
65
|
+
description: {
|
|
66
|
+
document: {
|
|
67
|
+
data: {},
|
|
68
|
+
nodes: [
|
|
69
|
+
{
|
|
70
|
+
data: {},
|
|
71
|
+
nodes: [
|
|
72
|
+
{
|
|
73
|
+
marks: [],
|
|
74
|
+
object: "text",
|
|
75
|
+
text: "Añadimos descripción a la regla",
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
object: "block",
|
|
79
|
+
type: "paragraph",
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
object: "document",
|
|
83
|
+
},
|
|
84
|
+
object: "value",
|
|
85
|
+
},
|
|
86
|
+
updated_by: 171,
|
|
87
|
+
},
|
|
88
|
+
user_id: 171,
|
|
89
|
+
user_name: null,
|
|
90
|
+
user: {
|
|
91
|
+
email: "some.user@domain.tld",
|
|
92
|
+
full_name: "Some User",
|
|
93
|
+
id: 171,
|
|
94
|
+
user_name: "some.user",
|
|
95
|
+
},
|
|
96
|
+
ts: "2021-09-16T09:30:52.317357Z",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 177692,
|
|
100
|
+
service: "td_dd",
|
|
101
|
+
resource_id: 777,
|
|
102
|
+
resource_type: "rule",
|
|
103
|
+
event: "rule_updated",
|
|
104
|
+
payload: {
|
|
105
|
+
content: {
|
|
106
|
+
changed: {
|
|
107
|
+
data_stew: null,
|
|
108
|
+
principle: "Validez",
|
|
109
|
+
scheduler: "",
|
|
110
|
+
tags: "et",
|
|
111
|
+
},
|
|
112
|
+
removed: {
|
|
113
|
+
data_owner: null,
|
|
114
|
+
proyecto: ["P1"],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
df_name: "quality_template",
|
|
118
|
+
updated_by: 426,
|
|
119
|
+
},
|
|
120
|
+
user_id: 426,
|
|
121
|
+
user_name: null,
|
|
122
|
+
user: {
|
|
123
|
+
email: "some.user@domain.tld",
|
|
124
|
+
full_name: "Some User",
|
|
125
|
+
id: 426,
|
|
126
|
+
user_name: "some.user",
|
|
127
|
+
},
|
|
128
|
+
ts: "2021-10-20T07:56:45.891087Z",
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
const parsed = [
|
|
133
|
+
{
|
|
134
|
+
...events[0],
|
|
135
|
+
payload: [{ field: "des01", action: "created" }],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
...events[1],
|
|
139
|
+
payload: [{ field: "domain_id", action: "changed", value: 140 }],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
...events[2],
|
|
143
|
+
payload: [
|
|
144
|
+
{
|
|
145
|
+
field: "description",
|
|
146
|
+
action: "changed",
|
|
147
|
+
value: "Añadimos descripción a la regla",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
...events[3],
|
|
153
|
+
payload: [
|
|
154
|
+
{ field: "df_name", action: "changed", value: "quality_template" },
|
|
155
|
+
{ action: "changed", field: "data_stew", value: null },
|
|
156
|
+
{ action: "changed", field: "principle", value: "Validez" },
|
|
157
|
+
{ action: "changed", field: "scheduler", value: "" },
|
|
158
|
+
{ action: "changed", field: "tags", value: "et" },
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
it("should return all the events with the new payload", () => {
|
|
164
|
+
const res = getParsedEvents({ events });
|
|
165
|
+
expect(res).toEqual(parsed);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("should return empty array when we have no elements", () => {
|
|
169
|
+
const res = getParsedEvents({ events: [] });
|
|
170
|
+
expect(res).toHaveLength(0);
|
|
171
|
+
expect(res).toEqual(expect.arrayContaining([]));
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -8,6 +8,24 @@ const getEvents = ({ events }) => {
|
|
|
8
8
|
const transformFieldFormat = (field) =>
|
|
9
9
|
_.isBoolean(field) ? _.toString(field) : field;
|
|
10
10
|
|
|
11
|
+
const findDeep = (obj, key) =>
|
|
12
|
+
_.has(key, obj)
|
|
13
|
+
? obj[key]
|
|
14
|
+
: _.flatten(
|
|
15
|
+
_.map((v) => (typeof v == "object" ? findDeep(v, key) : []), obj)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const transformRulePayloadFormat = (payload, field) => {
|
|
19
|
+
switch (field) {
|
|
20
|
+
case "content":
|
|
21
|
+
return payload.content;
|
|
22
|
+
case "description":
|
|
23
|
+
return _.first(findDeep(payload.description, "text"));
|
|
24
|
+
default:
|
|
25
|
+
return payload[field];
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
11
29
|
const getParsedEvents = createSelector([getEvents], (events) => {
|
|
12
30
|
return _.map((d) => {
|
|
13
31
|
switch (d.event) {
|
|
@@ -68,6 +86,43 @@ const getParsedEvents = createSelector([getEvents], (events) => {
|
|
|
68
86
|
}))
|
|
69
87
|
)(d),
|
|
70
88
|
};
|
|
89
|
+
case "rule_created":
|
|
90
|
+
return {
|
|
91
|
+
...d,
|
|
92
|
+
payload: [
|
|
93
|
+
{
|
|
94
|
+
field: _.path("payload.name")(d),
|
|
95
|
+
action: "created",
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
case "rule_updated":
|
|
101
|
+
const content = _.flow(
|
|
102
|
+
_.getOr({}, "payload.content.changed"),
|
|
103
|
+
_.toPairs,
|
|
104
|
+
_.map(([field, value]) => ({
|
|
105
|
+
field,
|
|
106
|
+
value,
|
|
107
|
+
action: "changed",
|
|
108
|
+
}))
|
|
109
|
+
)(d);
|
|
110
|
+
return {
|
|
111
|
+
...d,
|
|
112
|
+
payload: [
|
|
113
|
+
..._.flow(
|
|
114
|
+
_.path("payload"),
|
|
115
|
+
_.omit(["updated_by", "content"]),
|
|
116
|
+
_.keys,
|
|
117
|
+
_.map((field) => ({
|
|
118
|
+
field: field,
|
|
119
|
+
action: "changed",
|
|
120
|
+
value: transformRulePayloadFormat(d.payload, field),
|
|
121
|
+
}))
|
|
122
|
+
)(d),
|
|
123
|
+
...content,
|
|
124
|
+
],
|
|
125
|
+
};
|
|
71
126
|
|
|
72
127
|
default:
|
|
73
128
|
return {
|
package/src/selectors/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { datasetDefaultFiltersSelector } from "./datasetDefaultFiltersSelector";
|
|
1
2
|
export { getImplementationsExecution } from "./getImplementationsExecution";
|
|
2
3
|
export { getRuleAvailableFilters } from "./getRuleAvailableFilters";
|
|
3
4
|
export { getRuleSelectedFilters } from "./getRuleSelectedFilters";
|
|
@@ -22,7 +23,6 @@ export {
|
|
|
22
23
|
defaultImplementationColumns,
|
|
23
24
|
} from "./getRuleImplementationColumns";
|
|
24
25
|
export { getPreviousRuleImplementationQuery } from "./getPreviousRuleImplementationQuery";
|
|
25
|
-
export { getRuleImplementationFormFilters } from "./getRuleImplementationFormFilters";
|
|
26
26
|
export { getRuleImplementationAvailableFilters } from "./getRuleImplementationAvailableFilters";
|
|
27
27
|
export { getRuleImplementationSelectedFilters } from "./getRuleImplementationSelectedFilters";
|
|
28
28
|
export { getRuleImplementationSelectedFilterValues } from "./getRuleImplementationSelectedFilterValues";
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { clearRule, setImplementationFilterValues } from "../../routines";
|
|
2
|
-
import { ruleImplementationFilterValues } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
const value = { system: { name: "Whatever" } };
|
|
6
|
-
|
|
7
|
-
describe("reducers: ruleImplementationFilterValues", () => {
|
|
8
|
-
const initialState = null;
|
|
9
|
-
|
|
10
|
-
it("should provide the initial state", () => {
|
|
11
|
-
expect(ruleImplementationFilterValues(undefined, {})).toEqual(initialState);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should handle the setImplementationFilterValues.TRIGGER action", () => {
|
|
15
|
-
expect(
|
|
16
|
-
ruleImplementationFilterValues(fooState, {
|
|
17
|
-
type: setImplementationFilterValues.TRIGGER,
|
|
18
|
-
payload: { value }
|
|
19
|
-
})
|
|
20
|
-
).toEqual(value);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should handle the clearRule.TRIGGER action", () => {
|
|
24
|
-
expect(
|
|
25
|
-
ruleImplementationFilterValues(fooState, {
|
|
26
|
-
type: clearRule.TRIGGER
|
|
27
|
-
})
|
|
28
|
-
).toEqual(null);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should ignore unknown actions", () => {
|
|
32
|
-
expect(ruleImplementationFilterValues(fooState, { type: "FOO" })).toBe(
|
|
33
|
-
fooState
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { clearRule, setImplementationFilterValues } from "../routines";
|
|
2
|
-
|
|
3
|
-
/** @type {string} */
|
|
4
|
-
export const initialState = null;
|
|
5
|
-
|
|
6
|
-
export const ruleImplementationFilterValues = (
|
|
7
|
-
state = initialState,
|
|
8
|
-
{ type, payload }
|
|
9
|
-
) => {
|
|
10
|
-
switch (type) {
|
|
11
|
-
case setImplementationFilterValues.TRIGGER: {
|
|
12
|
-
const { value } = payload;
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
case clearRule.TRIGGER:
|
|
16
|
-
return initialState;
|
|
17
|
-
default:
|
|
18
|
-
return state;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getRuleImplementationFormFilters } from "..";
|
|
2
|
-
|
|
3
|
-
const ruleImplementationFormFilters = [
|
|
4
|
-
{ name: "system.name", filter: "system.name.raw", values: v => [v] }
|
|
5
|
-
];
|
|
6
|
-
|
|
7
|
-
const ruleImplementationFilterValues = { system: { name: "foo" } };
|
|
8
|
-
|
|
9
|
-
describe("selectors: getRuleImplementationFormFilters", () => {
|
|
10
|
-
it("should return null when params do not exists", () => {
|
|
11
|
-
const res = getRuleImplementationFormFilters({});
|
|
12
|
-
expect(res).toMatchObject({});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("should return default filters", () => {
|
|
16
|
-
const res = getRuleImplementationFormFilters({
|
|
17
|
-
ruleImplementationFormFilters,
|
|
18
|
-
ruleImplementationFilterValues
|
|
19
|
-
});
|
|
20
|
-
expect(res).toMatchObject({ "system.name.raw": ["foo"] });
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { createSelector } from "reselect";
|
|
3
|
-
|
|
4
|
-
export const getRuleImplementationFormFilters = createSelector(
|
|
5
|
-
[
|
|
6
|
-
_.prop("ruleImplementationFilterValues"),
|
|
7
|
-
_.prop("ruleImplementationFormFilters")
|
|
8
|
-
],
|
|
9
|
-
(ruleImplementationFilterValues, ruleImplementationFormFilters) =>
|
|
10
|
-
ruleImplementationFilterValues && ruleImplementationFormFilters
|
|
11
|
-
? _.reduce(
|
|
12
|
-
(acc, { name, filter, values }) => ({
|
|
13
|
-
...acc,
|
|
14
|
-
[filter]: values(_.path(name)(ruleImplementationFilterValues))
|
|
15
|
-
}),
|
|
16
|
-
{}
|
|
17
|
-
)(ruleImplementationFormFilters)
|
|
18
|
-
: {}
|
|
19
|
-
);
|