From c6af3c6a8b107c4dae20442cce88899bf71b02ac Mon Sep 17 00:00:00 2001 From: Quan HL Date: Thu, 27 Jul 2023 06:53:37 +0700 Subject: [PATCH] add testcase --- lib/session/call-session.js | 2 +- test/create-call-test.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 7ea8ac53..dbe2e53d 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -1792,7 +1792,7 @@ class CallSession extends Emitter { //this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`); this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl) .catch((err) => this.logger.error(err, 'redis error')); - + if (this.wakeupResolver && !this.dlg && this.isCurrentCallHigherThan(CallStatus.Failed)) { // Someone is waiting for call to be final this.wakeupResolver({reason: 'session ended'}); diff --git a/test/create-call-test.js b/test/create-call-test.js index 44b61b23..dd2b5545 100644 --- a/test/create-call-test.js +++ b/test/create-call-test.js @@ -32,6 +32,7 @@ test('test create-call timeout', async(t) => { // GIVEN let account_sid = '622f62e4-303a-49f2-bbe0-eb1e1714e37a'; + const from = "restdialtimeout"; const post = bent('http://127.0.0.1:3000/', 'POST', 'json', 201); post('v1/createCall', { 'account_sid':account_sid, @@ -40,13 +41,22 @@ test('test create-call timeout', async(t) => { "url": "https://public-apps.jambonz.us/hello-world", "method": "POST" }, - "from": "15083718299", + "call_status_hook": { + "url": "http://127.0.0.1:3100/callStatus", + "method": "POST" + }, + from, "to": { "type": "phone", "number": "15583084809" }}); //THEN await p; + + let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`); + t.ok(obj.body.sip_reason = 'Request Terminated', + 'create-call timeout: status callback successfully executed'); + disconnect(); } catch (err) { console.log(`error received: ${err}`);