@webex/calling 3.13.0-next.1 → 3.13.0-next.10
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/README.md +1 -1
- package/dist/CallHistory/CallHistory.js +1 -1
- package/dist/CallHistory/CallHistory.js.map +1 -1
- package/dist/CallHistory/CallHistory.test.js +2 -1
- package/dist/CallHistory/CallHistory.test.js.map +1 -1
- package/dist/CallQueue/CallQueue.js +1322 -0
- package/dist/CallQueue/CallQueue.js.map +1 -0
- package/dist/CallQueue/CallQueue.test.js +3321 -0
- package/dist/CallQueue/CallQueue.test.js.map +1 -0
- package/dist/CallQueue/constants.js +65 -0
- package/dist/CallQueue/constants.js.map +1 -0
- package/dist/CallQueue/types.js +4 -0
- package/dist/CallQueue/types.js.map +1 -0
- package/dist/CallQueue/utils.js +370 -0
- package/dist/CallQueue/utils.js.map +1 -0
- package/dist/CallQueue/utils.test.js +548 -0
- package/dist/CallQueue/utils.test.js.map +1 -0
- package/dist/CallingClient/constants.js +1 -1
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/registration/register.js +2 -2
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +133 -97
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/Events/types.js +1 -0
- package/dist/Events/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/Voicemail/Voicemail.js +10 -10
- package/dist/Voicemail/Voicemail.js.map +1 -1
- package/dist/Voicemail/Voicemail.test.js +40 -20
- package/dist/Voicemail/Voicemail.test.js.map +1 -1
- package/dist/api.js +47 -8
- package/dist/api.js.map +1 -1
- package/dist/common/Utils.js +8 -7
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +320 -239
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/index.js +102 -45
- package/dist/index.js.map +1 -1
- package/dist/module/CallHistory/CallHistory.js +1 -1
- package/dist/module/CallQueue/CallQueue.js +718 -0
- package/dist/module/CallQueue/constants.js +41 -0
- package/dist/module/CallQueue/types.js +1 -0
- package/dist/module/CallQueue/utils.js +253 -0
- package/dist/module/CallingClient/constants.js +1 -1
- package/dist/module/CallingClient/registration/register.js +1 -1
- package/dist/module/Events/types.js +1 -0
- package/dist/module/Voicemail/Voicemail.js +10 -10
- package/dist/module/api.js +5 -2
- package/dist/module/common/Utils.js +7 -5
- package/dist/module/index.js +4 -1
- package/dist/types/CallQueue/CallQueue.d.ts +45 -0
- package/dist/types/CallQueue/CallQueue.d.ts.map +1 -0
- package/dist/types/CallQueue/constants.d.ts +37 -0
- package/dist/types/CallQueue/constants.d.ts.map +1 -0
- package/dist/types/CallQueue/types.d.ts +97 -0
- package/dist/types/CallQueue/types.d.ts.map +1 -0
- package/dist/types/CallQueue/utils.d.ts +19 -0
- package/dist/types/CallQueue/utils.d.ts.map +1 -0
- package/dist/types/CallingClient/constants.d.ts +1 -1
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/Events/types.d.ts +2 -1
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +1 -1
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/api.d.ts +8 -4
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +11 -24
|
@@ -0,0 +1,3321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
+
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
7
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
8
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
9
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
10
|
+
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
11
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
15
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
16
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
|
|
17
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
18
|
+
var _from = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/from"));
|
|
19
|
+
var _deleteProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/delete-property"));
|
|
20
|
+
var _sinon = _interopRequireDefault(require("sinon"));
|
|
21
|
+
var _testHelperChai = require("@webex/test-helper-chai");
|
|
22
|
+
var _events = require("events");
|
|
23
|
+
var _types = require("../Logger/types");
|
|
24
|
+
var _testUtil = require("../common/testUtil");
|
|
25
|
+
var _types2 = require("../common/types");
|
|
26
|
+
var _types3 = require("../Events/types");
|
|
27
|
+
var utils = _interopRequireWildcard(require("../common/Utils"));
|
|
28
|
+
var _SDKConnector = _interopRequireDefault(require("../SDKConnector"));
|
|
29
|
+
var _CallQueue = require("./CallQueue");
|
|
30
|
+
var _constants = require("./constants");
|
|
31
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t45 in e) "default" !== _t45 && {}.hasOwnProperty.call(e, _t45) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t45)) && (i.get || i.set) ? o(f, _t45, i) : f[_t45] = e[_t45]); return f; })(e, t); }
|
|
32
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
33
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
34
|
+
jest.mock('../SDKConnector', function () {
|
|
35
|
+
return {
|
|
36
|
+
__esModule: true,
|
|
37
|
+
default: {
|
|
38
|
+
getWebex: jest.fn(),
|
|
39
|
+
setWebex: jest.fn()
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
var createCallQueueClient = function createCallQueueClient() {
|
|
44
|
+
jest.mocked(_SDKConnector.default.getWebex).mockReturnValue(arguments.length <= 0 ? undefined : arguments[0]);
|
|
45
|
+
return _CallQueue.createCallQueueClient.apply(void 0, arguments);
|
|
46
|
+
};
|
|
47
|
+
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
48
|
+
var WEBEX_API_INT = 'https://integration.webexapis.com/v1/';
|
|
49
|
+
var TEST_OPTIONS = {
|
|
50
|
+
webexApiBaseUrl: 'https://integration.webexapis.com'
|
|
51
|
+
};
|
|
52
|
+
var EXPECTED_LIFECYCLE_CONFLICT = {
|
|
53
|
+
statusCode: 409,
|
|
54
|
+
data: {
|
|
55
|
+
error: 'Call queue client was reinitialized; refresh settings'
|
|
56
|
+
},
|
|
57
|
+
message: 'FAILURE'
|
|
58
|
+
};
|
|
59
|
+
var EXPECTED_LIFECYCLE_CONFLICT_AFTER_UPDATE = {
|
|
60
|
+
statusCode: 409,
|
|
61
|
+
data: {
|
|
62
|
+
error: 'Call queue client was reinitialized; request may have completed; refresh settings before retrying'
|
|
63
|
+
},
|
|
64
|
+
message: 'FAILURE'
|
|
65
|
+
};
|
|
66
|
+
var client = createCallQueueClient(webex, {
|
|
67
|
+
level: _types.LOGGER.INFO
|
|
68
|
+
}, TEST_OPTIONS);
|
|
69
|
+
var mercuryHandlers = new _map.default(webex.internal.mercury.on.mock.calls.map(function (call) {
|
|
70
|
+
return [call[0], call[1]];
|
|
71
|
+
}));
|
|
72
|
+
function deferredResponse() {
|
|
73
|
+
var resolve;
|
|
74
|
+
var promise = new _promise.default(function (done) {
|
|
75
|
+
resolve = done;
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
promise: promise,
|
|
79
|
+
resolve: resolve
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function startQueueRequest(queueClient, method) {
|
|
83
|
+
if (method === 'GET') return queueClient.getCallQueueSettings();
|
|
84
|
+
if (method === 'PUT') {
|
|
85
|
+
return queueClient.updateCallQueueSettings({
|
|
86
|
+
agentACDState: _constants.ACD_STATE.AVAILABLE
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return queueClient.syncTelephonyCalls();
|
|
90
|
+
}
|
|
91
|
+
describe('CallQueue client', function () {
|
|
92
|
+
beforeEach(function () {
|
|
93
|
+
jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
94
|
+
});
|
|
95
|
+
afterEach(function () {
|
|
96
|
+
jest.clearAllMocks();
|
|
97
|
+
});
|
|
98
|
+
it('registers Mercury listeners for telephony agent sync, state, and join', function () {
|
|
99
|
+
expect((0, _from.default)(mercuryHandlers.keys())).toEqual(expect.arrayContaining(['event:telephony_agents.sync', 'event:telephony_agents.state', 'event:telephony_agents.join', 'event:telephony_agent.sync', 'event:telephony_agent.state', 'event:telephony_agent.join']));
|
|
100
|
+
});
|
|
101
|
+
it('rolls back partially registered Mercury listeners if initialization fails', function () {
|
|
102
|
+
var failedWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
103
|
+
var mercury = new _events.EventEmitter();
|
|
104
|
+
var existingSubscriber = jest.fn();
|
|
105
|
+
mercury.on(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_SYNC, existingSubscriber);
|
|
106
|
+
var registrations = 0;
|
|
107
|
+
failedWebex.internal.mercury.on.mockImplementation(function (event, listener) {
|
|
108
|
+
mercury.on(event, listener);
|
|
109
|
+
registrations += 1;
|
|
110
|
+
if (registrations === 2) throw new Error('Mercury registration failed');
|
|
111
|
+
});
|
|
112
|
+
failedWebex.internal.mercury.off.mockImplementation(function (event, listener) {
|
|
113
|
+
mercury.off(event, listener);
|
|
114
|
+
});
|
|
115
|
+
expect(function () {
|
|
116
|
+
return createCallQueueClient(failedWebex, {
|
|
117
|
+
level: _types.LOGGER.INFO
|
|
118
|
+
}, TEST_OPTIONS);
|
|
119
|
+
}).toThrow('Mercury registration failed');
|
|
120
|
+
expect(mercury.listeners(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_SYNC)).toEqual([existingSubscriber]);
|
|
121
|
+
expect(mercury.listenerCount(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)).toBe(0);
|
|
122
|
+
});
|
|
123
|
+
it('loads primary-line queue settings', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
124
|
+
var _response$data$callQu, _response$data$callQu2;
|
|
125
|
+
var response;
|
|
126
|
+
return _regenerator.default.wrap(function (_context) {
|
|
127
|
+
while (1) switch (_context.prev = _context.next) {
|
|
128
|
+
case 0:
|
|
129
|
+
webex.request.mockResolvedValue({
|
|
130
|
+
statusCode: 200,
|
|
131
|
+
headers: {
|
|
132
|
+
trackingid: 'tracking-1'
|
|
133
|
+
},
|
|
134
|
+
body: {
|
|
135
|
+
agentACDState: 'SIGN_OUT',
|
|
136
|
+
queues: [{
|
|
137
|
+
id: 'queue-1',
|
|
138
|
+
name: 'Sales',
|
|
139
|
+
available: false,
|
|
140
|
+
allowLogOffEnabled: true
|
|
141
|
+
}]
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
_context.next = 1;
|
|
145
|
+
return client.getCallQueueSettings();
|
|
146
|
+
case 1:
|
|
147
|
+
response = _context.sent;
|
|
148
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
149
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/queues"),
|
|
150
|
+
method: _types2.HTTP_METHODS.GET
|
|
151
|
+
});
|
|
152
|
+
expect(response.statusCode).toBe(200);
|
|
153
|
+
expect((_response$data$callQu = response.data.callQueue) === null || _response$data$callQu === void 0 ? void 0 : _response$data$callQu.acdState).toBe(_constants.ACD_STATE.SIGN_OUT);
|
|
154
|
+
expect((_response$data$callQu2 = response.data.callQueue) === null || _response$data$callQu2 === void 0 ? void 0 : _response$data$callQu2.queues[0].id).toBe('queue-1');
|
|
155
|
+
case 2:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee);
|
|
160
|
+
})));
|
|
161
|
+
it.each([['Integration', 'https://integration.webexapis.com'], ['Production', 'https://webexapis.com'], ['FedRAMP', 'https://api-usgov.webex.com']])('routes queue reads, catalog, writes, and sync to the supplied %s API', /*#__PURE__*/function () {
|
|
162
|
+
var _ref2 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(_, baseUrl) {
|
|
163
|
+
var otherWebex, queueClient, _t, _t2, _t3;
|
|
164
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
165
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
166
|
+
case 0:
|
|
167
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
168
|
+
queueClient = createCallQueueClient(otherWebex, {
|
|
169
|
+
level: _types.LOGGER.INFO
|
|
170
|
+
}, {
|
|
171
|
+
webexApiBaseUrl: baseUrl
|
|
172
|
+
});
|
|
173
|
+
otherWebex.request.mockImplementation(/*#__PURE__*/function () {
|
|
174
|
+
var _ref4 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
|
|
175
|
+
var uri;
|
|
176
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
177
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
uri = _ref3.uri;
|
|
180
|
+
return _context2.abrupt("return", {
|
|
181
|
+
statusCode: 200,
|
|
182
|
+
body: uri.endsWith('/telephony/config/queues') ? {
|
|
183
|
+
queues: [{
|
|
184
|
+
id: 'queue-1',
|
|
185
|
+
name: 'Sales'
|
|
186
|
+
}]
|
|
187
|
+
} : {
|
|
188
|
+
agentACDState: 'AVAILABLE',
|
|
189
|
+
queues: [{
|
|
190
|
+
id: 'queue-1',
|
|
191
|
+
available: true
|
|
192
|
+
}]
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
case 1:
|
|
196
|
+
case "end":
|
|
197
|
+
return _context2.stop();
|
|
198
|
+
}
|
|
199
|
+
}, _callee2);
|
|
200
|
+
}));
|
|
201
|
+
return function (_x3) {
|
|
202
|
+
return _ref4.apply(this, arguments);
|
|
203
|
+
};
|
|
204
|
+
}());
|
|
205
|
+
_t = expect;
|
|
206
|
+
_context3.next = 1;
|
|
207
|
+
return queueClient.getCallQueueSettings();
|
|
208
|
+
case 1:
|
|
209
|
+
_t(_context3.sent.statusCode).toBe(200);
|
|
210
|
+
_t2 = expect;
|
|
211
|
+
_context3.next = 2;
|
|
212
|
+
return queueClient.updateCallQueueSettings({
|
|
213
|
+
agentACDState: _constants.ACD_STATE.UNAVAILABLE
|
|
214
|
+
});
|
|
215
|
+
case 2:
|
|
216
|
+
_t2(_context3.sent.statusCode).toBe(200);
|
|
217
|
+
_t3 = expect;
|
|
218
|
+
_context3.next = 3;
|
|
219
|
+
return queueClient.syncTelephonyCalls();
|
|
220
|
+
case 3:
|
|
221
|
+
_t3(_context3.sent.statusCode).toBe(200);
|
|
222
|
+
expect(otherWebex.request).toHaveBeenNthCalledWith(1, expect.objectContaining({
|
|
223
|
+
uri: "".concat(baseUrl, "/v1/telephony/config/people/me/settings/queues"),
|
|
224
|
+
method: _types2.HTTP_METHODS.GET
|
|
225
|
+
}));
|
|
226
|
+
expect(otherWebex.request).toHaveBeenNthCalledWith(2, expect.objectContaining({
|
|
227
|
+
uri: "".concat(baseUrl, "/v1/telephony/config/queues"),
|
|
228
|
+
method: _types2.HTTP_METHODS.GET
|
|
229
|
+
}));
|
|
230
|
+
expect(otherWebex.request).toHaveBeenNthCalledWith(3, expect.objectContaining({
|
|
231
|
+
uri: "".concat(baseUrl, "/v1/telephony/config/people/me/settings/queues"),
|
|
232
|
+
method: _types2.HTTP_METHODS.PUT
|
|
233
|
+
}));
|
|
234
|
+
expect(otherWebex.request).toHaveBeenNthCalledWith(4, expect.objectContaining({
|
|
235
|
+
uri: "".concat(baseUrl, "/v1/telephony/calls/sync/invoke"),
|
|
236
|
+
method: _types2.HTTP_METHODS.POST
|
|
237
|
+
}));
|
|
238
|
+
queueClient.dispose();
|
|
239
|
+
case 4:
|
|
240
|
+
case "end":
|
|
241
|
+
return _context3.stop();
|
|
242
|
+
}
|
|
243
|
+
}, _callee3);
|
|
244
|
+
}));
|
|
245
|
+
return function (_x, _x2) {
|
|
246
|
+
return _ref2.apply(this, arguments);
|
|
247
|
+
};
|
|
248
|
+
}());
|
|
249
|
+
it('accepts one trailing slash without duplicating the version segment', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
250
|
+
var otherWebex, queueClient;
|
|
251
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
252
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
253
|
+
case 0:
|
|
254
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
255
|
+
queueClient = createCallQueueClient(otherWebex, {
|
|
256
|
+
level: _types.LOGGER.INFO
|
|
257
|
+
}, {
|
|
258
|
+
webexApiBaseUrl: 'https://integration.webexapis.com/'
|
|
259
|
+
});
|
|
260
|
+
otherWebex.request.mockResolvedValue({
|
|
261
|
+
statusCode: 200,
|
|
262
|
+
body: {
|
|
263
|
+
agentACDState: 'AVAILABLE',
|
|
264
|
+
queues: []
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
_context4.next = 1;
|
|
268
|
+
return queueClient.getCallQueueSettings();
|
|
269
|
+
case 1:
|
|
270
|
+
expect(otherWebex.request).toHaveBeenCalledWith(expect.objectContaining({
|
|
271
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/queues")
|
|
272
|
+
}));
|
|
273
|
+
queueClient.dispose();
|
|
274
|
+
case 2:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context4.stop();
|
|
277
|
+
}
|
|
278
|
+
}, _callee4);
|
|
279
|
+
})));
|
|
280
|
+
it.each(['', 'http://webexapis.com', 'https://webexapis.com.evil.example', 'https://webexapis.com@evil.example', 'https://user@webexapis.com', 'https://webexapis.com:443', 'https://webexapis.com/v1', 'https://webexapis.com?foo=bar', 'https://webexapis.com#fragment', 'https://webexapis.com//'])('rejects an invalid API base %s before sending requests', /*#__PURE__*/function () {
|
|
281
|
+
var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(baseUrl) {
|
|
282
|
+
var _otherWebex$internal$;
|
|
283
|
+
var otherWebex, queueClient, syncListener, _t4, _t5, _t6;
|
|
284
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
285
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
286
|
+
case 0:
|
|
287
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
288
|
+
queueClient = createCallQueueClient(otherWebex, {
|
|
289
|
+
level: _types.LOGGER.INFO
|
|
290
|
+
}, {
|
|
291
|
+
webexApiBaseUrl: baseUrl
|
|
292
|
+
});
|
|
293
|
+
_t4 = expect;
|
|
294
|
+
_context5.next = 1;
|
|
295
|
+
return queueClient.getCallQueueSettings();
|
|
296
|
+
case 1:
|
|
297
|
+
_t4(_context5.sent.statusCode).toBe(400);
|
|
298
|
+
_t5 = expect;
|
|
299
|
+
_context5.next = 2;
|
|
300
|
+
return queueClient.updateCallQueueSettings({
|
|
301
|
+
agentACDState: _constants.ACD_STATE.AVAILABLE
|
|
302
|
+
});
|
|
303
|
+
case 2:
|
|
304
|
+
_t5(_context5.sent.statusCode).toBe(400);
|
|
305
|
+
_t6 = expect;
|
|
306
|
+
_context5.next = 3;
|
|
307
|
+
return queueClient.syncTelephonyCalls();
|
|
308
|
+
case 3:
|
|
309
|
+
_t6(_context5.sent.statusCode).toBe(400);
|
|
310
|
+
syncListener = (_otherWebex$internal$ = otherWebex.internal.mercury.on.mock.calls.find(function (_ref7) {
|
|
311
|
+
var _ref8 = (0, _slicedToArray2.default)(_ref7, 1),
|
|
312
|
+
event = _ref8[0];
|
|
313
|
+
return event === _constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_SYNC;
|
|
314
|
+
})) === null || _otherWebex$internal$ === void 0 ? void 0 : _otherWebex$internal$[1];
|
|
315
|
+
syncListener === null || syncListener === void 0 ? void 0 : syncListener({
|
|
316
|
+
data: {
|
|
317
|
+
agentACDState: 'AVAILABLE'
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
_context5.next = 4;
|
|
321
|
+
return _promise.default.resolve();
|
|
322
|
+
case 4:
|
|
323
|
+
expect(otherWebex.request).not.toHaveBeenCalled();
|
|
324
|
+
queueClient.dispose();
|
|
325
|
+
case 5:
|
|
326
|
+
case "end":
|
|
327
|
+
return _context5.stop();
|
|
328
|
+
}
|
|
329
|
+
}, _callee5);
|
|
330
|
+
}));
|
|
331
|
+
return function (_x4) {
|
|
332
|
+
return _ref6.apply(this, arguments);
|
|
333
|
+
};
|
|
334
|
+
}());
|
|
335
|
+
it('fails closed when JavaScript callers omit options', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
336
|
+
var otherWebex, queueClient, _t7;
|
|
337
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
338
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
339
|
+
case 0:
|
|
340
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)(); // @ts-expect-error Exercise a JavaScript caller that omits the required options.
|
|
341
|
+
queueClient = createCallQueueClient(otherWebex, {
|
|
342
|
+
level: _types.LOGGER.INFO
|
|
343
|
+
});
|
|
344
|
+
_t7 = expect;
|
|
345
|
+
_context6.next = 1;
|
|
346
|
+
return queueClient.getCallQueueSettings();
|
|
347
|
+
case 1:
|
|
348
|
+
_t7(_context6.sent.statusCode).toBe(400);
|
|
349
|
+
expect(otherWebex.request).not.toHaveBeenCalled();
|
|
350
|
+
queueClient.dispose();
|
|
351
|
+
case 2:
|
|
352
|
+
case "end":
|
|
353
|
+
return _context6.stop();
|
|
354
|
+
}
|
|
355
|
+
}, _callee6);
|
|
356
|
+
})));
|
|
357
|
+
it.each(['device', 'features', 'entitlement', 'models'])('starts accepting requests after delayed registration when %s is initially missing', /*#__PURE__*/function () {
|
|
358
|
+
var _ref0 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7(missing) {
|
|
359
|
+
var lateWebex, device, features, entitlement, models, missingFields, _missingFields, target, field, earlyClient, _t8, _t9, _t0;
|
|
360
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
361
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
362
|
+
case 0:
|
|
363
|
+
lateWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
364
|
+
device = lateWebex.internal.device;
|
|
365
|
+
features = device.features;
|
|
366
|
+
entitlement = features.entitlement;
|
|
367
|
+
models = entitlement.models;
|
|
368
|
+
missingFields = {
|
|
369
|
+
device: [lateWebex.internal, 'device'],
|
|
370
|
+
features: [device, 'features'],
|
|
371
|
+
entitlement: [features, 'entitlement'],
|
|
372
|
+
models: [entitlement, 'models']
|
|
373
|
+
};
|
|
374
|
+
_missingFields = (0, _slicedToArray2.default)(missingFields[missing], 2), target = _missingFields[0], field = _missingFields[1];
|
|
375
|
+
(0, _deleteProperty.default)(target, field);
|
|
376
|
+
earlyClient = createCallQueueClient(lateWebex, {
|
|
377
|
+
level: _types.LOGGER.INFO
|
|
378
|
+
}, TEST_OPTIONS);
|
|
379
|
+
_t8 = expect;
|
|
380
|
+
_context7.next = 1;
|
|
381
|
+
return earlyClient.getCallQueueSettings();
|
|
382
|
+
case 1:
|
|
383
|
+
_t8(_context7.sent.statusCode).toBe(501);
|
|
384
|
+
expect(lateWebex.request).not.toHaveBeenCalled();
|
|
385
|
+
expect(lateWebex.internal.mercury.on).not.toHaveBeenCalled();
|
|
386
|
+
lateWebex.internal.device = device;
|
|
387
|
+
device.features = features;
|
|
388
|
+
features.entitlement = entitlement;
|
|
389
|
+
entitlement.models = models;
|
|
390
|
+
lateWebex.request.mockResolvedValue({
|
|
391
|
+
statusCode: 200,
|
|
392
|
+
body: {
|
|
393
|
+
agentACDState: 'AVAILABLE',
|
|
394
|
+
queues: []
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
_t9 = expect;
|
|
398
|
+
_context7.next = 2;
|
|
399
|
+
return earlyClient.getCallQueueSettings();
|
|
400
|
+
case 2:
|
|
401
|
+
_t9(_context7.sent.statusCode).toBe(200);
|
|
402
|
+
_t0 = expect;
|
|
403
|
+
_context7.next = 3;
|
|
404
|
+
return earlyClient.getCallQueueSettings();
|
|
405
|
+
case 3:
|
|
406
|
+
_t0(_context7.sent.statusCode).toBe(200);
|
|
407
|
+
expect(lateWebex.internal.mercury.on).toHaveBeenCalledWith(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_SYNC, expect.any(Function));
|
|
408
|
+
expect(lateWebex.internal.mercury.on).toHaveBeenCalledTimes(6);
|
|
409
|
+
earlyClient.dispose();
|
|
410
|
+
case 4:
|
|
411
|
+
case "end":
|
|
412
|
+
return _context7.stop();
|
|
413
|
+
}
|
|
414
|
+
}, _callee7);
|
|
415
|
+
}));
|
|
416
|
+
return function (_x5) {
|
|
417
|
+
return _ref0.apply(this, arguments);
|
|
418
|
+
};
|
|
419
|
+
}());
|
|
420
|
+
it('prepares an early client for reuse after registration without duplicate listeners or requests', function () {
|
|
421
|
+
var lateWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
422
|
+
var features = lateWebex.internal.device.features;
|
|
423
|
+
(0, _deleteProperty.default)(lateWebex.internal.device, 'features');
|
|
424
|
+
var earlyClient = createCallQueueClient(lateWebex, {
|
|
425
|
+
level: _types.LOGGER.INFO
|
|
426
|
+
}, TEST_OPTIONS);
|
|
427
|
+
_testHelperChai.assert.isTrue(earlyClient.prepareForReuse());
|
|
428
|
+
_testHelperChai.assert.lengthOf(lateWebex.internal.mercury.on.mock.calls, 0);
|
|
429
|
+
lateWebex.internal.device.features = features;
|
|
430
|
+
_testHelperChai.assert.isTrue(earlyClient.prepareForReuse());
|
|
431
|
+
_testHelperChai.assert.lengthOf(lateWebex.internal.mercury.on.mock.calls, 6);
|
|
432
|
+
_testHelperChai.assert.isTrue(earlyClient.prepareForReuse());
|
|
433
|
+
_testHelperChai.assert.lengthOf(lateWebex.internal.mercury.on.mock.calls, 6);
|
|
434
|
+
_testHelperChai.assert.lengthOf(lateWebex.request.mock.calls, 0);
|
|
435
|
+
earlyClient.dispose();
|
|
436
|
+
});
|
|
437
|
+
it('reuses a compatible client in the factory without duplicating listeners', function () {
|
|
438
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
439
|
+
var first = createCallQueueClient(boundWebex, {
|
|
440
|
+
level: _types.LOGGER.INFO
|
|
441
|
+
}, TEST_OPTIONS);
|
|
442
|
+
var reused = createCallQueueClient(boundWebex, {
|
|
443
|
+
level: _types.LOGGER.INFO
|
|
444
|
+
}, TEST_OPTIONS, first);
|
|
445
|
+
_testHelperChai.assert.strictEqual(reused, first);
|
|
446
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.on.mock.calls, 6);
|
|
447
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.off.mock.calls, 0);
|
|
448
|
+
reused.dispose();
|
|
449
|
+
});
|
|
450
|
+
it.each(['apiBaseUrl', 'logger', 'account'])('replaces and cleans up a prior client when %s changes', function (changed) {
|
|
451
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
452
|
+
var first = createCallQueueClient(boundWebex, {
|
|
453
|
+
level: _types.LOGGER.INFO
|
|
454
|
+
}, TEST_OPTIONS);
|
|
455
|
+
var logger = {
|
|
456
|
+
level: changed === 'logger' ? _types.LOGGER.TRACE : _types.LOGGER.INFO
|
|
457
|
+
};
|
|
458
|
+
var options = changed === 'apiBaseUrl' ? {
|
|
459
|
+
webexApiBaseUrl: 'https://webexapis.com'
|
|
460
|
+
} : TEST_OPTIONS;
|
|
461
|
+
if (changed === 'account') boundWebex.internal.device.userId = 'another-user';
|
|
462
|
+
var replacement = createCallQueueClient(boundWebex, logger, options, first);
|
|
463
|
+
_testHelperChai.assert.notStrictEqual(replacement, first);
|
|
464
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.off.mock.calls, 6);
|
|
465
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.on.mock.calls, 12);
|
|
466
|
+
replacement.dispose();
|
|
467
|
+
});
|
|
468
|
+
it('disposes a prior client when reuse readiness throws', function () {
|
|
469
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
470
|
+
var first = createCallQueueClient(boundWebex, {
|
|
471
|
+
level: _types.LOGGER.INFO
|
|
472
|
+
}, TEST_OPTIONS);
|
|
473
|
+
jest.spyOn(first, 'prepareForReuse').mockImplementation(function () {
|
|
474
|
+
throw new Error('Backend failed');
|
|
475
|
+
});
|
|
476
|
+
expect(function () {
|
|
477
|
+
return createCallQueueClient(boundWebex, {
|
|
478
|
+
level: _types.LOGGER.INFO
|
|
479
|
+
}, TEST_OPTIONS, first);
|
|
480
|
+
}).toThrow('Backend failed');
|
|
481
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.off.mock.calls, 6);
|
|
482
|
+
});
|
|
483
|
+
it('rejects reuse and requests after disposal', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
484
|
+
var otherWebex, other, _t1;
|
|
485
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
486
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
487
|
+
case 0:
|
|
488
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
489
|
+
other = createCallQueueClient(otherWebex, {
|
|
490
|
+
level: _types.LOGGER.INFO
|
|
491
|
+
}, TEST_OPTIONS);
|
|
492
|
+
other.dispose();
|
|
493
|
+
_testHelperChai.assert.isFalse(other.prepareForReuse());
|
|
494
|
+
_testHelperChai.assert.lengthOf(otherWebex.internal.mercury.on.mock.calls, 6);
|
|
495
|
+
_t1 = _testHelperChai.assert;
|
|
496
|
+
_context8.next = 1;
|
|
497
|
+
return other.getCallQueueSettings();
|
|
498
|
+
case 1:
|
|
499
|
+
_t1.equal.call(_t1, _context8.sent.statusCode, 400);
|
|
500
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 0);
|
|
501
|
+
case 2:
|
|
502
|
+
case "end":
|
|
503
|
+
return _context8.stop();
|
|
504
|
+
}
|
|
505
|
+
}, _callee8);
|
|
506
|
+
})));
|
|
507
|
+
it('reloads queue membership policy after a client is prepared for reuse', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
508
|
+
var otherWebex, other, status, updated;
|
|
509
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
510
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
511
|
+
case 0:
|
|
512
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
513
|
+
other = createCallQueueClient(otherWebex, {
|
|
514
|
+
level: _types.LOGGER.INFO
|
|
515
|
+
}, TEST_OPTIONS);
|
|
516
|
+
status = function status(allowLogOffEnabled) {
|
|
517
|
+
return {
|
|
518
|
+
statusCode: 200,
|
|
519
|
+
body: {
|
|
520
|
+
agentACDState: 'AVAILABLE',
|
|
521
|
+
queues: [{
|
|
522
|
+
id: 'q1',
|
|
523
|
+
name: 'Sales',
|
|
524
|
+
available: true,
|
|
525
|
+
allowLogOffEnabled: allowLogOffEnabled
|
|
526
|
+
}]
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
otherWebex.request.mockResolvedValueOnce(status(false)).mockResolvedValueOnce(status(true)).mockResolvedValueOnce({
|
|
531
|
+
statusCode: 204
|
|
532
|
+
});
|
|
533
|
+
_context9.next = 1;
|
|
534
|
+
return other.getCallQueueSettings();
|
|
535
|
+
case 1:
|
|
536
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
537
|
+
_context9.next = 2;
|
|
538
|
+
return other.updateCallQueueSettings({
|
|
539
|
+
queues: [{
|
|
540
|
+
id: 'q1',
|
|
541
|
+
available: false
|
|
542
|
+
}]
|
|
543
|
+
});
|
|
544
|
+
case 2:
|
|
545
|
+
updated = _context9.sent;
|
|
546
|
+
_testHelperChai.assert.equal(updated.statusCode, 204);
|
|
547
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 3);
|
|
548
|
+
_testHelperChai.assert.deepEqual(otherWebex.request.mock.calls[2][0].body, {
|
|
549
|
+
queues: [{
|
|
550
|
+
id: 'q1',
|
|
551
|
+
available: false
|
|
552
|
+
}]
|
|
553
|
+
});
|
|
554
|
+
other.dispose();
|
|
555
|
+
case 3:
|
|
556
|
+
case "end":
|
|
557
|
+
return _context9.stop();
|
|
558
|
+
}
|
|
559
|
+
}, _callee9);
|
|
560
|
+
})));
|
|
561
|
+
it.each(['GET', 'PUT'])('does not commit a %s response from before reinitialization', /*#__PURE__*/function () {
|
|
562
|
+
var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0(method) {
|
|
563
|
+
var _yield$other$getCallQ, _yield$other$syncTele;
|
|
564
|
+
var otherWebex, other, oldRequest, pending, staleResponse, _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17;
|
|
565
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
566
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
567
|
+
case 0:
|
|
568
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
569
|
+
other = createCallQueueClient(otherWebex, {
|
|
570
|
+
level: _types.LOGGER.INFO
|
|
571
|
+
}, TEST_OPTIONS);
|
|
572
|
+
oldRequest = deferredResponse();
|
|
573
|
+
otherWebex.request.mockReturnValueOnce(oldRequest.promise).mockResolvedValueOnce({
|
|
574
|
+
statusCode: 200,
|
|
575
|
+
body: {
|
|
576
|
+
agentACDState: 'UNAVAILABLE',
|
|
577
|
+
queues: []
|
|
578
|
+
}
|
|
579
|
+
}).mockResolvedValueOnce({
|
|
580
|
+
statusCode: 204
|
|
581
|
+
});
|
|
582
|
+
pending = method === 'GET' ? other.getCallQueueSettings() : other.updateCallQueueSettings({
|
|
583
|
+
agentACDState: _constants.ACD_STATE.AVAILABLE
|
|
584
|
+
});
|
|
585
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
586
|
+
_t10 = _testHelperChai.assert;
|
|
587
|
+
_context0.next = 1;
|
|
588
|
+
return other.getCallQueueSettings();
|
|
589
|
+
case 1:
|
|
590
|
+
_t12 = _yield$other$getCallQ = _context0.sent.data.callQueue;
|
|
591
|
+
_t11 = _t12 === null;
|
|
592
|
+
if (_t11) {
|
|
593
|
+
_context0.next = 2;
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
_t11 = _yield$other$getCallQ === void 0;
|
|
597
|
+
case 2:
|
|
598
|
+
if (!_t11) {
|
|
599
|
+
_context0.next = 3;
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
_t13 = void 0;
|
|
603
|
+
_context0.next = 4;
|
|
604
|
+
break;
|
|
605
|
+
case 3:
|
|
606
|
+
_t13 = _yield$other$getCallQ.acdState;
|
|
607
|
+
case 4:
|
|
608
|
+
_t10.equal.call(_t10, _t13, _constants.ACD_STATE.UNAVAILABLE);
|
|
609
|
+
oldRequest.resolve({
|
|
610
|
+
statusCode: 200,
|
|
611
|
+
body: {
|
|
612
|
+
agentACDState: 'AVAILABLE',
|
|
613
|
+
queues: []
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
_context0.next = 5;
|
|
617
|
+
return pending;
|
|
618
|
+
case 5:
|
|
619
|
+
staleResponse = _context0.sent;
|
|
620
|
+
_testHelperChai.assert.deepEqual(staleResponse, method === 'PUT' ? EXPECTED_LIFECYCLE_CONFLICT_AFTER_UPDATE : EXPECTED_LIFECYCLE_CONFLICT);
|
|
621
|
+
_t14 = _testHelperChai.assert;
|
|
622
|
+
_context0.next = 6;
|
|
623
|
+
return other.syncTelephonyCalls();
|
|
624
|
+
case 6:
|
|
625
|
+
_t16 = _yield$other$syncTele = _context0.sent.data.callQueue;
|
|
626
|
+
_t15 = _t16 === null;
|
|
627
|
+
if (_t15) {
|
|
628
|
+
_context0.next = 7;
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
_t15 = _yield$other$syncTele === void 0;
|
|
632
|
+
case 7:
|
|
633
|
+
if (!_t15) {
|
|
634
|
+
_context0.next = 8;
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
_t17 = void 0;
|
|
638
|
+
_context0.next = 9;
|
|
639
|
+
break;
|
|
640
|
+
case 8:
|
|
641
|
+
_t17 = _yield$other$syncTele.acdState;
|
|
642
|
+
case 9:
|
|
643
|
+
_t14.equal.call(_t14, _t17, _constants.ACD_STATE.UNAVAILABLE);
|
|
644
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 3);
|
|
645
|
+
other.dispose();
|
|
646
|
+
case 10:
|
|
647
|
+
case "end":
|
|
648
|
+
return _context0.stop();
|
|
649
|
+
}
|
|
650
|
+
}, _callee0);
|
|
651
|
+
}));
|
|
652
|
+
return function (_x6) {
|
|
653
|
+
return _ref11.apply(this, arguments);
|
|
654
|
+
};
|
|
655
|
+
}());
|
|
656
|
+
it.each(['queue name lookup', 'settings refresh'])('returns a lifecycle conflict when reinitialized during an update %s', /*#__PURE__*/function () {
|
|
657
|
+
var _ref12 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1(operation) {
|
|
658
|
+
var otherWebex, other, pendingRead, readStarted, started, updateBody, update, response;
|
|
659
|
+
return _regenerator.default.wrap(function (_context1) {
|
|
660
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
661
|
+
case 0:
|
|
662
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
663
|
+
other = createCallQueueClient(otherWebex, {
|
|
664
|
+
level: _types.LOGGER.INFO
|
|
665
|
+
}, TEST_OPTIONS);
|
|
666
|
+
pendingRead = deferredResponse();
|
|
667
|
+
started = new _promise.default(function (resolve) {
|
|
668
|
+
readStarted = resolve;
|
|
669
|
+
});
|
|
670
|
+
updateBody = operation === 'queue name lookup' ? {
|
|
671
|
+
agentACDState: 'AVAILABLE',
|
|
672
|
+
queues: [{
|
|
673
|
+
id: 'q1',
|
|
674
|
+
available: true
|
|
675
|
+
}]
|
|
676
|
+
} : undefined;
|
|
677
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
678
|
+
statusCode: 200,
|
|
679
|
+
body: updateBody
|
|
680
|
+
}).mockImplementationOnce(function () {
|
|
681
|
+
readStarted();
|
|
682
|
+
return pendingRead.promise;
|
|
683
|
+
});
|
|
684
|
+
update = other.updateCallQueueSettings({
|
|
685
|
+
agentACDState: _constants.ACD_STATE.AVAILABLE
|
|
686
|
+
});
|
|
687
|
+
_context1.next = 1;
|
|
688
|
+
return started;
|
|
689
|
+
case 1:
|
|
690
|
+
_testHelperChai.assert.include(otherWebex.request.mock.calls[1][0].uri, operation === 'queue name lookup' ? '/telephony/config/queues' : '/settings/queues');
|
|
691
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
692
|
+
pendingRead.resolve({
|
|
693
|
+
statusCode: 200,
|
|
694
|
+
body: {
|
|
695
|
+
agentACDState: 'AVAILABLE',
|
|
696
|
+
queues: []
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
_context1.next = 2;
|
|
700
|
+
return update;
|
|
701
|
+
case 2:
|
|
702
|
+
response = _context1.sent;
|
|
703
|
+
_testHelperChai.assert.deepEqual(response, EXPECTED_LIFECYCLE_CONFLICT_AFTER_UPDATE);
|
|
704
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 2);
|
|
705
|
+
other.dispose();
|
|
706
|
+
case 3:
|
|
707
|
+
case "end":
|
|
708
|
+
return _context1.stop();
|
|
709
|
+
}
|
|
710
|
+
}, _callee1);
|
|
711
|
+
}));
|
|
712
|
+
return function (_x7) {
|
|
713
|
+
return _ref12.apply(this, arguments);
|
|
714
|
+
};
|
|
715
|
+
}());
|
|
716
|
+
it('does not send a membership update after its policy read is superseded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
717
|
+
var otherWebex, other, policy, update, response;
|
|
718
|
+
return _regenerator.default.wrap(function (_context10) {
|
|
719
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
720
|
+
case 0:
|
|
721
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
722
|
+
other = createCallQueueClient(otherWebex, {
|
|
723
|
+
level: _types.LOGGER.INFO
|
|
724
|
+
}, TEST_OPTIONS);
|
|
725
|
+
policy = deferredResponse();
|
|
726
|
+
otherWebex.request.mockReturnValueOnce(policy.promise);
|
|
727
|
+
update = other.updateCallQueueSettings({
|
|
728
|
+
queues: [{
|
|
729
|
+
id: 'q1',
|
|
730
|
+
available: false
|
|
731
|
+
}]
|
|
732
|
+
});
|
|
733
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
734
|
+
policy.resolve({
|
|
735
|
+
statusCode: 200,
|
|
736
|
+
body: {
|
|
737
|
+
agentACDState: 'AVAILABLE',
|
|
738
|
+
queues: [{
|
|
739
|
+
id: 'q1',
|
|
740
|
+
name: 'Sales',
|
|
741
|
+
available: true,
|
|
742
|
+
allowLogOffEnabled: true
|
|
743
|
+
}]
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
_context10.next = 1;
|
|
747
|
+
return update;
|
|
748
|
+
case 1:
|
|
749
|
+
response = _context10.sent;
|
|
750
|
+
_testHelperChai.assert.deepEqual(response, EXPECTED_LIFECYCLE_CONFLICT);
|
|
751
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 1);
|
|
752
|
+
other.dispose();
|
|
753
|
+
case 2:
|
|
754
|
+
case "end":
|
|
755
|
+
return _context10.stop();
|
|
756
|
+
}
|
|
757
|
+
}, _callee10);
|
|
758
|
+
})));
|
|
759
|
+
it.each(['GET', 'PUT', 'SYNC'])('returns a lifecycle conflict if reinitialized during %s diagnostic upload', /*#__PURE__*/function () {
|
|
760
|
+
var _ref14 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11(method) {
|
|
761
|
+
var otherWebex, other, finishUpload, upload, pending, response;
|
|
762
|
+
return _regenerator.default.wrap(function (_context11) {
|
|
763
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
764
|
+
case 0:
|
|
765
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
766
|
+
other = createCallQueueClient(otherWebex, {
|
|
767
|
+
level: _types.LOGGER.INFO
|
|
768
|
+
}, TEST_OPTIONS);
|
|
769
|
+
upload = new _promise.default(function (resolve) {
|
|
770
|
+
finishUpload = resolve;
|
|
771
|
+
});
|
|
772
|
+
utils.uploadLogs.mockReturnValueOnce(upload);
|
|
773
|
+
otherWebex.request.mockRejectedValueOnce({
|
|
774
|
+
statusCode: 500
|
|
775
|
+
});
|
|
776
|
+
pending = startQueueRequest(other, method);
|
|
777
|
+
_context11.next = 1;
|
|
778
|
+
return _promise.default.resolve();
|
|
779
|
+
case 1:
|
|
780
|
+
_testHelperChai.assert.lengthOf(utils.uploadLogs.mock.calls, 1);
|
|
781
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
782
|
+
finishUpload();
|
|
783
|
+
_context11.next = 2;
|
|
784
|
+
return pending;
|
|
785
|
+
case 2:
|
|
786
|
+
response = _context11.sent;
|
|
787
|
+
_testHelperChai.assert.deepEqual(response, method === 'PUT' ? EXPECTED_LIFECYCLE_CONFLICT_AFTER_UPDATE : EXPECTED_LIFECYCLE_CONFLICT);
|
|
788
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 1);
|
|
789
|
+
other.dispose();
|
|
790
|
+
case 3:
|
|
791
|
+
case "end":
|
|
792
|
+
return _context11.stop();
|
|
793
|
+
}
|
|
794
|
+
}, _callee11);
|
|
795
|
+
}));
|
|
796
|
+
return function (_x8) {
|
|
797
|
+
return _ref14.apply(this, arguments);
|
|
798
|
+
};
|
|
799
|
+
}());
|
|
800
|
+
it.each(['GET', 'PUT', 'SYNC'])('does not start diagnostic handling for a stale %s failure', /*#__PURE__*/function () {
|
|
801
|
+
var _ref15 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12(method) {
|
|
802
|
+
var otherWebex, other, rejectRequest, request, pending, _t18;
|
|
803
|
+
return _regenerator.default.wrap(function (_context12) {
|
|
804
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
805
|
+
case 0:
|
|
806
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
807
|
+
other = createCallQueueClient(otherWebex, {
|
|
808
|
+
level: _types.LOGGER.INFO
|
|
809
|
+
}, TEST_OPTIONS);
|
|
810
|
+
request = new _promise.default(function (_, reject) {
|
|
811
|
+
rejectRequest = reject;
|
|
812
|
+
});
|
|
813
|
+
otherWebex.request.mockReturnValueOnce(request);
|
|
814
|
+
pending = startQueueRequest(other, method);
|
|
815
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
816
|
+
rejectRequest({
|
|
817
|
+
statusCode: 500
|
|
818
|
+
});
|
|
819
|
+
_t18 = _testHelperChai.assert;
|
|
820
|
+
_context12.next = 1;
|
|
821
|
+
return pending;
|
|
822
|
+
case 1:
|
|
823
|
+
_t18.deepEqual.call(_t18, _context12.sent, method === 'PUT' ? EXPECTED_LIFECYCLE_CONFLICT_AFTER_UPDATE : EXPECTED_LIFECYCLE_CONFLICT);
|
|
824
|
+
_testHelperChai.assert.lengthOf(utils.uploadLogs.mock.calls, 0);
|
|
825
|
+
other.dispose();
|
|
826
|
+
case 2:
|
|
827
|
+
case "end":
|
|
828
|
+
return _context12.stop();
|
|
829
|
+
}
|
|
830
|
+
}, _callee12);
|
|
831
|
+
}));
|
|
832
|
+
return function (_x9) {
|
|
833
|
+
return _ref15.apply(this, arguments);
|
|
834
|
+
};
|
|
835
|
+
}());
|
|
836
|
+
it.each([['GET', 'during'], ['GET', 'after'], ['PUT', 'during'], ['PUT', 'after'], ['SYNC', 'during'], ['SYNC', 'after']])('returns a lifecycle conflict for %s when reinitialized %s error processing', /*#__PURE__*/function () {
|
|
837
|
+
var _ref16 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13(method, timing) {
|
|
838
|
+
var otherWebex, other, finishHandling, handlingStarted, started, handler, pending, reused, _t19;
|
|
839
|
+
return _regenerator.default.wrap(function (_context13) {
|
|
840
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
841
|
+
case 0:
|
|
842
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
843
|
+
other = createCallQueueClient(otherWebex, {
|
|
844
|
+
level: _types.LOGGER.INFO
|
|
845
|
+
}, TEST_OPTIONS);
|
|
846
|
+
started = new _promise.default(function (resolve) {
|
|
847
|
+
handlingStarted = resolve;
|
|
848
|
+
});
|
|
849
|
+
handler = jest.spyOn(utils, 'serviceErrorCodeHandler').mockImplementationOnce(function () {
|
|
850
|
+
handlingStarted();
|
|
851
|
+
return new _promise.default(function (resolve) {
|
|
852
|
+
finishHandling = resolve;
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
otherWebex.request.mockRejectedValueOnce({
|
|
856
|
+
statusCode: 500
|
|
857
|
+
});
|
|
858
|
+
pending = startQueueRequest(other, method);
|
|
859
|
+
reused = false;
|
|
860
|
+
_context13.prev = 1;
|
|
861
|
+
_context13.next = 2;
|
|
862
|
+
return started;
|
|
863
|
+
case 2:
|
|
864
|
+
if (timing === 'during') reused = other.prepareForReuse();
|
|
865
|
+
finishHandling({
|
|
866
|
+
statusCode: 500,
|
|
867
|
+
data: {
|
|
868
|
+
error: 'Server error'
|
|
869
|
+
},
|
|
870
|
+
message: 'FAILURE'
|
|
871
|
+
});
|
|
872
|
+
if (timing === 'after') {
|
|
873
|
+
queueMicrotask(function () {
|
|
874
|
+
reused = other.prepareForReuse();
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
_t19 = _testHelperChai.assert;
|
|
878
|
+
_context13.next = 3;
|
|
879
|
+
return pending;
|
|
880
|
+
case 3:
|
|
881
|
+
_t19.deepEqual.call(_t19, _context13.sent, method === 'PUT' ? EXPECTED_LIFECYCLE_CONFLICT_AFTER_UPDATE : EXPECTED_LIFECYCLE_CONFLICT);
|
|
882
|
+
_testHelperChai.assert.isTrue(reused);
|
|
883
|
+
case 4:
|
|
884
|
+
_context13.prev = 4;
|
|
885
|
+
handler.mockRestore();
|
|
886
|
+
other.dispose();
|
|
887
|
+
return _context13.finish(4);
|
|
888
|
+
case 5:
|
|
889
|
+
case "end":
|
|
890
|
+
return _context13.stop();
|
|
891
|
+
}
|
|
892
|
+
}, _callee13, null, [[1,, 4, 5]]);
|
|
893
|
+
}));
|
|
894
|
+
return function (_x0, _x1) {
|
|
895
|
+
return _ref16.apply(this, arguments);
|
|
896
|
+
};
|
|
897
|
+
}());
|
|
898
|
+
it('rejects a sync response from an earlier lifecycle', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
899
|
+
var otherWebex, other, oldSync, sync, _t20;
|
|
900
|
+
return _regenerator.default.wrap(function (_context14) {
|
|
901
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
902
|
+
case 0:
|
|
903
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
904
|
+
other = createCallQueueClient(otherWebex, {
|
|
905
|
+
level: _types.LOGGER.INFO
|
|
906
|
+
}, TEST_OPTIONS);
|
|
907
|
+
oldSync = deferredResponse();
|
|
908
|
+
otherWebex.request.mockReturnValueOnce(oldSync.promise);
|
|
909
|
+
sync = other.syncTelephonyCalls();
|
|
910
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
911
|
+
oldSync.resolve({
|
|
912
|
+
statusCode: 204
|
|
913
|
+
});
|
|
914
|
+
_t20 = _testHelperChai.assert;
|
|
915
|
+
_context14.next = 1;
|
|
916
|
+
return sync;
|
|
917
|
+
case 1:
|
|
918
|
+
_t20.deepEqual.call(_t20, _context14.sent, EXPECTED_LIFECYCLE_CONFLICT);
|
|
919
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 1);
|
|
920
|
+
other.dispose();
|
|
921
|
+
case 2:
|
|
922
|
+
case "end":
|
|
923
|
+
return _context14.stop();
|
|
924
|
+
}
|
|
925
|
+
}, _callee14);
|
|
926
|
+
})));
|
|
927
|
+
it('does not commit an event refresh started before reinitialization', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
928
|
+
var _otherWebex$internal$2;
|
|
929
|
+
var otherWebex, other, listener, oldRefresh, newRefresh, handler;
|
|
930
|
+
return _regenerator.default.wrap(function (_context15) {
|
|
931
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
932
|
+
case 0:
|
|
933
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
934
|
+
other = createCallQueueClient(otherWebex, {
|
|
935
|
+
level: _types.LOGGER.INFO
|
|
936
|
+
}, TEST_OPTIONS);
|
|
937
|
+
listener = _sinon.default.spy();
|
|
938
|
+
other.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
939
|
+
oldRefresh = deferredResponse();
|
|
940
|
+
newRefresh = deferredResponse();
|
|
941
|
+
otherWebex.request.mockReturnValueOnce(oldRefresh.promise).mockReturnValueOnce(newRefresh.promise);
|
|
942
|
+
handler = (_otherWebex$internal$2 = otherWebex.internal.mercury.on.mock.calls.find(function (_ref19) {
|
|
943
|
+
var _ref20 = (0, _slicedToArray2.default)(_ref19, 1),
|
|
944
|
+
event = _ref20[0];
|
|
945
|
+
return event === _constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE;
|
|
946
|
+
})) === null || _otherWebex$internal$2 === void 0 ? void 0 : _otherWebex$internal$2[1];
|
|
947
|
+
handler({
|
|
948
|
+
data: {
|
|
949
|
+
state: 'available'
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
953
|
+
handler({
|
|
954
|
+
data: {
|
|
955
|
+
state: 'unavailable'
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
oldRefresh.resolve({
|
|
959
|
+
statusCode: 200,
|
|
960
|
+
body: {
|
|
961
|
+
agentACDState: 'AVAILABLE',
|
|
962
|
+
queues: []
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
_context15.next = 1;
|
|
966
|
+
return new _promise.default(function (resolve) {
|
|
967
|
+
setTimeout(resolve, 0);
|
|
968
|
+
});
|
|
969
|
+
case 1:
|
|
970
|
+
_testHelperChai.assert.notCalled(listener);
|
|
971
|
+
newRefresh.resolve({
|
|
972
|
+
statusCode: 200,
|
|
973
|
+
body: {
|
|
974
|
+
agentACDState: 'UNAVAILABLE',
|
|
975
|
+
queues: []
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
_context15.next = 2;
|
|
979
|
+
return new _promise.default(function (resolve) {
|
|
980
|
+
setTimeout(resolve, 0);
|
|
981
|
+
});
|
|
982
|
+
case 2:
|
|
983
|
+
_testHelperChai.assert.calledOnceWithExactly(listener, {
|
|
984
|
+
acdState: _constants.ACD_STATE.UNAVAILABLE,
|
|
985
|
+
queues: []
|
|
986
|
+
});
|
|
987
|
+
other.dispose();
|
|
988
|
+
case 3:
|
|
989
|
+
case "end":
|
|
990
|
+
return _context15.stop();
|
|
991
|
+
}
|
|
992
|
+
}, _callee15);
|
|
993
|
+
})));
|
|
994
|
+
it('does not fetch queue names when an event listener reinitializes the client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
995
|
+
var _otherWebex$internal$3;
|
|
996
|
+
var otherWebex, other, listener, handler;
|
|
997
|
+
return _regenerator.default.wrap(function (_context16) {
|
|
998
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
999
|
+
case 0:
|
|
1000
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
1001
|
+
other = createCallQueueClient(otherWebex, {
|
|
1002
|
+
level: _types.LOGGER.INFO
|
|
1003
|
+
}, TEST_OPTIONS);
|
|
1004
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
1005
|
+
statusCode: 200,
|
|
1006
|
+
body: {
|
|
1007
|
+
agentACDState: 'AVAILABLE',
|
|
1008
|
+
queues: []
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
_context16.next = 1;
|
|
1012
|
+
return other.getCallQueueSettings();
|
|
1013
|
+
case 1:
|
|
1014
|
+
listener = _sinon.default.spy(function () {
|
|
1015
|
+
return other.prepareForReuse();
|
|
1016
|
+
});
|
|
1017
|
+
other.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
1018
|
+
handler = (_otherWebex$internal$3 = otherWebex.internal.mercury.on.mock.calls.find(function (_ref22) {
|
|
1019
|
+
var _ref23 = (0, _slicedToArray2.default)(_ref22, 1),
|
|
1020
|
+
event = _ref23[0];
|
|
1021
|
+
return event === _constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_JOIN;
|
|
1022
|
+
})) === null || _otherWebex$internal$3 === void 0 ? void 0 : _otherWebex$internal$3[1];
|
|
1023
|
+
handler({
|
|
1024
|
+
data: {
|
|
1025
|
+
joinInfo: [{
|
|
1026
|
+
queueId: 'q1',
|
|
1027
|
+
status: 'joined'
|
|
1028
|
+
}]
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
_testHelperChai.assert.calledOnce(listener);
|
|
1032
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 1);
|
|
1033
|
+
other.dispose();
|
|
1034
|
+
case 2:
|
|
1035
|
+
case "end":
|
|
1036
|
+
return _context16.stop();
|
|
1037
|
+
}
|
|
1038
|
+
}, _callee16);
|
|
1039
|
+
})));
|
|
1040
|
+
it('ignores an already-dispatched Mercury callback after disposal', function () {
|
|
1041
|
+
var _otherWebex$internal$4;
|
|
1042
|
+
var otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
1043
|
+
var other = createCallQueueClient(otherWebex, {
|
|
1044
|
+
level: _types.LOGGER.INFO
|
|
1045
|
+
}, TEST_OPTIONS);
|
|
1046
|
+
var handler = (_otherWebex$internal$4 = otherWebex.internal.mercury.on.mock.calls.find(function (_ref24) {
|
|
1047
|
+
var _ref25 = (0, _slicedToArray2.default)(_ref24, 1),
|
|
1048
|
+
event = _ref25[0];
|
|
1049
|
+
return event === _constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE;
|
|
1050
|
+
})) === null || _otherWebex$internal$4 === void 0 ? void 0 : _otherWebex$internal$4[1];
|
|
1051
|
+
other.dispose();
|
|
1052
|
+
handler({
|
|
1053
|
+
data: {
|
|
1054
|
+
state: 'available'
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 0);
|
|
1058
|
+
});
|
|
1059
|
+
it('does not retain catalog names from a request made before reinitialization', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
1060
|
+
var _yield$other$getCallQ2, _result$data$callQueu;
|
|
1061
|
+
var otherWebex, other, oldCatalog, status, pending, result, _t21, _t22, _t23, _t24, _t25;
|
|
1062
|
+
return _regenerator.default.wrap(function (_context17) {
|
|
1063
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1064
|
+
case 0:
|
|
1065
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
1066
|
+
other = createCallQueueClient(otherWebex, {
|
|
1067
|
+
level: _types.LOGGER.INFO
|
|
1068
|
+
}, TEST_OPTIONS);
|
|
1069
|
+
oldCatalog = deferredResponse();
|
|
1070
|
+
status = {
|
|
1071
|
+
statusCode: 200,
|
|
1072
|
+
body: {
|
|
1073
|
+
agentACDState: 'AVAILABLE',
|
|
1074
|
+
queues: [{
|
|
1075
|
+
id: 'q1',
|
|
1076
|
+
available: true
|
|
1077
|
+
}]
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
otherWebex.request.mockResolvedValueOnce(status).mockReturnValueOnce(oldCatalog.promise).mockResolvedValueOnce(status).mockResolvedValueOnce({
|
|
1081
|
+
statusCode: 200,
|
|
1082
|
+
body: {
|
|
1083
|
+
queues: [{
|
|
1084
|
+
id: 'q1',
|
|
1085
|
+
name: 'Current'
|
|
1086
|
+
}]
|
|
1087
|
+
}
|
|
1088
|
+
}).mockResolvedValueOnce({
|
|
1089
|
+
statusCode: 204
|
|
1090
|
+
});
|
|
1091
|
+
pending = other.getCallQueueSettings();
|
|
1092
|
+
_context17.next = 1;
|
|
1093
|
+
return _promise.default.resolve();
|
|
1094
|
+
case 1:
|
|
1095
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 2);
|
|
1096
|
+
_testHelperChai.assert.isTrue(other.prepareForReuse());
|
|
1097
|
+
_t21 = _testHelperChai.assert;
|
|
1098
|
+
_context17.next = 2;
|
|
1099
|
+
return other.getCallQueueSettings();
|
|
1100
|
+
case 2:
|
|
1101
|
+
_t23 = _yield$other$getCallQ2 = _context17.sent.data.callQueue;
|
|
1102
|
+
_t22 = _t23 === null;
|
|
1103
|
+
if (_t22) {
|
|
1104
|
+
_context17.next = 3;
|
|
1105
|
+
break;
|
|
1106
|
+
}
|
|
1107
|
+
_t22 = _yield$other$getCallQ2 === void 0;
|
|
1108
|
+
case 3:
|
|
1109
|
+
if (!_t22) {
|
|
1110
|
+
_context17.next = 4;
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1113
|
+
_t24 = void 0;
|
|
1114
|
+
_context17.next = 5;
|
|
1115
|
+
break;
|
|
1116
|
+
case 4:
|
|
1117
|
+
_t24 = _yield$other$getCallQ2.queues[0].name;
|
|
1118
|
+
case 5:
|
|
1119
|
+
_t21.equal.call(_t21, _t24, 'Current');
|
|
1120
|
+
oldCatalog.resolve({
|
|
1121
|
+
statusCode: 200,
|
|
1122
|
+
body: {
|
|
1123
|
+
queues: [{
|
|
1124
|
+
id: 'q1',
|
|
1125
|
+
name: 'Old'
|
|
1126
|
+
}]
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
_t25 = _testHelperChai.assert;
|
|
1130
|
+
_context17.next = 6;
|
|
1131
|
+
return pending;
|
|
1132
|
+
case 6:
|
|
1133
|
+
_t25.equal.call(_t25, _context17.sent.statusCode, 409);
|
|
1134
|
+
_context17.next = 7;
|
|
1135
|
+
return other.updateCallQueueSettings({
|
|
1136
|
+
agentACDState: _constants.ACD_STATE.UNAVAILABLE
|
|
1137
|
+
});
|
|
1138
|
+
case 7:
|
|
1139
|
+
result = _context17.sent;
|
|
1140
|
+
_testHelperChai.assert.equal((_result$data$callQueu = result.data.callQueue) === null || _result$data$callQueu === void 0 ? void 0 : _result$data$callQueu.queues[0].name, 'Current');
|
|
1141
|
+
other.dispose();
|
|
1142
|
+
case 8:
|
|
1143
|
+
case "end":
|
|
1144
|
+
return _context17.stop();
|
|
1145
|
+
}
|
|
1146
|
+
}, _callee17);
|
|
1147
|
+
})));
|
|
1148
|
+
it.each([['UCM', 'NATIVE_SIP_CALL_TO_UCM', 'bc-sp-standard'], ['BroadWorks', 'NATIVE_WEBEX_TEAMS_CALLING', 'broadworks-connector']])('requires replacement if a listening client changes to %s', function (_, behavior, entitlement) {
|
|
1149
|
+
var otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
1150
|
+
var other = createCallQueueClient(otherWebex, {
|
|
1151
|
+
level: _types.LOGGER.INFO
|
|
1152
|
+
}, TEST_OPTIONS);
|
|
1153
|
+
otherWebex.internal.device.callingBehavior = behavior;
|
|
1154
|
+
otherWebex.internal.device.features.entitlement.models[0]._values.key = entitlement;
|
|
1155
|
+
_testHelperChai.assert.isFalse(other.prepareForReuse());
|
|
1156
|
+
_testHelperChai.assert.lengthOf(otherWebex.internal.mercury.on.mock.calls, 6);
|
|
1157
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 0);
|
|
1158
|
+
other.dispose();
|
|
1159
|
+
});
|
|
1160
|
+
it.each([['non-array models', {}], ['null model', [null]], ['missing values', [{}]], ['null values', [{
|
|
1161
|
+
_values: null
|
|
1162
|
+
}]], ['missing key', [{
|
|
1163
|
+
_values: {}
|
|
1164
|
+
}]], ['non-string key', [{
|
|
1165
|
+
_values: {
|
|
1166
|
+
key: null
|
|
1167
|
+
}
|
|
1168
|
+
}]], ['partially populated array', [{
|
|
1169
|
+
_values: {
|
|
1170
|
+
key: 'bc-sp-standard'
|
|
1171
|
+
}
|
|
1172
|
+
}, {}]]])('defers backend detection for %s until data is complete', /*#__PURE__*/function () {
|
|
1173
|
+
var _ref27 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18(_, incompleteModels) {
|
|
1174
|
+
var lateWebex, entitlement, models, earlyClient, _t26, _t27;
|
|
1175
|
+
return _regenerator.default.wrap(function (_context18) {
|
|
1176
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1177
|
+
case 0:
|
|
1178
|
+
lateWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
1179
|
+
entitlement = lateWebex.internal.device.features.entitlement;
|
|
1180
|
+
models = entitlement.models;
|
|
1181
|
+
entitlement.models = incompleteModels;
|
|
1182
|
+
earlyClient = createCallQueueClient(lateWebex, {
|
|
1183
|
+
level: _types.LOGGER.INFO
|
|
1184
|
+
}, TEST_OPTIONS);
|
|
1185
|
+
_t26 = expect;
|
|
1186
|
+
_context18.next = 1;
|
|
1187
|
+
return earlyClient.getCallQueueSettings();
|
|
1188
|
+
case 1:
|
|
1189
|
+
_t26(_context18.sent.statusCode).toBe(501);
|
|
1190
|
+
expect(lateWebex.request).not.toHaveBeenCalled();
|
|
1191
|
+
expect(lateWebex.internal.mercury.on).not.toHaveBeenCalled();
|
|
1192
|
+
entitlement.models = models;
|
|
1193
|
+
lateWebex.request.mockResolvedValue({
|
|
1194
|
+
statusCode: 200,
|
|
1195
|
+
body: {
|
|
1196
|
+
agentACDState: 'AVAILABLE',
|
|
1197
|
+
queues: []
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
_t27 = expect;
|
|
1201
|
+
_context18.next = 2;
|
|
1202
|
+
return earlyClient.getCallQueueSettings();
|
|
1203
|
+
case 2:
|
|
1204
|
+
_t27(_context18.sent.statusCode).toBe(200);
|
|
1205
|
+
expect(lateWebex.internal.mercury.on).toHaveBeenCalledTimes(6);
|
|
1206
|
+
earlyClient.dispose();
|
|
1207
|
+
case 3:
|
|
1208
|
+
case "end":
|
|
1209
|
+
return _context18.stop();
|
|
1210
|
+
}
|
|
1211
|
+
}, _callee18);
|
|
1212
|
+
}));
|
|
1213
|
+
return function (_x10, _x11) {
|
|
1214
|
+
return _ref27.apply(this, arguments);
|
|
1215
|
+
};
|
|
1216
|
+
}());
|
|
1217
|
+
it.each([['UCM', 'NATIVE_SIP_CALL_TO_UCM', 'bc-sp-standard'], ['BroadWorks', 'NATIVE_WEBEX_TEAMS_CALLING', 'broadworks-connector']])('does not start queue requests or listeners for %s', /*#__PURE__*/function () {
|
|
1218
|
+
var _ref28 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19(_, behavior, entitlement) {
|
|
1219
|
+
var otherWebex, other, _t28;
|
|
1220
|
+
return _regenerator.default.wrap(function (_context19) {
|
|
1221
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1222
|
+
case 0:
|
|
1223
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
1224
|
+
otherWebex.internal.device.callingBehavior = behavior;
|
|
1225
|
+
otherWebex.internal.device.features.entitlement.models[0]._values.key = entitlement;
|
|
1226
|
+
other = createCallQueueClient(otherWebex, {
|
|
1227
|
+
level: _types.LOGGER.INFO
|
|
1228
|
+
}, TEST_OPTIONS);
|
|
1229
|
+
_t28 = expect;
|
|
1230
|
+
_context19.next = 1;
|
|
1231
|
+
return other.getCallQueueSettings();
|
|
1232
|
+
case 1:
|
|
1233
|
+
_t28(_context19.sent.statusCode).toBe(501);
|
|
1234
|
+
expect(otherWebex.request).not.toHaveBeenCalled();
|
|
1235
|
+
expect(otherWebex.internal.mercury.on).not.toHaveBeenCalled();
|
|
1236
|
+
other.dispose();
|
|
1237
|
+
case 2:
|
|
1238
|
+
case "end":
|
|
1239
|
+
return _context19.stop();
|
|
1240
|
+
}
|
|
1241
|
+
}, _callee19);
|
|
1242
|
+
}));
|
|
1243
|
+
return function (_x12, _x13, _x14) {
|
|
1244
|
+
return _ref28.apply(this, arguments);
|
|
1245
|
+
};
|
|
1246
|
+
}());
|
|
1247
|
+
it('does not hide unexpected backend detection errors', function () {
|
|
1248
|
+
var backend = _sinon.default.stub(utils, 'getCallingBackEnd').throws(new Error('Unexpected backend error'));
|
|
1249
|
+
try {
|
|
1250
|
+
expect(function () {
|
|
1251
|
+
return createCallQueueClient(webex, {
|
|
1252
|
+
level: _types.LOGGER.INFO
|
|
1253
|
+
}, TEST_OPTIONS);
|
|
1254
|
+
}).toThrow('Unexpected backend error');
|
|
1255
|
+
} finally {
|
|
1256
|
+
backend.restore();
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
it('fills a missing display name from the queue catalog', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
1260
|
+
var _response$data$callQu3, _response$data$callQu4, _response$data$callQu5;
|
|
1261
|
+
var queueId, gatewayQueueId, response;
|
|
1262
|
+
return _regenerator.default.wrap(function (_context21) {
|
|
1263
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1264
|
+
case 0:
|
|
1265
|
+
queueId = 'Y2lzY29zcGFyazovL3VzL0NBTExfUVVFVUUvNGFiNmJkZGEtYzY4NC00OGYzLTkyMTctNjBmZGJiODA0OWIz';
|
|
1266
|
+
gatewayQueueId = '4ab6bdda-c684-48f3-9217-60fdbb8049b3';
|
|
1267
|
+
webex.request.mockImplementation(/*#__PURE__*/function () {
|
|
1268
|
+
var _ref30 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20(options) {
|
|
1269
|
+
return _regenerator.default.wrap(function (_context20) {
|
|
1270
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1271
|
+
case 0:
|
|
1272
|
+
if (!options.uri.endsWith('telephony/config/queues')) {
|
|
1273
|
+
_context20.next = 1;
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
return _context20.abrupt("return", {
|
|
1277
|
+
statusCode: 200,
|
|
1278
|
+
body: {
|
|
1279
|
+
queues: [{
|
|
1280
|
+
id: queueId,
|
|
1281
|
+
name: 'TestQueue',
|
|
1282
|
+
extension: '4000',
|
|
1283
|
+
enabled: true
|
|
1284
|
+
}]
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
case 1:
|
|
1288
|
+
return _context20.abrupt("return", {
|
|
1289
|
+
statusCode: 200,
|
|
1290
|
+
body: {
|
|
1291
|
+
agentACDState: 'SIGN_OUT',
|
|
1292
|
+
queues: [{
|
|
1293
|
+
id: gatewayQueueId,
|
|
1294
|
+
available: true,
|
|
1295
|
+
extension: '4000',
|
|
1296
|
+
allowLogOffEnabled: false
|
|
1297
|
+
}]
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
case 2:
|
|
1301
|
+
case "end":
|
|
1302
|
+
return _context20.stop();
|
|
1303
|
+
}
|
|
1304
|
+
}, _callee20);
|
|
1305
|
+
}));
|
|
1306
|
+
return function (_x15) {
|
|
1307
|
+
return _ref30.apply(this, arguments);
|
|
1308
|
+
};
|
|
1309
|
+
}());
|
|
1310
|
+
_context21.next = 1;
|
|
1311
|
+
return client.getCallQueueSettings();
|
|
1312
|
+
case 1:
|
|
1313
|
+
response = _context21.sent;
|
|
1314
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1315
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/queues"),
|
|
1316
|
+
method: _types2.HTTP_METHODS.GET
|
|
1317
|
+
});
|
|
1318
|
+
expect((_response$data$callQu3 = response.data.callQueue) === null || _response$data$callQu3 === void 0 ? void 0 : _response$data$callQu3.queues[0].name).toBe('TestQueue');
|
|
1319
|
+
expect((_response$data$callQu4 = response.data.callQueue) === null || _response$data$callQu4 === void 0 ? void 0 : _response$data$callQu4.queues[0].id).toBe(gatewayQueueId);
|
|
1320
|
+
expect((_response$data$callQu5 = response.data.callQueue) === null || _response$data$callQu5 === void 0 ? void 0 : _response$data$callQu5.queues[0].allowLogOffEnabled).toBe(false);
|
|
1321
|
+
case 2:
|
|
1322
|
+
case "end":
|
|
1323
|
+
return _context21.stop();
|
|
1324
|
+
}
|
|
1325
|
+
}, _callee21);
|
|
1326
|
+
})));
|
|
1327
|
+
it('follows same-catalog Link headers to find queue names', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
1328
|
+
var _response$data$callQu6;
|
|
1329
|
+
var catalogClient, next, response;
|
|
1330
|
+
return _regenerator.default.wrap(function (_context23) {
|
|
1331
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1332
|
+
case 0:
|
|
1333
|
+
catalogClient = createCallQueueClient(webex, {
|
|
1334
|
+
level: _types.LOGGER.INFO
|
|
1335
|
+
}, TEST_OPTIONS);
|
|
1336
|
+
next = "".concat(WEBEX_API_INT, "telephony/config/queues?start=1");
|
|
1337
|
+
webex.request.mockImplementation(/*#__PURE__*/function () {
|
|
1338
|
+
var _ref32 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22(options) {
|
|
1339
|
+
return _regenerator.default.wrap(function (_context22) {
|
|
1340
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1341
|
+
case 0:
|
|
1342
|
+
if (!(options.uri === next)) {
|
|
1343
|
+
_context22.next = 1;
|
|
1344
|
+
break;
|
|
1345
|
+
}
|
|
1346
|
+
return _context22.abrupt("return", {
|
|
1347
|
+
statusCode: 200,
|
|
1348
|
+
body: {
|
|
1349
|
+
queues: [{
|
|
1350
|
+
id: 'queue-next',
|
|
1351
|
+
name: 'Next queue'
|
|
1352
|
+
}]
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
case 1:
|
|
1356
|
+
if (!options.uri.endsWith('/telephony/config/queues')) {
|
|
1357
|
+
_context22.next = 2;
|
|
1358
|
+
break;
|
|
1359
|
+
}
|
|
1360
|
+
return _context22.abrupt("return", {
|
|
1361
|
+
statusCode: 200,
|
|
1362
|
+
body: {
|
|
1363
|
+
queues: []
|
|
1364
|
+
},
|
|
1365
|
+
headers: {
|
|
1366
|
+
link: "<".concat(next, ">; rel=\"next\"")
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
case 2:
|
|
1370
|
+
return _context22.abrupt("return", {
|
|
1371
|
+
statusCode: 200,
|
|
1372
|
+
body: {
|
|
1373
|
+
agentACDState: 'AVAILABLE',
|
|
1374
|
+
queues: [{
|
|
1375
|
+
id: 'queue-next'
|
|
1376
|
+
}]
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
case 3:
|
|
1380
|
+
case "end":
|
|
1381
|
+
return _context22.stop();
|
|
1382
|
+
}
|
|
1383
|
+
}, _callee22);
|
|
1384
|
+
}));
|
|
1385
|
+
return function (_x16) {
|
|
1386
|
+
return _ref32.apply(this, arguments);
|
|
1387
|
+
};
|
|
1388
|
+
}());
|
|
1389
|
+
_context23.next = 1;
|
|
1390
|
+
return catalogClient.getCallQueueSettings();
|
|
1391
|
+
case 1:
|
|
1392
|
+
response = _context23.sent;
|
|
1393
|
+
expect((_response$data$callQu6 = response.data.callQueue) === null || _response$data$callQu6 === void 0 ? void 0 : _response$data$callQu6.queues[0].name).toBe('Next queue');
|
|
1394
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1395
|
+
uri: next,
|
|
1396
|
+
method: _types2.HTTP_METHODS.GET
|
|
1397
|
+
});
|
|
1398
|
+
case 2:
|
|
1399
|
+
case "end":
|
|
1400
|
+
return _context23.stop();
|
|
1401
|
+
}
|
|
1402
|
+
}, _callee23);
|
|
1403
|
+
})));
|
|
1404
|
+
it('does not follow a catalog Link to another origin', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
|
|
1405
|
+
var catalogClient;
|
|
1406
|
+
return _regenerator.default.wrap(function (_context24) {
|
|
1407
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1408
|
+
case 0:
|
|
1409
|
+
catalogClient = createCallQueueClient(webex, {
|
|
1410
|
+
level: _types.LOGGER.INFO
|
|
1411
|
+
}, TEST_OPTIONS);
|
|
1412
|
+
webex.request.mockResolvedValueOnce({
|
|
1413
|
+
statusCode: 200,
|
|
1414
|
+
body: {
|
|
1415
|
+
agentACDState: 'AVAILABLE',
|
|
1416
|
+
queues: [{
|
|
1417
|
+
id: 'queue-next'
|
|
1418
|
+
}]
|
|
1419
|
+
}
|
|
1420
|
+
}).mockResolvedValueOnce({
|
|
1421
|
+
statusCode: 200,
|
|
1422
|
+
body: {
|
|
1423
|
+
queues: []
|
|
1424
|
+
},
|
|
1425
|
+
headers: {
|
|
1426
|
+
link: '<https://example.com/v1/telephony/config/queues?start=1>; rel="next"'
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
_context24.next = 1;
|
|
1430
|
+
return catalogClient.getCallQueueSettings();
|
|
1431
|
+
case 1:
|
|
1432
|
+
expect(webex.request).toHaveBeenCalledTimes(2);
|
|
1433
|
+
case 2:
|
|
1434
|
+
case "end":
|
|
1435
|
+
return _context24.stop();
|
|
1436
|
+
}
|
|
1437
|
+
}, _callee24);
|
|
1438
|
+
})));
|
|
1439
|
+
it('loads a secondary line when the line id is safe', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1440
|
+
return _regenerator.default.wrap(function (_context25) {
|
|
1441
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1442
|
+
case 0:
|
|
1443
|
+
webex.request.mockResolvedValue({
|
|
1444
|
+
statusCode: 200,
|
|
1445
|
+
body: {
|
|
1446
|
+
agentACDState: 'AVAILABLE',
|
|
1447
|
+
queues: []
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
_context25.next = 1;
|
|
1451
|
+
return client.getCallQueueSettings('line-owner-1');
|
|
1452
|
+
case 1:
|
|
1453
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1454
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/secondaryLines/line-owner-1/queues"),
|
|
1455
|
+
method: _types2.HTTP_METHODS.GET
|
|
1456
|
+
});
|
|
1457
|
+
case 2:
|
|
1458
|
+
case "end":
|
|
1459
|
+
return _context25.stop();
|
|
1460
|
+
}
|
|
1461
|
+
}, _callee25);
|
|
1462
|
+
})));
|
|
1463
|
+
it('encodes a raw virtual-line UUID in public API requests', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
|
|
1464
|
+
var lineId, encodedLine;
|
|
1465
|
+
return _regenerator.default.wrap(function (_context26) {
|
|
1466
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1467
|
+
case 0:
|
|
1468
|
+
lineId = '36d87d6c-7531-4b2f-a4ef-d71e6aacb86f';
|
|
1469
|
+
encodedLine = btoa("ciscospark://us/VIRTUAL_LINE/".concat(lineId)).replace(/=+$/, '');
|
|
1470
|
+
webex.request.mockResolvedValue({
|
|
1471
|
+
statusCode: 200,
|
|
1472
|
+
body: {
|
|
1473
|
+
agentACDState: 'AVAILABLE',
|
|
1474
|
+
queues: []
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
_context26.next = 1;
|
|
1478
|
+
return client.getCallQueueSettings(lineId);
|
|
1479
|
+
case 1:
|
|
1480
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1481
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/secondaryLines/").concat(encodedLine, "/queues"),
|
|
1482
|
+
method: _types2.HTTP_METHODS.GET
|
|
1483
|
+
});
|
|
1484
|
+
case 2:
|
|
1485
|
+
case "end":
|
|
1486
|
+
return _context26.stop();
|
|
1487
|
+
}
|
|
1488
|
+
}, _callee26);
|
|
1489
|
+
})));
|
|
1490
|
+
it('encodes a raw queue UUID in a public membership update', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
|
|
1491
|
+
var queueId, encodedQueue;
|
|
1492
|
+
return _regenerator.default.wrap(function (_context27) {
|
|
1493
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1494
|
+
case 0:
|
|
1495
|
+
queueId = '4ab6bdda-c684-48f3-9217-60fdbb8049b3';
|
|
1496
|
+
encodedQueue = btoa("ciscospark://us/CALL_QUEUE/".concat(queueId)).replace(/=+$/, '');
|
|
1497
|
+
webex.request.mockResolvedValue({
|
|
1498
|
+
statusCode: 200,
|
|
1499
|
+
body: {
|
|
1500
|
+
agentACDState: 'AVAILABLE',
|
|
1501
|
+
queues: [{
|
|
1502
|
+
id: encodedQueue,
|
|
1503
|
+
available: true
|
|
1504
|
+
}]
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
_context27.next = 1;
|
|
1508
|
+
return client.updateCallQueueSettings({
|
|
1509
|
+
queues: [{
|
|
1510
|
+
id: queueId,
|
|
1511
|
+
available: true
|
|
1512
|
+
}]
|
|
1513
|
+
});
|
|
1514
|
+
case 1:
|
|
1515
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1516
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/queues"),
|
|
1517
|
+
method: _types2.HTTP_METHODS.PUT,
|
|
1518
|
+
body: {
|
|
1519
|
+
queues: [{
|
|
1520
|
+
id: encodedQueue,
|
|
1521
|
+
available: true
|
|
1522
|
+
}]
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
case 2:
|
|
1526
|
+
case "end":
|
|
1527
|
+
return _context27.stop();
|
|
1528
|
+
}
|
|
1529
|
+
}, _callee27);
|
|
1530
|
+
})));
|
|
1531
|
+
it('does not request settings for a line id that could change the path', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
|
|
1532
|
+
var response;
|
|
1533
|
+
return _regenerator.default.wrap(function (_context28) {
|
|
1534
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1535
|
+
case 0:
|
|
1536
|
+
_context28.next = 1;
|
|
1537
|
+
return client.getCallQueueSettings('../other');
|
|
1538
|
+
case 1:
|
|
1539
|
+
response = _context28.sent;
|
|
1540
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
1541
|
+
expect(response.statusCode).toBe(400);
|
|
1542
|
+
case 2:
|
|
1543
|
+
case "end":
|
|
1544
|
+
return _context28.stop();
|
|
1545
|
+
}
|
|
1546
|
+
}, _callee28);
|
|
1547
|
+
})));
|
|
1548
|
+
it('patches ACD state and queue join', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
|
|
1549
|
+
var _response$data$callQu7;
|
|
1550
|
+
var response;
|
|
1551
|
+
return _regenerator.default.wrap(function (_context29) {
|
|
1552
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1553
|
+
case 0:
|
|
1554
|
+
webex.request.mockResolvedValue({
|
|
1555
|
+
statusCode: 200,
|
|
1556
|
+
body: {
|
|
1557
|
+
agentACDState: 'AVAILABLE',
|
|
1558
|
+
queues: [{
|
|
1559
|
+
id: 'queue-1',
|
|
1560
|
+
available: true,
|
|
1561
|
+
allowLogOffEnabled: true
|
|
1562
|
+
}]
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
_context29.next = 1;
|
|
1566
|
+
return client.updateCallQueueSettings({
|
|
1567
|
+
agentACDState: _constants.ACD_STATE.AVAILABLE,
|
|
1568
|
+
queues: [{
|
|
1569
|
+
id: 'queue-1',
|
|
1570
|
+
available: true
|
|
1571
|
+
}]
|
|
1572
|
+
});
|
|
1573
|
+
case 1:
|
|
1574
|
+
response = _context29.sent;
|
|
1575
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1576
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/queues"),
|
|
1577
|
+
method: _types2.HTTP_METHODS.PUT,
|
|
1578
|
+
body: {
|
|
1579
|
+
agentACDState: _constants.ACD_STATE.AVAILABLE,
|
|
1580
|
+
queues: [{
|
|
1581
|
+
id: 'queue-1',
|
|
1582
|
+
available: true
|
|
1583
|
+
}]
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1586
|
+
expect((_response$data$callQu7 = response.data.callQueue) === null || _response$data$callQu7 === void 0 ? void 0 : _response$data$callQu7.acdState).toBe(_constants.ACD_STATE.AVAILABLE);
|
|
1587
|
+
case 2:
|
|
1588
|
+
case "end":
|
|
1589
|
+
return _context29.stop();
|
|
1590
|
+
}
|
|
1591
|
+
}, _callee29);
|
|
1592
|
+
})));
|
|
1593
|
+
it('keeps a queue joined when the agent is not allowed to log off', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
|
|
1594
|
+
return _regenerator.default.wrap(function (_context30) {
|
|
1595
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1596
|
+
case 0:
|
|
1597
|
+
webex.request.mockResolvedValueOnce({
|
|
1598
|
+
statusCode: 200,
|
|
1599
|
+
body: {
|
|
1600
|
+
agentACDState: 'AVAILABLE',
|
|
1601
|
+
queues: [{
|
|
1602
|
+
id: 'locked',
|
|
1603
|
+
name: 'Overnight',
|
|
1604
|
+
available: true,
|
|
1605
|
+
allowLogOffEnabled: false
|
|
1606
|
+
}]
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
_context30.next = 1;
|
|
1610
|
+
return client.getCallQueueSettings();
|
|
1611
|
+
case 1:
|
|
1612
|
+
webex.request.mockResolvedValueOnce({
|
|
1613
|
+
statusCode: 204
|
|
1614
|
+
});
|
|
1615
|
+
_context30.next = 2;
|
|
1616
|
+
return client.updateCallQueueSettings({
|
|
1617
|
+
queues: [{
|
|
1618
|
+
id: 'locked',
|
|
1619
|
+
available: false
|
|
1620
|
+
}]
|
|
1621
|
+
});
|
|
1622
|
+
case 2:
|
|
1623
|
+
expect(webex.request).toHaveBeenLastCalledWith({
|
|
1624
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/queues"),
|
|
1625
|
+
method: _types2.HTTP_METHODS.PUT,
|
|
1626
|
+
body: {
|
|
1627
|
+
queues: [{
|
|
1628
|
+
id: 'locked',
|
|
1629
|
+
available: true
|
|
1630
|
+
}]
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
case 3:
|
|
1634
|
+
case "end":
|
|
1635
|
+
return _context30.stop();
|
|
1636
|
+
}
|
|
1637
|
+
}, _callee30);
|
|
1638
|
+
})));
|
|
1639
|
+
it('uses the target line settings when a queue is updated', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee32() {
|
|
1640
|
+
var lineAwareClient;
|
|
1641
|
+
return _regenerator.default.wrap(function (_context32) {
|
|
1642
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1643
|
+
case 0:
|
|
1644
|
+
lineAwareClient = createCallQueueClient(webex, {
|
|
1645
|
+
level: _types.LOGGER.INFO
|
|
1646
|
+
}, TEST_OPTIONS);
|
|
1647
|
+
webex.request.mockImplementation(/*#__PURE__*/function () {
|
|
1648
|
+
var _ref41 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31(options) {
|
|
1649
|
+
var isSecondaryLine;
|
|
1650
|
+
return _regenerator.default.wrap(function (_context31) {
|
|
1651
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1652
|
+
case 0:
|
|
1653
|
+
if (!(options.method === _types2.HTTP_METHODS.PUT)) {
|
|
1654
|
+
_context31.next = 1;
|
|
1655
|
+
break;
|
|
1656
|
+
}
|
|
1657
|
+
return _context31.abrupt("return", {
|
|
1658
|
+
statusCode: 204
|
|
1659
|
+
});
|
|
1660
|
+
case 1:
|
|
1661
|
+
isSecondaryLine = options.uri.includes('/secondaryLines/line-owner-2/');
|
|
1662
|
+
return _context31.abrupt("return", {
|
|
1663
|
+
statusCode: 200,
|
|
1664
|
+
body: {
|
|
1665
|
+
agentACDState: 'AVAILABLE',
|
|
1666
|
+
queues: [{
|
|
1667
|
+
id: 'shared-queue',
|
|
1668
|
+
name: 'Shared queue',
|
|
1669
|
+
available: true,
|
|
1670
|
+
allowLogOffEnabled: !isSecondaryLine
|
|
1671
|
+
}]
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
case 2:
|
|
1675
|
+
case "end":
|
|
1676
|
+
return _context31.stop();
|
|
1677
|
+
}
|
|
1678
|
+
}, _callee31);
|
|
1679
|
+
}));
|
|
1680
|
+
return function (_x17) {
|
|
1681
|
+
return _ref41.apply(this, arguments);
|
|
1682
|
+
};
|
|
1683
|
+
}());
|
|
1684
|
+
_context32.next = 1;
|
|
1685
|
+
return lineAwareClient.getCallQueueSettings();
|
|
1686
|
+
case 1:
|
|
1687
|
+
_context32.next = 2;
|
|
1688
|
+
return lineAwareClient.updateCallQueueSettings({
|
|
1689
|
+
queues: [{
|
|
1690
|
+
id: 'shared-queue',
|
|
1691
|
+
available: false
|
|
1692
|
+
}]
|
|
1693
|
+
}, 'line-owner-2');
|
|
1694
|
+
case 2:
|
|
1695
|
+
expect(webex.request).toHaveBeenNthCalledWith(1, {
|
|
1696
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/queues"),
|
|
1697
|
+
method: _types2.HTTP_METHODS.GET
|
|
1698
|
+
});
|
|
1699
|
+
expect(webex.request).toHaveBeenNthCalledWith(2, {
|
|
1700
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/secondaryLines/line-owner-2/queues"),
|
|
1701
|
+
method: _types2.HTTP_METHODS.GET
|
|
1702
|
+
});
|
|
1703
|
+
expect(webex.request).toHaveBeenNthCalledWith(3, {
|
|
1704
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/secondaryLines/line-owner-2/queues"),
|
|
1705
|
+
method: _types2.HTTP_METHODS.PUT,
|
|
1706
|
+
body: {
|
|
1707
|
+
queues: [{
|
|
1708
|
+
id: 'shared-queue',
|
|
1709
|
+
available: true
|
|
1710
|
+
}]
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
case 3:
|
|
1714
|
+
case "end":
|
|
1715
|
+
return _context32.stop();
|
|
1716
|
+
}
|
|
1717
|
+
}, _callee32);
|
|
1718
|
+
})));
|
|
1719
|
+
it('rejects an update that sets nothing', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee33() {
|
|
1720
|
+
var response;
|
|
1721
|
+
return _regenerator.default.wrap(function (_context33) {
|
|
1722
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1723
|
+
case 0:
|
|
1724
|
+
_context33.next = 1;
|
|
1725
|
+
return client.updateCallQueueSettings({});
|
|
1726
|
+
case 1:
|
|
1727
|
+
response = _context33.sent;
|
|
1728
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
1729
|
+
expect(response.statusCode).toBe(400);
|
|
1730
|
+
case 2:
|
|
1731
|
+
case "end":
|
|
1732
|
+
return _context33.stop();
|
|
1733
|
+
}
|
|
1734
|
+
}, _callee33);
|
|
1735
|
+
})));
|
|
1736
|
+
it('rejects an empty queue update', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee34() {
|
|
1737
|
+
var response;
|
|
1738
|
+
return _regenerator.default.wrap(function (_context34) {
|
|
1739
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
1740
|
+
case 0:
|
|
1741
|
+
_context34.next = 1;
|
|
1742
|
+
return client.updateCallQueueSettings({
|
|
1743
|
+
queues: []
|
|
1744
|
+
});
|
|
1745
|
+
case 1:
|
|
1746
|
+
response = _context34.sent;
|
|
1747
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
1748
|
+
expect(response.statusCode).toBe(400);
|
|
1749
|
+
expect(response.data.error).toBe('queues must include at least one queue update');
|
|
1750
|
+
case 2:
|
|
1751
|
+
case "end":
|
|
1752
|
+
return _context34.stop();
|
|
1753
|
+
}
|
|
1754
|
+
}, _callee34);
|
|
1755
|
+
})));
|
|
1756
|
+
it.each([['null request', null], ['missing request', undefined], ['array request', []], ['string request', 'invalid'], ['null queues', {
|
|
1757
|
+
queues: null
|
|
1758
|
+
}], ['object queues', {
|
|
1759
|
+
queues: {}
|
|
1760
|
+
}], ['string queues', {
|
|
1761
|
+
queues: 'invalid'
|
|
1762
|
+
}], ['numeric queues', {
|
|
1763
|
+
queues: 1
|
|
1764
|
+
}]])('rejects %s from JavaScript callers without making a request', /*#__PURE__*/function () {
|
|
1765
|
+
var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35(_, request) {
|
|
1766
|
+
var response;
|
|
1767
|
+
return _regenerator.default.wrap(function (_context35) {
|
|
1768
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
1769
|
+
case 0:
|
|
1770
|
+
_context35.next = 1;
|
|
1771
|
+
return client.updateCallQueueSettings(request);
|
|
1772
|
+
case 1:
|
|
1773
|
+
response = _context35.sent;
|
|
1774
|
+
expect(response.statusCode).toBe(400);
|
|
1775
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
1776
|
+
case 2:
|
|
1777
|
+
case "end":
|
|
1778
|
+
return _context35.stop();
|
|
1779
|
+
}
|
|
1780
|
+
}, _callee35);
|
|
1781
|
+
}));
|
|
1782
|
+
return function (_x18, _x19) {
|
|
1783
|
+
return _ref44.apply(this, arguments);
|
|
1784
|
+
};
|
|
1785
|
+
}());
|
|
1786
|
+
it('rejects an unsupported ACD state', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36() {
|
|
1787
|
+
var response;
|
|
1788
|
+
return _regenerator.default.wrap(function (_context36) {
|
|
1789
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1790
|
+
case 0:
|
|
1791
|
+
_context36.next = 1;
|
|
1792
|
+
return client.updateCallQueueSettings({
|
|
1793
|
+
agentACDState: 'LUNCH'
|
|
1794
|
+
});
|
|
1795
|
+
case 1:
|
|
1796
|
+
response = _context36.sent;
|
|
1797
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
1798
|
+
expect(response.statusCode).toBe(400);
|
|
1799
|
+
case 2:
|
|
1800
|
+
case "end":
|
|
1801
|
+
return _context36.stop();
|
|
1802
|
+
}
|
|
1803
|
+
}, _callee36);
|
|
1804
|
+
})));
|
|
1805
|
+
it('does not call the network when the user is not on Webex Calling cloud', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
|
|
1806
|
+
var backend, other, response;
|
|
1807
|
+
return _regenerator.default.wrap(function (_context37) {
|
|
1808
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
1809
|
+
case 0:
|
|
1810
|
+
backend = jest.spyOn(utils, 'getCallingBackEnd').mockReturnValue(_types2.CALLING_BACKEND.UCM);
|
|
1811
|
+
other = createCallQueueClient(webex, {
|
|
1812
|
+
level: _types.LOGGER.INFO
|
|
1813
|
+
}, TEST_OPTIONS);
|
|
1814
|
+
_context37.next = 1;
|
|
1815
|
+
return other.getCallQueueSettings();
|
|
1816
|
+
case 1:
|
|
1817
|
+
response = _context37.sent;
|
|
1818
|
+
backend.mockRestore();
|
|
1819
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
1820
|
+
expect(response.statusCode).toBe(501);
|
|
1821
|
+
case 2:
|
|
1822
|
+
case "end":
|
|
1823
|
+
return _context37.stop();
|
|
1824
|
+
}
|
|
1825
|
+
}, _callee37);
|
|
1826
|
+
})));
|
|
1827
|
+
it('posts telephony sync', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
|
|
1828
|
+
var response;
|
|
1829
|
+
return _regenerator.default.wrap(function (_context38) {
|
|
1830
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
1831
|
+
case 0:
|
|
1832
|
+
webex.request.mockResolvedValue({
|
|
1833
|
+
statusCode: 204
|
|
1834
|
+
});
|
|
1835
|
+
_context38.next = 1;
|
|
1836
|
+
return client.syncTelephonyCalls();
|
|
1837
|
+
case 1:
|
|
1838
|
+
response = _context38.sent;
|
|
1839
|
+
expect(webex.request).toHaveBeenCalledWith({
|
|
1840
|
+
uri: "".concat(WEBEX_API_INT, "telephony/calls/sync/invoke"),
|
|
1841
|
+
method: _types2.HTTP_METHODS.POST,
|
|
1842
|
+
body: {
|
|
1843
|
+
wdmUrl: webex.internal.device.url,
|
|
1844
|
+
resources: [{
|
|
1845
|
+
resource: 'telephony_agents'
|
|
1846
|
+
}]
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
expect(response.statusCode).toBe(204);
|
|
1850
|
+
expect(response.message).toBe('SUCCESS');
|
|
1851
|
+
case 2:
|
|
1852
|
+
case "end":
|
|
1853
|
+
return _context38.stop();
|
|
1854
|
+
}
|
|
1855
|
+
}, _callee38);
|
|
1856
|
+
})));
|
|
1857
|
+
it('rejects sync without a registered device URL', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39() {
|
|
1858
|
+
var original, response;
|
|
1859
|
+
return _regenerator.default.wrap(function (_context39) {
|
|
1860
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
1861
|
+
case 0:
|
|
1862
|
+
original = webex.internal.device.url;
|
|
1863
|
+
_context39.prev = 1;
|
|
1864
|
+
webex.internal.device.url = '';
|
|
1865
|
+
_context39.next = 2;
|
|
1866
|
+
return client.syncTelephonyCalls();
|
|
1867
|
+
case 2:
|
|
1868
|
+
response = _context39.sent;
|
|
1869
|
+
expect(response.statusCode).toBe(400);
|
|
1870
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
1871
|
+
case 3:
|
|
1872
|
+
_context39.prev = 3;
|
|
1873
|
+
webex.internal.device.url = original;
|
|
1874
|
+
return _context39.finish(3);
|
|
1875
|
+
case 4:
|
|
1876
|
+
case "end":
|
|
1877
|
+
return _context39.stop();
|
|
1878
|
+
}
|
|
1879
|
+
}, _callee39, null, [[1,, 3, 4]]);
|
|
1880
|
+
})));
|
|
1881
|
+
it('scopes virtual-line events and ignores events for another person', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40() {
|
|
1882
|
+
var lineId, scoped, listener, handlers, join;
|
|
1883
|
+
return _regenerator.default.wrap(function (_context40) {
|
|
1884
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
1885
|
+
case 0:
|
|
1886
|
+
lineId = '36d87d6c-7531-4b2f-a4ef-d71e6aacb86f';
|
|
1887
|
+
scoped = createCallQueueClient(webex, {
|
|
1888
|
+
level: _types.LOGGER.INFO
|
|
1889
|
+
}, TEST_OPTIONS);
|
|
1890
|
+
listener = jest.fn();
|
|
1891
|
+
scoped.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
1892
|
+
webex.request.mockResolvedValue({
|
|
1893
|
+
statusCode: 200,
|
|
1894
|
+
body: {
|
|
1895
|
+
agentACDState: 'AVAILABLE',
|
|
1896
|
+
queues: [{
|
|
1897
|
+
id: 'queue-1',
|
|
1898
|
+
name: 'Sales',
|
|
1899
|
+
available: true
|
|
1900
|
+
}]
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
_context40.next = 1;
|
|
1904
|
+
return scoped.getCallQueueSettings(lineId);
|
|
1905
|
+
case 1:
|
|
1906
|
+
handlers = new _map.default(webex.internal.mercury.on.mock.calls.map(function (call) {
|
|
1907
|
+
return [call[0], call[1]];
|
|
1908
|
+
}));
|
|
1909
|
+
join = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_JOIN);
|
|
1910
|
+
join === null || join === void 0 ? void 0 : join({
|
|
1911
|
+
data: {
|
|
1912
|
+
actorType: 'PERSON',
|
|
1913
|
+
actorId: 'a-different-person',
|
|
1914
|
+
joinInfo: [{
|
|
1915
|
+
queueId: 'queue-1',
|
|
1916
|
+
status: 'unjoined'
|
|
1917
|
+
}]
|
|
1918
|
+
}
|
|
1919
|
+
});
|
|
1920
|
+
join === null || join === void 0 ? void 0 : join({
|
|
1921
|
+
data: {
|
|
1922
|
+
actorType: 'PLACE',
|
|
1923
|
+
actorId: lineId,
|
|
1924
|
+
joinInfo: [{
|
|
1925
|
+
queueId: 'queue-1',
|
|
1926
|
+
status: 'unjoined'
|
|
1927
|
+
}]
|
|
1928
|
+
}
|
|
1929
|
+
});
|
|
1930
|
+
expect(listener).not.toHaveBeenCalled();
|
|
1931
|
+
join === null || join === void 0 ? void 0 : join({
|
|
1932
|
+
data: {
|
|
1933
|
+
actorType: 'VIRTUAL_LINE',
|
|
1934
|
+
actorId: btoa("ciscospark://us/VIRTUAL_LINE/".concat(lineId)),
|
|
1935
|
+
joinInfo: [{
|
|
1936
|
+
queueId: 'queue-1',
|
|
1937
|
+
status: 'unjoined'
|
|
1938
|
+
}]
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
expect(listener).toHaveBeenCalledWith({
|
|
1942
|
+
acdState: _constants.ACD_STATE.AVAILABLE,
|
|
1943
|
+
queues: [{
|
|
1944
|
+
id: 'queue-1',
|
|
1945
|
+
name: 'Sales',
|
|
1946
|
+
available: false
|
|
1947
|
+
}],
|
|
1948
|
+
lineOwnerId: lineId
|
|
1949
|
+
});
|
|
1950
|
+
scoped.dispose();
|
|
1951
|
+
case 2:
|
|
1952
|
+
case "end":
|
|
1953
|
+
return _context40.stop();
|
|
1954
|
+
}
|
|
1955
|
+
}, _callee40);
|
|
1956
|
+
})));
|
|
1957
|
+
it('refreshes the actual state when a join event arrives before settings have loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
|
|
1958
|
+
var _handlers$get;
|
|
1959
|
+
var otherWebex, other, listener, handlers;
|
|
1960
|
+
return _regenerator.default.wrap(function (_context41) {
|
|
1961
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
1962
|
+
case 0:
|
|
1963
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
1964
|
+
other = createCallQueueClient(otherWebex, {
|
|
1965
|
+
level: _types.LOGGER.INFO
|
|
1966
|
+
}, TEST_OPTIONS);
|
|
1967
|
+
listener = jest.fn();
|
|
1968
|
+
other.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
1969
|
+
otherWebex.request.mockResolvedValue({
|
|
1970
|
+
statusCode: 200,
|
|
1971
|
+
body: {
|
|
1972
|
+
agentACDState: 'AVAILABLE',
|
|
1973
|
+
queues: [{
|
|
1974
|
+
id: 'queue-1',
|
|
1975
|
+
name: 'Sales',
|
|
1976
|
+
available: true
|
|
1977
|
+
}]
|
|
1978
|
+
}
|
|
1979
|
+
});
|
|
1980
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
1981
|
+
return [call[0], call[1]];
|
|
1982
|
+
}));
|
|
1983
|
+
(_handlers$get = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_JOIN)) === null || _handlers$get === void 0 ? void 0 : _handlers$get({
|
|
1984
|
+
data: {
|
|
1985
|
+
actorType: 'PERSON',
|
|
1986
|
+
actorId: btoa("ciscospark://us/PEOPLE/".concat(otherWebex.internal.device.userId)),
|
|
1987
|
+
joinInfo: [{
|
|
1988
|
+
queueId: 'queue-1',
|
|
1989
|
+
status: 'joined'
|
|
1990
|
+
}]
|
|
1991
|
+
}
|
|
1992
|
+
});
|
|
1993
|
+
expect(listener).not.toHaveBeenCalled();
|
|
1994
|
+
_context41.next = 1;
|
|
1995
|
+
return new _promise.default(function (resolve) {
|
|
1996
|
+
setTimeout(resolve, 0);
|
|
1997
|
+
});
|
|
1998
|
+
case 1:
|
|
1999
|
+
expect(otherWebex.request).toHaveBeenCalledWith({
|
|
2000
|
+
uri: "".concat(WEBEX_API_INT, "telephony/config/people/me/settings/queues"),
|
|
2001
|
+
method: _types2.HTTP_METHODS.GET
|
|
2002
|
+
});
|
|
2003
|
+
expect(listener).toHaveBeenCalledWith({
|
|
2004
|
+
acdState: _constants.ACD_STATE.AVAILABLE,
|
|
2005
|
+
queues: [{
|
|
2006
|
+
id: 'queue-1',
|
|
2007
|
+
name: 'Sales',
|
|
2008
|
+
available: true
|
|
2009
|
+
}]
|
|
2010
|
+
});
|
|
2011
|
+
other.dispose();
|
|
2012
|
+
case 2:
|
|
2013
|
+
case "end":
|
|
2014
|
+
return _context41.stop();
|
|
2015
|
+
}
|
|
2016
|
+
}, _callee41);
|
|
2017
|
+
})));
|
|
2018
|
+
it('refreshes again when an uncached join event is followed by a state event', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
|
|
2019
|
+
var _handlers$get2, _handlers$get3;
|
|
2020
|
+
var otherWebex, other, listener, first, second, handlers, actorId;
|
|
2021
|
+
return _regenerator.default.wrap(function (_context42) {
|
|
2022
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
2023
|
+
case 0:
|
|
2024
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2025
|
+
other = createCallQueueClient(otherWebex, {
|
|
2026
|
+
level: _types.LOGGER.INFO
|
|
2027
|
+
}, TEST_OPTIONS);
|
|
2028
|
+
listener = jest.fn();
|
|
2029
|
+
other.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
2030
|
+
first = deferredResponse();
|
|
2031
|
+
second = deferredResponse();
|
|
2032
|
+
otherWebex.request.mockReturnValueOnce(first.promise).mockReturnValueOnce(second.promise);
|
|
2033
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2034
|
+
return [call[0], call[1]];
|
|
2035
|
+
}));
|
|
2036
|
+
actorId = otherWebex.internal.device.userId;
|
|
2037
|
+
(_handlers$get2 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_JOIN)) === null || _handlers$get2 === void 0 ? void 0 : _handlers$get2({
|
|
2038
|
+
data: {
|
|
2039
|
+
actorType: 'PERSON',
|
|
2040
|
+
actorId: actorId,
|
|
2041
|
+
joinInfo: [{
|
|
2042
|
+
queueId: 'queue-1',
|
|
2043
|
+
status: 'joined'
|
|
2044
|
+
}]
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
(_handlers$get3 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)) === null || _handlers$get3 === void 0 ? void 0 : _handlers$get3({
|
|
2048
|
+
data: {
|
|
2049
|
+
actorType: 'PERSON',
|
|
2050
|
+
actorId: actorId,
|
|
2051
|
+
acdStateInfo: {
|
|
2052
|
+
state: 'unavailable'
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
first.resolve({
|
|
2057
|
+
statusCode: 200,
|
|
2058
|
+
body: {
|
|
2059
|
+
agentACDState: 'AVAILABLE',
|
|
2060
|
+
queues: [{
|
|
2061
|
+
id: 'queue-1',
|
|
2062
|
+
name: 'Sales',
|
|
2063
|
+
available: true
|
|
2064
|
+
}]
|
|
2065
|
+
}
|
|
2066
|
+
});
|
|
2067
|
+
_context42.next = 1;
|
|
2068
|
+
return new _promise.default(function (resolve) {
|
|
2069
|
+
setTimeout(resolve, 0);
|
|
2070
|
+
});
|
|
2071
|
+
case 1:
|
|
2072
|
+
expect(listener).not.toHaveBeenCalled();
|
|
2073
|
+
second.resolve({
|
|
2074
|
+
statusCode: 200,
|
|
2075
|
+
body: {
|
|
2076
|
+
agentACDState: 'UNAVAILABLE',
|
|
2077
|
+
queues: [{
|
|
2078
|
+
id: 'queue-1',
|
|
2079
|
+
name: 'Sales',
|
|
2080
|
+
available: true
|
|
2081
|
+
}]
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
_context42.next = 2;
|
|
2085
|
+
return new _promise.default(function (resolve) {
|
|
2086
|
+
setTimeout(resolve, 0);
|
|
2087
|
+
});
|
|
2088
|
+
case 2:
|
|
2089
|
+
expect(listener).toHaveBeenCalledWith({
|
|
2090
|
+
acdState: _constants.ACD_STATE.UNAVAILABLE,
|
|
2091
|
+
queues: [{
|
|
2092
|
+
id: 'queue-1',
|
|
2093
|
+
name: 'Sales',
|
|
2094
|
+
available: true
|
|
2095
|
+
}]
|
|
2096
|
+
});
|
|
2097
|
+
other.dispose();
|
|
2098
|
+
case 3:
|
|
2099
|
+
case "end":
|
|
2100
|
+
return _context42.stop();
|
|
2101
|
+
}
|
|
2102
|
+
}, _callee42);
|
|
2103
|
+
})));
|
|
2104
|
+
it.each([['unknown state', {
|
|
2105
|
+
state: 'future-unknown-state'
|
|
2106
|
+
}], ['unrecognized join status', {
|
|
2107
|
+
joinInfo: [{
|
|
2108
|
+
queueId: 'q1',
|
|
2109
|
+
status: 'unknown'
|
|
2110
|
+
}]
|
|
2111
|
+
}], ['empty event', {
|
|
2112
|
+
eventType: 'heartbeat'
|
|
2113
|
+
}]])('does not invalidate an in-flight GET for a %s event', /*#__PURE__*/function () {
|
|
2114
|
+
var _ref52 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43(_, payload) {
|
|
2115
|
+
var _handlers$get4, _yield$pending$data$c;
|
|
2116
|
+
var otherWebex, other, deferred, pending, handlers, _t29, _t30, _t31, _t32;
|
|
2117
|
+
return _regenerator.default.wrap(function (_context43) {
|
|
2118
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
2119
|
+
case 0:
|
|
2120
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2121
|
+
other = createCallQueueClient(otherWebex, {
|
|
2122
|
+
level: _types.LOGGER.INFO
|
|
2123
|
+
}, TEST_OPTIONS);
|
|
2124
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2125
|
+
statusCode: 200,
|
|
2126
|
+
body: {
|
|
2127
|
+
agentACDState: 'AVAILABLE',
|
|
2128
|
+
queues: []
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
_context43.next = 1;
|
|
2132
|
+
return other.getCallQueueSettings();
|
|
2133
|
+
case 1:
|
|
2134
|
+
deferred = deferredResponse();
|
|
2135
|
+
otherWebex.request.mockReturnValueOnce(deferred.promise);
|
|
2136
|
+
pending = other.getCallQueueSettings();
|
|
2137
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2138
|
+
return [call[0], call[1]];
|
|
2139
|
+
}));
|
|
2140
|
+
(_handlers$get4 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)) === null || _handlers$get4 === void 0 ? void 0 : _handlers$get4({
|
|
2141
|
+
data: _objectSpread({
|
|
2142
|
+
actorType: 'PERSON',
|
|
2143
|
+
actorId: otherWebex.internal.device.userId
|
|
2144
|
+
}, payload)
|
|
2145
|
+
});
|
|
2146
|
+
deferred.resolve({
|
|
2147
|
+
statusCode: 200,
|
|
2148
|
+
body: {
|
|
2149
|
+
agentACDState: 'UNAVAILABLE',
|
|
2150
|
+
queues: []
|
|
2151
|
+
}
|
|
2152
|
+
});
|
|
2153
|
+
_t29 = _testHelperChai.assert;
|
|
2154
|
+
_context43.next = 2;
|
|
2155
|
+
return pending;
|
|
2156
|
+
case 2:
|
|
2157
|
+
_t31 = _yield$pending$data$c = _context43.sent.data.callQueue;
|
|
2158
|
+
_t30 = _t31 === null;
|
|
2159
|
+
if (_t30) {
|
|
2160
|
+
_context43.next = 3;
|
|
2161
|
+
break;
|
|
2162
|
+
}
|
|
2163
|
+
_t30 = _yield$pending$data$c === void 0;
|
|
2164
|
+
case 3:
|
|
2165
|
+
if (!_t30) {
|
|
2166
|
+
_context43.next = 4;
|
|
2167
|
+
break;
|
|
2168
|
+
}
|
|
2169
|
+
_t32 = void 0;
|
|
2170
|
+
_context43.next = 5;
|
|
2171
|
+
break;
|
|
2172
|
+
case 4:
|
|
2173
|
+
_t32 = _yield$pending$data$c.acdState;
|
|
2174
|
+
case 5:
|
|
2175
|
+
_t29.equal.call(_t29, _t32, _constants.ACD_STATE.UNAVAILABLE);
|
|
2176
|
+
other.dispose();
|
|
2177
|
+
case 6:
|
|
2178
|
+
case "end":
|
|
2179
|
+
return _context43.stop();
|
|
2180
|
+
}
|
|
2181
|
+
}, _callee43);
|
|
2182
|
+
}));
|
|
2183
|
+
return function (_x20, _x21) {
|
|
2184
|
+
return _ref52.apply(this, arguments);
|
|
2185
|
+
};
|
|
2186
|
+
}());
|
|
2187
|
+
it.each([['unrecognized join status', {
|
|
2188
|
+
joinInfo: [{
|
|
2189
|
+
queueId: 'q1',
|
|
2190
|
+
status: 'unknown'
|
|
2191
|
+
}]
|
|
2192
|
+
}], ['malformed queue record', {
|
|
2193
|
+
queues: [{
|
|
2194
|
+
name: 'Missing id'
|
|
2195
|
+
}]
|
|
2196
|
+
}]])('does not invalidate the initial GET for an event with %s', /*#__PURE__*/function () {
|
|
2197
|
+
var _ref53 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44(_, payload) {
|
|
2198
|
+
var _handlers$get5, _result$data$callQueu2;
|
|
2199
|
+
var otherWebex, other, deferred, pending, handlers, result;
|
|
2200
|
+
return _regenerator.default.wrap(function (_context44) {
|
|
2201
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
2202
|
+
case 0:
|
|
2203
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2204
|
+
other = createCallQueueClient(otherWebex, {
|
|
2205
|
+
level: _types.LOGGER.INFO
|
|
2206
|
+
}, TEST_OPTIONS);
|
|
2207
|
+
deferred = deferredResponse();
|
|
2208
|
+
otherWebex.request.mockReturnValueOnce(deferred.promise);
|
|
2209
|
+
pending = other.getCallQueueSettings();
|
|
2210
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2211
|
+
return [call[0], call[1]];
|
|
2212
|
+
}));
|
|
2213
|
+
(_handlers$get5 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_SYNC)) === null || _handlers$get5 === void 0 ? void 0 : _handlers$get5({
|
|
2214
|
+
data: _objectSpread({
|
|
2215
|
+
actorType: 'PERSON',
|
|
2216
|
+
actorId: otherWebex.internal.device.userId
|
|
2217
|
+
}, payload)
|
|
2218
|
+
});
|
|
2219
|
+
deferred.resolve({
|
|
2220
|
+
statusCode: 200,
|
|
2221
|
+
body: {
|
|
2222
|
+
agentACDState: 'AVAILABLE',
|
|
2223
|
+
queues: []
|
|
2224
|
+
}
|
|
2225
|
+
});
|
|
2226
|
+
_context44.next = 1;
|
|
2227
|
+
return pending;
|
|
2228
|
+
case 1:
|
|
2229
|
+
result = _context44.sent;
|
|
2230
|
+
_testHelperChai.assert.equal(result.statusCode, 200);
|
|
2231
|
+
_testHelperChai.assert.equal((_result$data$callQueu2 = result.data.callQueue) === null || _result$data$callQueu2 === void 0 ? void 0 : _result$data$callQueu2.acdState, _constants.ACD_STATE.AVAILABLE);
|
|
2232
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 1);
|
|
2233
|
+
other.dispose();
|
|
2234
|
+
case 2:
|
|
2235
|
+
case "end":
|
|
2236
|
+
return _context44.stop();
|
|
2237
|
+
}
|
|
2238
|
+
}, _callee44);
|
|
2239
|
+
}));
|
|
2240
|
+
return function (_x22, _x23) {
|
|
2241
|
+
return _ref53.apply(this, arguments);
|
|
2242
|
+
};
|
|
2243
|
+
}());
|
|
2244
|
+
it.each([['queue', {
|
|
2245
|
+
queues: []
|
|
2246
|
+
}], ['membership', {
|
|
2247
|
+
joinInfo: []
|
|
2248
|
+
}]])('refreshes an uncached line for a valid empty %s list', /*#__PURE__*/function () {
|
|
2249
|
+
var _ref54 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(_, payload) {
|
|
2250
|
+
var _handlers$get6, _result$data$callQueu3;
|
|
2251
|
+
var otherWebex, other, initial, refresh, pending, handlers, result;
|
|
2252
|
+
return _regenerator.default.wrap(function (_context45) {
|
|
2253
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
2254
|
+
case 0:
|
|
2255
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2256
|
+
other = createCallQueueClient(otherWebex, {
|
|
2257
|
+
level: _types.LOGGER.INFO
|
|
2258
|
+
}, TEST_OPTIONS);
|
|
2259
|
+
initial = deferredResponse();
|
|
2260
|
+
refresh = deferredResponse();
|
|
2261
|
+
otherWebex.request.mockReturnValueOnce(initial.promise).mockReturnValueOnce(refresh.promise);
|
|
2262
|
+
pending = other.getCallQueueSettings();
|
|
2263
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2264
|
+
return [call[0], call[1]];
|
|
2265
|
+
}));
|
|
2266
|
+
(_handlers$get6 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_SYNC)) === null || _handlers$get6 === void 0 ? void 0 : _handlers$get6({
|
|
2267
|
+
data: _objectSpread({
|
|
2268
|
+
actorType: 'PERSON',
|
|
2269
|
+
actorId: otherWebex.internal.device.userId
|
|
2270
|
+
}, payload)
|
|
2271
|
+
});
|
|
2272
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 2);
|
|
2273
|
+
refresh.resolve({
|
|
2274
|
+
statusCode: 200,
|
|
2275
|
+
body: {
|
|
2276
|
+
agentACDState: 'UNAVAILABLE',
|
|
2277
|
+
queues: []
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
initial.resolve({
|
|
2281
|
+
statusCode: 200,
|
|
2282
|
+
body: {
|
|
2283
|
+
agentACDState: 'AVAILABLE',
|
|
2284
|
+
queues: []
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
_context45.next = 1;
|
|
2288
|
+
return pending;
|
|
2289
|
+
case 1:
|
|
2290
|
+
result = _context45.sent;
|
|
2291
|
+
_testHelperChai.assert.equal(result.statusCode, 200);
|
|
2292
|
+
_testHelperChai.assert.equal((_result$data$callQueu3 = result.data.callQueue) === null || _result$data$callQueu3 === void 0 ? void 0 : _result$data$callQueu3.acdState, _constants.ACD_STATE.UNAVAILABLE);
|
|
2293
|
+
other.dispose();
|
|
2294
|
+
case 2:
|
|
2295
|
+
case "end":
|
|
2296
|
+
return _context45.stop();
|
|
2297
|
+
}
|
|
2298
|
+
}, _callee45);
|
|
2299
|
+
}));
|
|
2300
|
+
return function (_x24, _x25) {
|
|
2301
|
+
return _ref54.apply(this, arguments);
|
|
2302
|
+
};
|
|
2303
|
+
}());
|
|
2304
|
+
it('keeps an unchanged valid event newer than an in-flight GET', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
|
|
2305
|
+
var _handlers$get7, _yield$pending$data$c2;
|
|
2306
|
+
var otherWebex, other, deferred, pending, handlers, _t33, _t34, _t35, _t36;
|
|
2307
|
+
return _regenerator.default.wrap(function (_context46) {
|
|
2308
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
2309
|
+
case 0:
|
|
2310
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2311
|
+
other = createCallQueueClient(otherWebex, {
|
|
2312
|
+
level: _types.LOGGER.INFO
|
|
2313
|
+
}, TEST_OPTIONS);
|
|
2314
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2315
|
+
statusCode: 200,
|
|
2316
|
+
body: {
|
|
2317
|
+
agentACDState: 'AVAILABLE',
|
|
2318
|
+
queues: []
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
_context46.next = 1;
|
|
2322
|
+
return other.getCallQueueSettings();
|
|
2323
|
+
case 1:
|
|
2324
|
+
deferred = deferredResponse();
|
|
2325
|
+
otherWebex.request.mockReturnValueOnce(deferred.promise);
|
|
2326
|
+
pending = other.getCallQueueSettings();
|
|
2327
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2328
|
+
return [call[0], call[1]];
|
|
2329
|
+
}));
|
|
2330
|
+
(_handlers$get7 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)) === null || _handlers$get7 === void 0 ? void 0 : _handlers$get7({
|
|
2331
|
+
data: {
|
|
2332
|
+
actorType: 'PERSON',
|
|
2333
|
+
actorId: otherWebex.internal.device.userId,
|
|
2334
|
+
state: 'available'
|
|
2335
|
+
}
|
|
2336
|
+
});
|
|
2337
|
+
deferred.resolve({
|
|
2338
|
+
statusCode: 200,
|
|
2339
|
+
body: {
|
|
2340
|
+
agentACDState: 'UNAVAILABLE',
|
|
2341
|
+
queues: []
|
|
2342
|
+
}
|
|
2343
|
+
});
|
|
2344
|
+
_t33 = _testHelperChai.assert;
|
|
2345
|
+
_context46.next = 2;
|
|
2346
|
+
return pending;
|
|
2347
|
+
case 2:
|
|
2348
|
+
_t35 = _yield$pending$data$c2 = _context46.sent.data.callQueue;
|
|
2349
|
+
_t34 = _t35 === null;
|
|
2350
|
+
if (_t34) {
|
|
2351
|
+
_context46.next = 3;
|
|
2352
|
+
break;
|
|
2353
|
+
}
|
|
2354
|
+
_t34 = _yield$pending$data$c2 === void 0;
|
|
2355
|
+
case 3:
|
|
2356
|
+
if (!_t34) {
|
|
2357
|
+
_context46.next = 4;
|
|
2358
|
+
break;
|
|
2359
|
+
}
|
|
2360
|
+
_t36 = void 0;
|
|
2361
|
+
_context46.next = 5;
|
|
2362
|
+
break;
|
|
2363
|
+
case 4:
|
|
2364
|
+
_t36 = _yield$pending$data$c2.acdState;
|
|
2365
|
+
case 5:
|
|
2366
|
+
_t33.equal.call(_t33, _t36, _constants.ACD_STATE.AVAILABLE);
|
|
2367
|
+
other.dispose();
|
|
2368
|
+
case 6:
|
|
2369
|
+
case "end":
|
|
2370
|
+
return _context46.stop();
|
|
2371
|
+
}
|
|
2372
|
+
}, _callee46);
|
|
2373
|
+
})));
|
|
2374
|
+
it('does not overwrite a newer Mercury state with an older in-flight GET', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47() {
|
|
2375
|
+
var _handlers$get8, _response$data$callQu8, _response$data$callQu9;
|
|
2376
|
+
var otherWebex, other, body, oldGet, read, handlers, response;
|
|
2377
|
+
return _regenerator.default.wrap(function (_context47) {
|
|
2378
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
2379
|
+
case 0:
|
|
2380
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2381
|
+
other = createCallQueueClient(otherWebex, {
|
|
2382
|
+
level: _types.LOGGER.INFO
|
|
2383
|
+
}, TEST_OPTIONS);
|
|
2384
|
+
body = {
|
|
2385
|
+
agentACDState: 'AVAILABLE',
|
|
2386
|
+
queues: [{
|
|
2387
|
+
id: 'queue-1',
|
|
2388
|
+
name: 'Sales',
|
|
2389
|
+
available: true
|
|
2390
|
+
}]
|
|
2391
|
+
};
|
|
2392
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2393
|
+
statusCode: 200,
|
|
2394
|
+
body: body
|
|
2395
|
+
});
|
|
2396
|
+
_context47.next = 1;
|
|
2397
|
+
return other.getCallQueueSettings();
|
|
2398
|
+
case 1:
|
|
2399
|
+
oldGet = deferredResponse();
|
|
2400
|
+
otherWebex.request.mockReturnValueOnce(oldGet.promise);
|
|
2401
|
+
read = other.getCallQueueSettings();
|
|
2402
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2403
|
+
return [call[0], call[1]];
|
|
2404
|
+
}));
|
|
2405
|
+
(_handlers$get8 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)) === null || _handlers$get8 === void 0 ? void 0 : _handlers$get8({
|
|
2406
|
+
data: {
|
|
2407
|
+
actorType: 'PERSON',
|
|
2408
|
+
actorId: otherWebex.internal.device.userId,
|
|
2409
|
+
state: 'unavailable'
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
oldGet.resolve({
|
|
2413
|
+
statusCode: 200,
|
|
2414
|
+
body: body
|
|
2415
|
+
});
|
|
2416
|
+
_context47.next = 2;
|
|
2417
|
+
return read;
|
|
2418
|
+
case 2:
|
|
2419
|
+
response = _context47.sent;
|
|
2420
|
+
expect((_response$data$callQu8 = response.data.callQueue) === null || _response$data$callQu8 === void 0 ? void 0 : _response$data$callQu8.acdState).toBe(_constants.ACD_STATE.UNAVAILABLE);
|
|
2421
|
+
expect((_response$data$callQu9 = response.data.callQueue) === null || _response$data$callQu9 === void 0 ? void 0 : _response$data$callQu9.queues).toEqual(body.queues);
|
|
2422
|
+
other.dispose();
|
|
2423
|
+
case 3:
|
|
2424
|
+
case "end":
|
|
2425
|
+
return _context47.stop();
|
|
2426
|
+
}
|
|
2427
|
+
}, _callee47);
|
|
2428
|
+
})));
|
|
2429
|
+
it('waits for the latest replacement event refresh while a GET is pending', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
|
|
2430
|
+
var _handlers$get9, _handlers$get0, _response$data$callQu0;
|
|
2431
|
+
var otherWebex, other, original, first, second, settled, read, handlers, actorId, response;
|
|
2432
|
+
return _regenerator.default.wrap(function (_context48) {
|
|
2433
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
2434
|
+
case 0:
|
|
2435
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2436
|
+
other = createCallQueueClient(otherWebex, {
|
|
2437
|
+
level: _types.LOGGER.INFO
|
|
2438
|
+
}, TEST_OPTIONS);
|
|
2439
|
+
original = deferredResponse();
|
|
2440
|
+
first = deferredResponse();
|
|
2441
|
+
second = deferredResponse();
|
|
2442
|
+
otherWebex.request.mockReturnValueOnce(original.promise).mockReturnValueOnce(first.promise).mockReturnValueOnce(second.promise);
|
|
2443
|
+
settled = false;
|
|
2444
|
+
read = other.getCallQueueSettings().then(function (result) {
|
|
2445
|
+
settled = true;
|
|
2446
|
+
return result;
|
|
2447
|
+
});
|
|
2448
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2449
|
+
return [call[0], call[1]];
|
|
2450
|
+
}));
|
|
2451
|
+
actorId = otherWebex.internal.device.userId;
|
|
2452
|
+
(_handlers$get9 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_JOIN)) === null || _handlers$get9 === void 0 ? void 0 : _handlers$get9({
|
|
2453
|
+
data: {
|
|
2454
|
+
actorType: 'PERSON',
|
|
2455
|
+
actorId: actorId,
|
|
2456
|
+
joinInfo: [{
|
|
2457
|
+
queueId: 'q1',
|
|
2458
|
+
status: 'joined'
|
|
2459
|
+
}]
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
original.resolve({
|
|
2463
|
+
statusCode: 200,
|
|
2464
|
+
body: {
|
|
2465
|
+
agentACDState: 'AVAILABLE',
|
|
2466
|
+
queues: []
|
|
2467
|
+
}
|
|
2468
|
+
});
|
|
2469
|
+
_context48.next = 1;
|
|
2470
|
+
return new _promise.default(function (resolve) {
|
|
2471
|
+
setTimeout(resolve, 0);
|
|
2472
|
+
});
|
|
2473
|
+
case 1:
|
|
2474
|
+
(_handlers$get0 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)) === null || _handlers$get0 === void 0 ? void 0 : _handlers$get0({
|
|
2475
|
+
data: {
|
|
2476
|
+
actorType: 'PERSON',
|
|
2477
|
+
actorId: actorId,
|
|
2478
|
+
state: 'unavailable'
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2481
|
+
first.resolve({
|
|
2482
|
+
statusCode: 200,
|
|
2483
|
+
body: {
|
|
2484
|
+
agentACDState: 'AVAILABLE',
|
|
2485
|
+
queues: []
|
|
2486
|
+
}
|
|
2487
|
+
});
|
|
2488
|
+
_context48.next = 2;
|
|
2489
|
+
return new _promise.default(function (resolve) {
|
|
2490
|
+
setTimeout(resolve, 0);
|
|
2491
|
+
});
|
|
2492
|
+
case 2:
|
|
2493
|
+
expect(settled).toBe(false);
|
|
2494
|
+
second.resolve({
|
|
2495
|
+
statusCode: 200,
|
|
2496
|
+
body: {
|
|
2497
|
+
agentACDState: 'UNAVAILABLE',
|
|
2498
|
+
queues: []
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2501
|
+
_context48.next = 3;
|
|
2502
|
+
return read;
|
|
2503
|
+
case 3:
|
|
2504
|
+
response = _context48.sent;
|
|
2505
|
+
expect((_response$data$callQu0 = response.data.callQueue) === null || _response$data$callQu0 === void 0 ? void 0 : _response$data$callQu0.acdState).toBe(_constants.ACD_STATE.UNAVAILABLE);
|
|
2506
|
+
other.dispose();
|
|
2507
|
+
case 4:
|
|
2508
|
+
case "end":
|
|
2509
|
+
return _context48.stop();
|
|
2510
|
+
}
|
|
2511
|
+
}, _callee48);
|
|
2512
|
+
})));
|
|
2513
|
+
it('does not let an older event refresh overwrite a later GET', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49() {
|
|
2514
|
+
var _handlers$get1, _updated$data$callQue;
|
|
2515
|
+
var otherWebex, other, listener, oldGet, handlers, updated;
|
|
2516
|
+
return _regenerator.default.wrap(function (_context49) {
|
|
2517
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
2518
|
+
case 0:
|
|
2519
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2520
|
+
other = createCallQueueClient(otherWebex, {
|
|
2521
|
+
level: _types.LOGGER.INFO
|
|
2522
|
+
}, TEST_OPTIONS);
|
|
2523
|
+
listener = jest.fn();
|
|
2524
|
+
other.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
2525
|
+
oldGet = deferredResponse();
|
|
2526
|
+
otherWebex.request.mockReturnValueOnce(oldGet.promise).mockResolvedValueOnce({
|
|
2527
|
+
statusCode: 200,
|
|
2528
|
+
body: {
|
|
2529
|
+
agentACDState: 'UNAVAILABLE',
|
|
2530
|
+
queues: []
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2534
|
+
return [call[0], call[1]];
|
|
2535
|
+
}));
|
|
2536
|
+
(_handlers$get1 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)) === null || _handlers$get1 === void 0 ? void 0 : _handlers$get1({
|
|
2537
|
+
data: {
|
|
2538
|
+
actorType: 'PERSON',
|
|
2539
|
+
actorId: otherWebex.internal.device.userId,
|
|
2540
|
+
state: 'available'
|
|
2541
|
+
}
|
|
2542
|
+
});
|
|
2543
|
+
_context49.next = 1;
|
|
2544
|
+
return other.getCallQueueSettings();
|
|
2545
|
+
case 1:
|
|
2546
|
+
oldGet.resolve({
|
|
2547
|
+
statusCode: 200,
|
|
2548
|
+
body: {
|
|
2549
|
+
agentACDState: 'AVAILABLE',
|
|
2550
|
+
queues: []
|
|
2551
|
+
}
|
|
2552
|
+
});
|
|
2553
|
+
_context49.next = 2;
|
|
2554
|
+
return new _promise.default(function (resolve) {
|
|
2555
|
+
setTimeout(resolve, 0);
|
|
2556
|
+
});
|
|
2557
|
+
case 2:
|
|
2558
|
+
expect(listener).not.toHaveBeenCalled();
|
|
2559
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2560
|
+
statusCode: 204
|
|
2561
|
+
});
|
|
2562
|
+
_context49.next = 3;
|
|
2563
|
+
return other.updateCallQueueSettings({
|
|
2564
|
+
queues: [{
|
|
2565
|
+
id: 'q1',
|
|
2566
|
+
available: true
|
|
2567
|
+
}]
|
|
2568
|
+
});
|
|
2569
|
+
case 3:
|
|
2570
|
+
updated = _context49.sent;
|
|
2571
|
+
expect((_updated$data$callQue = updated.data.callQueue) === null || _updated$data$callQue === void 0 ? void 0 : _updated$data$callQue.acdState).toBe(_constants.ACD_STATE.UNAVAILABLE);
|
|
2572
|
+
other.dispose();
|
|
2573
|
+
case 4:
|
|
2574
|
+
case "end":
|
|
2575
|
+
return _context49.stop();
|
|
2576
|
+
}
|
|
2577
|
+
}, _callee49);
|
|
2578
|
+
})));
|
|
2579
|
+
it('does not let an older GET overwrite a successful update', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
|
|
2580
|
+
var _yield$read$data$call;
|
|
2581
|
+
var otherWebex, other, initial, oldGet, read, _t37, _t38, _t39, _t40;
|
|
2582
|
+
return _regenerator.default.wrap(function (_context50) {
|
|
2583
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
2584
|
+
case 0:
|
|
2585
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2586
|
+
other = createCallQueueClient(otherWebex, {
|
|
2587
|
+
level: _types.LOGGER.INFO
|
|
2588
|
+
}, TEST_OPTIONS);
|
|
2589
|
+
initial = {
|
|
2590
|
+
agentACDState: 'AVAILABLE',
|
|
2591
|
+
queues: []
|
|
2592
|
+
};
|
|
2593
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2594
|
+
statusCode: 200,
|
|
2595
|
+
body: initial
|
|
2596
|
+
});
|
|
2597
|
+
_context50.next = 1;
|
|
2598
|
+
return other.getCallQueueSettings();
|
|
2599
|
+
case 1:
|
|
2600
|
+
oldGet = deferredResponse();
|
|
2601
|
+
otherWebex.request.mockReturnValueOnce(oldGet.promise).mockResolvedValueOnce({
|
|
2602
|
+
statusCode: 204
|
|
2603
|
+
});
|
|
2604
|
+
read = other.getCallQueueSettings();
|
|
2605
|
+
_context50.next = 2;
|
|
2606
|
+
return other.updateCallQueueSettings({
|
|
2607
|
+
agentACDState: _constants.ACD_STATE.UNAVAILABLE
|
|
2608
|
+
});
|
|
2609
|
+
case 2:
|
|
2610
|
+
oldGet.resolve({
|
|
2611
|
+
statusCode: 200,
|
|
2612
|
+
body: initial
|
|
2613
|
+
});
|
|
2614
|
+
_t37 = expect;
|
|
2615
|
+
_context50.next = 3;
|
|
2616
|
+
return read;
|
|
2617
|
+
case 3:
|
|
2618
|
+
_t39 = _yield$read$data$call = _context50.sent.data.callQueue;
|
|
2619
|
+
_t38 = _t39 === null;
|
|
2620
|
+
if (_t38) {
|
|
2621
|
+
_context50.next = 4;
|
|
2622
|
+
break;
|
|
2623
|
+
}
|
|
2624
|
+
_t38 = _yield$read$data$call === void 0;
|
|
2625
|
+
case 4:
|
|
2626
|
+
if (!_t38) {
|
|
2627
|
+
_context50.next = 5;
|
|
2628
|
+
break;
|
|
2629
|
+
}
|
|
2630
|
+
_t40 = void 0;
|
|
2631
|
+
_context50.next = 6;
|
|
2632
|
+
break;
|
|
2633
|
+
case 5:
|
|
2634
|
+
_t40 = _yield$read$data$call.acdState;
|
|
2635
|
+
case 6:
|
|
2636
|
+
_t37(_t40).toBe(_constants.ACD_STATE.UNAVAILABLE);
|
|
2637
|
+
other.dispose();
|
|
2638
|
+
case 7:
|
|
2639
|
+
case "end":
|
|
2640
|
+
return _context50.stop();
|
|
2641
|
+
}
|
|
2642
|
+
}, _callee50);
|
|
2643
|
+
})));
|
|
2644
|
+
it('does not let an older GET overwrite a later completed GET', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51() {
|
|
2645
|
+
var _yield$read$data$call2;
|
|
2646
|
+
var otherWebex, other, oldGet, read, _t41, _t42, _t43, _t44;
|
|
2647
|
+
return _regenerator.default.wrap(function (_context51) {
|
|
2648
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
2649
|
+
case 0:
|
|
2650
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2651
|
+
other = createCallQueueClient(otherWebex, {
|
|
2652
|
+
level: _types.LOGGER.INFO
|
|
2653
|
+
}, TEST_OPTIONS);
|
|
2654
|
+
oldGet = deferredResponse();
|
|
2655
|
+
otherWebex.request.mockReturnValueOnce(oldGet.promise).mockResolvedValueOnce({
|
|
2656
|
+
statusCode: 200,
|
|
2657
|
+
body: {
|
|
2658
|
+
agentACDState: 'UNAVAILABLE',
|
|
2659
|
+
queues: []
|
|
2660
|
+
}
|
|
2661
|
+
});
|
|
2662
|
+
read = other.getCallQueueSettings();
|
|
2663
|
+
_context51.next = 1;
|
|
2664
|
+
return other.getCallQueueSettings();
|
|
2665
|
+
case 1:
|
|
2666
|
+
oldGet.resolve({
|
|
2667
|
+
statusCode: 200,
|
|
2668
|
+
body: {
|
|
2669
|
+
agentACDState: 'AVAILABLE',
|
|
2670
|
+
queues: []
|
|
2671
|
+
}
|
|
2672
|
+
});
|
|
2673
|
+
_t41 = expect;
|
|
2674
|
+
_context51.next = 2;
|
|
2675
|
+
return read;
|
|
2676
|
+
case 2:
|
|
2677
|
+
_t43 = _yield$read$data$call2 = _context51.sent.data.callQueue;
|
|
2678
|
+
_t42 = _t43 === null;
|
|
2679
|
+
if (_t42) {
|
|
2680
|
+
_context51.next = 3;
|
|
2681
|
+
break;
|
|
2682
|
+
}
|
|
2683
|
+
_t42 = _yield$read$data$call2 === void 0;
|
|
2684
|
+
case 3:
|
|
2685
|
+
if (!_t42) {
|
|
2686
|
+
_context51.next = 4;
|
|
2687
|
+
break;
|
|
2688
|
+
}
|
|
2689
|
+
_t44 = void 0;
|
|
2690
|
+
_context51.next = 5;
|
|
2691
|
+
break;
|
|
2692
|
+
case 4:
|
|
2693
|
+
_t44 = _yield$read$data$call2.acdState;
|
|
2694
|
+
case 5:
|
|
2695
|
+
_t41(_t44).toBe(_constants.ACD_STATE.UNAVAILABLE);
|
|
2696
|
+
other.dispose();
|
|
2697
|
+
case 6:
|
|
2698
|
+
case "end":
|
|
2699
|
+
return _context51.stop();
|
|
2700
|
+
}
|
|
2701
|
+
}, _callee51);
|
|
2702
|
+
})));
|
|
2703
|
+
it('refreshes after an update overlaps a Mercury event', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
|
|
2704
|
+
var _handlers$get10, _response$data$callQu1;
|
|
2705
|
+
var otherWebex, other, patch, update, handlers, response;
|
|
2706
|
+
return _regenerator.default.wrap(function (_context52) {
|
|
2707
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
2708
|
+
case 0:
|
|
2709
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2710
|
+
other = createCallQueueClient(otherWebex, {
|
|
2711
|
+
level: _types.LOGGER.INFO
|
|
2712
|
+
}, TEST_OPTIONS);
|
|
2713
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2714
|
+
statusCode: 200,
|
|
2715
|
+
body: {
|
|
2716
|
+
agentACDState: 'AVAILABLE',
|
|
2717
|
+
queues: []
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
_context52.next = 1;
|
|
2721
|
+
return other.getCallQueueSettings();
|
|
2722
|
+
case 1:
|
|
2723
|
+
patch = deferredResponse();
|
|
2724
|
+
otherWebex.request.mockReturnValueOnce(patch.promise).mockResolvedValueOnce({
|
|
2725
|
+
statusCode: 200,
|
|
2726
|
+
body: {
|
|
2727
|
+
agentACDState: 'WRAP_UP',
|
|
2728
|
+
queues: []
|
|
2729
|
+
}
|
|
2730
|
+
});
|
|
2731
|
+
update = other.updateCallQueueSettings({
|
|
2732
|
+
agentACDState: _constants.ACD_STATE.WRAP_UP
|
|
2733
|
+
});
|
|
2734
|
+
handlers = new _map.default(otherWebex.internal.mercury.on.mock.calls.map(function (call) {
|
|
2735
|
+
return [call[0], call[1]];
|
|
2736
|
+
}));
|
|
2737
|
+
(_handlers$get10 = handlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE)) === null || _handlers$get10 === void 0 ? void 0 : _handlers$get10({
|
|
2738
|
+
data: {
|
|
2739
|
+
actorType: 'PERSON',
|
|
2740
|
+
actorId: otherWebex.internal.device.userId,
|
|
2741
|
+
state: 'unavailable'
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
patch.resolve({
|
|
2745
|
+
statusCode: 204
|
|
2746
|
+
});
|
|
2747
|
+
_context52.next = 2;
|
|
2748
|
+
return update;
|
|
2749
|
+
case 2:
|
|
2750
|
+
response = _context52.sent;
|
|
2751
|
+
expect(response.statusCode).toBe(204);
|
|
2752
|
+
expect((_response$data$callQu1 = response.data.callQueue) === null || _response$data$callQu1 === void 0 ? void 0 : _response$data$callQu1.acdState).toBe(_constants.ACD_STATE.WRAP_UP);
|
|
2753
|
+
expect(otherWebex.request).toHaveBeenCalledTimes(3);
|
|
2754
|
+
other.dispose();
|
|
2755
|
+
case 3:
|
|
2756
|
+
case "end":
|
|
2757
|
+
return _context52.stop();
|
|
2758
|
+
}
|
|
2759
|
+
}, _callee52);
|
|
2760
|
+
})));
|
|
2761
|
+
it('fails safely when the first GET has no agent state', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53() {
|
|
2762
|
+
var otherWebex, other, response;
|
|
2763
|
+
return _regenerator.default.wrap(function (_context53) {
|
|
2764
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
2765
|
+
case 0:
|
|
2766
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2767
|
+
other = createCallQueueClient(otherWebex, {
|
|
2768
|
+
level: _types.LOGGER.INFO
|
|
2769
|
+
}, TEST_OPTIONS);
|
|
2770
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2771
|
+
statusCode: 200,
|
|
2772
|
+
body: {
|
|
2773
|
+
queues: [{
|
|
2774
|
+
id: 'q1',
|
|
2775
|
+
name: 'Sales',
|
|
2776
|
+
available: true
|
|
2777
|
+
}]
|
|
2778
|
+
}
|
|
2779
|
+
});
|
|
2780
|
+
_context53.next = 1;
|
|
2781
|
+
return other.getCallQueueSettings();
|
|
2782
|
+
case 1:
|
|
2783
|
+
response = _context53.sent;
|
|
2784
|
+
expect(response.statusCode).toBe(502);
|
|
2785
|
+
expect(response.data.callQueue).toBeUndefined();
|
|
2786
|
+
other.dispose();
|
|
2787
|
+
case 2:
|
|
2788
|
+
case "end":
|
|
2789
|
+
return _context53.stop();
|
|
2790
|
+
}
|
|
2791
|
+
}, _callee53);
|
|
2792
|
+
})));
|
|
2793
|
+
it('rejects a malformed GET queue list without replacing cached settings', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
|
|
2794
|
+
var _refreshed$data$callQ;
|
|
2795
|
+
var otherWebex, other, rejected, refreshed;
|
|
2796
|
+
return _regenerator.default.wrap(function (_context54) {
|
|
2797
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
2798
|
+
case 0:
|
|
2799
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2800
|
+
other = createCallQueueClient(otherWebex, {
|
|
2801
|
+
level: _types.LOGGER.INFO
|
|
2802
|
+
}, TEST_OPTIONS);
|
|
2803
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2804
|
+
statusCode: 200,
|
|
2805
|
+
body: {
|
|
2806
|
+
agentACDState: 'AVAILABLE',
|
|
2807
|
+
queues: [{
|
|
2808
|
+
id: 'q1',
|
|
2809
|
+
name: 'Sales',
|
|
2810
|
+
available: true
|
|
2811
|
+
}]
|
|
2812
|
+
}
|
|
2813
|
+
}).mockResolvedValueOnce({
|
|
2814
|
+
statusCode: 200,
|
|
2815
|
+
body: {
|
|
2816
|
+
agentACDState: 'UNAVAILABLE',
|
|
2817
|
+
queues: [{
|
|
2818
|
+
name: 'Missing id'
|
|
2819
|
+
}]
|
|
2820
|
+
}
|
|
2821
|
+
}).mockResolvedValueOnce({
|
|
2822
|
+
statusCode: 200,
|
|
2823
|
+
body: {
|
|
2824
|
+
agentACDState: 'UNAVAILABLE'
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
_context54.next = 1;
|
|
2828
|
+
return other.getCallQueueSettings();
|
|
2829
|
+
case 1:
|
|
2830
|
+
_context54.next = 2;
|
|
2831
|
+
return other.getCallQueueSettings();
|
|
2832
|
+
case 2:
|
|
2833
|
+
rejected = _context54.sent;
|
|
2834
|
+
_testHelperChai.assert.equal(rejected.statusCode, 502);
|
|
2835
|
+
_testHelperChai.assert.isUndefined(rejected.data.callQueue);
|
|
2836
|
+
_context54.next = 3;
|
|
2837
|
+
return other.getCallQueueSettings();
|
|
2838
|
+
case 3:
|
|
2839
|
+
refreshed = _context54.sent;
|
|
2840
|
+
_testHelperChai.assert.deepEqual((_refreshed$data$callQ = refreshed.data.callQueue) === null || _refreshed$data$callQ === void 0 ? void 0 : _refreshed$data$callQ.queues, [{
|
|
2841
|
+
id: 'q1',
|
|
2842
|
+
name: 'Sales',
|
|
2843
|
+
available: true
|
|
2844
|
+
}]);
|
|
2845
|
+
other.dispose();
|
|
2846
|
+
case 4:
|
|
2847
|
+
case "end":
|
|
2848
|
+
return _context54.stop();
|
|
2849
|
+
}
|
|
2850
|
+
}, _callee54);
|
|
2851
|
+
})));
|
|
2852
|
+
it.each([true, false])('refreshes after a malformed PUT settings body (refresh valid: %s)', /*#__PURE__*/function () {
|
|
2853
|
+
var _ref64 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55(refreshValid) {
|
|
2854
|
+
var otherWebex, other, response, _response$data$callQu10, _response$data$callQu11;
|
|
2855
|
+
return _regenerator.default.wrap(function (_context55) {
|
|
2856
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
2857
|
+
case 0:
|
|
2858
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2859
|
+
other = createCallQueueClient(otherWebex, {
|
|
2860
|
+
level: _types.LOGGER.INFO
|
|
2861
|
+
}, TEST_OPTIONS);
|
|
2862
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2863
|
+
statusCode: 200,
|
|
2864
|
+
body: {
|
|
2865
|
+
agentACDState: 'AVAILABLE',
|
|
2866
|
+
queues: [{
|
|
2867
|
+
id: 'q1',
|
|
2868
|
+
name: 'Sales'
|
|
2869
|
+
}]
|
|
2870
|
+
}
|
|
2871
|
+
}).mockResolvedValueOnce({
|
|
2872
|
+
statusCode: 200,
|
|
2873
|
+
body: {
|
|
2874
|
+
agentACDState: 'AVAILABLE',
|
|
2875
|
+
queues: [{
|
|
2876
|
+
name: 'Missing id'
|
|
2877
|
+
}]
|
|
2878
|
+
}
|
|
2879
|
+
}).mockResolvedValueOnce({
|
|
2880
|
+
statusCode: 200,
|
|
2881
|
+
body: refreshValid ? {
|
|
2882
|
+
agentACDState: 'UNAVAILABLE',
|
|
2883
|
+
queues: [{
|
|
2884
|
+
id: 'q2',
|
|
2885
|
+
name: 'Support'
|
|
2886
|
+
}]
|
|
2887
|
+
} : {
|
|
2888
|
+
agentACDState: 'UNAVAILABLE',
|
|
2889
|
+
queues: [{
|
|
2890
|
+
name: 'Missing id'
|
|
2891
|
+
}]
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2894
|
+
_context55.next = 1;
|
|
2895
|
+
return other.getCallQueueSettings();
|
|
2896
|
+
case 1:
|
|
2897
|
+
_context55.next = 2;
|
|
2898
|
+
return other.updateCallQueueSettings({
|
|
2899
|
+
agentACDState: _constants.ACD_STATE.UNAVAILABLE
|
|
2900
|
+
});
|
|
2901
|
+
case 2:
|
|
2902
|
+
response = _context55.sent;
|
|
2903
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 3);
|
|
2904
|
+
if (refreshValid) {
|
|
2905
|
+
_testHelperChai.assert.equal(response.statusCode, 200);
|
|
2906
|
+
_testHelperChai.assert.equal((_response$data$callQu10 = response.data.callQueue) === null || _response$data$callQu10 === void 0 ? void 0 : _response$data$callQu10.acdState, _constants.ACD_STATE.UNAVAILABLE);
|
|
2907
|
+
_testHelperChai.assert.deepEqual((_response$data$callQu11 = response.data.callQueue) === null || _response$data$callQu11 === void 0 ? void 0 : _response$data$callQu11.queues, [{
|
|
2908
|
+
id: 'q2',
|
|
2909
|
+
name: 'Support'
|
|
2910
|
+
}]);
|
|
2911
|
+
} else {
|
|
2912
|
+
_testHelperChai.assert.equal(response.statusCode, 502);
|
|
2913
|
+
_testHelperChai.assert.isUndefined(response.data.callQueue);
|
|
2914
|
+
}
|
|
2915
|
+
other.dispose();
|
|
2916
|
+
case 3:
|
|
2917
|
+
case "end":
|
|
2918
|
+
return _context55.stop();
|
|
2919
|
+
}
|
|
2920
|
+
}, _callee55);
|
|
2921
|
+
}));
|
|
2922
|
+
return function (_x26) {
|
|
2923
|
+
return _ref64.apply(this, arguments);
|
|
2924
|
+
};
|
|
2925
|
+
}());
|
|
2926
|
+
it.each([['non-settings body', {
|
|
2927
|
+
status: 'ok'
|
|
2928
|
+
}], ['malformed state with null queues', {
|
|
2929
|
+
agentACDState: 'unknown',
|
|
2930
|
+
queues: null
|
|
2931
|
+
}], ['no body', undefined]])('keeps the local update fallback for a %s', /*#__PURE__*/function () {
|
|
2932
|
+
var _ref65 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56(_, body) {
|
|
2933
|
+
var _response$data$callQu12;
|
|
2934
|
+
var otherWebex, other, response;
|
|
2935
|
+
return _regenerator.default.wrap(function (_context56) {
|
|
2936
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
2937
|
+
case 0:
|
|
2938
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2939
|
+
other = createCallQueueClient(otherWebex, {
|
|
2940
|
+
level: _types.LOGGER.INFO
|
|
2941
|
+
}, TEST_OPTIONS);
|
|
2942
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2943
|
+
statusCode: 200,
|
|
2944
|
+
body: {
|
|
2945
|
+
agentACDState: 'AVAILABLE',
|
|
2946
|
+
queues: [{
|
|
2947
|
+
id: 'q1',
|
|
2948
|
+
name: 'Sales'
|
|
2949
|
+
}]
|
|
2950
|
+
}
|
|
2951
|
+
}).mockResolvedValueOnce({
|
|
2952
|
+
statusCode: 200,
|
|
2953
|
+
body: body
|
|
2954
|
+
});
|
|
2955
|
+
_context56.next = 1;
|
|
2956
|
+
return other.getCallQueueSettings();
|
|
2957
|
+
case 1:
|
|
2958
|
+
_context56.next = 2;
|
|
2959
|
+
return other.updateCallQueueSettings({
|
|
2960
|
+
agentACDState: _constants.ACD_STATE.UNAVAILABLE
|
|
2961
|
+
});
|
|
2962
|
+
case 2:
|
|
2963
|
+
response = _context56.sent;
|
|
2964
|
+
_testHelperChai.assert.equal(response.statusCode, 200);
|
|
2965
|
+
_testHelperChai.assert.equal((_response$data$callQu12 = response.data.callQueue) === null || _response$data$callQu12 === void 0 ? void 0 : _response$data$callQu12.acdState, _constants.ACD_STATE.UNAVAILABLE);
|
|
2966
|
+
_testHelperChai.assert.lengthOf(otherWebex.request.mock.calls, 2);
|
|
2967
|
+
other.dispose();
|
|
2968
|
+
case 3:
|
|
2969
|
+
case "end":
|
|
2970
|
+
return _context56.stop();
|
|
2971
|
+
}
|
|
2972
|
+
}, _callee56);
|
|
2973
|
+
}));
|
|
2974
|
+
return function (_x27, _x28) {
|
|
2975
|
+
return _ref65.apply(this, arguments);
|
|
2976
|
+
};
|
|
2977
|
+
}());
|
|
2978
|
+
it('loads settings after a queue-only update with no cached state', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57() {
|
|
2979
|
+
var _response$data$callQu13;
|
|
2980
|
+
var otherWebex, other, response;
|
|
2981
|
+
return _regenerator.default.wrap(function (_context57) {
|
|
2982
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
2983
|
+
case 0:
|
|
2984
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
2985
|
+
other = createCallQueueClient(otherWebex, {
|
|
2986
|
+
level: _types.LOGGER.INFO
|
|
2987
|
+
}, TEST_OPTIONS);
|
|
2988
|
+
otherWebex.request.mockResolvedValueOnce({
|
|
2989
|
+
statusCode: 204
|
|
2990
|
+
}).mockResolvedValueOnce({
|
|
2991
|
+
statusCode: 200,
|
|
2992
|
+
body: {
|
|
2993
|
+
agentACDState: 'UNAVAILABLE',
|
|
2994
|
+
queues: [{
|
|
2995
|
+
id: 'q1',
|
|
2996
|
+
name: 'Sales',
|
|
2997
|
+
available: true
|
|
2998
|
+
}]
|
|
2999
|
+
}
|
|
3000
|
+
});
|
|
3001
|
+
_context57.next = 1;
|
|
3002
|
+
return other.updateCallQueueSettings({
|
|
3003
|
+
queues: [{
|
|
3004
|
+
id: 'q1',
|
|
3005
|
+
available: true
|
|
3006
|
+
}]
|
|
3007
|
+
});
|
|
3008
|
+
case 1:
|
|
3009
|
+
response = _context57.sent;
|
|
3010
|
+
expect(response.statusCode).toBe(204);
|
|
3011
|
+
expect((_response$data$callQu13 = response.data.callQueue) === null || _response$data$callQu13 === void 0 ? void 0 : _response$data$callQu13.acdState).toBe(_constants.ACD_STATE.UNAVAILABLE);
|
|
3012
|
+
expect(otherWebex.request).toHaveBeenCalledTimes(2);
|
|
3013
|
+
other.dispose();
|
|
3014
|
+
case 2:
|
|
3015
|
+
case "end":
|
|
3016
|
+
return _context57.stop();
|
|
3017
|
+
}
|
|
3018
|
+
}, _callee57);
|
|
3019
|
+
})));
|
|
3020
|
+
it('uses the bound Webex instance and unregisters only its queue listeners on disposal', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58() {
|
|
3021
|
+
var otherWebex, other;
|
|
3022
|
+
return _regenerator.default.wrap(function (_context58) {
|
|
3023
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
3024
|
+
case 0:
|
|
3025
|
+
otherWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
3026
|
+
other = createCallQueueClient(otherWebex, {
|
|
3027
|
+
level: _types.LOGGER.INFO
|
|
3028
|
+
}, TEST_OPTIONS);
|
|
3029
|
+
otherWebex.request.mockResolvedValue({
|
|
3030
|
+
statusCode: 200,
|
|
3031
|
+
body: {
|
|
3032
|
+
agentACDState: 'AVAILABLE',
|
|
3033
|
+
queues: []
|
|
3034
|
+
}
|
|
3035
|
+
});
|
|
3036
|
+
_context58.next = 1;
|
|
3037
|
+
return other.getCallQueueSettings();
|
|
3038
|
+
case 1:
|
|
3039
|
+
expect(otherWebex.request).toHaveBeenCalledTimes(1);
|
|
3040
|
+
expect(webex.request).not.toHaveBeenCalled();
|
|
3041
|
+
other.dispose();
|
|
3042
|
+
expect(otherWebex.internal.mercury.off.mock.calls).toEqual(otherWebex.internal.mercury.on.mock.calls);
|
|
3043
|
+
expect(webex.internal.mercury.off).not.toHaveBeenCalled();
|
|
3044
|
+
case 2:
|
|
3045
|
+
case "end":
|
|
3046
|
+
return _context58.stop();
|
|
3047
|
+
}
|
|
3048
|
+
}, _callee58);
|
|
3049
|
+
})));
|
|
3050
|
+
it('rejects a Webex instance different from the one bound to SDKConnector', function () {
|
|
3051
|
+
jest.mocked(_SDKConnector.default.getWebex).mockReturnValue(webex);
|
|
3052
|
+
expect(function () {
|
|
3053
|
+
return (0, _CallQueue.createCallQueueClient)((0, _testUtil.getTestUtilsWebex)(), {
|
|
3054
|
+
level: _types.LOGGER.INFO
|
|
3055
|
+
}, TEST_OPTIONS);
|
|
3056
|
+
}).toThrow('Call queue Webex instance must match the SDKConnector instance');
|
|
3057
|
+
});
|
|
3058
|
+
it('keeps other subscribers receiving events when one queue client is disposed', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59() {
|
|
3059
|
+
var boundWebex, mercury, first, second, unrelated, observed;
|
|
3060
|
+
return _regenerator.default.wrap(function (_context59) {
|
|
3061
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
3062
|
+
case 0:
|
|
3063
|
+
boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
3064
|
+
mercury = new _events.EventEmitter();
|
|
3065
|
+
boundWebex.internal.mercury.on.mockImplementation(function (event, handler) {
|
|
3066
|
+
mercury.on(event, handler);
|
|
3067
|
+
});
|
|
3068
|
+
boundWebex.internal.mercury.off.mockImplementation(function (event, handler) {
|
|
3069
|
+
mercury.off(event, handler);
|
|
3070
|
+
});
|
|
3071
|
+
first = createCallQueueClient(boundWebex, {
|
|
3072
|
+
level: _types.LOGGER.INFO
|
|
3073
|
+
}, TEST_OPTIONS);
|
|
3074
|
+
second = createCallQueueClient(boundWebex, {
|
|
3075
|
+
level: _types.LOGGER.INFO
|
|
3076
|
+
}, TEST_OPTIONS);
|
|
3077
|
+
boundWebex.request.mockResolvedValue({
|
|
3078
|
+
statusCode: 200,
|
|
3079
|
+
body: {
|
|
3080
|
+
agentACDState: 'UNAVAILABLE',
|
|
3081
|
+
queues: []
|
|
3082
|
+
}
|
|
3083
|
+
});
|
|
3084
|
+
_context59.next = 1;
|
|
3085
|
+
return second.getCallQueueSettings();
|
|
3086
|
+
case 1:
|
|
3087
|
+
unrelated = jest.fn();
|
|
3088
|
+
observed = jest.fn();
|
|
3089
|
+
mercury.on(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE, unrelated);
|
|
3090
|
+
second.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, observed);
|
|
3091
|
+
first.dispose();
|
|
3092
|
+
mercury.emit(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE, {
|
|
3093
|
+
data: {
|
|
3094
|
+
agentACDState: 'AVAILABLE',
|
|
3095
|
+
queues: []
|
|
3096
|
+
}
|
|
3097
|
+
});
|
|
3098
|
+
expect(unrelated).toHaveBeenCalledTimes(1);
|
|
3099
|
+
expect(observed).toHaveBeenCalledTimes(1);
|
|
3100
|
+
second.dispose();
|
|
3101
|
+
case 2:
|
|
3102
|
+
case "end":
|
|
3103
|
+
return _context59.stop();
|
|
3104
|
+
}
|
|
3105
|
+
}, _callee59);
|
|
3106
|
+
})));
|
|
3107
|
+
it('emits the merged status when a Mercury state event arrives', function () {
|
|
3108
|
+
var publicClient = client;
|
|
3109
|
+
var listener = jest.fn();
|
|
3110
|
+
publicClient.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
3111
|
+
var stateHandler = mercuryHandlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_STATE);
|
|
3112
|
+
stateHandler === null || stateHandler === void 0 ? void 0 : stateHandler({
|
|
3113
|
+
data: {
|
|
3114
|
+
acdStateInfo: {
|
|
3115
|
+
state: 'unavailable'
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
});
|
|
3119
|
+
expect(listener).toHaveBeenCalledWith(expect.objectContaining({
|
|
3120
|
+
acdState: _constants.ACD_STATE.UNAVAILABLE
|
|
3121
|
+
}));
|
|
3122
|
+
publicClient.off(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
3123
|
+
listener.mockClear();
|
|
3124
|
+
stateHandler === null || stateHandler === void 0 ? void 0 : stateHandler({
|
|
3125
|
+
data: {
|
|
3126
|
+
acdStateInfo: {
|
|
3127
|
+
state: 'available'
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3131
|
+
expect(listener).not.toHaveBeenCalled();
|
|
3132
|
+
});
|
|
3133
|
+
it('emits the full queue snapshot when a Mercury sync event arrives', function () {
|
|
3134
|
+
var listener = jest.fn();
|
|
3135
|
+
client.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
3136
|
+
var syncHandler = mercuryHandlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_SYNC);
|
|
3137
|
+
syncHandler === null || syncHandler === void 0 ? void 0 : syncHandler({
|
|
3138
|
+
data: {
|
|
3139
|
+
agentACDState: 'available',
|
|
3140
|
+
queues: [{
|
|
3141
|
+
id: 'sync-queue',
|
|
3142
|
+
name: 'Sync queue',
|
|
3143
|
+
available: true
|
|
3144
|
+
}]
|
|
3145
|
+
}
|
|
3146
|
+
});
|
|
3147
|
+
expect(listener).toHaveBeenCalledWith({
|
|
3148
|
+
acdState: _constants.ACD_STATE.AVAILABLE,
|
|
3149
|
+
queues: [{
|
|
3150
|
+
id: 'sync-queue',
|
|
3151
|
+
name: 'Sync queue',
|
|
3152
|
+
available: true
|
|
3153
|
+
}]
|
|
3154
|
+
});
|
|
3155
|
+
client.off(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
3156
|
+
});
|
|
3157
|
+
it('emits the queue membership change when a Mercury join event arrives', function () {
|
|
3158
|
+
var listener = jest.fn();
|
|
3159
|
+
client.on(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
3160
|
+
var joinHandler = mercuryHandlers.get(_constants.CALL_QUEUE_MERCURY_EVENT_KEYS.TELEPHONY_AGENT_JOIN);
|
|
3161
|
+
joinHandler === null || joinHandler === void 0 ? void 0 : joinHandler({
|
|
3162
|
+
data: {
|
|
3163
|
+
queues: [{
|
|
3164
|
+
id: 'joined-queue',
|
|
3165
|
+
name: 'Joined queue',
|
|
3166
|
+
available: true
|
|
3167
|
+
}]
|
|
3168
|
+
}
|
|
3169
|
+
});
|
|
3170
|
+
expect(listener).toHaveBeenCalledWith(expect.objectContaining({
|
|
3171
|
+
queues: expect.arrayContaining([expect.objectContaining({
|
|
3172
|
+
id: 'joined-queue',
|
|
3173
|
+
name: 'Joined queue',
|
|
3174
|
+
available: true
|
|
3175
|
+
})])
|
|
3176
|
+
}));
|
|
3177
|
+
client.off(_types3.COMMON_EVENT_KEYS.CALL_QUEUE_UPDATED, listener);
|
|
3178
|
+
});
|
|
3179
|
+
it('returns the service error when the settings request fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60() {
|
|
3180
|
+
var response;
|
|
3181
|
+
return _regenerator.default.wrap(function (_context60) {
|
|
3182
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
3183
|
+
case 0:
|
|
3184
|
+
webex.request.mockRejectedValue({
|
|
3185
|
+
statusCode: 401
|
|
3186
|
+
});
|
|
3187
|
+
_context60.next = 1;
|
|
3188
|
+
return client.getCallQueueSettings();
|
|
3189
|
+
case 1:
|
|
3190
|
+
response = _context60.sent;
|
|
3191
|
+
expect(response.statusCode).toBe(401);
|
|
3192
|
+
expect(response.message).toBe('FAILURE');
|
|
3193
|
+
case 2:
|
|
3194
|
+
case "end":
|
|
3195
|
+
return _context60.stop();
|
|
3196
|
+
}
|
|
3197
|
+
}, _callee60);
|
|
3198
|
+
})));
|
|
3199
|
+
it.each([['read settings', function () {
|
|
3200
|
+
return client.getCallQueueSettings();
|
|
3201
|
+
}], ['update settings', function () {
|
|
3202
|
+
return client.updateCallQueueSettings({
|
|
3203
|
+
agentACDState: _constants.ACD_STATE.AVAILABLE
|
|
3204
|
+
});
|
|
3205
|
+
}], ['sync events', function () {
|
|
3206
|
+
return client.syncTelephonyCalls();
|
|
3207
|
+
}]])('returns the original service failure when log upload fails during %s', /*#__PURE__*/function () {
|
|
3208
|
+
var _ref70 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61(_, request) {
|
|
3209
|
+
var response;
|
|
3210
|
+
return _regenerator.default.wrap(function (_context61) {
|
|
3211
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
3212
|
+
case 0:
|
|
3213
|
+
webex.request.mockRejectedValue({
|
|
3214
|
+
statusCode: 401
|
|
3215
|
+
});
|
|
3216
|
+
jest.spyOn(utils, 'uploadLogs').mockRejectedValueOnce(new Error('Log upload failed'));
|
|
3217
|
+
_context61.next = 1;
|
|
3218
|
+
return request();
|
|
3219
|
+
case 1:
|
|
3220
|
+
response = _context61.sent;
|
|
3221
|
+
expect(webex.request).toHaveBeenCalledTimes(1);
|
|
3222
|
+
expect(utils.uploadLogs).toHaveBeenCalledTimes(1);
|
|
3223
|
+
expect(response).toEqual({
|
|
3224
|
+
statusCode: 401,
|
|
3225
|
+
data: {
|
|
3226
|
+
error: 'User is unauthorised, possible token expiry'
|
|
3227
|
+
},
|
|
3228
|
+
message: 'FAILURE'
|
|
3229
|
+
});
|
|
3230
|
+
case 2:
|
|
3231
|
+
case "end":
|
|
3232
|
+
return _context61.stop();
|
|
3233
|
+
}
|
|
3234
|
+
}, _callee61);
|
|
3235
|
+
}));
|
|
3236
|
+
return function (_x29, _x30) {
|
|
3237
|
+
return _ref70.apply(this, arguments);
|
|
3238
|
+
};
|
|
3239
|
+
}());
|
|
3240
|
+
it('returns a failure when a request rejects without an error', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62() {
|
|
3241
|
+
var response;
|
|
3242
|
+
return _regenerator.default.wrap(function (_context62) {
|
|
3243
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
3244
|
+
case 0:
|
|
3245
|
+
webex.request.mockRejectedValue(undefined);
|
|
3246
|
+
jest.spyOn(utils, 'uploadLogs').mockRejectedValueOnce(new Error('Log upload failed'));
|
|
3247
|
+
_context62.next = 1;
|
|
3248
|
+
return client.getCallQueueSettings();
|
|
3249
|
+
case 1:
|
|
3250
|
+
response = _context62.sent;
|
|
3251
|
+
expect(response).toEqual({
|
|
3252
|
+
statusCode: 422,
|
|
3253
|
+
data: {
|
|
3254
|
+
error: '422 Exception has occurred'
|
|
3255
|
+
},
|
|
3256
|
+
message: 'FAILURE'
|
|
3257
|
+
});
|
|
3258
|
+
case 2:
|
|
3259
|
+
case "end":
|
|
3260
|
+
return _context62.stop();
|
|
3261
|
+
}
|
|
3262
|
+
}, _callee62);
|
|
3263
|
+
})));
|
|
3264
|
+
});
|
|
3265
|
+
describe('managed call queue client factory', function () {
|
|
3266
|
+
var logger = {
|
|
3267
|
+
level: _types.LOGGER.INFO
|
|
3268
|
+
};
|
|
3269
|
+
afterEach(function () {
|
|
3270
|
+
_sinon.default.restore();
|
|
3271
|
+
jest.clearAllMocks();
|
|
3272
|
+
});
|
|
3273
|
+
it('reuses a client and disposes it when the queue feature is disabled', function () {
|
|
3274
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
3275
|
+
jest.mocked(_SDKConnector.default.getWebex).mockReturnValue(boundWebex);
|
|
3276
|
+
var first = (0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS, undefined, true);
|
|
3277
|
+
_testHelperChai.assert.isDefined(first);
|
|
3278
|
+
var reused = (0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS, first, true);
|
|
3279
|
+
_testHelperChai.assert.strictEqual(reused, first);
|
|
3280
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.on.mock.calls, 6);
|
|
3281
|
+
var disabled = (0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS, first, false);
|
|
3282
|
+
_testHelperChai.assert.isUndefined(disabled);
|
|
3283
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.off.mock.calls, 6);
|
|
3284
|
+
});
|
|
3285
|
+
it('does not create or register a client when initially disabled', function () {
|
|
3286
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
3287
|
+
jest.mocked(_SDKConnector.default.getWebex).mockReturnValue(boundWebex);
|
|
3288
|
+
_testHelperChai.assert.isUndefined((0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS, undefined, false));
|
|
3289
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.on.mock.calls, 0);
|
|
3290
|
+
});
|
|
3291
|
+
it('cleans up a previous client and isolates an initialization error', function () {
|
|
3292
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
3293
|
+
jest.mocked(_SDKConnector.default.getWebex).mockReturnValue(boundWebex);
|
|
3294
|
+
var previous = (0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS);
|
|
3295
|
+
_sinon.default.stub(previous, 'prepareForReuse').throws(new Error('Backend failed'));
|
|
3296
|
+
var result = (0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS, previous, true);
|
|
3297
|
+
_testHelperChai.assert.isUndefined(result);
|
|
3298
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.off.mock.calls, 6);
|
|
3299
|
+
});
|
|
3300
|
+
it('isolates a constructor failure and rolls back partial event subscriptions', function () {
|
|
3301
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
3302
|
+
jest.mocked(_SDKConnector.default.getWebex).mockReturnValue(boundWebex);
|
|
3303
|
+
boundWebex.internal.mercury.on.mockImplementationOnce(function () {
|
|
3304
|
+
throw new Error('Subscription failed');
|
|
3305
|
+
});
|
|
3306
|
+
var result = (0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS, undefined, true);
|
|
3307
|
+
_testHelperChai.assert.isUndefined(result);
|
|
3308
|
+
_testHelperChai.assert.lengthOf(boundWebex.internal.mercury.off.mock.calls, 1);
|
|
3309
|
+
});
|
|
3310
|
+
it('isolates disposal failures when disabling the client', function () {
|
|
3311
|
+
var boundWebex = (0, _testUtil.getTestUtilsWebex)();
|
|
3312
|
+
jest.mocked(_SDKConnector.default.getWebex).mockReturnValue(boundWebex);
|
|
3313
|
+
var previous = (0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS);
|
|
3314
|
+
var dispose = _sinon.default.stub(previous, 'dispose').throws(new Error('Cleanup failed'));
|
|
3315
|
+
_testHelperChai.assert.isUndefined((0, _CallQueue.createCallQueueClient)(boundWebex, logger, TEST_OPTIONS, previous, false));
|
|
3316
|
+
_testHelperChai.assert.calledTwice(dispose);
|
|
3317
|
+
dispose.restore();
|
|
3318
|
+
previous.dispose();
|
|
3319
|
+
});
|
|
3320
|
+
});
|
|
3321
|
+
//# sourceMappingURL=CallQueue.test.js.map
|