Skip to content

Commit 5e12c98

Browse files
rsi2mGitHub Enterprise
authored and
GitHub Enterprise
committed
Voice Test Fixes (#436)
* Due to error wrapping that happens in lib/util/Request.js#handleError, err no longer has response field * TransferTask fixes * Enabling the rest of the tests * axios bump
1 parent 74d5903 commit 5e12c98

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
"dependencies": {
5959
"@babel/runtime": "^7.16.3",
60-
"axios": "^1.7.9",
60+
"axios": "^1.8.2 ",
6161
"events": "3.3.0",
6262
"graphql": "^14",
6363
"graphql-ws": "^5.16.2",

test/voice/outbound/spec/Task.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const credentials = require('../../../env');
1010
const chai = require('chai');
1111
chai.use(require('sinon-chai'));
1212
const assert = chai.assert;
13+
const expect = chai.expect;
1314

1415
describe('Outbound Voice Task', () => {
1516
const aliceToken = getAccessToken(credentials.accountSid, credentials.multiTaskWorkspaceSid, credentials.multiTaskAliceSid);
@@ -176,15 +177,15 @@ describe('Outbound Voice Task', () => {
176177
await aliceReservation.task.hold(credentials.multiTaskBobSid, true);
177178
reject('Failed to throw 400 on request to hold worker B');
178179
} catch (err) {
179-
assert.strictEqual(err.response.status, 400, 'Task on-hold request failure error code');
180+
expect(err.toString()).contain('status code 400', 'Task on-hold request failure error code');;
180181
}
181182

182183
// Worker B tries to put worker A on hold
183184
try {
184185
await bobReservation.task.hold(credentials.multiTaskAliceSid, true);
185186
reject('Failed to throw 400 on request to hold worker A');
186187
} catch (err) {
187-
assert.strictEqual(err.response.status, 400, 'Task on-hold request failure error code');
188+
expect(err.toString()).contain('status code 400', 'Task on-hold request failure error code');
188189
}
189190
resolve('Outbound test fail if worker A put worker B (and vice versa) on hold if they are not in same conference');
190191
} catch (err) {
@@ -219,15 +220,15 @@ describe('Outbound Voice Task', () => {
219220
await aliceReservation.task.hold(credentials.multiTaskBobSid, true);
220221
reject('Failed to throw 400 on request to hold worker B');
221222
} catch (err) {
222-
assert.strictEqual(err.response.status, 400, 'Task on-hold request failure error code');
223+
expect(err.toString()).contain('status code 400', 'Task on-hold request failure error code');
223224
}
224225

225226
// Worker B tries to put worker A on hold
226227
try {
227228
await bobReservation.task.hold(credentials.multiTaskAliceSid, true);
228229
reject('Failed to throw 400 on request to hold worker A');
229230
} catch (err) {
230-
assert.strictEqual(err.response.status, 400, 'Task on-hold request failure error code');
231+
expect(err.toString()).contain('status code 400', 'Task on-hold request failure error code');
231232
resolve('Outbound test to fail when worker A puts worker B (and vice-versa) on hold if reservation of worker B is pending');
232233
}
233234
} catch (err) {
@@ -246,38 +247,37 @@ describe('Outbound Voice Task', () => {
246247
it('should throw a validation error when using an incorrect workflow sid', () => {
247248
return new Promise(async(resolve, reject) => {
248249
// eslint-disable-next-line
249-
const expected = `Value \'${credentials.multiTaskWorkflowSid}z\' provided for` +
250-
' WorkflowSid has an invalid format';
250+
const expectedDownstreamStatusText = `Value \'${credentials.multiTaskWorkflowSid}z\' provided for` +
251+
' WorkflowSid has an invalid format';
252+
const expectedErrorMessage = `Request failed with status code 400. ${expectedDownstreamStatusText}`
251253
try {
252254

253255
await alice.createTask(credentials.customerNumber, credentials.flexCCNumber,
254-
credentials.multiTaskWorkflowSid, credentials.multiTaskQueueSid);
256+
credentials.multiTaskWorkflowSid, credentials.multiTaskQueueSid);
255257

256258
await alice.createTask(credentials.customerNumber, credentials.flexCCNumber,
257-
credentials.multiTaskWorkflowSid + 'z', credentials.multiTaskQueueSid);
259+
credentials.multiTaskWorkflowSid + 'z', credentials.multiTaskQueueSid);
258260
reject('Invalid WorkflowSid should be rejected');
259261
} catch (err) {
260-
assert.strictEqual(err.response.status, 400, 'expecting a bad request');
261-
assert.strictEqual(err.response.statusText, expected,
262-
'Got a different validation failure than expected');
262+
assert.strictEqual(err.message, expectedErrorMessage,
263+
'Got a different validation failure than expected');
263264
resolve('Test for validation error when using an incorrect workflowSid finished');
264265
}
265266
});
266267
}).timeout(5000);
267268

268269
it('should throw a validation error when using an incorrect queue sid', () => {
269270
return new Promise(async(resolve, reject) => {
271+
let expectedErrorMessage = 'Request failed with status code 400. HTTP 400 Bad Request';
270272
try {
271273
await alice.createTask(credentials.customerNumber, credentials.flexCCNumber,
272-
credentials.multiTaskWorkflowSid, credentials.multiTaskQueueSid + 'z');
274+
credentials.multiTaskWorkflowSid, credentials.multiTaskQueueSid + 'z');
273275
reject('Invalid QueueSid should be rejected');
274276
} catch (err) {
275-
assert.strictEqual(err.response.status, 400, 'expecting a bad request');
276-
// taskrouter doesn't send a validation message here
277+
assert.strictEqual(err.message, expectedErrorMessage, 'expecting a bad request');
277278
resolve('Test for validation error when using an incorrect QueueSid finished');
278279
}
279280
});
280281
}).timeout(5000);
281282
});
282-
});
283-
283+
});

test/voice/outbound/spec/TaskTransferToWorker.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const credentials = require('../../../env');
1515
const chai = require('chai');
1616
chai.use(require('sinon-chai'));
1717
const assert = chai.assert;
18+
const expect = chai.expect;
1819

1920
describe('Task Transfer to Worker for Outbound Voice Task', () => {
2021
const aliceToken = getAccessToken(credentials.accountSid, credentials.multiTaskWorkspaceSid,
@@ -360,7 +361,7 @@ describe('Task Transfer to Worker for Outbound Voice Task', () => {
360361
try {
361362
await aliceReservation.task.transfer(credentials.multiTaskBobSid, { mode: TRANSFER_MODE.cold });
362363
} catch (err) {
363-
assert.strictEqual(err.response.status, 400, 'Task transfer failure error code');
364+
expect(err.toString()).contain('status code 400', 'Task transfer failure error code');
364365
resolve('Test to fail initiating transfer when transferee is unavailable is finished.');
365366
}
366367
} catch (err) {
@@ -922,7 +923,7 @@ describe('Task Transfer to Worker for Outbound Voice Task', () => {
922923
}
923924
} catch (err) {
924925
reject(
925-
`Failed to validate Reservation and Transfer properties sid=${bobReservation.sid}. Error: ${err}`);
926+
`Failed to validate Reservation and Transfer properties sid=${bobReservation.sid}. Error: ${err}`);
926927
}
927928
});
928929

0 commit comments

Comments
 (0)