Skip to content

Commit

Permalink
fix(plugin-presence): set status failed when attempting to set DND (#…
Browse files Browse the repository at this point in the history
…3960)

Co-authored-by: chrisadubois <chdubois@cisco.com>
  • Loading branch information
CormacGCisco and chrisadubois authored Nov 7, 2024
1 parent a9586f9 commit 1bd9436
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/@webex/internal-plugin-presence/src/presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const Presence = WebexPlugin.extend({
body: {
subject: this.webex.internal.device.userId,
eventType: status,
label: this.webex.internal.device.userId,
...(status !== 'dnd' && {label: this.webex.internal.device.userId}),
ttl,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,37 @@ describe.skip('plugin-presence', () => {
};
sinon.spy(webex, 'request');

webex.internal.presence.setStatus('dnd');
webex.internal.presence.setStatus('active');

assert.calledOnce(webex.request);

const request = webex.request.getCall(0);

assert.equal(request.args[0].body.label, testGuid);
});

it('does not pass a label to the API if the status is DND', () => {
const testGuid = 'test-guid';

webex.internal.device.userId = testGuid;

webex.request = function (options) {
return Promise.resolve({
statusCode: 204,
body: [],
options,
});
};
sinon.spy(webex, 'request');

webex.internal.presence.setStatus('dnd');

assert.calledOnce(webex.request);

const request = webex.request.getCall(0);

assert.notProperty(request.args[0].body, 'label');
});
});

describe('#initializeWorker()', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@webex/plugin-presence/src/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const Presence: IPresence = WebexPlugin.extend({
body: {
subject: this.webex.internal.device.userId,
eventType: status,
label: this.webex.internal.device.userId,
...(status !== 'dnd' && {label: this.webex.internal.device.userId}),
ttl,
},
})
Expand Down
25 changes: 24 additions & 1 deletion packages/@webex/plugin-presence/test/unit/spec/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,37 @@ describe('plugin-presence', () => {
};
sinon.spy(webex, 'request');

webex.presence.setStatus('dnd');
webex.presence.setStatus('active');

assert.calledOnce(webex.request);

const request = webex.request.getCall(0);

assert.equal(request.args[0].body.label, testGuid);
});

it('does not pass a label to the API if the status is DND', () => {
const testGuid = 'test-guid';

webex.internal.device.userId = testGuid;

webex.request = function (options) {
return Promise.resolve({
statusCode: 204,
body: [],
options,
});
};
sinon.spy(webex, 'request');

webex.presence.setStatus('dnd');

assert.calledOnce(webex.request);

const request = webex.request.getCall(0);

assert.notProperty(request.args[0].body, 'label');
});
});

describe('#initializeWorker()', () => {
Expand Down

0 comments on commit 1bd9436

Please sign in to comment.