Skip to content

Commit

Permalink
Merge pull request #486 from seiyako/master
Browse files Browse the repository at this point in the history
Resolve updateVoiceIdSpeakerId after _updateSpeakerIdInLcms resolves
  • Loading branch information
seiyako authored Oct 12, 2021
2 parents f72c101 + 64764e5 commit fabb2df
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amazon-connect-streams",
"version": "1.7.3",
"version": "1.7.4",
"description": "Amazon Connect Streams Library",
"engines": {
"node": ">=12.0.0"
Expand Down
2 changes: 1 addition & 1 deletion release/connect-streams-min.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions release/connect-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -25591,8 +25591,13 @@ AWS.apiLoader.services['sts']['2011-06-15'] = require('../apis/sts-2011-06-15.mi
}, {
success: function (data) {
connect.getLog().info("updateSpeakerIdInVoiceId succeeded").withObject(data).sendInternalLogToServer();
self._updateSpeakerIdInLcms(speakerId).catch(function(){});
resolve(data);
self._updateSpeakerIdInLcms(speakerId)
.then(function() {
resolve(data);
})
.catch(function(err) {
reject(err);
});
},
failure: function (err) {
var error;
Expand Down Expand Up @@ -26087,7 +26092,7 @@ AWS.apiLoader.services['sts']['2011-06-15'] = require('../apis/sts-2011-06-15.mi

connect.core = {};
connect.core.initialized = false;
connect.version = "1.7.3";
connect.version = "1.7.4";
connect.DEFAULT_BATCH_SIZE = 500;

var CCP_SYN_TIMEOUT = 1000; // 1 sec
Expand Down
9 changes: 7 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1735,8 +1735,13 @@
}, {
success: function (data) {
connect.getLog().info("updateSpeakerIdInVoiceId succeeded").withObject(data).sendInternalLogToServer();
self._updateSpeakerIdInLcms(speakerId).catch(function(){});
resolve(data);
self._updateSpeakerIdInLcms(speakerId)
.then(function() {
resolve(data);
})
.catch(function(err) {
reject(err);
});
},
failure: function (err) {
var error;
Expand Down
25 changes: 24 additions & 1 deletion test/unit/voiceid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ describe('VoiceId', () => {
connect.core.getClient.restore();
});

it('should get rejected when no speakerId without calling backend', async () => {
it('should get rejected without calling backend when no speakerId is passed in', async () => {
const response = {
data: 'fakeData'
};
Expand Down Expand Up @@ -1198,6 +1198,29 @@ describe('VoiceId', () => {
expect(error.type).to.equal(connect.VoiceIdErrorTypes.UPDATE_SPEAKER_ID_FAILED);
connect.core.getClient.restore();
});

it('should get rejected when _updateSpeakerIdInLcms api call fails', async () => {
const response = 'fakeData';
sinon.stub(connect.core, 'getClient').callsFake(() => ({
call: (endpoint, params, callbacks) => {
callbacks.success(response);
}
}));
const voiceId = new connect.VoiceId(contactId);
voiceId.checkConferenceCall = sinon.stub();
voiceId.getDomainId = sinon.stub().callsFake(() => Promise.resolve(domainId));
voiceId._updateSpeakerIdInLcms = sinon.stub().callsFake(() => Promise.reject({ type: connect.VoiceIdErrorTypes.UPDATE_SPEAKER_ID_IN_LCMS_FAILED }));

let obj, error;
try {
obj = await voiceId.updateSpeakerIdInVoiceId(speakerId);
} catch (e) {
error = e;
}
expect(obj).to.be.a('undefined');
expect(error.type).to.equal(connect.VoiceIdErrorTypes.UPDATE_SPEAKER_ID_IN_LCMS_FAILED);
connect.core.getClient.restore();
});
});

describe('syncSpeakerId', () => {
Expand Down

0 comments on commit fabb2df

Please sign in to comment.