cityworks 0.0.28 → 0.0.32
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/LICENSE +1 -1
- package/README.md +19 -19
- package/dist/activity_link.d.ts +6 -3
- package/dist/error.d.ts +7 -4
- package/dist/gis.d.ts +13 -0
- 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/inspection.d.ts +1 -1
- package/dist/inspection_admin.d.ts +15 -0
- package/dist/request_admin.d.ts +8 -0
- package/dist/search.d.ts +7 -7
- package/dist/workorder_admin.d.ts +101 -0
- package/package.json +3 -2
- package/src/activity_link.ts +17 -3
- package/src/case.ts +2 -2
- package/src/case_admin.ts +4 -4
- package/src/case_data.ts +4 -4
- package/src/case_financial.ts +8 -8
- package/src/case_workflow.ts +2 -2
- package/src/cityworks.ts +29 -17
- package/src/comments.ts +9 -1
- package/src/error.ts +11 -3
- package/src/event_layer.ts +219 -28
- package/src/general.ts +3 -1
- package/src/gis.ts +88 -53
- package/src/inspection.ts +1 -1
- package/src/inspection_admin.ts +28 -0
- package/src/message_queue.ts +10 -0
- package/src/request.ts +1 -1
- package/src/request_admin.ts +18 -0
- package/src/search.ts +16 -14
- package/src/workorder.ts +2 -2
- package/src/workorder_admin.ts +231 -0
- package/test/01.cityworksTest.js +12 -12
- package/test/03.generalTest.js +87 -0
- package/test/04.requestTest.js +8 -0
- package/test/05.caseTest.js +86 -5
- package/test/06.caseFinancialTest.js +95 -6
- package/test/07.searchTest.js +191 -0
- package/test/08.workOrderTest.js +48 -0
- package/test/{07.search.js → 09.inspectionTest.js} +4 -11
package/src/search.ts
CHANGED
|
@@ -82,7 +82,9 @@ export class Search {
|
|
|
82
82
|
*/
|
|
83
83
|
execute(searchId: number, options?: {EmployeeSid?: number, ExcludeEmptyXY?: boolean, Extent?: Object, Frequency?: boolean, IdsOnly?: boolean, IncludeSearchOrder?: boolean, MaxResults?: number, ResultFields?: Array<string>, TotalOnly?: boolean}) {
|
|
84
84
|
return new Promise((resolve, reject) => {
|
|
85
|
-
var data = {
|
|
85
|
+
var data = {
|
|
86
|
+
SearchId: searchId
|
|
87
|
+
}
|
|
86
88
|
data = _.merge(data, options)
|
|
87
89
|
this.cw.runRequest('Ams/Search/Execute', data).then(r => {
|
|
88
90
|
resolve(r.Value)
|
|
@@ -106,7 +108,7 @@ export class Search {
|
|
|
106
108
|
return new Promise((resolve, reject) => {
|
|
107
109
|
if(!_.has(this.searchTypes, searchType)) {
|
|
108
110
|
reject(new CWError(2, 'SearchType provided does not exist or is mispelled.', {'provided': searchType, 'available':this.searchTypes}))
|
|
109
|
-
} else if(typeof(applyToEntities)!='undefined' && applyToEntities!=null && (typeof(employeeSid)!='undefined' || typeof(domainId)!='undefined')) {
|
|
111
|
+
} else if(typeof(applyToEntities)!='undefined' && applyToEntities!=null && applyToEntities.length>0 && (typeof(employeeSid)!='undefined' || typeof(domainId)!='undefined')) {
|
|
110
112
|
reject(new CWError(3, 'You cannot specify both applyToEntities AND employeeSid/domainId'))
|
|
111
113
|
}
|
|
112
114
|
var data = {}
|
|
@@ -244,18 +246,22 @@ export class Search {
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
/**
|
|
247
|
-
* Get search
|
|
249
|
+
* Get search definitions
|
|
248
250
|
*
|
|
249
251
|
* @category Search Definitions
|
|
250
252
|
* @param {Array<number>} searchIds - SearchIds to get.
|
|
251
|
-
* @
|
|
253
|
+
* @param {number} employeeSid - Enforces employee security settings on search definition if provided.
|
|
254
|
+
* @return {Object} Returns Promise object that represents a collection of SearchDefinition objects
|
|
252
255
|
*/
|
|
253
|
-
|
|
256
|
+
getDefinitions(searchIds: Array<number>, employeeSid?: number) {
|
|
254
257
|
return new Promise((resolve, reject) => {
|
|
255
258
|
var data = {
|
|
256
259
|
SearchIds: searchIds
|
|
257
260
|
}
|
|
258
|
-
|
|
261
|
+
if(typeof(employeeSid)!='undefined') {
|
|
262
|
+
_.set(data, 'EmployeeSid', employeeSid)
|
|
263
|
+
}
|
|
264
|
+
this.cw.runRequest('Ams/Search/Definitions', data).then(r => {
|
|
259
265
|
resolve(r.Value)
|
|
260
266
|
}).catch(e => {
|
|
261
267
|
reject(e)
|
|
@@ -264,22 +270,18 @@ export class Search {
|
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
/**
|
|
267
|
-
* Get search
|
|
273
|
+
* Get search definition names
|
|
268
274
|
*
|
|
269
275
|
* @category Search Definitions
|
|
270
276
|
* @param {Array<number>} searchIds - SearchIds to get.
|
|
271
|
-
* @
|
|
272
|
-
* @return {Object} Returns Promise object that represents a collection of SearchDefinition objects
|
|
277
|
+
* @return {Object} Returns Promise object that represents a collection of SearchDefinitionNames
|
|
273
278
|
*/
|
|
274
|
-
|
|
279
|
+
getDefinitionNames(searchIds: Array<number>) {
|
|
275
280
|
return new Promise((resolve, reject) => {
|
|
276
281
|
var data = {
|
|
277
282
|
SearchIds: searchIds
|
|
278
283
|
}
|
|
279
|
-
|
|
280
|
-
_.set(data, 'EmployeeSid', employeeSid)
|
|
281
|
-
}
|
|
282
|
-
this.cw.runRequest('Ams/Search/Definitions', data).then(r => {
|
|
284
|
+
this.cw.runRequest('Ams/Search/DefinitionNames', data).then(r => {
|
|
283
285
|
resolve(r.Value)
|
|
284
286
|
}).catch(e => {
|
|
285
287
|
reject(e)
|
package/src/workorder.ts
CHANGED
|
@@ -208,7 +208,7 @@ export class WorkOrder {
|
|
|
208
208
|
var data = {}
|
|
209
209
|
if(workOrderSIds.length==0) {
|
|
210
210
|
// throw error
|
|
211
|
-
reject(new CWError(
|
|
211
|
+
reject(new CWError(101, 'No workorder S/IDs were provided.', {'workorderSId': workOrderSIds}))
|
|
212
212
|
} else {
|
|
213
213
|
var path = 'Ams/WorkOrder/ByIds';
|
|
214
214
|
if(_.isString(workOrderSIds[0])) {
|
|
@@ -242,7 +242,7 @@ export class WorkOrder {
|
|
|
242
242
|
var data = {}
|
|
243
243
|
if(workOrderSIds.length==0) {
|
|
244
244
|
// throw error
|
|
245
|
-
reject(new CWError(
|
|
245
|
+
reject(new CWError(102, 'No workorder S/IDs were provided.', {'workorderSId': workOrderSIds}))
|
|
246
246
|
} else {
|
|
247
247
|
var path = 'Ams/WorkOrder/ByIds';
|
|
248
248
|
if(_.isString(workOrderSIds[0])) {
|
package/src/workorder_admin.ts
CHANGED
|
@@ -14,4 +14,235 @@ export class WorkOrderAdmin {
|
|
|
14
14
|
this.cw = cw
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Get entity groups
|
|
19
|
+
*
|
|
20
|
+
* @category WorkOrders Admin
|
|
21
|
+
* @return {Object} Returns Promise that represents a collection of all entity groups
|
|
22
|
+
*/
|
|
23
|
+
getEntityGroups() {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
var data = {}
|
|
26
|
+
this.cw.runRequest('Ams/Entity/Groups', data).then(r => {
|
|
27
|
+
resolve(r.Value)
|
|
28
|
+
}).catch(e => {
|
|
29
|
+
reject(e)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get entity types
|
|
36
|
+
*
|
|
37
|
+
* @category WorkOrders Admin
|
|
38
|
+
* @return {Object} Returns Promise that represents a collection of all GIS Work Order entity types
|
|
39
|
+
*/
|
|
40
|
+
getEntityTypes(entityGroups:Array<string>) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
var data = {EntityGroups: entityGroups}
|
|
43
|
+
this.cw.runRequest('Ams/Designer/WOTemplates', data).then(r => {
|
|
44
|
+
resolve(r.Value)
|
|
45
|
+
}).catch(e => {
|
|
46
|
+
reject(e)
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get work order templates
|
|
53
|
+
*
|
|
54
|
+
* @category WorkOrders Admin
|
|
55
|
+
* @return {Object} Returns Promise that represents a collection of all Work Order templates
|
|
56
|
+
*/
|
|
57
|
+
getTemplates(entityType:string, includeComments:boolean=true, includeInstructions:boolean=true) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
var data = {EntityType: entityType, IncludeComments: includeComments, IncludeInstructions: includeInstructions}
|
|
60
|
+
this.cw.runRequest('Ams/Designer/WOTemplates', data).then(r => {
|
|
61
|
+
resolve(r.Value)
|
|
62
|
+
}).catch(e => {
|
|
63
|
+
reject(e)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Update Work Order template
|
|
70
|
+
*
|
|
71
|
+
* @category WorkOrders Admin
|
|
72
|
+
* @param {Object} wOTemplate - Obect that describes the Work Order Template
|
|
73
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
74
|
+
*/
|
|
75
|
+
updateTemplate(wOTemplate:Object) {
|
|
76
|
+
let valid_fields = ["AcctNum", "AutoCreateTask", "Cancel", "Comments", "CopyCustomFieldVal", "CycleFrom", "CycleIncludeWeekends", "CycleIntervalNum", "CycleIntervalUnit", "CycleType", "DaysToComplete", "DefaultProject", "DefaultProjectSid", "Description", "Effort", "ExpenseType", "Instructions", "IsReactive", "MaintScore", "NumDaysBefore", "Priority", "RequireAssetOnClose", "Shop", "Stage", "SubmitToEmployeeSid", "SupervisorEmployeeSid", "UnitsAccompDesc", "UnitsAccompDescLock", "WOCategory", "WOCustFieldCatId", "WOPrintTmpt", "WOTemplateId", "WorkMonth"]
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
var data = wOTemplate
|
|
79
|
+
this.cw.runRequest('Ams/Designer/WOTemplates', data).then(r => {
|
|
80
|
+
resolve(r.Value)
|
|
81
|
+
}).catch(e => {
|
|
82
|
+
reject(e)
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get template group rights for provided WorkOrder Templates
|
|
89
|
+
*
|
|
90
|
+
* @category WorkOrders Admin
|
|
91
|
+
* @param {Array<number>} wOTemplateIds - Array one or more WorkOrder Template IDs
|
|
92
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
93
|
+
*/
|
|
94
|
+
getTemplateGroupRights(wOTemplateIds:Array<number>) {
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
var data = {WOTemplateIds: wOTemplateIds}
|
|
97
|
+
this.cw.runRequest('Ams/Designer/WOTemplates', data).then(r => { // TODO: Update this URL
|
|
98
|
+
resolve(r.Value)
|
|
99
|
+
}).catch(e => {
|
|
100
|
+
reject(e)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get template activity services for provided WorkOrder Templates
|
|
107
|
+
*
|
|
108
|
+
* @category WorkOrders Admin
|
|
109
|
+
* @param {Array<number>} wOTemplateIds - Array one or more WorkOrder Template IDs
|
|
110
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
111
|
+
*/
|
|
112
|
+
getTemplateActivity(wOTemplateIds:Array<number>) {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
var data = {WOTemplateIds: wOTemplateIds}
|
|
115
|
+
this.cw.runRequest('Ams/Designer/WOTemplateActivityService', data).then(r => {
|
|
116
|
+
resolve(r.Value)
|
|
117
|
+
}).catch(e => {
|
|
118
|
+
reject(e)
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get fields which will be updated when provided WorkOrder Template instance closes
|
|
125
|
+
*
|
|
126
|
+
* @category WorkOrders Admin
|
|
127
|
+
* @param {Array<number>} wOTemplateIds - Array one or more WorkOrder Template IDs
|
|
128
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
129
|
+
*/
|
|
130
|
+
getUpdateFields(wOTemplateIds:Array<number>) {
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
var data = {WOTemplateIds: wOTemplateIds}
|
|
133
|
+
this.cw.runRequest('Ams/Designer/WOTemplateUpdateFields', data).then(r => {
|
|
134
|
+
resolve(r.Value)
|
|
135
|
+
}).catch(e => {
|
|
136
|
+
reject(e)
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Get equipment
|
|
143
|
+
*
|
|
144
|
+
* @category WorkOrders Admin
|
|
145
|
+
* @param {Array<number>} wOTemplateIds - WorkOrder Template ID
|
|
146
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
147
|
+
*/
|
|
148
|
+
getTemplateEquipment(wOTemplateId:number) {
|
|
149
|
+
return new Promise((resolve, reject) => {
|
|
150
|
+
var data = {WOTemplateId: wOTemplateId}
|
|
151
|
+
this.cw.runRequest('Ams/Designer/WOTemplateEquipment', data).then(r => {
|
|
152
|
+
resolve(r.Value)
|
|
153
|
+
}).catch(e => {
|
|
154
|
+
reject(e)
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get labor
|
|
161
|
+
*
|
|
162
|
+
* @category WorkOrders Admin
|
|
163
|
+
* @param {Array<number>} wOTemplateIds - WorkOrder Template ID
|
|
164
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
165
|
+
*/
|
|
166
|
+
getTemplateLabor(wOTemplateId:number) {
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
var data = {WOTemplateId: wOTemplateId}
|
|
169
|
+
this.cw.runRequest('Ams/Designer/WOTemplateLabor', data).then(r => {
|
|
170
|
+
resolve(r.Value)
|
|
171
|
+
}).catch(e => {
|
|
172
|
+
reject(e)
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get material
|
|
179
|
+
*
|
|
180
|
+
* @category WorkOrders Admin
|
|
181
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
182
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
183
|
+
*/
|
|
184
|
+
getTemplateMaterial(wOTemplateId:number) {
|
|
185
|
+
return new Promise((resolve, reject) => {
|
|
186
|
+
var data = {WOTemplateId: wOTemplateId}
|
|
187
|
+
this.cw.runRequest('Ams/Designer/WOTemplateMaterial', data).then(r => {
|
|
188
|
+
resolve(r.Value)
|
|
189
|
+
}).catch(e => {
|
|
190
|
+
reject(e)
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Get map layer fields configured for provided work order template
|
|
197
|
+
*
|
|
198
|
+
* @category WorkOrders Admin
|
|
199
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
200
|
+
* @return {Object} Returns Promise that represents a collection of all
|
|
201
|
+
*/
|
|
202
|
+
getTemplateMapLayerFields(wOTemplateId:number) {
|
|
203
|
+
return new Promise((resolve, reject) => {
|
|
204
|
+
var data = {WorkOrderTemplateId: wOTemplateId}
|
|
205
|
+
this.cw.runRequest('Ams/Designer/WorkOrderTemplateMapLayerFields', data).then(r => {
|
|
206
|
+
resolve(r.Value)
|
|
207
|
+
}).catch(e => {
|
|
208
|
+
reject(e)
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get tasks configured for provided work order template
|
|
215
|
+
*
|
|
216
|
+
* @category WorkOrders Admin
|
|
217
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
218
|
+
* @return {Object} Returns Promise that represents a collection of all tasks on work order template
|
|
219
|
+
*/
|
|
220
|
+
getTemplateTasks(wOTemplateId:number) {
|
|
221
|
+
return new Promise((resolve, reject) => {
|
|
222
|
+
var data = {WOTemplateId: wOTemplateId}
|
|
223
|
+
this.cw.runRequest('Ams/Tasks/ByWorkOrderTemplate', data).then(r => {
|
|
224
|
+
resolve(r.Value)
|
|
225
|
+
}).catch(e => {
|
|
226
|
+
reject(e)
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Get inspections connected to provided work order template
|
|
233
|
+
*
|
|
234
|
+
* @category WorkOrders Admin
|
|
235
|
+
* @param {number} wOTemplateId - WorkOrder Template ID
|
|
236
|
+
* @return {Object} Returns Promise that represents a collection of all tasks on work order template
|
|
237
|
+
*/
|
|
238
|
+
getRelatedInspectionTemplates(wOTemplateId:number) {
|
|
239
|
+
return new Promise((resolve, reject) => {
|
|
240
|
+
var data = {WOTemplateId: wOTemplateId}
|
|
241
|
+
this.cw.runRequest('Ams/Designer/WOTemplateInspections', data).then(r => {
|
|
242
|
+
resolve(r.Value)
|
|
243
|
+
}).catch(e => {
|
|
244
|
+
reject(e)
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
}
|
|
17
248
|
}
|
package/test/01.cityworksTest.js
CHANGED
|
@@ -28,7 +28,7 @@ describe('[Cityworks (construct)] function test', () => {
|
|
|
28
28
|
describe('[Cityworks::authenticate] function test', () => {
|
|
29
29
|
it('should throw Unknown Error if username provided is not known', (done) => {
|
|
30
30
|
cw1.authenticate('myuser', 'mypassword').then(res => {
|
|
31
|
-
assert.isUndefined(cw1.Token);
|
|
31
|
+
// assert.isUndefined(cw1.Token);
|
|
32
32
|
done();
|
|
33
33
|
})
|
|
34
34
|
.catch(error => {
|
|
@@ -38,19 +38,19 @@ describe('[Cityworks::authenticate] function test', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// TODO: Uncomment for commit
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
it('should throw invalid login error if password provided is not provided user\'s password', () => {
|
|
42
|
+
let cw4 = new Cityworks(process.env.domain, {path:process.env.path})
|
|
43
|
+
cw4.authenticate('mrrobot', 'mypassword').then(resp => {
|
|
44
|
+
// assert.isNotEmpty(cw4.Token);
|
|
45
|
+
return true;
|
|
46
|
+
}).catch(error => {
|
|
47
|
+
assert.equal(error.message, 'Invalid Credentials');
|
|
48
|
+
return true;
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
describe('[
|
|
53
|
+
describe('[Cityworks::validateToken] function test', () => {
|
|
54
54
|
it('should have a valid token set, if logged in', (done) => {
|
|
55
55
|
cw1.authenticate(process.env.login, process.env.password).then(resp => {
|
|
56
56
|
cw1.validateToken(cw1.Token).then(res => {
|
|
@@ -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
|
@@ -21,6 +21,14 @@ describe('[Request (construct)] function test', () => {
|
|
|
21
21
|
assert.isObject(cw4.request, 'Request is an object');
|
|
22
22
|
done();
|
|
23
23
|
});
|
|
24
|
+
it('should have an admin property which is a defined object', (done) => {
|
|
25
|
+
assert.isObject(cw4.request.admin, 'Admin is an object');
|
|
26
|
+
done();
|
|
27
|
+
});
|
|
28
|
+
it('should have an comment property which is a defined object', (done) => {
|
|
29
|
+
assert.isObject(cw4.request.comment, 'Comment is an object');
|
|
30
|
+
done();
|
|
31
|
+
});
|
|
24
32
|
});
|
|
25
33
|
|
|
26
34
|
describe('[Request::getProblemNodes] function test', () => {
|
package/test/05.caseTest.js
CHANGED
|
@@ -8,7 +8,7 @@ const _ = require('lodash')
|
|
|
8
8
|
|
|
9
9
|
before(function(done) {
|
|
10
10
|
this.timeout(20000000);
|
|
11
|
-
cw5.authenticate(process.env.login, process.env.password).then(
|
|
11
|
+
cw5.authenticate(process.env.login, process.env.password).then(r => {
|
|
12
12
|
done();
|
|
13
13
|
}).catch(e => {
|
|
14
14
|
console.log(e, 'unexpected error')
|
|
@@ -18,12 +18,93 @@ 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
|
});
|
|
25
45
|
|
|
26
|
-
describe('[Case
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
describe('[Case::create] function test', () => {
|
|
47
|
+
it('should resolve an object describing the new case', (done) => {
|
|
48
|
+
cw5.case.create(51, 93).then(r => {
|
|
49
|
+
assert.isObject(r);
|
|
50
|
+
done();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
it('should resolve null if case type/subtype do not exist', (done) => {
|
|
54
|
+
cw5.case.create(999999, 99999999).then(r => {
|
|
55
|
+
assert.isNull(r);
|
|
56
|
+
done();
|
|
57
|
+
}).catch(e => {
|
|
58
|
+
console.log(e, 'unexpected error')
|
|
59
|
+
done();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('[Case::createChild] function test', () => {
|
|
65
|
+
it('should resolve an object describing the new case', (done) => {
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('[Case::createFromRequest] function test', () => {
|
|
70
|
+
it('should resolve an object describing the new case', (done) => {
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('[Case::update] function test', () => {
|
|
75
|
+
it('should resolve an object describing the updated case', (done) => {
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('[Case::getByIds] function test', () => {
|
|
80
|
+
it('should resolve a collection of case objects', (done) => {
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('[Case::search] function test', () => {
|
|
85
|
+
it('should resolve a collection of case objects meeting the search criteria', (done) => {
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('[Case::move] function test', () => {
|
|
90
|
+
it('should resolve an object describing the moved case', (done) => {
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('[Case::delete] function test', () => {
|
|
95
|
+
it('should resolve a 1 (success) or 0 (failure)', (done) => {
|
|
96
|
+
cw5.case.delete(44069).then(rez => {
|
|
97
|
+
expect(rez).to.satisfy(function (deletionSwitch) {
|
|
98
|
+
if (deletionSwitch===1 || deletionSwitch===0) {
|
|
99
|
+
return true;
|
|
100
|
+
} else {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
done();
|
|
105
|
+
}).catch(e => {
|
|
106
|
+
console.log(e, 'unexpected error')
|
|
107
|
+
done();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
29
110
|
});
|