@outliant/sunrise-utils 1.0.0
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/.eslintignore +5 -0
- package/.eslintrc +53 -0
- package/.github/workflows/pr-dev-workflow.yml +16 -0
- package/.nvmrc +1 -0
- package/.release-it.js +26 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +12 -0
- package/README.md +19 -0
- package/changelog.hbs +13 -0
- package/helpers/es.js +6 -0
- package/helpers/projectFilter/projectFieldFilter.js +587 -0
- package/helpers/searchFilter.js +86 -0
- package/helpers/taskFilter/criticalPathFilter.js +144 -0
- package/helpers/taskFilter/index.js +228 -0
- package/helpers/taskFilter/onHoldFilter.js +101 -0
- package/helpers/taskFilter/ownerFilter.js +148 -0
- package/helpers/taskFilter/pathAgeFilter.js +18 -0
- package/helpers/taskFilter/regionFilter.js +82 -0
- package/helpers/taskFilter/statusFilter.js +177 -0
- package/helpers/taskFilter/taskFieldFilter.js +309 -0
- package/helpers/taskSortScript.js +356 -0
- package/index.d.ts +11 -0
- package/index.js +9 -0
- package/lib/fieldConditions.js +166 -0
- package/lib/logger.js +48 -0
- package/lib/taskPipeline.js +137 -0
- package/package.json +73 -0
- package/test/helpers/projectFilter/projectFieldFilter.spec.js +881 -0
- package/test/helpers/taskFilter/criticalPathFilter.spec.js +174 -0
- package/test/helpers/taskFilter/index.spec.js +339 -0
- package/test/helpers/taskFilter/onHoldFilter.spec.js +112 -0
- package/test/helpers/taskFilter/ownerFilter.spec.js +226 -0
- package/test/helpers/taskFilter/pathAgeFilter.spec.js +47 -0
- package/test/helpers/taskFilter/regionFilter.spec.js +131 -0
- package/test/helpers/taskFilter/statusFilter.spec.js +197 -0
- package/test/helpers/taskFilter/taskFieldFilter.spec.js +355 -0
- package/test/lib/fieldConditions.spec.js +17 -0
- package/test/lib/logger.spec.js +117 -0
- package/test/lib/taskPipeline.spec.js +162 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-env node, mocha */
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
|
|
6
|
+
// To test
|
|
7
|
+
const criticalPathFilter = require('../../../helpers/taskFilter/criticalPathFilter');
|
|
8
|
+
|
|
9
|
+
describe('taskFilter/criticalPathFilter', function () {
|
|
10
|
+
const filters = [
|
|
11
|
+
{
|
|
12
|
+
input: {
|
|
13
|
+
condition: 'is_equal',
|
|
14
|
+
field_id: '',
|
|
15
|
+
type: 'critical_path_stage',
|
|
16
|
+
field_type: 'select',
|
|
17
|
+
value: 'ad5c7d3b-47e0-4a72-8903-6e971812740e',
|
|
18
|
+
second_value: ''
|
|
19
|
+
},
|
|
20
|
+
output: {
|
|
21
|
+
bool: {
|
|
22
|
+
must: [
|
|
23
|
+
{ exists: { field: 'critical_path.stage_id' } },
|
|
24
|
+
{
|
|
25
|
+
term: {
|
|
26
|
+
'critical_path.stage_id': {
|
|
27
|
+
value: 'ad5c7d3b-47e0-4a72-8903-6e971812740e'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
input: {
|
|
37
|
+
condition: 'not_equal',
|
|
38
|
+
field_id: '',
|
|
39
|
+
type: 'critical_path_stage',
|
|
40
|
+
field_type: 'select',
|
|
41
|
+
value: '24684458-a275-40d7-9e87-c33a06af0f8e',
|
|
42
|
+
second_value: ''
|
|
43
|
+
},
|
|
44
|
+
output: {
|
|
45
|
+
bool: {
|
|
46
|
+
must_not: [
|
|
47
|
+
{
|
|
48
|
+
term: {
|
|
49
|
+
'critical_path.stage_id': {
|
|
50
|
+
value: '24684458-a275-40d7-9e87-c33a06af0f8e'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
input: {
|
|
60
|
+
condition: 'is_empty',
|
|
61
|
+
field_id: '',
|
|
62
|
+
type: 'critical_path_stage',
|
|
63
|
+
field_type: 'select',
|
|
64
|
+
value: '',
|
|
65
|
+
second_value: ''
|
|
66
|
+
},
|
|
67
|
+
output: {
|
|
68
|
+
bool: {
|
|
69
|
+
should: [
|
|
70
|
+
{ bool: { must_not: [{ exists: { field: 'critical_path' } }] } },
|
|
71
|
+
{
|
|
72
|
+
bool: {
|
|
73
|
+
must_not: [{ exists: { field: 'critical_path.stage_id' } }]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{ term: { 'critical_path.stage_id': { value: '' } } }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
input: {
|
|
83
|
+
condition: 'is_not_empty',
|
|
84
|
+
field_id: '',
|
|
85
|
+
type: 'critical_path_stage',
|
|
86
|
+
field_type: 'select',
|
|
87
|
+
value: '',
|
|
88
|
+
second_value: ''
|
|
89
|
+
},
|
|
90
|
+
output: {
|
|
91
|
+
bool: {
|
|
92
|
+
must: [
|
|
93
|
+
{ exists: { field: 'critical_path' } },
|
|
94
|
+
{ exists: { field: 'critical_path.stage_id' } }
|
|
95
|
+
],
|
|
96
|
+
must_not: [{ term: { 'critical_path.stage_id': { value: '' } } }]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
input: {
|
|
102
|
+
condition: 'is_any_of',
|
|
103
|
+
field_id: '',
|
|
104
|
+
type: 'critical_path_stage',
|
|
105
|
+
field_type: 'select',
|
|
106
|
+
value:
|
|
107
|
+
'163ba61c-acfa-4f92-bc18-cdef2ab2a959;e03ab325-f630-4517-8055-02c6c0f84141',
|
|
108
|
+
second_value: ''
|
|
109
|
+
},
|
|
110
|
+
output: {
|
|
111
|
+
bool: {
|
|
112
|
+
must: [
|
|
113
|
+
{ exists: { field: 'critical_path.stage_id' } },
|
|
114
|
+
{
|
|
115
|
+
terms: {
|
|
116
|
+
'critical_path.stage_id': [
|
|
117
|
+
'163ba61c-acfa-4f92-bc18-cdef2ab2a959',
|
|
118
|
+
'e03ab325-f630-4517-8055-02c6c0f84141'
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
input: {
|
|
128
|
+
condition: 'is_any_of',
|
|
129
|
+
field_id: '',
|
|
130
|
+
type: 'critical_path_stage',
|
|
131
|
+
field_type: 'select',
|
|
132
|
+
value: [
|
|
133
|
+
'163ba61c-acfa-4f92-bc18-cdef2ab2a959',
|
|
134
|
+
'e03ab325-f630-4517-8055-02c6c0f84141'
|
|
135
|
+
],
|
|
136
|
+
second_value: ''
|
|
137
|
+
},
|
|
138
|
+
output: {
|
|
139
|
+
bool: {
|
|
140
|
+
must: [
|
|
141
|
+
{ exists: { field: 'critical_path.stage_id' } },
|
|
142
|
+
{
|
|
143
|
+
terms: {
|
|
144
|
+
'critical_path.stage_id': [
|
|
145
|
+
'163ba61c-acfa-4f92-bc18-cdef2ab2a959',
|
|
146
|
+
'e03ab325-f630-4517-8055-02c6c0f84141'
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
input: {
|
|
156
|
+
condition: 'unknown_condition',
|
|
157
|
+
field_id: '',
|
|
158
|
+
type: 'critical_path_stage',
|
|
159
|
+
field_type: 'select',
|
|
160
|
+
value: '',
|
|
161
|
+
second_value: ''
|
|
162
|
+
},
|
|
163
|
+
output: null
|
|
164
|
+
}
|
|
165
|
+
];
|
|
166
|
+
filters.forEach((filter) => {
|
|
167
|
+
it(`${filter.input.condition}: ${JSON.stringify(
|
|
168
|
+
filter.input.value
|
|
169
|
+
)}`, (done) => {
|
|
170
|
+
expect(criticalPathFilter(filter.input)).to.deep.equal(filter.output);
|
|
171
|
+
done();
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-env node, mocha */
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
|
|
6
|
+
// To test
|
|
7
|
+
const taskFilter = require('../../../helpers/taskFilter/index');
|
|
8
|
+
|
|
9
|
+
describe('taskFilter', function () {
|
|
10
|
+
describe('buildTaskPipelineFilter', function () {
|
|
11
|
+
it('should handle status filter', (done) => {
|
|
12
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
13
|
+
condition: 'is_equal',
|
|
14
|
+
field_id: '',
|
|
15
|
+
type: 'status',
|
|
16
|
+
field_type: 'select',
|
|
17
|
+
value: 'pending',
|
|
18
|
+
second_value: ''
|
|
19
|
+
});
|
|
20
|
+
expect(filter).to.be.deep.equal({
|
|
21
|
+
bool: {
|
|
22
|
+
must: [{ term: { is_ready: true } }, { term: { is_complete: false } }]
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
done();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should handle owner filter', (done) => {
|
|
29
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
30
|
+
condition: 'is_equal',
|
|
31
|
+
field_id: '',
|
|
32
|
+
type: 'owner',
|
|
33
|
+
field_type: 'select',
|
|
34
|
+
value: '7744bfdb-b798-400f-9d82-b157722afd8b',
|
|
35
|
+
second_value: ''
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
expect(filter).to.be.deep.equal({
|
|
39
|
+
bool: {
|
|
40
|
+
must: [
|
|
41
|
+
{
|
|
42
|
+
term: {
|
|
43
|
+
user_id: { value: '7744bfdb-b798-400f-9d82-b157722afd8b' }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should handle region filter', (done) => {
|
|
53
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
54
|
+
condition: 'is_equal',
|
|
55
|
+
field_id: '',
|
|
56
|
+
type: 'region',
|
|
57
|
+
field_type: 'checkbox',
|
|
58
|
+
value: [
|
|
59
|
+
'0PbPSnUBiH_7DigZLwM_',
|
|
60
|
+
'1fbPSnUBiH_7DigZTgMZ',
|
|
61
|
+
'0fbPSnUBiH_7DigZNQOZ'
|
|
62
|
+
],
|
|
63
|
+
second_value: ''
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(filter).to.be.deep.equal({
|
|
67
|
+
bool: {
|
|
68
|
+
should: [
|
|
69
|
+
{ term: { region_id: { value: '0PbPSnUBiH_7DigZLwM_' } } },
|
|
70
|
+
{ term: { region_id: { value: '1fbPSnUBiH_7DigZTgMZ' } } },
|
|
71
|
+
{ term: { region_id: { value: '0fbPSnUBiH_7DigZNQOZ' } } }
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
done();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should handle critical_path_stage filter', (done) => {
|
|
79
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
80
|
+
condition: 'is_equal',
|
|
81
|
+
field_id: '',
|
|
82
|
+
type: 'critical_path_stage',
|
|
83
|
+
field_type: 'select',
|
|
84
|
+
value: 'ad5c7d3b-47e0-4a72-8903-6e971812740e',
|
|
85
|
+
second_value: ''
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(filter).to.be.deep.equal({
|
|
89
|
+
bool: {
|
|
90
|
+
must: [
|
|
91
|
+
{ exists: { field: 'critical_path.stage_id' } },
|
|
92
|
+
{
|
|
93
|
+
term: {
|
|
94
|
+
'critical_path.stage_id': {
|
|
95
|
+
value: 'ad5c7d3b-47e0-4a72-8903-6e971812740e'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
done();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should handle on_hold filter', (done) => {
|
|
106
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
107
|
+
condition: 'is_equal',
|
|
108
|
+
field_id: '',
|
|
109
|
+
type: 'on_hold',
|
|
110
|
+
field_type: 'select',
|
|
111
|
+
value: 'Yes',
|
|
112
|
+
second_value: ''
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(filter).to.be.deep.equal({
|
|
116
|
+
bool: { must: [{ term: { on_hold: { value: true } } }] }
|
|
117
|
+
});
|
|
118
|
+
done();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should handle path_age filter', (done) => {
|
|
122
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
123
|
+
condition: 'is_equal',
|
|
124
|
+
field_id: '',
|
|
125
|
+
field_type: 'select',
|
|
126
|
+
type: 'path_age',
|
|
127
|
+
value: 'b3fd91b3-ecc9-41ae-b770-912a34e02e70'
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
expect(filter).to.be.deep.equal({
|
|
131
|
+
term: {
|
|
132
|
+
'critical_path.color_id': {
|
|
133
|
+
value: 'b3fd91b3-ecc9-41ae-b770-912a34e02e70'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
done();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should handle task_templates array filter', (done) => {
|
|
141
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
142
|
+
condition: 'is_equal',
|
|
143
|
+
field_id: '',
|
|
144
|
+
field_type: 'checkbox',
|
|
145
|
+
type: 'task_templates',
|
|
146
|
+
value: ['vFvy63gBfTAqAzzhaReL', '5iHf03cBytxFrtc2G7E-']
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
expect(filter).to.be.deep.equal({
|
|
150
|
+
bool: {
|
|
151
|
+
should: [
|
|
152
|
+
{ term: { task_template_id: { value: 'vFvy63gBfTAqAzzhaReL' } } },
|
|
153
|
+
{ term: { task_template_id: { value: '5iHf03cBytxFrtc2G7E-' } } }
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
done();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should handle task_templates string filter', (done) => {
|
|
161
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
162
|
+
condition: 'is_equal',
|
|
163
|
+
field_id: '',
|
|
164
|
+
field_type: 'checkbox',
|
|
165
|
+
type: 'task_templates',
|
|
166
|
+
value: 'vFvy63gBfTAqAzzhaReL;5iHf03cBytxFrtc2G7E-'
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
expect(filter).to.be.deep.equal({
|
|
170
|
+
bool: {
|
|
171
|
+
should: [
|
|
172
|
+
{ term: { task_template_id: { value: 'vFvy63gBfTAqAzzhaReL' } } },
|
|
173
|
+
{ term: { task_template_id: { value: '5iHf03cBytxFrtc2G7E-' } } }
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
done();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should handle dealinformation filter', (done) => {
|
|
181
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
182
|
+
condition: 'is_empty',
|
|
183
|
+
field_id: 'b6d0fe7c-f049-4b17-b6b9-d0bce4c35e57',
|
|
184
|
+
type: 'dealinformation',
|
|
185
|
+
field_type: 'number',
|
|
186
|
+
value: '',
|
|
187
|
+
second_value: ''
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
expect(filter).to.be.deep.equal({
|
|
191
|
+
bool: {
|
|
192
|
+
should: [
|
|
193
|
+
{
|
|
194
|
+
bool: {
|
|
195
|
+
must: [
|
|
196
|
+
{
|
|
197
|
+
nested: {
|
|
198
|
+
path: 'fields',
|
|
199
|
+
query: {
|
|
200
|
+
bool: {
|
|
201
|
+
must: [
|
|
202
|
+
{
|
|
203
|
+
term: {
|
|
204
|
+
'fields.id': {
|
|
205
|
+
value: 'b6d0fe7c-f049-4b17-b6b9-d0bce4c35e57'
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{ term: { 'fields.text': { value: '' } } }
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
bool: {
|
|
220
|
+
must_not: [
|
|
221
|
+
{
|
|
222
|
+
nested: {
|
|
223
|
+
path: 'fields',
|
|
224
|
+
query: {
|
|
225
|
+
bool: {
|
|
226
|
+
must: [
|
|
227
|
+
{
|
|
228
|
+
term: {
|
|
229
|
+
'fields.id': {
|
|
230
|
+
value: 'b6d0fe7c-f049-4b17-b6b9-d0bce4c35e57'
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
done();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('should handle contactinformation filter', (done) => {
|
|
249
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
250
|
+
condition: 'is_not_empty',
|
|
251
|
+
field_id: 'b6d0fe7c-f049-4b17-b6b9-d0bce4c35e57',
|
|
252
|
+
type: 'contactinformation',
|
|
253
|
+
field_type: 'number',
|
|
254
|
+
value: '',
|
|
255
|
+
second_value: ''
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
expect(filter).to.be.deep.equal({
|
|
259
|
+
bool: {
|
|
260
|
+
must: [
|
|
261
|
+
{
|
|
262
|
+
nested: {
|
|
263
|
+
path: 'fields',
|
|
264
|
+
query: {
|
|
265
|
+
bool: {
|
|
266
|
+
must: [
|
|
267
|
+
{
|
|
268
|
+
term: {
|
|
269
|
+
'fields.id': {
|
|
270
|
+
value: 'b6d0fe7c-f049-4b17-b6b9-d0bce4c35e57'
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{ exists: { field: 'fields.text' } },
|
|
275
|
+
{
|
|
276
|
+
bool: {
|
|
277
|
+
must_not: [{ term: { 'fields.text': { value: '' } } }]
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
done();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('should handle ticketinformation filter', (done) => {
|
|
292
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
293
|
+
condition: 'is_any_of',
|
|
294
|
+
field_id: '2726455e-fd84-4049-9756-e981e20a8772',
|
|
295
|
+
type: 'ticketinformation',
|
|
296
|
+
field_type: 'select',
|
|
297
|
+
value: 'Commercial;Hanwha',
|
|
298
|
+
second_value: ''
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
expect(filter).to.be.deep.equal({
|
|
302
|
+
nested: {
|
|
303
|
+
path: 'fields',
|
|
304
|
+
query: {
|
|
305
|
+
bool: {
|
|
306
|
+
must: [
|
|
307
|
+
{
|
|
308
|
+
term: {
|
|
309
|
+
'fields.id': {
|
|
310
|
+
value: '2726455e-fd84-4049-9756-e981e20a8772'
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
{ terms: { 'fields.text': ['Commercial', 'Hanwha'] } }
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
done();
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it('default', (done) => {
|
|
324
|
+
const filter = taskFilter.buildTaskPipelineFilter({
|
|
325
|
+
condition: 'is_equal',
|
|
326
|
+
field_id: '',
|
|
327
|
+
type: 'last_comment',
|
|
328
|
+
field_type: 'textarea',
|
|
329
|
+
value: 'test',
|
|
330
|
+
second_value: ''
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
expect(filter).to.be.deep.equal({
|
|
334
|
+
query_string: { fields: ['last_comment'], query: '*test*' }
|
|
335
|
+
});
|
|
336
|
+
done();
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-env node, mocha */
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
|
|
6
|
+
// To test
|
|
7
|
+
const onHoldFilter = require('../../../helpers/taskFilter/onHoldFilter');
|
|
8
|
+
|
|
9
|
+
describe('taskFilter/onHoldFilter', function () {
|
|
10
|
+
const filters = [
|
|
11
|
+
{
|
|
12
|
+
input: {
|
|
13
|
+
condition: 'is_equal',
|
|
14
|
+
field_id: '',
|
|
15
|
+
type: 'on_hold',
|
|
16
|
+
field_type: 'select',
|
|
17
|
+
value: 'Yes',
|
|
18
|
+
second_value: ''
|
|
19
|
+
},
|
|
20
|
+
output: { bool: { must: [{ term: { on_hold: { value: true } } }] } }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
input: {
|
|
24
|
+
condition: 'not_equal',
|
|
25
|
+
field_id: '',
|
|
26
|
+
type: 'on_hold',
|
|
27
|
+
field_type: 'select',
|
|
28
|
+
value: 'No',
|
|
29
|
+
second_value: ''
|
|
30
|
+
},
|
|
31
|
+
output: { bool: { must_not: [{ term: { on_hold: { value: false } } }] } }
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
input: {
|
|
35
|
+
condition: 'is_empty',
|
|
36
|
+
field_id: '',
|
|
37
|
+
type: 'on_hold',
|
|
38
|
+
field_type: 'select',
|
|
39
|
+
value: '',
|
|
40
|
+
second_value: ''
|
|
41
|
+
},
|
|
42
|
+
output: { bool: { must_not: [{ exists: { field: 'on_hold' } }] } }
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
input: {
|
|
46
|
+
condition: 'is_not_empty',
|
|
47
|
+
field_id: '',
|
|
48
|
+
type: 'on_hold',
|
|
49
|
+
field_type: 'select',
|
|
50
|
+
value: '',
|
|
51
|
+
second_value: ''
|
|
52
|
+
},
|
|
53
|
+
output: { bool: { must: [{ exists: { field: 'on_hold' } }] } }
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
input: {
|
|
57
|
+
condition: 'is_any_of',
|
|
58
|
+
field_id: '',
|
|
59
|
+
type: 'on_hold',
|
|
60
|
+
field_type: 'select',
|
|
61
|
+
value: 'No;Yes',
|
|
62
|
+
second_value: ''
|
|
63
|
+
},
|
|
64
|
+
output: {
|
|
65
|
+
bool: {
|
|
66
|
+
should: [
|
|
67
|
+
{ term: { on_hold: { value: false } } },
|
|
68
|
+
{ term: { on_hold: { value: true } } }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
input: {
|
|
75
|
+
condition: 'is_any_of',
|
|
76
|
+
field_id: '',
|
|
77
|
+
type: 'on_hold',
|
|
78
|
+
field_type: 'select',
|
|
79
|
+
value: ['No', 'Yes'],
|
|
80
|
+
second_value: ''
|
|
81
|
+
},
|
|
82
|
+
output: {
|
|
83
|
+
bool: {
|
|
84
|
+
should: [
|
|
85
|
+
{ term: { on_hold: { value: false } } },
|
|
86
|
+
{ term: { on_hold: { value: true } } }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
input: {
|
|
93
|
+
condition: 'unknown_condition',
|
|
94
|
+
field_id: '',
|
|
95
|
+
type: 'on_hold',
|
|
96
|
+
field_type: 'select',
|
|
97
|
+
value: '',
|
|
98
|
+
second_value: ''
|
|
99
|
+
},
|
|
100
|
+
output: null
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
filters.forEach((filter) => {
|
|
105
|
+
it(`${filter.input.condition}: ${JSON.stringify(
|
|
106
|
+
filter.input.value
|
|
107
|
+
)}`, (done) => {
|
|
108
|
+
expect(onHoldFilter(filter.input)).to.deep.equal(filter.output);
|
|
109
|
+
done();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|