@outliant/sunrise-utils 1.1.12 → 1.1.14

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.
@@ -145,6 +145,60 @@ describe('projectFilter/projectFieldFilter', function () {
145
145
  }
146
146
  }
147
147
  },
148
+ {
149
+ input: {
150
+ condition: 'is_none_of',
151
+ field_id: '2726455e-fd84-4049-9756-e981e20a8772',
152
+ type: 'ticketinformation',
153
+ field_type: 'select',
154
+ value: 'Commercial;Hanwha',
155
+ second_value: ''
156
+ },
157
+ output: {
158
+ bool: {
159
+ must_not: [
160
+ {
161
+ bool: {
162
+ must: [
163
+ {
164
+ nested: {
165
+ path: 'fields',
166
+ query: {
167
+ bool: {
168
+ must: [
169
+ { term: { 'fields.id': { value: '2726455e-fd84-4049-9756-e981e20a8772' } } },
170
+ { term: { 'fields.text': { value: 'Commercial' } } }
171
+ ]
172
+ }
173
+ }
174
+ }
175
+ }
176
+ ]
177
+ }
178
+ },
179
+ {
180
+ bool: {
181
+ must: [
182
+ {
183
+ nested: {
184
+ path: 'fields',
185
+ query: {
186
+ bool: {
187
+ must: [
188
+ { term: { 'fields.id': { value: '2726455e-fd84-4049-9756-e981e20a8772' } } },
189
+ { term: { 'fields.text': { value: 'Hanwha' } } }
190
+ ]
191
+ }
192
+ }
193
+ }
194
+ }
195
+ ]
196
+ }
197
+ }
198
+ ]
199
+ }
200
+ }
201
+ },
148
202
  {
149
203
  input: {
150
204
  condition: 'is_any_of',
@@ -174,6 +228,106 @@ describe('projectFilter/projectFieldFilter', function () {
174
228
  }
175
229
  }
176
230
  },
231
+ {
232
+ input: {
233
+ condition: 'is_none_of',
234
+ field_id: '2726455e-fd84-4049-9756-e981e20a8772',
235
+ type: 'dealinformation',
236
+ field_type: 'select',
237
+ value: ['Commercial', 'Hanwha'],
238
+ second_value: ''
239
+ },
240
+ output: {
241
+ bool: {
242
+ must_not: [
243
+ {
244
+ bool: {
245
+ must: [
246
+ {
247
+ nested: {
248
+ path: 'fields',
249
+ query: {
250
+ bool: {
251
+ must: [
252
+ { term: { 'fields.id': { value: '2726455e-fd84-4049-9756-e981e20a8772' } } },
253
+ { term: { 'fields.text': { value: 'Commercial' } } }
254
+ ]
255
+ }
256
+ }
257
+ }
258
+ }
259
+ ]
260
+ }
261
+ },
262
+ {
263
+ bool: {
264
+ must: [
265
+ {
266
+ nested: {
267
+ path: 'fields',
268
+ query: {
269
+ bool: {
270
+ must: [
271
+ { term: { 'fields.id': { value: '2726455e-fd84-4049-9756-e981e20a8772' } } },
272
+ { term: { 'fields.text': { value: 'Hanwha' } } }
273
+ ]
274
+ }
275
+ }
276
+ }
277
+ }
278
+ ]
279
+ }
280
+ }
281
+ ]
282
+ }
283
+ }
284
+ },
285
+ {
286
+ input: {
287
+ condition: 'is_none_of',
288
+ field_id: '2726455e-fd84-4049-9756-e981e20a8772',
289
+ type: 'dealinformation',
290
+ field_type: 'select',
291
+ value: 'Hanwha',
292
+ second_value: ''
293
+ },
294
+ output: {
295
+ bool: {
296
+ must_not: [
297
+ {
298
+ bool: {
299
+ must: [
300
+ {
301
+ nested: {
302
+ path: 'fields',
303
+ query: {
304
+ bool: {
305
+ must: [
306
+ { term: { 'fields.id': { value: '2726455e-fd84-4049-9756-e981e20a8772' } } },
307
+ { term: { 'fields.text': { value: 'Hanwha' } } }
308
+ ]
309
+ }
310
+ }
311
+ }
312
+ }
313
+ ]
314
+ }
315
+ }
316
+ ]
317
+ }
318
+ }
319
+ },
320
+ {
321
+ input: {
322
+ condition: 'is_none_of',
323
+ field_id: '2726455e-fd84-4049-9756-e981e20a8772',
324
+ type: 'dealinformation',
325
+ field_type: 'select',
326
+ value: null,
327
+ second_value: ''
328
+ },
329
+ output: null
330
+ },
177
331
  {
178
332
  input: {
179
333
  condition: 'is_equal',
@@ -1131,7 +1285,6 @@ describe('projectFilter/projectFilter', () => {
1131
1285
  it(`${filter.input.condition}: ${JSON.stringify(
1132
1286
  filter.input.value
1133
1287
  )}`, (done) => {
1134
-
1135
1288
  const observed = projectFilter(filter.input);
1136
1289
 
1137
1290
  expect(observed).to.deep.equal(filter.output);
@@ -161,7 +161,110 @@ describe('taskFilter/criticalPathFilter', function () {
161
161
  second_value: ''
162
162
  },
163
163
  output: null
164
- }
164
+ },
165
+ {
166
+ input: {
167
+ condition: 'is_none_of',
168
+ field_id: '',
169
+ type: 'critical_path_stage',
170
+ field_type: 'select',
171
+ value:
172
+ '163ba61c-acfa-4f92-bc18-cdef2ab2a959;e03ab325-f630-4517-8055-02c6c0f84141',
173
+ second_value: ''
174
+ },
175
+ output: {
176
+ bool: {
177
+ must_not: [
178
+ {
179
+ bool: {
180
+ must: [
181
+ { exists: { field: 'critical_path.stage_id' } },
182
+ { term: { 'critical_path.stage_id': { value: '163ba61c-acfa-4f92-bc18-cdef2ab2a959' } } }
183
+ ]
184
+ }
185
+ },
186
+ {
187
+ bool: {
188
+ must: [
189
+ { exists: { field: 'critical_path.stage_id' } },
190
+ { term: { 'critical_path.stage_id': { value: 'e03ab325-f630-4517-8055-02c6c0f84141' } } }
191
+ ]
192
+ }
193
+ }
194
+ ]
195
+ }
196
+ }
197
+ },
198
+ {
199
+ input: {
200
+ condition: 'is_none_of',
201
+ field_id: '',
202
+ type: 'critical_path_stage',
203
+ field_type: 'select',
204
+ value: [
205
+ '163ba61c-acfa-4f92-bc18-cdef2ab2a959',
206
+ 'e03ab325-f630-4517-8055-02c6c0f84141'
207
+ ],
208
+ second_value: ''
209
+ },
210
+ output: {
211
+ bool: {
212
+ must_not: [
213
+ {
214
+ bool: {
215
+ must: [
216
+ { exists: { field: 'critical_path.stage_id' } },
217
+ { term: { 'critical_path.stage_id': { value: '163ba61c-acfa-4f92-bc18-cdef2ab2a959' } } }
218
+ ]
219
+ }
220
+ },
221
+ {
222
+ bool: {
223
+ must: [
224
+ { exists: { field: 'critical_path.stage_id' } },
225
+ { term: { 'critical_path.stage_id': { value: 'e03ab325-f630-4517-8055-02c6c0f84141' } } }
226
+ ]
227
+ }
228
+ }
229
+ ]
230
+ }
231
+ }
232
+ },
233
+ {
234
+ input: {
235
+ condition: 'is_none_of',
236
+ field_id: '',
237
+ type: 'critical_path_stage',
238
+ field_type: 'select',
239
+ value: '163ba61c-acfa-4f92-bc18-cdef2ab2a959',
240
+ second_value: ''
241
+ },
242
+ output: {
243
+ bool: {
244
+ must_not: [
245
+ {
246
+ bool: {
247
+ must: [
248
+ { exists: { field: 'critical_path.stage_id' } },
249
+ { term: { 'critical_path.stage_id': { value: '163ba61c-acfa-4f92-bc18-cdef2ab2a959' } } }
250
+ ]
251
+ }
252
+ }
253
+ ]
254
+ }
255
+ }
256
+ },
257
+ {
258
+ input: {
259
+ condition: 'is_none_of',
260
+ field_id: '',
261
+ type: 'critical_path_stage',
262
+ field_type: 'select',
263
+ value: null,
264
+ second_value: ''
265
+ },
266
+ output: null
267
+ },
165
268
  ];
166
269
  filters.forEach((filter) => {
167
270
  it(`${filter.input.condition}: ${JSON.stringify(
@@ -98,6 +98,100 @@ describe('taskFilter/onHoldFilter', function () {
98
98
  second_value: ''
99
99
  },
100
100
  output: null
101
+ },
102
+ {
103
+ input: {
104
+ condition: 'is_none_of',
105
+ field_id: '',
106
+ type: 'on_hold',
107
+ field_type: 'select',
108
+ value: 'No;Yes',
109
+ second_value: ''
110
+ },
111
+ output: {
112
+ bool: {
113
+ must_not: [
114
+ {
115
+ bool: {
116
+ must: [
117
+ { term: { on_hold: { value: false } } }
118
+ ]
119
+ }
120
+ },
121
+ {
122
+ bool: {
123
+ must: [
124
+ { term: { on_hold: { value: true } } }
125
+ ]
126
+ }
127
+ }
128
+ ]
129
+ }
130
+ }
131
+ },
132
+ {
133
+ input: {
134
+ condition: 'is_none_of',
135
+ field_id: '',
136
+ type: 'on_hold',
137
+ field_type: 'select',
138
+ value: ['No', 'Yes'],
139
+ second_value: ''
140
+ },
141
+ output: {
142
+ bool: {
143
+ must_not: [
144
+ {
145
+ bool: {
146
+ must: [
147
+ { term: { on_hold: { value: false } } }
148
+ ]
149
+ }
150
+ },
151
+ {
152
+ bool: {
153
+ must: [
154
+ { term: { on_hold: { value: true } } }
155
+ ]
156
+ }
157
+ }
158
+ ]
159
+ }
160
+ }
161
+ },
162
+ {
163
+ input: {
164
+ condition: 'is_none_of',
165
+ field_id: '',
166
+ type: 'on_hold',
167
+ field_type: 'select',
168
+ value: 'Yes',
169
+ second_value: ''
170
+ },
171
+ output: {
172
+ bool: {
173
+ must_not: [
174
+ {
175
+ bool: {
176
+ must: [
177
+ { term: { on_hold: { value: true } } }
178
+ ]
179
+ }
180
+ }
181
+ ]
182
+ }
183
+ }
184
+ },
185
+ {
186
+ input: {
187
+ condition: 'is_none_of',
188
+ field_id: '',
189
+ type: 'on_hold',
190
+ field_type: 'select',
191
+ value: null,
192
+ second_value: ''
193
+ },
194
+ output: null
101
195
  }
102
196
  ];
103
197
 
@@ -212,6 +212,100 @@ describe('taskFilter/ownerFilter', function () {
212
212
  must: [{ term: { team_id: { value: 'LlrJx3gBfTAqAzzhrb2J' } } }]
213
213
  }
214
214
  }
215
+ },
216
+ {
217
+ input: {
218
+ condition: 'is_none_of',
219
+ field_id: '',
220
+ type: 'owner',
221
+ field_type: 'select',
222
+ value: 'meow1;meow2',
223
+ second_value: ''
224
+ },
225
+ output: {
226
+ bool: {
227
+ must_not: [
228
+ {
229
+ bool: {
230
+ must: [
231
+ { term: { team_id: { value: 'meow1' } } }
232
+ ]
233
+ }
234
+ },
235
+ {
236
+ bool: {
237
+ must: [
238
+ { term: { team_id: { value: 'meow2' } } }
239
+ ]
240
+ }
241
+ }
242
+ ]
243
+ }
244
+ }
245
+ },
246
+ {
247
+ input: {
248
+ condition: 'is_none_of',
249
+ field_id: '',
250
+ type: 'owner',
251
+ field_type: 'select',
252
+ value: ['meow1', 'meow2'],
253
+ second_value: ''
254
+ },
255
+ output: {
256
+ bool: {
257
+ must_not: [
258
+ {
259
+ bool: {
260
+ must: [
261
+ { term: { team_id: { value: 'meow1' } } }
262
+ ]
263
+ }
264
+ },
265
+ {
266
+ bool: {
267
+ must: [
268
+ { term: { team_id: { value: 'meow2' } } }
269
+ ]
270
+ }
271
+ }
272
+ ]
273
+ }
274
+ }
275
+ },
276
+ {
277
+ input: {
278
+ condition: 'is_none_of',
279
+ field_id: '',
280
+ type: 'owner',
281
+ field_type: 'select',
282
+ value: 'meow',
283
+ second_value: ''
284
+ },
285
+ output: {
286
+ bool: {
287
+ must_not: [
288
+ {
289
+ bool: {
290
+ must: [
291
+ { term: { team_id: { value: 'meow' } } }
292
+ ]
293
+ }
294
+ }
295
+ ]
296
+ }
297
+ }
298
+ },
299
+ {
300
+ input: {
301
+ condition: 'is_none_of',
302
+ field_id: '',
303
+ type: 'owner',
304
+ field_type: 'select',
305
+ value: null,
306
+ second_value: ''
307
+ },
308
+ output: null
215
309
  }
216
310
  ];
217
311
 
@@ -117,6 +117,100 @@ describe('taskFilter/regionFilter', function () {
117
117
  second_value: ''
118
118
  },
119
119
  output: null
120
+ },
121
+ {
122
+ input: {
123
+ condition: 'is_none_of',
124
+ field_id: '',
125
+ type: 'region',
126
+ field_type: 'checkbox',
127
+ value: 'meow1,meow2',
128
+ second_value: ''
129
+ },
130
+ output: {
131
+ bool: {
132
+ must_not: [
133
+ {
134
+ bool: {
135
+ should: [
136
+ { term: { region_id: { value: 'meow1' } } }
137
+ ]
138
+ }
139
+ },
140
+ {
141
+ bool: {
142
+ should: [
143
+ { term: { region_id: { value: 'meow2' } } }
144
+ ]
145
+ }
146
+ }
147
+ ]
148
+ }
149
+ }
150
+ },
151
+ {
152
+ input: {
153
+ condition: 'is_none_of',
154
+ field_id: '',
155
+ type: 'region',
156
+ field_type: 'checkbox',
157
+ value: ['meow1', 'meow2'],
158
+ second_value: ''
159
+ },
160
+ output: {
161
+ bool: {
162
+ must_not: [
163
+ {
164
+ bool: {
165
+ should: [
166
+ { term: { region_id: { value: 'meow1' } } }
167
+ ]
168
+ }
169
+ },
170
+ {
171
+ bool: {
172
+ should: [
173
+ { term: { region_id: { value: 'meow2' } } }
174
+ ]
175
+ }
176
+ }
177
+ ]
178
+ }
179
+ }
180
+ },
181
+ {
182
+ input: {
183
+ condition: 'is_none_of',
184
+ field_id: '',
185
+ type: 'region',
186
+ field_type: 'checkbox',
187
+ value: 'meow',
188
+ second_value: ''
189
+ },
190
+ output: {
191
+ bool: {
192
+ must_not: [
193
+ {
194
+ bool: {
195
+ should: [
196
+ { term: { region_id: { value: 'meow' } } }
197
+ ]
198
+ }
199
+ }
200
+ ]
201
+ }
202
+ }
203
+ },
204
+ {
205
+ input: {
206
+ condition: 'is_none_of',
207
+ field_id: '',
208
+ type: 'region',
209
+ field_type: 'checkbox',
210
+ value: null,
211
+ second_value: ''
212
+ },
213
+ output: null
120
214
  }
121
215
  ];
122
216
 
@@ -182,6 +182,103 @@ describe('taskFilter/statusFilter', function () {
182
182
  second_value: ''
183
183
  },
184
184
  output: null
185
+ },
186
+ {
187
+ input: {
188
+ condition: 'is_none_of',
189
+ field_id: '',
190
+ type: 'status',
191
+ field_type: 'select',
192
+ value: 'new;on_hold',
193
+ second_value: ''
194
+ },
195
+ output: {
196
+ bool: {
197
+ must_not: [
198
+ {
199
+ bool: {
200
+ must: [
201
+ { term: { is_ready: false } },
202
+ { term: { is_complete: false } }
203
+ ]
204
+ }
205
+ },
206
+ {
207
+ bool: {
208
+ must: [
209
+ { term: { on_hold: true } }
210
+ ]
211
+ }
212
+ }
213
+ ]
214
+ }
215
+ }
216
+ },
217
+ {
218
+ input: {
219
+ condition: 'is_none_of',
220
+ field_id: '',
221
+ type: 'status',
222
+ field_type: 'select',
223
+ value: ['new', 'on_hold'],
224
+ second_value: ''
225
+ },
226
+ output: {
227
+ bool: {
228
+ must_not: [
229
+ {
230
+ bool: {
231
+ must: [
232
+ { term: { is_ready: false } },
233
+ { term: { is_complete: false } }
234
+ ]
235
+ }
236
+ },
237
+ {
238
+ bool: {
239
+ must: [
240
+ { term: { on_hold: true } }
241
+ ]
242
+ }
243
+ }
244
+ ]
245
+ }
246
+ }
247
+ },
248
+ {
249
+ input: {
250
+ condition: 'is_none_of',
251
+ field_id: '',
252
+ type: 'status',
253
+ field_type: 'select',
254
+ value: 'new',
255
+ second_value: ''
256
+ },
257
+ output: {
258
+ bool: {
259
+ must_not: [
260
+ {
261
+ bool: {
262
+ must: [
263
+ { term: { is_ready: false } },
264
+ { term: { is_complete: false } }
265
+ ]
266
+ }
267
+ }
268
+ ]
269
+ }
270
+ }
271
+ },
272
+ {
273
+ input: {
274
+ condition: 'is_none_of',
275
+ field_id: '',
276
+ type: 'status',
277
+ field_type: 'select',
278
+ value: null,
279
+ second_value: ''
280
+ },
281
+ output: null
185
282
  }
186
283
  ];
187
284
 
@@ -190,7 +287,6 @@ describe('taskFilter/statusFilter', function () {
190
287
  filter.input.value
191
288
  )}`, (done) => {
192
289
  expect(statusFilter(filter.input)).to.deep.equal(filter.output);
193
-
194
290
  done();
195
291
  });
196
292
  });