@webex/internal-plugin-conversation 3.0.0-beta.9 → 3.0.0-bnr.2
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 -3
- package/dist/activities.js +8 -69
- package/dist/activities.js.map +1 -1
- package/dist/activity-thread-ordering.js +19 -79
- package/dist/activity-thread-ordering.js.map +1 -1
- package/dist/config.js +1 -7
- package/dist/config.js.map +1 -1
- package/dist/constants.js +4 -5
- package/dist/constants.js.map +1 -1
- package/dist/conversation.js +790 -1199
- package/dist/conversation.js.map +1 -1
- package/dist/convo-error.js +0 -23
- package/dist/convo-error.js.map +1 -1
- package/dist/decryption-transforms.js +35 -98
- package/dist/decryption-transforms.js.map +1 -1
- package/dist/encryption-transforms.js +11 -48
- package/dist/encryption-transforms.js.map +1 -1
- package/dist/index.js +7 -50
- package/dist/index.js.map +1 -1
- package/dist/internal-plugin-conversation.d.ts +21 -0
- package/dist/share-activity.js +40 -106
- package/dist/share-activity.js.map +1 -1
- package/dist/to-array.js +9 -11
- package/dist/to-array.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/activities.d.ts +32 -0
- package/dist/types/activity-thread-ordering.d.ts +18 -0
- package/dist/types/config.d.ts +19 -0
- package/dist/types/constants.d.ts +5 -0
- package/dist/types/conversation.d.ts +2 -0
- package/dist/types/convo-error.d.ts +10 -0
- package/dist/types/decryption-transforms.d.ts +1 -0
- package/dist/types/encryption-transforms.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/share-activity.d.ts +7 -0
- package/dist/types/to-array.d.ts +9 -0
- package/package.json +15 -15
- package/src/activities.js +10 -7
- package/src/activity-thread-ordering.js +27 -30
- package/src/activity-threading.md +68 -49
- package/src/config.js +5 -5
- package/src/conversation.js +621 -589
- package/src/decryption-transforms.js +103 -62
- package/src/encryption-transforms.js +103 -83
- package/src/index.js +82 -66
- package/src/share-activity.js +64 -55
- package/src/to-array.js +2 -2
- package/test/integration/spec/create.js +184 -118
- package/test/integration/spec/encryption.js +250 -186
- package/test/integration/spec/get.js +761 -513
- package/test/integration/spec/mercury.js +37 -27
- package/test/integration/spec/share.js +292 -229
- package/test/integration/spec/verbs.js +628 -441
- package/test/unit/spec/conversation.js +265 -163
- package/test/unit/spec/decrypt-transforms.js +112 -131
- package/test/unit/spec/encryption-transforms.js +24 -18
- package/test/unit/spec/share-activity.js +37 -40
|
@@ -8,7 +8,13 @@ import sinon from 'sinon';
|
|
|
8
8
|
|
|
9
9
|
import Conversation from '@webex/internal-plugin-conversation';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
rootActivityManager,
|
|
13
|
+
getLoopCounterFailsafe,
|
|
14
|
+
noMoreActivitiesManager,
|
|
15
|
+
bookendManager,
|
|
16
|
+
activityManager,
|
|
17
|
+
} from '../../../src/activity-thread-ordering';
|
|
12
18
|
import {ACTIVITY_TYPES, getActivityType, OLDER, NEWER} from '../../../src/activities';
|
|
13
19
|
|
|
14
20
|
describe('plugin-conversation', () => {
|
|
@@ -20,8 +26,8 @@ describe('plugin-conversation', () => {
|
|
|
20
26
|
beforeEach(() => {
|
|
21
27
|
webex = new MockWebex({
|
|
22
28
|
children: {
|
|
23
|
-
conversation: Conversation
|
|
24
|
-
}
|
|
29
|
+
conversation: Conversation,
|
|
30
|
+
},
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
webex.internal.services = {};
|
|
@@ -29,6 +35,47 @@ describe('plugin-conversation', () => {
|
|
|
29
35
|
webex.internal.services.getServiceFromClusterId = sinon.stub().returns({url: convoUrl});
|
|
30
36
|
});
|
|
31
37
|
|
|
38
|
+
describe('addReaction()', () => {
|
|
39
|
+
it('should add recipients to the payload if provided', () => {
|
|
40
|
+
const {conversation} = webex.internal;
|
|
41
|
+
const recipientId = 'example-recipient-id';
|
|
42
|
+
const expected = {items: [{id: recipientId, objectType: 'person'}]}
|
|
43
|
+
conversation.sendReaction = sinon.stub().returns(Promise.resolve())
|
|
44
|
+
conversation.createReactionHmac = sinon.stub().returns(Promise.resolve('hmac'))
|
|
45
|
+
|
|
46
|
+
return conversation.addReaction({}, 'example-display-name', {}, recipientId)
|
|
47
|
+
.then(() => {
|
|
48
|
+
assert.deepEqual(conversation.sendReaction.args[0][1].recipients, expected);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('deleteReaction()', () => {
|
|
54
|
+
it('should add recipients to the payload if provided', () => {
|
|
55
|
+
const {conversation} = webex.internal;
|
|
56
|
+
const recipientId = 'example-recipient-id';
|
|
57
|
+
const expected = {items: [{id: recipientId, objectType: 'person'}]}
|
|
58
|
+
conversation.sendReaction = sinon.stub().returns(Promise.resolve())
|
|
59
|
+
|
|
60
|
+
return conversation.deleteReaction({}, 'example-reaction-id', recipientId)
|
|
61
|
+
.then(() => {
|
|
62
|
+
assert.deepEqual(conversation.sendReaction.args[0][1].recipients, expected);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('prepare()', () => {
|
|
68
|
+
it('should ammend activity recipients to the returned object', () => {
|
|
69
|
+
const {conversation} = webex.internal;
|
|
70
|
+
const activity = { recipients: 'example-recipients' };
|
|
71
|
+
|
|
72
|
+
return conversation.prepare(activity)
|
|
73
|
+
.then((results) => {
|
|
74
|
+
assert.deepEqual(results.recipients, activity.recipients);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
32
79
|
describe('processInmeetingchatEvent()', () => {
|
|
33
80
|
beforeEach(() => {
|
|
34
81
|
webex.transform = sinon.stub().callsFake((obj) => Promise.resolve(obj));
|
|
@@ -53,8 +100,8 @@ describe('plugin-conversation', () => {
|
|
|
53
100
|
describe('#_inferConversationUrl', () => {
|
|
54
101
|
const testConvo = {test: 'convo'};
|
|
55
102
|
|
|
56
|
-
it('Returns given convo if no id', () =>
|
|
57
|
-
.then((convo) => {
|
|
103
|
+
it('Returns given convo if no id', () =>
|
|
104
|
+
webex.internal.conversation._inferConversationUrl(testConvo).then((convo) => {
|
|
58
105
|
assert.notCalled(webex.internal.feature.getFeature);
|
|
59
106
|
assert.notCalled(webex.internal.services.get);
|
|
60
107
|
assert.equal(convo.test, 'convo');
|
|
@@ -68,22 +115,20 @@ describe('plugin-conversation', () => {
|
|
|
68
115
|
it('returns unmodified convo if URL is defined', () => {
|
|
69
116
|
testConvo.url = 'http://example.com';
|
|
70
117
|
|
|
71
|
-
return webex.internal.conversation._inferConversationUrl(testConvo)
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
118
|
+
return webex.internal.conversation._inferConversationUrl(testConvo).then((convo) => {
|
|
119
|
+
assert.called(webex.internal.feature.getFeature);
|
|
120
|
+
assert.notCalled(webex.internal.services.get);
|
|
121
|
+
assert.equal(convo.url, 'http://example.com');
|
|
122
|
+
});
|
|
77
123
|
});
|
|
78
124
|
it('builds URL if not defined', () => {
|
|
79
125
|
delete testConvo.url;
|
|
80
126
|
|
|
81
|
-
return webex.internal.conversation._inferConversationUrl(testConvo)
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
127
|
+
return webex.internal.conversation._inferConversationUrl(testConvo).then((convo) => {
|
|
128
|
+
assert.called(webex.internal.feature.getFeature);
|
|
129
|
+
assert.called(webex.internal.services.get);
|
|
130
|
+
assert.equal(convo.url, `${convoUrl}/conversations/id1`);
|
|
131
|
+
});
|
|
87
132
|
});
|
|
88
133
|
});
|
|
89
134
|
describe('HA is enabled', () => {
|
|
@@ -94,22 +139,20 @@ describe('plugin-conversation', () => {
|
|
|
94
139
|
it('builds URL if already defined', () => {
|
|
95
140
|
testConvo.url = 'https://example.com';
|
|
96
141
|
|
|
97
|
-
return webex.internal.conversation._inferConversationUrl(testConvo)
|
|
98
|
-
.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
142
|
+
return webex.internal.conversation._inferConversationUrl(testConvo).then((convo) => {
|
|
143
|
+
assert.called(webex.internal.feature.getFeature);
|
|
144
|
+
assert.called(webex.internal.services.get);
|
|
145
|
+
assert.equal(convo.url, `${convoUrl}/conversations/id1`);
|
|
146
|
+
});
|
|
103
147
|
});
|
|
104
148
|
it('builds URL if not defined', () => {
|
|
105
149
|
delete testConvo.url;
|
|
106
150
|
|
|
107
|
-
return webex.internal.conversation._inferConversationUrl(testConvo)
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
151
|
+
return webex.internal.conversation._inferConversationUrl(testConvo).then((convo) => {
|
|
152
|
+
assert.called(webex.internal.feature.getFeature);
|
|
153
|
+
assert.called(webex.internal.services.get);
|
|
154
|
+
assert.equal(convo.url, `${convoUrl}/conversations/id1`);
|
|
155
|
+
});
|
|
113
156
|
});
|
|
114
157
|
});
|
|
115
158
|
});
|
|
@@ -118,9 +161,11 @@ describe('plugin-conversation', () => {
|
|
|
118
161
|
it('should not return a promise', () => {
|
|
119
162
|
try {
|
|
120
163
|
webex.internal.conversation.getConvoUrl({url: 'convoUrl'}).then();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
164
|
+
} catch (error) {
|
|
165
|
+
assert.equal(
|
|
166
|
+
error.message,
|
|
167
|
+
'webex.internal.conversation.getConvoUrl(...).then is not a function'
|
|
168
|
+
);
|
|
124
169
|
}
|
|
125
170
|
});
|
|
126
171
|
|
|
@@ -135,13 +180,17 @@ describe('plugin-conversation', () => {
|
|
|
135
180
|
it('should convert a "us" cluster to WEBEX_CONVERSATION_DEFAULT_CLUSTER cluster', async () => {
|
|
136
181
|
await webex.internal.conversation.getUrlFromClusterId({cluster: 'us'});
|
|
137
182
|
|
|
138
|
-
sinon.assert.calledWith(webex.internal.services.getServiceFromClusterId, {
|
|
183
|
+
sinon.assert.calledWith(webex.internal.services.getServiceFromClusterId, {
|
|
184
|
+
clusterId: process.env.WEBEX_CONVERSATION_DEFAULT_CLUSTER,
|
|
185
|
+
});
|
|
139
186
|
});
|
|
140
187
|
|
|
141
188
|
it('should add the cluster service when missing', async () => {
|
|
142
189
|
await webex.internal.conversation.getUrlFromClusterId({cluster: 'urn:TEAM:us-west-2_r'});
|
|
143
190
|
|
|
144
|
-
sinon.assert.calledWith(webex.internal.services.getServiceFromClusterId, {
|
|
191
|
+
sinon.assert.calledWith(webex.internal.services.getServiceFromClusterId, {
|
|
192
|
+
clusterId: 'urn:TEAM:us-west-2_r:identityLookup',
|
|
193
|
+
});
|
|
145
194
|
});
|
|
146
195
|
});
|
|
147
196
|
|
|
@@ -149,8 +198,7 @@ describe('plugin-conversation', () => {
|
|
|
149
198
|
it('should throw an error if a page is passed with no links', () => {
|
|
150
199
|
try {
|
|
151
200
|
webex.internal.conversation.paginate({page: {}});
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
201
|
+
} catch (error) {
|
|
154
202
|
assert.equal(error.message, 'No link to follow for the provided page');
|
|
155
203
|
}
|
|
156
204
|
});
|
|
@@ -158,32 +206,40 @@ describe('plugin-conversation', () => {
|
|
|
158
206
|
|
|
159
207
|
describe('#getReactionSummaryByParentId()', () => {
|
|
160
208
|
beforeEach(() => {
|
|
161
|
-
webex.request = sinon.stub().returns(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
209
|
+
webex.request = sinon.stub().returns(
|
|
210
|
+
Promise.resolve({
|
|
211
|
+
body: {
|
|
212
|
+
children: [
|
|
213
|
+
{type: 'reactionSelfSummary'},
|
|
214
|
+
{type: 'reactionSelfSummary'},
|
|
215
|
+
{type: 'reactionSummary'},
|
|
216
|
+
{type: 'notAReaction'},
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
);
|
|
171
221
|
});
|
|
172
222
|
|
|
173
|
-
it('should call request', () =>
|
|
174
|
-
.then(() => {
|
|
223
|
+
it('should call request', () =>
|
|
224
|
+
webex.internal.conversation.getReactionSummaryByParentId(convoUrl, 'test-id').then(() => {
|
|
175
225
|
assert.called(webex.request);
|
|
176
226
|
}));
|
|
177
227
|
|
|
178
|
-
it('should not retrieve non reaction summary objects', () =>
|
|
179
|
-
.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
228
|
+
it('should not retrieve non reaction summary objects', () =>
|
|
229
|
+
webex.internal.conversation
|
|
230
|
+
.getReactionSummaryByParentId(convoUrl, 'test-id')
|
|
231
|
+
.then((result) => {
|
|
232
|
+
assert.equal(result.length, 3);
|
|
233
|
+
assert.notInclude(result, {type: 'notAReaction'});
|
|
234
|
+
}));
|
|
183
235
|
});
|
|
184
236
|
|
|
185
237
|
describe('#listAllChildActivitiesByParentId()', () => {
|
|
186
|
-
const options = {
|
|
238
|
+
const options = {
|
|
239
|
+
conversationUrl: convoUrl,
|
|
240
|
+
activityParentId: '123-abc',
|
|
241
|
+
query: {activityType: 'reply'},
|
|
242
|
+
};
|
|
187
243
|
let dayCount = 0;
|
|
188
244
|
const createActivityItemBatch = (itemCount) => {
|
|
189
245
|
const counter = [...Array(itemCount).keys()];
|
|
@@ -191,54 +247,58 @@ describe('plugin-conversation', () => {
|
|
|
191
247
|
dayCount += 1;
|
|
192
248
|
|
|
193
249
|
return counter.map((n) => ({
|
|
194
|
-
published: new Date(2020, 0, 1, dayCount, n)
|
|
250
|
+
published: new Date(2020, 0, 1, dayCount, n),
|
|
195
251
|
}));
|
|
196
252
|
};
|
|
197
253
|
|
|
198
254
|
const createMockChildResponse = (itemsToReturn = 10) => {
|
|
199
255
|
const response = {
|
|
200
256
|
body: {
|
|
201
|
-
items: createActivityItemBatch(itemsToReturn)
|
|
257
|
+
items: createActivityItemBatch(itemsToReturn),
|
|
202
258
|
},
|
|
203
259
|
headers: {
|
|
204
|
-
link: '<https://www.cisco.com>; rel=next'
|
|
205
|
-
}
|
|
260
|
+
link: '<https://www.cisco.com>; rel=next',
|
|
261
|
+
},
|
|
206
262
|
};
|
|
207
263
|
|
|
208
264
|
return response;
|
|
209
265
|
};
|
|
210
266
|
|
|
211
267
|
beforeEach(() => {
|
|
212
|
-
webex.request = sinon
|
|
268
|
+
webex.request = sinon
|
|
269
|
+
.stub()
|
|
213
270
|
.onCall(0)
|
|
214
271
|
.returns(Promise.resolve(createMockChildResponse()))
|
|
215
272
|
.onCall(1)
|
|
216
273
|
.returns(Promise.resolve(createMockChildResponse()))
|
|
217
274
|
.onCall(2)
|
|
218
275
|
.returns(Promise.resolve(createMockChildResponse(3)))
|
|
219
|
-
.returns(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
276
|
+
.returns(
|
|
277
|
+
Promise.resolve(
|
|
278
|
+
Promise.resolve({
|
|
279
|
+
body: {
|
|
280
|
+
items: [],
|
|
281
|
+
},
|
|
282
|
+
headers: {},
|
|
283
|
+
})
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
});
|
|
287
|
+
it('retrieves correct children count', () =>
|
|
288
|
+
webex.internal.conversation.listAllChildActivitiesByParentId(options).then((res) => {
|
|
228
289
|
assert.equal(res.length, 23);
|
|
229
290
|
}));
|
|
230
291
|
|
|
231
292
|
it('calls #listChildActivitiesByParentId() to initiate the request', () => {
|
|
232
293
|
const spy = sinon.spy(webex.internal.conversation, 'listChildActivitiesByParentId');
|
|
233
294
|
|
|
234
|
-
return webex.internal.conversation.listAllChildActivitiesByParentId(options)
|
|
235
|
-
.
|
|
236
|
-
|
|
237
|
-
});
|
|
295
|
+
return webex.internal.conversation.listAllChildActivitiesByParentId(options).then(() => {
|
|
296
|
+
assert(spy.calledOnce);
|
|
297
|
+
});
|
|
238
298
|
});
|
|
239
299
|
|
|
240
|
-
it('returns children in ascending published order', () =>
|
|
241
|
-
.then((res) => {
|
|
300
|
+
it('returns children in ascending published order', () =>
|
|
301
|
+
webex.internal.conversation.listAllChildActivitiesByParentId(options).then((res) => {
|
|
242
302
|
const firstMessageOlderThanLastMessage = res[0].published < res[res.length - 1].published;
|
|
243
303
|
|
|
244
304
|
assert.isTrue(firstMessageOlderThanLastMessage, 'activities out of order');
|
|
@@ -249,8 +309,7 @@ describe('plugin-conversation', () => {
|
|
|
249
309
|
it('should throw an error when called without a conversationUrl option', (done) => {
|
|
250
310
|
try {
|
|
251
311
|
webex.internal.conversation.listActivitiesThreadOrdered({});
|
|
252
|
-
}
|
|
253
|
-
catch (e) {
|
|
312
|
+
} catch (e) {
|
|
254
313
|
assert.equal(e.message, 'must provide a conversation URL or conversation ID');
|
|
255
314
|
done();
|
|
256
315
|
}
|
|
@@ -259,12 +318,17 @@ describe('plugin-conversation', () => {
|
|
|
259
318
|
it('calls #_listActivitiesThreadOrdered()', () => {
|
|
260
319
|
const spy = sinon.spy(webex.internal.conversation, '_listActivitiesThreadOrdered');
|
|
261
320
|
|
|
262
|
-
webex.internal.conversation.listActivitiesThreadOrdered({
|
|
321
|
+
webex.internal.conversation.listActivitiesThreadOrdered({
|
|
322
|
+
conversationUrl: convoUrl,
|
|
323
|
+
includeChildren: true,
|
|
324
|
+
});
|
|
263
325
|
sinon.assert.calledWith(spy, {url: convoUrl, includeChildren: true});
|
|
264
326
|
});
|
|
265
327
|
|
|
266
328
|
it('returns expected wrapped functions', () => {
|
|
267
|
-
const functions = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
329
|
+
const functions = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
330
|
+
conversationUrl: convoUrl,
|
|
331
|
+
});
|
|
268
332
|
|
|
269
333
|
assert.hasAllKeys(functions, ['jumpToActivity', 'getOlder', 'getNewer']);
|
|
270
334
|
});
|
|
@@ -275,16 +339,20 @@ describe('plugin-conversation', () => {
|
|
|
275
339
|
beforeEach(() => {
|
|
276
340
|
webex.internal.conversation._listActivitiesThreadOrdered = sinon.stub().returns({
|
|
277
341
|
next() {
|
|
278
|
-
return new Promise((resolve) =>
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
342
|
+
return new Promise((resolve) =>
|
|
343
|
+
resolve({
|
|
344
|
+
value: returnedVal,
|
|
345
|
+
next() {},
|
|
346
|
+
})
|
|
347
|
+
);
|
|
348
|
+
},
|
|
283
349
|
});
|
|
284
350
|
});
|
|
285
351
|
|
|
286
352
|
it('getOlder() should implement the iterator protocol', () => {
|
|
287
|
-
const {getOlder} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
353
|
+
const {getOlder} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
354
|
+
conversationUrl: convoUrl,
|
|
355
|
+
});
|
|
288
356
|
|
|
289
357
|
return getOlder().then((result) => {
|
|
290
358
|
assert.hasAllKeys(result, ['done', 'value']);
|
|
@@ -292,7 +360,9 @@ describe('plugin-conversation', () => {
|
|
|
292
360
|
});
|
|
293
361
|
|
|
294
362
|
it('getNewer() should implement the iterator protocol', () => {
|
|
295
|
-
const {getNewer} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
363
|
+
const {getNewer} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
364
|
+
conversationUrl: convoUrl,
|
|
365
|
+
});
|
|
296
366
|
|
|
297
367
|
return getNewer().then((result) => {
|
|
298
368
|
assert.hasAllKeys(result, ['done', 'value']);
|
|
@@ -301,29 +371,36 @@ describe('plugin-conversation', () => {
|
|
|
301
371
|
|
|
302
372
|
describe('jumpToActivity()', () => {
|
|
303
373
|
it('should throw an error if search object is missing', () => {
|
|
304
|
-
const {jumpToActivity} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
374
|
+
const {jumpToActivity} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
375
|
+
conversationUrl: convoUrl,
|
|
376
|
+
});
|
|
305
377
|
|
|
306
378
|
try {
|
|
307
379
|
jumpToActivity();
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
380
|
+
} catch (e) {
|
|
381
|
+
assert.equal(
|
|
382
|
+
e.message,
|
|
383
|
+
'Search must be an activity object from conversation service'
|
|
384
|
+
);
|
|
311
385
|
}
|
|
312
386
|
});
|
|
313
387
|
|
|
314
388
|
it('should throw an error if activity.target.url is missing', () => {
|
|
315
|
-
const {jumpToActivity} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
389
|
+
const {jumpToActivity} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
390
|
+
conversationUrl: convoUrl,
|
|
391
|
+
});
|
|
316
392
|
|
|
317
393
|
try {
|
|
318
394
|
assert.throws(jumpToActivity({target: null}));
|
|
319
|
-
}
|
|
320
|
-
catch (e) {
|
|
395
|
+
} catch (e) {
|
|
321
396
|
//
|
|
322
397
|
}
|
|
323
398
|
});
|
|
324
399
|
|
|
325
400
|
it('should implement the iterator protocol', () => {
|
|
326
|
-
const {jumpToActivity} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
401
|
+
const {jumpToActivity} = webex.internal.conversation.listActivitiesThreadOrdered({
|
|
402
|
+
conversationUrl: convoUrl,
|
|
403
|
+
});
|
|
327
404
|
|
|
328
405
|
return jumpToActivity({target: {url: 'newUrl'}}).then((result) => {
|
|
329
406
|
assert.hasAllKeys(result, ['done', 'value']);
|
|
@@ -336,8 +413,8 @@ describe('plugin-conversation', () => {
|
|
|
336
413
|
describe('activity-thread-ordering helpers', () => {
|
|
337
414
|
const createSimpleActivityByType = (type) => ({
|
|
338
415
|
parent: {
|
|
339
|
-
type
|
|
340
|
-
}
|
|
416
|
+
type,
|
|
417
|
+
},
|
|
341
418
|
});
|
|
342
419
|
|
|
343
420
|
describe('getActivityType', () => {
|
|
@@ -384,8 +461,7 @@ describe('plugin-conversation', () => {
|
|
|
384
461
|
externalCount += 1;
|
|
385
462
|
incrementLoop();
|
|
386
463
|
}
|
|
387
|
-
}
|
|
388
|
-
catch (e) {
|
|
464
|
+
} catch (e) {
|
|
389
465
|
assert.equal(e.message, 'max fetches reached');
|
|
390
466
|
}
|
|
391
467
|
});
|
|
@@ -404,11 +480,15 @@ describe('plugin-conversation', () => {
|
|
|
404
480
|
checkAndSetNoOlderActs = funcs.checkAndSetNoOlderActs;
|
|
405
481
|
});
|
|
406
482
|
|
|
407
|
-
|
|
408
483
|
it('should return expected exposed functions', () => {
|
|
409
484
|
const functions = noMoreActivitiesManager();
|
|
410
485
|
|
|
411
|
-
assert.hasAllKeys(functions, [
|
|
486
|
+
assert.hasAllKeys(functions, [
|
|
487
|
+
'getNoMoreActs',
|
|
488
|
+
'checkAndSetNoMoreActs',
|
|
489
|
+
'checkAndSetNoNewerActs',
|
|
490
|
+
'checkAndSetNoOlderActs',
|
|
491
|
+
]);
|
|
412
492
|
});
|
|
413
493
|
|
|
414
494
|
it('should set no more activities when no newer activities exist', () => {
|
|
@@ -465,7 +545,7 @@ describe('plugin-conversation', () => {
|
|
|
465
545
|
it('should set the oldest and newest activity in a batch', () => {
|
|
466
546
|
const acts = [
|
|
467
547
|
{published: createDateISO(1), order: 0},
|
|
468
|
-
{published: createDateISO(2), order: 1}
|
|
548
|
+
{published: createDateISO(2), order: 1},
|
|
469
549
|
];
|
|
470
550
|
|
|
471
551
|
setBookends(acts);
|
|
@@ -476,14 +556,14 @@ describe('plugin-conversation', () => {
|
|
|
476
556
|
it('should bookends when newer and older activities exists', () => {
|
|
477
557
|
const acts = [
|
|
478
558
|
{published: createDateISO(5), order: 2},
|
|
479
|
-
{published: createDateISO(6), order: 3}
|
|
559
|
+
{published: createDateISO(6), order: 3},
|
|
480
560
|
];
|
|
481
561
|
|
|
482
562
|
setBookends(acts);
|
|
483
563
|
|
|
484
564
|
const nextActs = [
|
|
485
565
|
{published: createDateISO(1), order: 1},
|
|
486
|
-
{published: createDateISO(9), order: 4}
|
|
566
|
+
{published: createDateISO(9), order: 4},
|
|
487
567
|
];
|
|
488
568
|
|
|
489
569
|
setBookends(nextActs);
|
|
@@ -495,14 +575,14 @@ describe('plugin-conversation', () => {
|
|
|
495
575
|
it('should not update oldest activity when only newer activities exist', () => {
|
|
496
576
|
const acts = [
|
|
497
577
|
{published: createDateISO(1), order: 1},
|
|
498
|
-
{published: createDateISO(5), order: 2}
|
|
578
|
+
{published: createDateISO(5), order: 2},
|
|
499
579
|
];
|
|
500
580
|
|
|
501
581
|
setBookends(acts);
|
|
502
582
|
|
|
503
583
|
const nextActs = [
|
|
504
584
|
{published: createDateISO(6), order: 3},
|
|
505
|
-
{published: createDateISO(9), order: 4}
|
|
585
|
+
{published: createDateISO(9), order: 4},
|
|
506
586
|
];
|
|
507
587
|
|
|
508
588
|
setBookends(nextActs);
|
|
@@ -535,8 +615,8 @@ describe('plugin-conversation', () => {
|
|
|
535
615
|
id: '1',
|
|
536
616
|
activityType: 'reply',
|
|
537
617
|
parent: {
|
|
538
|
-
id: parentId
|
|
539
|
-
}
|
|
618
|
+
id: parentId,
|
|
619
|
+
},
|
|
540
620
|
};
|
|
541
621
|
const replyHandler = getActivityHandlerByKey(ACTIVITY_TYPES.REPLY);
|
|
542
622
|
|
|
@@ -550,8 +630,8 @@ describe('plugin-conversation', () => {
|
|
|
550
630
|
id: '2',
|
|
551
631
|
activityType: 'reply',
|
|
552
632
|
parent: {
|
|
553
|
-
id: parentId
|
|
554
|
-
}
|
|
633
|
+
id: parentId,
|
|
634
|
+
},
|
|
555
635
|
};
|
|
556
636
|
|
|
557
637
|
replyHandler(secondReplyAct);
|
|
@@ -562,8 +642,8 @@ describe('plugin-conversation', () => {
|
|
|
562
642
|
id: '3',
|
|
563
643
|
activityType: 'reply',
|
|
564
644
|
parent: {
|
|
565
|
-
id: parentId2
|
|
566
|
-
}
|
|
645
|
+
id: parentId2,
|
|
646
|
+
},
|
|
567
647
|
};
|
|
568
648
|
|
|
569
649
|
replyHandler(thirdReply);
|
|
@@ -580,17 +660,17 @@ describe('plugin-conversation', () => {
|
|
|
580
660
|
id: 'editId1',
|
|
581
661
|
parent: {
|
|
582
662
|
id: parentId,
|
|
583
|
-
type: 'edit'
|
|
663
|
+
type: 'edit',
|
|
584
664
|
},
|
|
585
|
-
published: new Date(1, 1, 1, 1, 1).toISOString()
|
|
665
|
+
published: new Date(1, 1, 1, 1, 1).toISOString(),
|
|
586
666
|
};
|
|
587
667
|
const tombstoneEdit = {
|
|
588
668
|
...editAct,
|
|
589
|
-
verb: ACTIVITY_TYPES.TOMBSTONE
|
|
669
|
+
verb: ACTIVITY_TYPES.TOMBSTONE,
|
|
590
670
|
};
|
|
591
671
|
const newerEdit = {
|
|
592
672
|
...editAct,
|
|
593
|
-
published: new Date(1, 1, 1, 1, 3).toISOString()
|
|
673
|
+
published: new Date(1, 1, 1, 1, 3).toISOString(),
|
|
594
674
|
};
|
|
595
675
|
|
|
596
676
|
editHandler(editAct);
|
|
@@ -613,13 +693,13 @@ describe('plugin-conversation', () => {
|
|
|
613
693
|
published: new Date(1, 1, 1, 1, 1).toISOString(),
|
|
614
694
|
type: 'reactionSummary',
|
|
615
695
|
parent: {
|
|
616
|
-
id: parentId
|
|
617
|
-
}
|
|
696
|
+
id: parentId,
|
|
697
|
+
},
|
|
618
698
|
};
|
|
619
699
|
|
|
620
700
|
const newerReaction = {
|
|
621
701
|
...reaction,
|
|
622
|
-
published: new Date(1, 1, 1, 1, 3).toISOString()
|
|
702
|
+
published: new Date(1, 1, 1, 1, 3).toISOString(),
|
|
623
703
|
};
|
|
624
704
|
|
|
625
705
|
reactionHandler(reaction);
|
|
@@ -628,7 +708,10 @@ describe('plugin-conversation', () => {
|
|
|
628
708
|
|
|
629
709
|
reactionHandler(newerReaction);
|
|
630
710
|
|
|
631
|
-
assert.equal(
|
|
711
|
+
assert.equal(
|
|
712
|
+
getActivityByTypeAndParentId(ACTIVITY_TYPES.REACTION, parentId),
|
|
713
|
+
newerReaction
|
|
714
|
+
);
|
|
632
715
|
});
|
|
633
716
|
});
|
|
634
717
|
});
|
|
@@ -636,16 +719,16 @@ describe('plugin-conversation', () => {
|
|
|
636
719
|
describe('#_createParsedServerActivity()', () => {
|
|
637
720
|
const activities = {
|
|
638
721
|
root1: {
|
|
639
|
-
id: 'root1'
|
|
722
|
+
id: 'root1',
|
|
640
723
|
},
|
|
641
724
|
reply1: {
|
|
642
725
|
id: 'reply1',
|
|
643
726
|
activityType: 'reply',
|
|
644
727
|
parent: {
|
|
645
728
|
id: 1,
|
|
646
|
-
type: 'reply'
|
|
647
|
-
}
|
|
648
|
-
}
|
|
729
|
+
type: 'reply',
|
|
730
|
+
},
|
|
731
|
+
},
|
|
649
732
|
};
|
|
650
733
|
|
|
651
734
|
it('should add editParent field to valid edit activity', () => {
|
|
@@ -653,11 +736,14 @@ describe('plugin-conversation', () => {
|
|
|
653
736
|
id: 'edit1',
|
|
654
737
|
parent: {
|
|
655
738
|
id: 'root1',
|
|
656
|
-
type: 'edit'
|
|
657
|
-
}
|
|
739
|
+
type: 'edit',
|
|
740
|
+
},
|
|
658
741
|
};
|
|
659
742
|
|
|
660
|
-
const parsedActivity = webex.internal.conversation._createParsedServerActivity(
|
|
743
|
+
const parsedActivity = webex.internal.conversation._createParsedServerActivity(
|
|
744
|
+
activity,
|
|
745
|
+
activities
|
|
746
|
+
);
|
|
661
747
|
|
|
662
748
|
assert.containsAllKeys(parsedActivity, ['editParent']);
|
|
663
749
|
});
|
|
@@ -668,11 +754,14 @@ describe('plugin-conversation', () => {
|
|
|
668
754
|
activityType: 'reply',
|
|
669
755
|
parent: {
|
|
670
756
|
id: 'root1',
|
|
671
|
-
type: 'reply'
|
|
672
|
-
}
|
|
757
|
+
type: 'reply',
|
|
758
|
+
},
|
|
673
759
|
};
|
|
674
760
|
|
|
675
|
-
const parsedActivity = webex.internal.conversation._createParsedServerActivity(
|
|
761
|
+
const parsedActivity = webex.internal.conversation._createParsedServerActivity(
|
|
762
|
+
activity,
|
|
763
|
+
activities
|
|
764
|
+
);
|
|
676
765
|
|
|
677
766
|
assert.containsAllKeys(parsedActivity, ['replyParent']);
|
|
678
767
|
});
|
|
@@ -682,11 +771,14 @@ describe('plugin-conversation', () => {
|
|
|
682
771
|
id: 'replyEdit1',
|
|
683
772
|
parent: {
|
|
684
773
|
id: 'reply1',
|
|
685
|
-
type: 'edit'
|
|
686
|
-
}
|
|
774
|
+
type: 'edit',
|
|
775
|
+
},
|
|
687
776
|
};
|
|
688
777
|
|
|
689
|
-
const parsedActivity = webex.internal.conversation._createParsedServerActivity(
|
|
778
|
+
const parsedActivity = webex.internal.conversation._createParsedServerActivity(
|
|
779
|
+
activity,
|
|
780
|
+
activities
|
|
781
|
+
);
|
|
690
782
|
|
|
691
783
|
assert.containsAllKeys(parsedActivity, ['replyParent', 'editParent']);
|
|
692
784
|
});
|
|
@@ -695,14 +787,15 @@ describe('plugin-conversation', () => {
|
|
|
695
787
|
const activity = {
|
|
696
788
|
id: 'throwAct1',
|
|
697
789
|
parent: {
|
|
698
|
-
id: 'root2'
|
|
699
|
-
}
|
|
790
|
+
id: 'root2',
|
|
791
|
+
},
|
|
700
792
|
};
|
|
701
793
|
|
|
702
794
|
try {
|
|
703
|
-
assert.throws(
|
|
704
|
-
|
|
705
|
-
|
|
795
|
+
assert.throws(
|
|
796
|
+
webex.internal.conversation._createParsedServerActivity(activity, activities)
|
|
797
|
+
);
|
|
798
|
+
} catch (e) {
|
|
706
799
|
// swallow error
|
|
707
800
|
}
|
|
708
801
|
});
|
|
@@ -717,50 +810,59 @@ describe('plugin-conversation', () => {
|
|
|
717
810
|
it('should reject if provided param is not an object', () => {
|
|
718
811
|
const request = webex.internal.conversation.delete(testConvo, 'hello');
|
|
719
812
|
|
|
720
|
-
return request
|
|
721
|
-
|
|
722
|
-
|
|
813
|
+
return request
|
|
814
|
+
.then(() => {
|
|
815
|
+
assert.equal(true, false, 'should have rejected');
|
|
816
|
+
})
|
|
723
817
|
.catch(() => {
|
|
724
818
|
assert.equal(true, true, 'object is not type object, rejects as expected');
|
|
725
819
|
});
|
|
726
820
|
});
|
|
727
821
|
it('deletes a non-meeting container activity', () => {
|
|
728
|
-
webex.internal.conversation.prepare = sinon
|
|
822
|
+
webex.internal.conversation.prepare = sinon
|
|
823
|
+
.stub()
|
|
824
|
+
.callsFake((activity, request) => Promise.resolve({activity, request}));
|
|
729
825
|
webex.internal.conversation.submit = sinon.stub().callsFake((p) => Promise.resolve(p));
|
|
730
826
|
|
|
731
827
|
// fix this to look like below
|
|
732
|
-
const request = webex.internal.conversation.delete(
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
{
|
|
740
|
-
|
|
828
|
+
const request = webex.internal.conversation.delete(
|
|
829
|
+
testConvo,
|
|
830
|
+
{
|
|
831
|
+
id: 'activity-id-1',
|
|
832
|
+
url: 'https://example.com/activity1',
|
|
833
|
+
object: {objectType: 'activity'},
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
object: {objectType: 'activity'},
|
|
837
|
+
}
|
|
838
|
+
);
|
|
741
839
|
|
|
742
840
|
return request.then(({request}) => {
|
|
743
841
|
assert.isUndefined(request.kmsMessage);
|
|
744
842
|
});
|
|
745
843
|
});
|
|
746
844
|
it('deletes a meeting container activity', () => {
|
|
747
|
-
webex.internal.conversation.prepare = sinon
|
|
845
|
+
webex.internal.conversation.prepare = sinon
|
|
846
|
+
.stub()
|
|
847
|
+
.callsFake((activity, request) => Promise.resolve({activity, request}));
|
|
748
848
|
webex.internal.conversation.submit = sinon.stub().callsFake((p) => Promise.resolve(p));
|
|
749
849
|
|
|
750
|
-
const request = webex.internal.conversation.delete(
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
850
|
+
const request = webex.internal.conversation.delete(
|
|
851
|
+
testConvo,
|
|
852
|
+
{
|
|
853
|
+
id: 'activity-id-2',
|
|
854
|
+
url: 'https://example.com/activity2',
|
|
855
|
+
object: {
|
|
856
|
+
kmsResourceObjectUrl: 'kms://example',
|
|
857
|
+
objectType: 'meetingContainer',
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
object: {
|
|
862
|
+
objectType: 'meetingContainer',
|
|
863
|
+
},
|
|
761
864
|
}
|
|
762
|
-
|
|
763
|
-
|
|
865
|
+
);
|
|
764
866
|
|
|
765
867
|
return request.then(({request}) => {
|
|
766
868
|
assert.equal(request.kmsMessage.method, 'delete');
|