cityworks 0.0.25 → 0.0.29
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/README.md +22 -0
- package/dist/case.d.ts +4 -0
- package/dist/case_workflow.d.ts +4 -0
- package/dist/comments.d.ts +53 -0
- package/dist/general.d.ts +6 -7
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/request.d.ts +4 -9
- package/dist/search.d.ts +117 -0
- package/dist/workorder.d.ts +5 -10
- package/package.json +1 -1
- package/src/case.ts +6 -1
- package/src/case_admin.ts +4 -4
- package/src/case_data.ts +3 -3
- package/src/case_financial.ts +8 -8
- package/src/case_workflow.ts +11 -2
- package/src/cityworks.ts +3 -2
- package/src/comments.ts +159 -0
- package/src/general.ts +17 -19
- package/src/message_queue.ts +12 -14
- package/src/request.ts +7 -22
- package/src/search.ts +322 -0
- package/src/workorder.ts +106 -129
- package/test/03.generalTest.js +87 -0
- package/test/04.requestTest.js +60 -1
- package/test/05.caseTest.js +21 -1
- package/test/06.caseFinancialTest.js +4 -4
- package/test/07.search.js +192 -0
- package/test/03.general.js +0 -87
package/src/workorder.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CWError } from './error'
|
|
2
2
|
const _ = require('lodash')
|
|
3
3
|
import { WorkOrderAdmin } from './workorder_admin'
|
|
4
|
+
import { Comments } from './comments'
|
|
4
5
|
|
|
5
6
|
export class WorkOrder {
|
|
6
7
|
/**
|
|
@@ -11,7 +12,12 @@ export class WorkOrder {
|
|
|
11
12
|
/**
|
|
12
13
|
* WorkOrder Administration methods
|
|
13
14
|
*/
|
|
14
|
-
admin
|
|
15
|
+
admin: Object
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* WorkOrder Comments methods
|
|
19
|
+
*/
|
|
20
|
+
comment: Object
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* @hidden
|
|
@@ -19,114 +25,115 @@ export class WorkOrder {
|
|
|
19
25
|
constructor(cw) {
|
|
20
26
|
this.cw = cw
|
|
21
27
|
this.admin = new WorkOrderAdmin(cw)
|
|
28
|
+
this.comment = new Comments(cw, 'WorkOrder')
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
if(typeof requestIds != 'undefined' && requestIds != null && !_.has(data, 'RequestIds')) {
|
|
43
|
-
_.set(data, 'RequestIds', requestIds);
|
|
44
|
-
}
|
|
45
|
-
this.cw.runRequest('Ams/WorkOrder/Create', data).then(r => {
|
|
46
|
-
resolve(r.Value)
|
|
47
|
-
}).catch(e => {
|
|
48
|
-
reject(e)
|
|
49
|
-
})
|
|
31
|
+
/**
|
|
32
|
+
* Create new workorders, including linkin to Requests & Inspections (optionally)
|
|
33
|
+
*
|
|
34
|
+
* @category WorkOrders
|
|
35
|
+
* @param {Object} wo_data - See /{subdirectory}/apidocs/#/data-type-infodataType=WorkOrder on the Cityworks instance
|
|
36
|
+
* @param {Array<number>} [inspectionIds] - The inspection IDs which the workorder should be linked to.
|
|
37
|
+
* @param {Array<number>} [requestIds] - The inspection IDs which the workorder should be linked to.
|
|
38
|
+
* @return {Object} Returns Promise that represents an object describing the newly-created workorder
|
|
39
|
+
*/
|
|
40
|
+
create(wo_data: Object, inspectionIds?: Array<number>, requestIds?: Array<number>) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
if(!_.has(wo_data, 'WOTemplateId') || !_.has(wo_data, 'EntityType')) {
|
|
43
|
+
reject(new CWError(2, 'WOTemplateId & EntityType must be provided.', {'provided': wo_data}))
|
|
44
|
+
} else {
|
|
45
|
+
var data = wo_data;
|
|
46
|
+
if(typeof inspectionIds != 'undefined' && inspectionIds != null && !_.has(data, 'InspectionIds')) {
|
|
47
|
+
_.set(data, 'InspectionIds', inspectionIds);
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Create new workorder linked to parent workorder
|
|
56
|
-
*
|
|
57
|
-
* @category WorkOrders
|
|
58
|
-
* @param {Object} wo_data - See /{subdirectory}/apidocs/#/data-type-infodataType=WorkOrder on the Cityworks instance
|
|
59
|
-
* @param {string|number} workOrderSId - The workorder S/ID which the entities should be added to. # for SID, string for ID.
|
|
60
|
-
* @return {Object} Returns Promise that represents an object describing the newly-created workorder
|
|
61
|
-
*/
|
|
62
|
-
createFromParent(wo_data: Object, workOrderSId: string|number, s: boolean = true) {
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
if(!_.has(wo_data, 'WOTemplateId') || !_.has(wo_data, 'EntityType')) {
|
|
65
|
-
reject(new CWError(2, 'WOTemplateId & EntityType must be provided.', {'provided': wo_data}))
|
|
66
|
-
} else {
|
|
67
|
-
var data = wo_data;
|
|
68
|
-
if(_.isString(workOrderSId)) {
|
|
69
|
-
_.set(data, 'WorkOrderId', workOrderSId)
|
|
70
|
-
} else {
|
|
71
|
-
_.set(data, 'WorkOrderSid', workOrderSId)
|
|
72
|
-
}
|
|
73
|
-
this.cw.runRequest('Ams/WorkOrder/Create', data).then(r => {
|
|
74
|
-
resolve(r.Value)
|
|
75
|
-
}).catch(e => {
|
|
76
|
-
reject(e)
|
|
77
|
-
})
|
|
49
|
+
if(typeof requestIds != 'undefined' && requestIds != null && !_.has(data, 'RequestIds')) {
|
|
50
|
+
_.set(data, 'RequestIds', requestIds);
|
|
78
51
|
}
|
|
79
|
-
|
|
80
|
-
|
|
52
|
+
this.cw.runRequest('Ams/WorkOrder/Create', data).then(r => {
|
|
53
|
+
resolve(r.Value)
|
|
54
|
+
}).catch(e => {
|
|
55
|
+
reject(e)
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
81
60
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Create new workorder linked to parent workorder
|
|
63
|
+
*
|
|
64
|
+
* @category WorkOrders
|
|
65
|
+
* @param {Object} wo_data - See /{subdirectory}/apidocs/#/data-type-infodataType=WorkOrder on the Cityworks instance
|
|
66
|
+
* @param {string|number} workOrderSId - The workorder S/ID which the entities should be added to. # for SID, string for ID.
|
|
67
|
+
* @return {Object} Returns Promise that represents an object describing the newly-created workorder
|
|
68
|
+
*/
|
|
69
|
+
createFromParent(wo_data: Object, workOrderSId: string|number, s: boolean = true) {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
if(!_.has(wo_data, 'WOTemplateId') || !_.has(wo_data, 'EntityType')) {
|
|
72
|
+
reject(new CWError(2, 'WOTemplateId & EntityType must be provided.', {'provided': wo_data}))
|
|
73
|
+
} else {
|
|
74
|
+
var data = wo_data;
|
|
75
|
+
if(_.isString(workOrderSId)) {
|
|
76
|
+
_.set(data, 'WorkOrderId', workOrderSId)
|
|
93
77
|
} else {
|
|
94
|
-
|
|
95
|
-
resolve(r.Value)
|
|
96
|
-
}).catch(e => {
|
|
97
|
-
reject(e)
|
|
98
|
-
})
|
|
78
|
+
_.set(data, 'WorkOrderSid', workOrderSId)
|
|
99
79
|
}
|
|
100
|
-
|
|
101
|
-
|
|
80
|
+
this.cw.runRequest('Ams/WorkOrder/Create', data).then(r => {
|
|
81
|
+
resolve(r.Value)
|
|
82
|
+
}).catch(e => {
|
|
83
|
+
reject(e)
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
}
|
|
102
88
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Update a WorkOrder
|
|
91
|
+
*
|
|
92
|
+
* @category WorkOrders
|
|
93
|
+
* @param {object} wo_data - See /{subdirectory}/apidocs/#/data-type-infodataType=WorkOrder on the Cityworks instance
|
|
94
|
+
* @return {Object} Returns Promise that represents an object describing the updated workorder
|
|
95
|
+
*/
|
|
96
|
+
update(wo_data: Object) {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
if(!_.has(wo_data, 'WorkOrderSid') && !_.has(wo_data, 'WorkOrderId')) {
|
|
99
|
+
reject(new CWError(3, 'WorkOrderId or WorkOrderSid must be provided.', {'provided': wo_data}))
|
|
100
|
+
} else {
|
|
101
|
+
this.cw.runRequest('Ams/WorkOrder/Update', wo_data).then(r => {
|
|
102
|
+
resolve(r.Value)
|
|
103
|
+
}).catch(e => {
|
|
104
|
+
reject(e)
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Combine WorkOrders
|
|
112
|
+
*
|
|
113
|
+
* @category WorkOrders
|
|
114
|
+
* @param {Array<string>} fromWorkOrderIds - The workorder IDs which should be combined.
|
|
115
|
+
* @param {string} toWorkOrderId - The work order ID for the single work order that should contain the info/entities from the other work orders
|
|
116
|
+
* @param {boolean} cancelCombinedWorkOrders - If the work orders combined into the single should then be canceled, default is true.
|
|
117
|
+
* @return {Object} Returns object that represents a collection of WorkOrders
|
|
118
|
+
*/
|
|
119
|
+
combine(fromWorkOrderIds: Array<string>, toWorkOrderId: string, cancelCombinedWorkOrders: boolean = true) {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
var data = {
|
|
122
|
+
CancelCombinedWorkOrders: cancelCombinedWorkOrders,
|
|
123
|
+
ToWorkOrderId: toWorkOrderId,
|
|
124
|
+
FromWorkOrderIds: fromWorkOrderIds
|
|
125
|
+
}
|
|
126
|
+
this.cw.runRequest('Ams/WorkOrder/Combine', data).then(r => {
|
|
127
|
+
if(r.Status>0) {
|
|
128
|
+
reject(new CWError(4, r.Message, {'response': r}))
|
|
129
|
+
} else {
|
|
130
|
+
resolve(r.Value)
|
|
118
131
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
reject(new CWError(4, r.Message, {'response': r}))
|
|
122
|
-
} else {
|
|
123
|
-
resolve(r.Value)
|
|
124
|
-
}
|
|
125
|
-
}).catch(e => {
|
|
126
|
-
reject(e)
|
|
127
|
-
})
|
|
132
|
+
}).catch(e => {
|
|
133
|
+
reject(e)
|
|
128
134
|
})
|
|
129
|
-
}
|
|
135
|
+
})
|
|
136
|
+
}
|
|
130
137
|
|
|
131
138
|
|
|
132
139
|
/**
|
|
@@ -312,36 +319,6 @@ export class WorkOrder {
|
|
|
312
319
|
})
|
|
313
320
|
}
|
|
314
321
|
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Add a comment to a workorder
|
|
318
|
-
*
|
|
319
|
-
* @category WorkOrders
|
|
320
|
-
* @param {number} workOrderSId - The S/ID of the workorder to retrieve. SID is default.
|
|
321
|
-
* @param {string} comment - The comment text to add.
|
|
322
|
-
* @return {Object} Returns Promise that represents an object describing the comment added
|
|
323
|
-
*/
|
|
324
|
-
comment(workOrderSId: string|number, comment: string) {
|
|
325
|
-
return new Promise((resolve, reject) => {
|
|
326
|
-
var data = {
|
|
327
|
-
Comments: comment
|
|
328
|
-
}
|
|
329
|
-
if(_.isString(workOrderSId)) {
|
|
330
|
-
_.set(data, 'WorkOrderId', workOrderSId)
|
|
331
|
-
} else if(_.isNumber(workOrderSId)) {
|
|
332
|
-
_.set(data, 'WorkOrderSid', workOrderSId)
|
|
333
|
-
} else {
|
|
334
|
-
// throw error - was not number or string
|
|
335
|
-
reject(new CWError(9, 'Workorder S/IDs was not provided.', {'workorderSId': workOrderSId}))
|
|
336
|
-
}
|
|
337
|
-
this.cw.runRequest('Ams/WorkOrder/AddComments', data).then(r => {
|
|
338
|
-
resolve(r.Value)
|
|
339
|
-
}).catch(e => {
|
|
340
|
-
reject(e)
|
|
341
|
-
})
|
|
342
|
-
})
|
|
343
|
-
}
|
|
344
|
-
|
|
345
322
|
/**
|
|
346
323
|
* Get entities on an existing WorkOrder
|
|
347
324
|
*
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
require('dotenv').config();
|
|
3
|
+
var chai = require('chai');
|
|
4
|
+
var expect = require('chai').expect;
|
|
5
|
+
var assert = require('chai').assert;
|
|
6
|
+
var chaiAsPromised = require("chai-as-promised");
|
|
7
|
+
chai.use(chaiAsPromised);
|
|
8
|
+
var Cityworks = require('../dist/index.js');
|
|
9
|
+
var cw3 = new Cityworks(process.env.domain, {path: process.env.path});
|
|
10
|
+
|
|
11
|
+
before(function(done) {
|
|
12
|
+
this.timeout(20000000);
|
|
13
|
+
cw3.authenticate(process.env.login, process.env.password).then(resp => {
|
|
14
|
+
done();
|
|
15
|
+
}).catch(e => {
|
|
16
|
+
console.log(e, 'unexpected error')
|
|
17
|
+
done();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('[General::notifications] function test', () => {
|
|
22
|
+
it('should resolve a collection', (done) => {
|
|
23
|
+
cw3.general.notifications().then(resp => {
|
|
24
|
+
assert.isArray(resp);
|
|
25
|
+
done();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('[General::amIWatching] function test', () => {
|
|
31
|
+
it('should reject with an error if the activity type is not available or does not exist', (done) => {
|
|
32
|
+
cw3.general.amIWatching('request', 42015).then(r => {
|
|
33
|
+
}).catch(e => {
|
|
34
|
+
assert.equal(e.message, 'Activity type provided does not exist.');
|
|
35
|
+
done();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
it('should resolve a boolean', (done) => {
|
|
39
|
+
cw3.general.amIWatching('case', 42015).then(r => {
|
|
40
|
+
assert.isBoolean(r);
|
|
41
|
+
done();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
it('should resolve with false if id does not exist', (done) => {
|
|
45
|
+
cw3.general.amIWatching('case', 200042015).then(r => {
|
|
46
|
+
assert.isFalse(r);
|
|
47
|
+
done();
|
|
48
|
+
}).catch(e => {
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
it('should reject with an error if the activity id is too large', (done) => {
|
|
53
|
+
cw3.general.amIWatching('case', 10000000000).then(response => {
|
|
54
|
+
}).catch(e => {
|
|
55
|
+
assert.equal(e.message, 'Unknown error.');
|
|
56
|
+
done();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('[General::quickSearch] function test', () => {
|
|
62
|
+
it('should resolve results', (done) => {
|
|
63
|
+
cw3.general.quickSearch('256460').then(r => {
|
|
64
|
+
assert.property(r, 'Permits');
|
|
65
|
+
done();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should resolve (empty) results even when the string is not found', (done) => {
|
|
70
|
+
cw3.general.quickSearch('SomethingSidewalk').then(r => {
|
|
71
|
+
assert.property(r, 'Permits');
|
|
72
|
+
done();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('[General::getActivityMetadataByIds] function test', () => {
|
|
78
|
+
it('should resolve an activity based on the metadata ids');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('[General::getWOEntityCostSummary] function test', () => {
|
|
82
|
+
it('should get an Entity\'s cost summary');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('[General::searchWOEntityCostSummary] function test', () => {
|
|
86
|
+
it('should resolve reults of a search for cost summary of an entity');
|
|
87
|
+
});
|
package/test/04.requestTest.js
CHANGED
|
@@ -193,10 +193,69 @@ describe('[Request::reopen] function test', () => {
|
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
describe('[Request::comment] function test', () => {
|
|
196
|
+
describe('[Request::comment.add] function test', () => {
|
|
197
|
+
it('should return the reopened request(s)', (done) => {
|
|
198
|
+
var ID = 1520675;
|
|
199
|
+
var comment = 'New comment on ' + Date().toString() + '.';
|
|
200
|
+
cw4.request.comment.add(ID, comment).then(resp => {
|
|
201
|
+
assert.equal(resp.Comments, comment);
|
|
202
|
+
done();
|
|
203
|
+
}).catch(e => {
|
|
204
|
+
console.log(e);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|
|
197
208
|
|
|
209
|
+
describe('[Request::comment.update] function test', () => {
|
|
210
|
+
it('should return the reopened request(s)', (done) => {
|
|
211
|
+
var ID = 1636877;
|
|
212
|
+
var comment = 'Updated this comment on ' + Date().toString() + '.';
|
|
213
|
+
cw4.request.comment.update(ID, comment).then(resp => {
|
|
214
|
+
assert.equal(resp.Comments, comment);
|
|
215
|
+
done();
|
|
216
|
+
}).catch(e => {
|
|
217
|
+
console.log(e);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
198
220
|
});
|
|
199
221
|
|
|
222
|
+
describe('[Request::comment.get] function test', () => {
|
|
223
|
+
it('should return the comments for the request', (done) => {
|
|
224
|
+
var ID = 1520675;
|
|
225
|
+
cw4.request.comment.get([ID]).then(resp => {
|
|
226
|
+
console.log(resp[ID]);
|
|
227
|
+
assert.isArray(resp);
|
|
228
|
+
done();
|
|
229
|
+
}).catch(e => {
|
|
230
|
+
console.log(e);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
describe('[Request::comment.getPredefined] function test', () => {
|
|
237
|
+
it('should return the comments for the activity type', (done) => {
|
|
238
|
+
cw4.request.comment.getPredefined(738).then(resp => {
|
|
239
|
+
assert.isArray(resp);
|
|
240
|
+
done();
|
|
241
|
+
}).catch(e => {
|
|
242
|
+
console.log(e);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// describe('[Request::comment.getForActivityList] function test', () => {
|
|
248
|
+
// it('should return the comments for the activity type', (done) => {
|
|
249
|
+
// cw4.request.comment.getForActivityList().then(resp => {
|
|
250
|
+
// console.log(resp);
|
|
251
|
+
// // assert.isArray(resp);
|
|
252
|
+
// done();
|
|
253
|
+
// }).catch(e => {
|
|
254
|
+
// console.log(e);
|
|
255
|
+
// });
|
|
256
|
+
// });
|
|
257
|
+
// });
|
|
258
|
+
|
|
200
259
|
describe('[Request::changeProblem] function test', () => {
|
|
201
260
|
|
|
202
261
|
});
|
package/test/05.caseTest.js
CHANGED
|
@@ -18,7 +18,27 @@ before(function(done) {
|
|
|
18
18
|
|
|
19
19
|
describe('[Case (construct)] function test', () => {
|
|
20
20
|
it('should be a defined object', (done) => {
|
|
21
|
-
assert.isObject(cw5.case, '
|
|
21
|
+
assert.isObject(cw5.case, 'Case is an object');
|
|
22
|
+
done();
|
|
23
|
+
});
|
|
24
|
+
it('should have an financial property which is a defined object', (done) => {
|
|
25
|
+
assert.isObject(cw5.case.financial, 'Financial is an object');
|
|
26
|
+
done();
|
|
27
|
+
});
|
|
28
|
+
it('should have an data property which is a defined object', (done) => {
|
|
29
|
+
assert.isObject(cw5.case.data, 'Financial is an object');
|
|
30
|
+
done();
|
|
31
|
+
});
|
|
32
|
+
it('should have an workflow property which is a defined object', (done) => {
|
|
33
|
+
assert.isObject(cw5.case.workflow, 'Financial is an object');
|
|
34
|
+
done();
|
|
35
|
+
});
|
|
36
|
+
it('should have an comment property which is a defined object', (done) => {
|
|
37
|
+
assert.isObject(cw5.case.comment, 'Financial is an object');
|
|
38
|
+
done();
|
|
39
|
+
});
|
|
40
|
+
it('should have an admin property which is a defined object', (done) => {
|
|
41
|
+
assert.isObject(cw5.case.admin, 'Financial is an object');
|
|
22
42
|
done();
|
|
23
43
|
});
|
|
24
44
|
});
|
|
@@ -23,9 +23,9 @@ describe('[CaseFinancial (construct)] function test', () => {
|
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
describe('[CaseFinancial::
|
|
26
|
+
describe('[CaseFinancial::getFees] function test', () => {
|
|
27
27
|
it('should resolve a collection of case fees', (done) => {
|
|
28
|
-
cw6.case.financial.
|
|
28
|
+
cw6.case.financial.getFees(16086).then(r => { // TODO: find case, then get fees
|
|
29
29
|
assert.isArray(r);
|
|
30
30
|
done();
|
|
31
31
|
});
|
|
@@ -73,11 +73,11 @@ describe('[CaseFinancial::getAllFeeTemplates] function test', () => {
|
|
|
73
73
|
|
|
74
74
|
describe('[CaseFinancial::searchFeeTemplates] function test', () => {
|
|
75
75
|
it('should resolve a collection of case fees with interest in the name', (done) => {
|
|
76
|
-
cw6.case.financial.searchFeeTemplates(
|
|
76
|
+
cw6.case.financial.searchFeeTemplates({FeeDesc: 'interest'}).then(r => { // TODO: find case, then get fees
|
|
77
77
|
assert.isArray(r);
|
|
78
78
|
done();
|
|
79
79
|
}).catch(e => {
|
|
80
|
-
console.log(e, e)
|
|
80
|
+
console.log(e, 'e')
|
|
81
81
|
})
|
|
82
82
|
});
|
|
83
83
|
});
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
require('dotenv').config();
|
|
3
|
+
var chai = require('chai');
|
|
4
|
+
var expect = require('chai').expect;
|
|
5
|
+
var assert = require('chai').assert;
|
|
6
|
+
var chaiAsPromised = require("chai-as-promised");
|
|
7
|
+
chai.use(chaiAsPromised);
|
|
8
|
+
var Cityworks = require('../dist/index.js');
|
|
9
|
+
var cw7 = new Cityworks(process.env.domain, {path: process.env.path});
|
|
10
|
+
|
|
11
|
+
before(function(done) {
|
|
12
|
+
this.timeout(20000000);
|
|
13
|
+
cw7.authenticate(process.env.login, process.env.password).then(resp => {
|
|
14
|
+
done();
|
|
15
|
+
}).catch(e => {
|
|
16
|
+
console.log(e, 'unexpected error')
|
|
17
|
+
done();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('[Search::quick] function test', () => {
|
|
22
|
+
it('should resolve results', (done) => {
|
|
23
|
+
cw7.search.quick('256460').then(r => {
|
|
24
|
+
assert.property(r, 'ServiceRequests');
|
|
25
|
+
done();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should resolve (empty) results even when the string is not found', (done) => {
|
|
30
|
+
cw7.search.quick('SomethingSidewalk').then(r => {
|
|
31
|
+
assert.property(r, 'Permits');
|
|
32
|
+
done();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('[Search::execute] function test', () => {
|
|
38
|
+
it('should resolve a collection of search results', (done) => {
|
|
39
|
+
cw7.search.execute(3897).then(r => {
|
|
40
|
+
assert.isArray(r);
|
|
41
|
+
done();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should resolve an empty array if search ID is not found', (done) => {
|
|
46
|
+
cw7.search.execute(999999999).then(r => {
|
|
47
|
+
assert.isEmpty(r);
|
|
48
|
+
done();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('[Search::getSaved] function test', () => {
|
|
54
|
+
it('should resolve a collection of saved searches', (done) => {
|
|
55
|
+
cw7.search.getSaved('Request').then(r => {
|
|
56
|
+
assert.isArray(r);
|
|
57
|
+
done();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should reject with an error if the search type does not exist', (done) => {
|
|
62
|
+
cw7.search.getSaved('ServiceRequest').then(r => {
|
|
63
|
+
}).catch(e => {
|
|
64
|
+
// console.log(e)
|
|
65
|
+
assert.equal(e.message, 'SearchType provided does not exist or is mispelled.')
|
|
66
|
+
done();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should reject with an error if the applyToEntities and employeeSid/domainId are all set at the same time', (done) => {
|
|
71
|
+
cw7.search.getSaved('Request', ['EASEMENT_TREES'], 127, 1).then(r => {
|
|
72
|
+
}).catch(e => {
|
|
73
|
+
assert.equal(e.message, 'You cannot specify both applyToEntities AND employeeSid/domainId')
|
|
74
|
+
done();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('[Search::displayFields] function test', () => {
|
|
80
|
+
it('should resolve a collection of display fields', (done) => {
|
|
81
|
+
cw7.search.displayFields('WorkOrder').then(r => {
|
|
82
|
+
assert.isArray(r);
|
|
83
|
+
done();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should reject with an error if the searchType is not found', (done) => {
|
|
88
|
+
cw7.search.displayFields('ServiceRequest').then(r => {
|
|
89
|
+
}).catch(e => {
|
|
90
|
+
assert.equal(e.message, 'SearchType provided does not exist or is mispelled.')
|
|
91
|
+
done();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('[Search::types] function test', () => {
|
|
97
|
+
it('should resolve a collection of types', (done) => {
|
|
98
|
+
cw7.search.types().then(r => {
|
|
99
|
+
assert.isArray(r);
|
|
100
|
+
done();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('[Search::disableServices] function test', () => {
|
|
106
|
+
it('should resolve dictionary of searchIDs and boolean', (done) => {
|
|
107
|
+
cw7.search.disableServices([4338]).then(r => {
|
|
108
|
+
assert.propertyVal(r, 4338, true);
|
|
109
|
+
done();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
it('should always be "False" if search ID does not exist', (done) => {
|
|
113
|
+
cw7.search.disableServices([9999999]).then(r => {
|
|
114
|
+
assert.propertyVal(r, 9999999, false);
|
|
115
|
+
done();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('[Search::enableServices] function test', () => {
|
|
121
|
+
it('should resolve dictionary of searchIDs and boolean', (done) => {
|
|
122
|
+
cw7.search.enableServices([4338]).then(r => {
|
|
123
|
+
assert.propertyVal(r, 4338, true);
|
|
124
|
+
done();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
it('should always be "False" if search ID does not exist', (done) => {
|
|
128
|
+
cw7.search.enableServices([9999999]).then(r => {
|
|
129
|
+
assert.propertyVal(r, 9999999, false);
|
|
130
|
+
done();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('[Search::getDefinition] function test', () => {
|
|
136
|
+
it('should resolve the definition of the search', (done) => {
|
|
137
|
+
cw7.search.getDefinition(4338).then(r => {
|
|
138
|
+
assert.isObject(r);
|
|
139
|
+
done();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
it('should be blanked search definition if the definition doesn\'t exist', (done) => {
|
|
143
|
+
cw7.search.getDefinition(9999999).then(r => {
|
|
144
|
+
assert.isEmpty(r.SearchFields);
|
|
145
|
+
done();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('[Search::getDefinitions] function test', () => {
|
|
151
|
+
it('should resolve the definition of the search', (done) => {
|
|
152
|
+
cw7.search.getDefinitions([4338,4337,4336]).then(r => {
|
|
153
|
+
assert.isArray(r);
|
|
154
|
+
done();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
it('should be blanked search definition(s) if the definitions don\'t exist', (done) => {
|
|
158
|
+
cw7.search.getDefinitions([9999999,99999999,999999999]).then(r => {
|
|
159
|
+
assert.isEmpty(r[0].SearchFields);
|
|
160
|
+
done();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('[Search::getDefinitionNames] function test', () => {
|
|
166
|
+
it('should resolve a collection', (done) => {
|
|
167
|
+
cw7.search.getDefinitionNames([1,2,3,4,5]).then(r => {
|
|
168
|
+
assert.isArray(r);
|
|
169
|
+
done();
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe('[Search::saveDefinition] function test', () => {
|
|
175
|
+
it('should resolve a collection', (done) => {
|
|
176
|
+
cw7.search.saveDefinition('Request').then(r => {
|
|
177
|
+
assert.isNumber(r.SearchId);
|
|
178
|
+
done();
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe('[Search::deleteDefinitions] function test', () => {
|
|
184
|
+
it('should resolve a list of success or failure to delete per id', (done) => {
|
|
185
|
+
cw7.search.saveDefinition('Request').then(r => {
|
|
186
|
+
cw7.search.deleteDefinitions([r.SearchId]).then(rez => {
|
|
187
|
+
assert.isBoolean(rez[r.SearchId]);
|
|
188
|
+
done();
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|