@webex/internal-plugin-conversation 3.0.0-beta.11 → 3.0.0-beta.111

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.
Files changed (44) hide show
  1. package/README.md +1 -3
  2. package/dist/activities.js +8 -69
  3. package/dist/activities.js.map +1 -1
  4. package/dist/activity-thread-ordering.js +19 -79
  5. package/dist/activity-thread-ordering.js.map +1 -1
  6. package/dist/config.js +1 -7
  7. package/dist/config.js.map +1 -1
  8. package/dist/constants.js +4 -5
  9. package/dist/constants.js.map +1 -1
  10. package/dist/conversation.js +790 -1199
  11. package/dist/conversation.js.map +1 -1
  12. package/dist/convo-error.js +0 -23
  13. package/dist/convo-error.js.map +1 -1
  14. package/dist/decryption-transforms.js +35 -98
  15. package/dist/decryption-transforms.js.map +1 -1
  16. package/dist/encryption-transforms.js +11 -48
  17. package/dist/encryption-transforms.js.map +1 -1
  18. package/dist/index.js +7 -50
  19. package/dist/index.js.map +1 -1
  20. package/dist/share-activity.js +40 -106
  21. package/dist/share-activity.js.map +1 -1
  22. package/dist/to-array.js +9 -11
  23. package/dist/to-array.js.map +1 -1
  24. package/package.json +15 -15
  25. package/src/activities.js +10 -7
  26. package/src/activity-thread-ordering.js +27 -30
  27. package/src/activity-threading.md +68 -49
  28. package/src/config.js +5 -5
  29. package/src/conversation.js +621 -589
  30. package/src/decryption-transforms.js +103 -62
  31. package/src/encryption-transforms.js +103 -83
  32. package/src/index.js +82 -66
  33. package/src/share-activity.js +64 -55
  34. package/src/to-array.js +2 -2
  35. package/test/integration/spec/create.js +184 -118
  36. package/test/integration/spec/encryption.js +250 -186
  37. package/test/integration/spec/get.js +763 -514
  38. package/test/integration/spec/mercury.js +37 -27
  39. package/test/integration/spec/share.js +292 -229
  40. package/test/integration/spec/verbs.js +628 -441
  41. package/test/unit/spec/conversation.js +265 -163
  42. package/test/unit/spec/decrypt-transforms.js +112 -131
  43. package/test/unit/spec/encryption-transforms.js +24 -18
  44. package/test/unit/spec/share-activity.js +37 -40
@@ -19,7 +19,7 @@ const postMessage = (webex, convo) => (msg) =>
19
19
  const postReply = (webex, conversation) => (threadObj) =>
20
20
  webex.internal.conversation.post(conversation, threadObj.displayName, {
21
21
  parentActivityId: threadObj.parentActivityId,
22
- activityType: 'reply'
22
+ activityType: 'reply',
23
23
  });
24
24
 
25
25
  const threadDisplayNames = ['thread 1', 'thread 2', 'thread 3'];
@@ -30,12 +30,10 @@ const createThreadObjs = (parents) => {
30
30
  for (const [ix, parentAct] of parents.entries()) {
31
31
  // add threads to every other, plus randoms for variability
32
32
  if (ix % 2 || Math.round(Math.random())) {
33
- threadObjects.push(
34
- {
35
- displayName: `${parentAct.object.displayName} ${msg}`,
36
- parentActivityId: parentAct.id
37
- }
38
- );
33
+ threadObjects.push({
34
+ displayName: `${parentAct.object.displayName} ${msg}`,
35
+ parentActivityId: parentAct.id,
36
+ });
39
37
  }
40
38
  }
41
39
  }
@@ -49,51 +47,65 @@ describe('plugin-conversation', function () {
49
47
  describe('when fetching conversations', () => {
50
48
  let kirk, mccoy, participants, scott, webex, spock, suluEU, checkov;
51
49
 
52
- before('create tests users and connect three to mercury', () => Promise.all([
53
- testUsers.create({count: 5}),
54
- testUsers.create({count: 1, config: {orgId: process.env.EU_PRIMARY_ORG_ID}})
55
- ])
56
- .then(([users, usersEU]) => {
50
+ before('create tests users and connect three to mercury', () =>
51
+ Promise.all([
52
+ testUsers.create({count: 5}),
53
+ testUsers.create({count: 1, config: {orgId: process.env.EU_PRIMARY_ORG_ID}}),
54
+ ]).then(([users, usersEU]) => {
57
55
  [spock, mccoy, kirk, scott, checkov] = users;
58
56
  [suluEU] = usersEU;
59
57
  participants = [spock, mccoy, kirk];
60
58
 
61
59
  spock.webex = new WebexCore({
62
60
  credentials: {
63
- supertoken: spock.token
64
- }
61
+ supertoken: spock.token,
62
+ },
65
63
  });
66
64
 
67
65
  webex = spock.webex;
68
66
 
69
67
  suluEU.webex = new WebexCore({
70
68
  credentials: {
71
- supertoken: suluEU.token
72
- }
69
+ supertoken: suluEU.token,
70
+ },
73
71
  });
74
72
 
75
73
  checkov.webex = new WebexCore({
76
74
  credentials: {
77
- supertoken: checkov.token
78
- }
75
+ supertoken: checkov.token,
76
+ },
79
77
  });
80
78
 
81
- return Promise.all([suluEU, checkov, spock].map((user) => user.webex.internal.services.waitForCatalog('postauth')
82
- .then(() => user.webex.internal.mercury.connect())));
83
- }));
79
+ return Promise.all(
80
+ [suluEU, checkov, spock].map((user) =>
81
+ user.webex.internal.services
82
+ .waitForCatalog('postauth')
83
+ .then(() => user.webex.internal.mercury.connect())
84
+ )
85
+ );
86
+ })
87
+ );
84
88
 
85
- after(() => Promise.all([suluEU, checkov, spock].map((user) => user.webex.internal.mercury.disconnect())));
89
+ after(() =>
90
+ Promise.all([suluEU, checkov, spock].map((user) => user.webex.internal.mercury.disconnect()))
91
+ );
86
92
 
87
93
  describe('#download()', () => {
88
94
  let sampleImageSmallOnePng = 'sample-image-small-one.png';
89
95
 
90
96
  let conversation, conversationRequestSpy;
91
97
 
92
- before('create conversation', () => webex.internal.conversation.create({participants})
93
- .then((c) => { conversation = c; }));
98
+ before('create conversation', () =>
99
+ webex.internal.conversation.create({participants}).then((c) => {
100
+ conversation = c;
101
+ })
102
+ );
94
103
 
95
- before('fetch image fixture', () => fh.fetch(sampleImageSmallOnePng)
96
- .then((res) => { sampleImageSmallOnePng = res; }));
104
+ before('fetch image fixture', () =>
105
+ fh.fetch(sampleImageSmallOnePng).then((res) => {
106
+ sampleImageSmallOnePng = res;
107
+ })
108
+ );
97
109
 
98
110
  beforeEach(() => {
99
111
  conversationRequestSpy = sinon.spy(webex.internal.conversation, 'request');
@@ -101,80 +113,105 @@ describe('plugin-conversation', function () {
101
113
 
102
114
  afterEach(() => conversationRequestSpy.restore());
103
115
 
104
- it('rejects for invalid options argument', () => webex.internal.conversation.share(conversation, [sampleImageSmallOnePng])
105
- .then((activity) => {
106
- const item = activity.object.files.items[0];
107
-
108
- item.options = {
109
- params: {
110
- allow: 'invalidOption'
111
- }
112
- };
116
+ it('rejects for invalid options argument', () =>
117
+ webex.internal.conversation
118
+ .share(conversation, [sampleImageSmallOnePng])
119
+ .then((activity) => {
120
+ const item = activity.object.files.items[0];
113
121
 
114
- assert.isRejected(webex.internal.conversation.download(item));
115
- }));
122
+ item.options = {
123
+ params: {
124
+ allow: 'invalidOption',
125
+ },
126
+ };
116
127
 
117
- it('downloads and decrypts an encrypted file', () => webex.internal.conversation.share(conversation, [sampleImageSmallOnePng])
118
- .then((activity) => webex.internal.conversation.download(activity.object.files.items[0]))
119
- .then((f) => fh.isMatchingFile(f, sampleImageSmallOnePng)
120
- .then((result) => assert.isTrue(result))));
128
+ assert.isRejected(webex.internal.conversation.download(item));
129
+ }));
121
130
 
122
- it('emits download progress events for encrypted files', () => webex.internal.conversation.share(conversation, [sampleImageSmallOnePng])
123
- .then((activity) => {
124
- const spy = sinon.spy();
131
+ it('downloads and decrypts an encrypted file', () =>
132
+ webex.internal.conversation
133
+ .share(conversation, [sampleImageSmallOnePng])
134
+ .then((activity) => webex.internal.conversation.download(activity.object.files.items[0]))
135
+ .then((f) =>
136
+ fh.isMatchingFile(f, sampleImageSmallOnePng).then((result) => assert.isTrue(result))
137
+ ));
138
+
139
+ it('emits download progress events for encrypted files', () =>
140
+ webex.internal.conversation
141
+ .share(conversation, [sampleImageSmallOnePng])
142
+ .then((activity) => {
143
+ const spy = sinon.spy();
125
144
 
126
- return webex.internal.conversation.download(activity.object.files.items[0])
127
- .on('progress', spy)
128
- .then(() => assert.called(spy));
129
- }));
145
+ return webex.internal.conversation
146
+ .download(activity.object.files.items[0])
147
+ .on('progress', spy)
148
+ .then(() => assert.called(spy));
149
+ }));
130
150
 
131
- it('downloads and decrypts a file without a scr key', () => webex.internal.conversation.download({
132
- scr: {
133
- loc: makeLocalUrl('/sample-image-small-one.png')
134
- }
135
- })
136
- .then((f) => fh.isMatchingFile(f, sampleImageSmallOnePng)
137
- .then((result) => assert.isTrue(result)))
138
- .then(() => conversationRequestSpy.returnValues[0]
139
- .then((res) => {
140
- assert.property(res.options.headers, 'cisco-no-http-redirect');
141
- assert.property(res.options.headers, 'spark-user-agent');
142
- assert.property(res.options.headers, 'trackingid');
143
- })));
144
-
145
- it('downloads and decrypts a non-encrypted file', () => webex.internal.conversation.download({url: makeLocalUrl('/sample-image-small-one.png')})
146
- .then((f) => fh.isMatchingFile(f, sampleImageSmallOnePng)
147
- .then((result) => assert.isTrue(result)))
148
- .then(() => conversationRequestSpy.returnValues[0]
149
- .then((res) => {
150
- assert.property(res.options.headers, 'cisco-no-http-redirect');
151
- assert.property(res.options.headers, 'spark-user-agent');
152
- assert.property(res.options.headers, 'trackingid');
153
- })));
154
-
155
- it('downloads non-encrypted file with specific options headers', () => webex.internal.conversation.download({url: makeLocalUrl('/sample-image-small-one.png')}, {
156
- headers: {
157
- 'cisco-no-http-redirect': null,
158
- 'spark-user-agent': null,
159
- trackingid: null
160
- }
161
- })
162
- .then((f) => fh.isMatchingFile(f, sampleImageSmallOnePng)
163
- .then((result) => assert.isTrue(result)))
164
- .then(() => conversationRequestSpy.returnValues[0]
165
- .then((res) => {
166
- assert.isUndefined(res.options.headers['cisco-no-http-redirect']);
167
- assert.isUndefined(res.options.headers['spark-user-agent']);
168
- assert.isUndefined(res.options.headers.trackingid);
169
- })));
151
+ it('downloads and decrypts a file without a scr key', () =>
152
+ webex.internal.conversation
153
+ .download({
154
+ scr: {
155
+ loc: makeLocalUrl('/sample-image-small-one.png'),
156
+ },
157
+ })
158
+ .then((f) =>
159
+ fh.isMatchingFile(f, sampleImageSmallOnePng).then((result) => assert.isTrue(result))
160
+ )
161
+ .then(() =>
162
+ conversationRequestSpy.returnValues[0].then((res) => {
163
+ assert.property(res.options.headers, 'cisco-no-http-redirect');
164
+ assert.property(res.options.headers, 'spark-user-agent');
165
+ assert.property(res.options.headers, 'trackingid');
166
+ })
167
+ ));
168
+
169
+ it('downloads and decrypts a non-encrypted file', () =>
170
+ webex.internal.conversation
171
+ .download({url: makeLocalUrl('/sample-image-small-one.png')})
172
+ .then((f) =>
173
+ fh.isMatchingFile(f, sampleImageSmallOnePng).then((result) => assert.isTrue(result))
174
+ )
175
+ .then(() =>
176
+ conversationRequestSpy.returnValues[0].then((res) => {
177
+ assert.property(res.options.headers, 'cisco-no-http-redirect');
178
+ assert.property(res.options.headers, 'spark-user-agent');
179
+ assert.property(res.options.headers, 'trackingid');
180
+ })
181
+ ));
182
+
183
+ it('downloads non-encrypted file with specific options headers', () =>
184
+ webex.internal.conversation
185
+ .download(
186
+ {url: makeLocalUrl('/sample-image-small-one.png')},
187
+ {
188
+ headers: {
189
+ 'cisco-no-http-redirect': null,
190
+ 'spark-user-agent': null,
191
+ trackingid: null,
192
+ },
193
+ }
194
+ )
195
+ .then((f) =>
196
+ fh.isMatchingFile(f, sampleImageSmallOnePng).then((result) => assert.isTrue(result))
197
+ )
198
+ .then(() =>
199
+ conversationRequestSpy.returnValues[0].then((res) => {
200
+ assert.isUndefined(res.options.headers['cisco-no-http-redirect']);
201
+ assert.isUndefined(res.options.headers['spark-user-agent']);
202
+ assert.isUndefined(res.options.headers.trackingid);
203
+ })
204
+ ));
170
205
 
171
206
  it('emits download progress events for non-encrypted files', () => {
172
207
  const spy = sinon.spy();
173
208
 
174
- return webex.internal.conversation.download({url: makeLocalUrl('/sample-image-small-one.png')})
209
+ return webex.internal.conversation
210
+ .download({url: makeLocalUrl('/sample-image-small-one.png')})
175
211
  .on('progress', spy)
176
- .then((f) => fh.isMatchingFile(f, sampleImageSmallOnePng)
177
- .then((result) => assert.isTrue(result)))
212
+ .then((f) =>
213
+ fh.isMatchingFile(f, sampleImageSmallOnePng).then((result) => assert.isTrue(result))
214
+ )
178
215
  .then(() => assert.called(spy));
179
216
  });
180
217
 
@@ -182,270 +219,338 @@ describe('plugin-conversation', function () {
182
219
  let fileItem;
183
220
  let sampleImagePortraitJpeg = 'Portrait_7.jpg';
184
221
 
185
- before('fetch image fixture', () => fh.fetch(sampleImagePortraitJpeg)
186
- .then((res) => {
222
+ before('fetch image fixture', () =>
223
+ fh.fetch(sampleImagePortraitJpeg).then((res) => {
187
224
  sampleImagePortraitJpeg = res;
188
225
  sampleImagePortraitJpeg.displayName = 'Portrait_7.jpg';
189
226
  sampleImagePortraitJpeg.mimeType = 'image/jpeg';
190
- }));
191
- it('does not add exif data', () => webex.internal.conversation.share(conversation, [sampleImagePortraitJpeg])
192
- .then((activity) => {
193
- fileItem = activity.object.files.items[0];
194
-
195
- return webex.internal.conversation.download(fileItem, {shouldNotAddExifData: true});
196
227
  })
197
- .then((f) => {
198
- assert.equal(fileItem.orientation, undefined);
228
+ );
229
+ it('does not add exif data', () =>
230
+ webex.internal.conversation
231
+ .share(conversation, [sampleImagePortraitJpeg])
232
+ .then((activity) => {
233
+ fileItem = activity.object.files.items[0];
199
234
 
200
- return fh.isMatchingFile(f, sampleImagePortraitJpeg);
201
- })
202
- .then((result) => assert.isTrue(result)));
235
+ return webex.internal.conversation.download(fileItem, {shouldNotAddExifData: true});
236
+ })
237
+ .then((f) => {
238
+ assert.equal(fileItem.orientation, undefined);
203
239
 
204
- it('adds exif data', () => webex.internal.conversation.share(conversation, [sampleImagePortraitJpeg])
205
- .then((activity) => {
206
- fileItem = activity.object.files.items[0];
240
+ return fh.isMatchingFile(f, sampleImagePortraitJpeg);
241
+ })
242
+ .then((result) => assert.isTrue(result)));
207
243
 
208
- return webex.internal.conversation.download(fileItem);
209
- })
210
- .then((f) => {
211
- assert.equal(fileItem.orientation, 7);
244
+ it('adds exif data', () =>
245
+ webex.internal.conversation
246
+ .share(conversation, [sampleImagePortraitJpeg])
247
+ .then((activity) => {
248
+ fileItem = activity.object.files.items[0];
212
249
 
213
- return fh.isMatchingFile(f, sampleImagePortraitJpeg);
214
- })
215
- .then((result) => assert.isTrue(result)));
250
+ return webex.internal.conversation.download(fileItem);
251
+ })
252
+ .then((f) => {
253
+ assert.equal(fileItem.orientation, 7);
254
+
255
+ return fh.isMatchingFile(f, sampleImagePortraitJpeg);
256
+ })
257
+ .then((result) => assert.isTrue(result)));
216
258
  });
217
259
  });
218
260
 
219
261
  describe('#get()', () => {
220
262
  let conversation, conversation2;
221
263
 
222
- before('create conversations', () => Promise.all([
223
- webex.internal.conversation.create({participants: [mccoy.id]})
224
- .then((c) => { conversation = c; }),
225
- webex.internal.conversation.create({participants: [scott.id]})
226
- .then((c) => { conversation2 = c; })
227
- ]));
228
-
229
- it('retrieves a single conversation by url', () => webex.internal.conversation.get({url: conversation.url})
230
- .then((c) => {
264
+ before('create conversations', () =>
265
+ Promise.all([
266
+ webex.internal.conversation.create({participants: [mccoy.id]}).then((c) => {
267
+ conversation = c;
268
+ }),
269
+ webex.internal.conversation.create({participants: [scott.id]}).then((c) => {
270
+ conversation2 = c;
271
+ }),
272
+ ])
273
+ );
274
+
275
+ it('retrieves a single conversation by url', () =>
276
+ webex.internal.conversation.get({url: conversation.url}).then((c) => {
231
277
  assert.equal(c.id, conversation.id);
232
278
  assert.equal(c.url, conversation.url);
233
279
  }));
234
280
 
235
- it('retrieves a single conversation by id', () => webex.internal.conversation.get({id: conversation.id})
236
- .then((c) => {
281
+ it('retrieves a single conversation by id', () =>
282
+ webex.internal.conversation.get({id: conversation.id}).then((c) => {
237
283
  assert.equal(c.id, conversation.id);
238
284
  assert.equal(c.url, conversation.url);
239
285
  }));
240
286
 
241
- it('retrieves a 1:1 conversation by userId', () => webex.internal.conversation.get({user: mccoy})
242
- .then((c) => {
287
+ it('retrieves a 1:1 conversation by userId', () =>
288
+ webex.internal.conversation.get({user: mccoy}).then((c) => {
243
289
  assert.equal(c.id, conversation.id);
244
290
  assert.equal(c.url, conversation.url);
245
291
  }));
246
292
 
247
- it('retrieves a 1:1 conversation with a deleted user', () => webex.internal.conversation.get({user: scott})
248
- .then((c) => {
249
- assert.equal(c.id, conversation2.id);
250
- assert.equal(c.url, conversation2.url);
251
- })
252
- .then(() => testUsers.remove([scott]))
253
- // add retries to address CI propagation delay
254
- .then(() => retry(() => assert.isRejected(webex.internal.conversation.get({user: scott}))))
255
- .then(() => retry(() => webex.internal.conversation.get({user: scott}, {includeConvWithDeletedUserUUID: true})))
256
- .then((c) => {
257
- assert.equal(c.id, conversation2.id);
258
- assert.equal(c.url, conversation2.url);
259
- }));
293
+ it('retrieves a 1:1 conversation with a deleted user', () =>
294
+ webex.internal.conversation
295
+ .get({user: scott})
296
+ .then((c) => {
297
+ assert.equal(c.id, conversation2.id);
298
+ assert.equal(c.url, conversation2.url);
299
+ })
300
+ .then(() => testUsers.remove([scott]))
301
+ // add retries to address CI propagation delay
302
+ .then(() =>
303
+ retry(() => assert.isRejected(webex.internal.conversation.get({user: scott})))
304
+ )
305
+ .then(() =>
306
+ retry(() =>
307
+ webex.internal.conversation.get({user: scott}, {includeConvWithDeletedUserUUID: true})
308
+ )
309
+ )
310
+ .then((c) => {
311
+ assert.equal(c.id, conversation2.id);
312
+ assert.equal(c.url, conversation2.url);
313
+ }));
260
314
 
261
- it('decrypts the contents of activities in the retrieved conversation', () => webex.internal.conversation.post(conversation, {
262
- displayName: 'Test Message'
263
- })
264
- .then(() => webex.internal.conversation.get({url: conversation.url}, {activitiesLimit: 50}))
265
- .then((c) => {
266
- const posts = c.activities.items.filter((activity) => activity.verb === 'post');
315
+ it('decrypts the contents of activities in the retrieved conversation', () =>
316
+ webex.internal.conversation
317
+ .post(conversation, {
318
+ displayName: 'Test Message',
319
+ })
320
+ .then(() =>
321
+ webex.internal.conversation.get({url: conversation.url}, {activitiesLimit: 50})
322
+ )
323
+ .then((c) => {
324
+ const posts = c.activities.items.filter((activity) => activity.verb === 'post');
267
325
 
268
- assert.lengthOf(posts, 1);
269
- assert.equal(posts[0].object.displayName, 'Test Message');
270
- }));
326
+ assert.lengthOf(posts, 1);
327
+ assert.equal(posts[0].object.displayName, 'Test Message');
328
+ }));
271
329
  });
272
330
 
273
331
  describe('#list()', () => {
274
332
  let conversation1, conversation2;
275
333
 
276
334
  before('create conversations', () =>
277
- webex.internal.conversation.create({
278
- displayName: 'test 1',
279
- participants
280
- })
281
- .then((c) => { conversation1 = c; })
282
- .then(() => webex.internal.conversation.create({
283
- displayName: 'test 2',
284
- participants
285
- }))
286
-
287
- .then((c) => { conversation2 = c; }));
288
-
289
- it('retrieves a set of conversations', () => webex.internal.conversation.list({
290
- conversationsLimit: 2
291
- })
292
- .then((conversations) => {
293
- assert.include(map(conversations, 'url'), conversation1.url);
294
- assert.include(map(conversations, 'url'), conversation2.url);
295
- }));
296
-
297
- it('retrieves a paginated set of conversations', () => webex.internal.conversation.paginate({
298
- conversationsLimit: 1,
299
- personRefresh: false,
300
- paginate: true
301
- })
302
- .then((response) => {
303
- const conversations = response.page.items;
304
-
305
- assert.lengthOf(conversations, 1);
306
- assert.equal(conversations[0].displayName, conversation2.displayName);
307
-
308
- return webex.internal.conversation.paginate({page: response.page});
309
- })
310
- .then((response) => {
311
- const conversations = response.page.items;
335
+ webex.internal.conversation
336
+ .create({
337
+ displayName: 'test 1',
338
+ participants,
339
+ })
340
+ .then((c) => {
341
+ conversation1 = c;
342
+ })
343
+ .then(() =>
344
+ webex.internal.conversation.create({
345
+ displayName: 'test 2',
346
+ participants,
347
+ })
348
+ )
312
349
 
313
- assert.lengthOf(conversations, 1);
314
- assert.equal(conversations[0].displayName, conversation1.displayName);
315
- }));
350
+ .then((c) => {
351
+ conversation2 = c;
352
+ })
353
+ );
316
354
 
317
- describe('with summary = true (ConversationsSummary)', () => {
318
- it('retrieves all conversations using conversationsSummary', () => webex.internal.conversation.list({
319
- summary: true
320
- })
355
+ it('retrieves a set of conversations', () =>
356
+ webex.internal.conversation
357
+ .list({
358
+ conversationsLimit: 2,
359
+ })
321
360
  .then((conversations) => {
322
361
  assert.include(map(conversations, 'url'), conversation1.url);
323
362
  assert.include(map(conversations, 'url'), conversation2.url);
324
363
  }));
325
364
 
326
- it('retrieves a set of (1) conversations using conversationsLimit', () => webex.internal.conversation.list({
327
- summary: true,
328
- conversationsLimit: 1
329
- })
330
- .then((conversations) => {
365
+ it('retrieves a paginated set of conversations', () =>
366
+ webex.internal.conversation
367
+ .paginate({
368
+ conversationsLimit: 1,
369
+ personRefresh: false,
370
+ paginate: true,
371
+ })
372
+ .then((response) => {
373
+ const conversations = response.page.items;
374
+
331
375
  assert.lengthOf(conversations, 1);
332
- assert.include(map(conversations, 'url'), conversation2.url);
333
- assert.include(map(conversations, 'displayName'), conversation2.displayName);
376
+ assert.equal(conversations[0].displayName, conversation2.displayName);
377
+
378
+ return webex.internal.conversation.paginate({page: response.page});
379
+ })
380
+ .then((response) => {
381
+ const conversations = response.page.items;
382
+
383
+ assert.lengthOf(conversations, 1);
384
+ assert.equal(conversations[0].displayName, conversation1.displayName);
334
385
  }));
335
- });
336
386
 
387
+ describe('with summary = true (ConversationsSummary)', () => {
388
+ it('retrieves all conversations using conversationsSummary', () =>
389
+ webex.internal.conversation
390
+ .list({
391
+ summary: true,
392
+ })
393
+ .then((conversations) => {
394
+ assert.include(map(conversations, 'url'), conversation1.url);
395
+ assert.include(map(conversations, 'url'), conversation2.url);
396
+ }));
397
+
398
+ it('retrieves a set of (1) conversations using conversationsLimit', () =>
399
+ webex.internal.conversation
400
+ .list({
401
+ summary: true,
402
+ conversationsLimit: 1,
403
+ })
404
+ .then((conversations) => {
405
+ assert.lengthOf(conversations, 1);
406
+ assert.include(map(conversations, 'url'), conversation2.url);
407
+ assert.include(map(conversations, 'displayName'), conversation2.displayName);
408
+ }));
409
+ });
337
410
 
338
411
  describe('with deferDecrypt = true', () => {
339
- it('retrieves a non-decrypted set of conversations each with a bound decrypt method', () => webex.internal.conversation.list({
340
- conversationsLimit: 2,
341
- deferDecrypt: true
342
- })
343
- .then(([c1, c2]) => {
344
- assert.lengthOf(c1.displayName.split('.'), 5, '5 periods implies this is a jwt and not a decrypted string');
345
- assert.notInclude(['test 1, test 2'], c1.displayName);
346
-
347
- assert.lengthOf(c2.displayName.split('.'), 5, '5 periods implies this is a jwt and not a decrypted string');
348
- assert.notInclude(['test 1, test 2'], c2.displayName);
349
-
350
- return Promise.all([
351
- c1.decrypt()
352
- .then(() => assert.notInclude(['test 1, test 2'], c1.displayName)),
353
- c2.decrypt()
354
- .then(() => assert.notInclude(['test 1, test 2'], c2.displayName))
355
- ]);
356
- }));
412
+ it('retrieves a non-decrypted set of conversations each with a bound decrypt method', () =>
413
+ webex.internal.conversation
414
+ .list({
415
+ conversationsLimit: 2,
416
+ deferDecrypt: true,
417
+ })
418
+ .then(([c1, c2]) => {
419
+ assert.lengthOf(
420
+ c1.displayName.split('.'),
421
+ 5,
422
+ '5 periods implies this is a jwt and not a decrypted string'
423
+ );
424
+ assert.notInclude(['test 1, test 2'], c1.displayName);
425
+
426
+ assert.lengthOf(
427
+ c2.displayName.split('.'),
428
+ 5,
429
+ '5 periods implies this is a jwt and not a decrypted string'
430
+ );
431
+ assert.notInclude(['test 1, test 2'], c2.displayName);
432
+
433
+ return Promise.all([
434
+ c1.decrypt().then(() => assert.notInclude(['test 1, test 2'], c1.displayName)),
435
+ c2.decrypt().then(() => assert.notInclude(['test 1, test 2'], c2.displayName)),
436
+ ]);
437
+ }));
357
438
  });
358
439
 
359
440
  describe('with deferDecrypt && summary = true', () => {
360
- it('retrieves a non-decrypted set of conversations each with a bound decrypt method', () => webex.internal.conversation.list({
361
- conversationsLimit: 2,
362
- deferDecrypt: true,
363
- summary: true
364
- })
365
- .then(([c1, c2]) => {
366
- assert.lengthOf(c1.displayName.split('.'), 5, '5 periods implies this is a jwt and not a decrypted string');
367
- assert.notInclude(['test 1, test 2'], c1.displayName);
368
-
369
- assert.lengthOf(c2.displayName.split('.'), 5, '5 periods implies this is a jwt and not a decrypted string');
370
- assert.notInclude(['test 1, test 2'], c2.displayName);
371
-
372
- return Promise.all([
373
- c1.decrypt()
374
- .then(() => assert.notInclude(['test 1, test 2'], c1.displayName)),
375
- c2.decrypt()
376
- .then(() => assert.notInclude(['test 1, test 2'], c2.displayName))
377
- ]);
378
- }));
441
+ it('retrieves a non-decrypted set of conversations each with a bound decrypt method', () =>
442
+ webex.internal.conversation
443
+ .list({
444
+ conversationsLimit: 2,
445
+ deferDecrypt: true,
446
+ summary: true,
447
+ })
448
+ .then(([c1, c2]) => {
449
+ assert.lengthOf(
450
+ c1.displayName.split('.'),
451
+ 5,
452
+ '5 periods implies this is a jwt and not a decrypted string'
453
+ );
454
+ assert.notInclude(['test 1, test 2'], c1.displayName);
455
+
456
+ assert.lengthOf(
457
+ c2.displayName.split('.'),
458
+ 5,
459
+ '5 periods implies this is a jwt and not a decrypted string'
460
+ );
461
+ assert.notInclude(['test 1, test 2'], c2.displayName);
462
+
463
+ return Promise.all([
464
+ c1.decrypt().then(() => assert.notInclude(['test 1, test 2'], c1.displayName)),
465
+ c2.decrypt().then(() => assert.notInclude(['test 1, test 2'], c2.displayName)),
466
+ ]);
467
+ }));
379
468
  });
380
469
 
381
- describe('with conversation from remote clusters', () => {
470
+ // SPARK-413317
471
+ describe.skip('with conversation from remote clusters', () => {
382
472
  let conversation3, conversation4;
383
473
 
384
- before('create conversations in EU cluster', () => Promise.all([
385
- suluEU.webex.internal.conversation.create({
386
- displayName: 'eu test 1',
387
- participants
388
- })
389
- .then((c) => { conversation3 = c; }),
390
- suluEU.webex.internal.conversation.create({
391
- displayName: 'eu test 2',
392
- participants: [checkov.id, spock.id]
393
- })
394
- .then((c) => { conversation4 = c; })
395
- ]));
474
+ before('create conversations in EU cluster', () =>
475
+ Promise.all([
476
+ suluEU.webex.internal.conversation
477
+ .create({
478
+ displayName: 'eu test 1',
479
+ participants,
480
+ })
481
+ .then((c) => {
482
+ conversation3 = c;
483
+ }),
484
+ suluEU.webex.internal.conversation
485
+ .create({
486
+ displayName: 'eu test 2',
487
+ participants: [checkov.id, spock.id],
488
+ })
489
+ .then((c) => {
490
+ conversation4 = c;
491
+ }),
492
+ ])
493
+ );
396
494
 
397
- it('retrieves local + remote cluster conversations', () => webex.internal.conversation.list()
398
- .then((conversations) => {
495
+ it('retrieves local + remote cluster conversations', () =>
496
+ webex.internal.conversation.list().then((conversations) => {
399
497
  assert.include(map(conversations, 'url'), conversation1.url);
400
498
  assert.include(map(conversations, 'url'), conversation2.url);
401
499
  assert.include(map(conversations, 'url'), conversation3.url);
402
500
  assert.include(map(conversations, 'url'), conversation4.url);
403
501
  }));
404
502
 
405
- it('retrieves only remote cluter conversations if user does not have any local conversations',
406
- () => checkov.webex.internal.conversation.list()
407
- .then((conversations) => {
408
- assert.include(map(conversations, 'url'), conversation4.url);
409
- assert.lengthOf(conversations, 1);
410
- }));
503
+ it('retrieves only remote cluter conversations if user does not have any local conversations', () =>
504
+ checkov.webex.internal.conversation.list().then((conversations) => {
505
+ assert.include(map(conversations, 'url'), conversation4.url);
506
+ assert.lengthOf(conversations, 1);
507
+ }));
411
508
  });
412
509
  });
413
510
 
414
511
  describe('#listLeft()', () => {
415
512
  let conversation;
416
513
 
417
- before('create conversation', () => webex.internal.conversation.create({participants})
418
- .then((c) => { conversation = c; }));
514
+ before('create conversation', () =>
515
+ webex.internal.conversation.create({participants}).then((c) => {
516
+ conversation = c;
517
+ })
518
+ );
419
519
 
420
- it('retrieves the conversations the current user has left', () => webex.internal.conversation.listLeft()
421
- .then((c) => {
422
- assert.lengthOf(c, 0);
520
+ it('retrieves the conversations the current user has left', () =>
521
+ webex.internal.conversation
522
+ .listLeft()
523
+ .then((c) => {
524
+ assert.lengthOf(c, 0);
423
525
 
424
- return webex.internal.conversation.leave(conversation);
425
- })
426
- .then(() => webex.internal.conversation.listLeft())
427
- .then((c) => {
428
- assert.lengthOf(c, 1);
429
- assert.equal(c[0].id, conversation.id);
430
- }));
526
+ return webex.internal.conversation.leave(conversation);
527
+ })
528
+ .then(() => webex.internal.conversation.listLeft())
529
+ .then((c) => {
530
+ assert.lengthOf(c, 1);
531
+ assert.equal(c[0].id, conversation.id);
532
+ }));
431
533
  });
432
534
 
433
535
  describe('#listActivities()', () => {
434
536
  let conversation;
435
537
 
436
- before('create conversation with activity', () => webex.internal.conversation.create({participants})
437
- .then((c) => {
538
+ before('create conversation with activity', () =>
539
+ webex.internal.conversation.create({participants}).then((c) => {
438
540
  conversation = c;
439
541
  assert.lengthOf(conversation.participants.items, 3);
440
542
 
441
543
  return webex.internal.conversation.post(conversation, {displayName: 'first message'});
442
- }));
443
-
444
- it('retrieves activities for the specified conversation', () => webex.internal.conversation.listActivities({conversationUrl: conversation.url})
445
- .then((activities) => {
446
- assert.isArray(activities);
447
- assert.lengthOf(activities, 2);
448
- }));
544
+ })
545
+ );
546
+
547
+ it('retrieves activities for the specified conversation', () =>
548
+ webex.internal.conversation
549
+ .listActivities({conversationUrl: conversation.url})
550
+ .then((activities) => {
551
+ assert.isArray(activities);
552
+ assert.lengthOf(activities, 2);
553
+ }));
449
554
  });
450
555
 
451
556
  describe('#listThreads()', () => {
@@ -454,8 +559,8 @@ describe('plugin-conversation', function () {
454
559
  before('connect mccoy to mercury', () => {
455
560
  webex2 = new WebexCore({
456
561
  credentials: {
457
- authorization: mccoy.token
458
- }
562
+ authorization: mccoy.token,
563
+ },
459
564
  });
460
565
 
461
566
  return webex2.internal.mercury.connect();
@@ -466,33 +571,40 @@ describe('plugin-conversation', function () {
466
571
  let conversation;
467
572
  let parent;
468
573
 
469
- before('create conversation', () => webex.internal.conversation.create({participants})
470
- .then((c) => {
574
+ before('create conversation', () =>
575
+ webex.internal.conversation.create({participants}).then((c) => {
471
576
  conversation = c;
472
577
  assert.lengthOf(conversation.participants.items, 3);
473
578
 
474
- return webex2.internal.conversation.post(conversation, {displayName: 'first message'}).then((parentActivity) => {
475
- parent = parentActivity;
476
- });
477
- }));
579
+ return webex2.internal.conversation
580
+ .post(conversation, {displayName: 'first message'})
581
+ .then((parentActivity) => {
582
+ parent = parentActivity;
583
+ });
584
+ })
585
+ );
478
586
 
479
- it('retrieves threads()', () => webex2.internal.conversation.post(conversation, 'thread1', {
480
- parentActivityId: parent.id,
481
- activityType: 'reply'
482
- }).then(() => webex2.internal.conversation.listThreads()).then((thread) => {
483
- assert.equal(thread.length, 1);
484
- const firstThread = thread[0];
587
+ it('retrieves threads()', () =>
588
+ webex2.internal.conversation
589
+ .post(conversation, 'thread1', {
590
+ parentActivityId: parent.id,
591
+ activityType: 'reply',
592
+ })
593
+ .then(() => webex2.internal.conversation.listThreads())
594
+ .then((thread) => {
595
+ assert.equal(thread.length, 1);
596
+ const firstThread = thread[0];
485
597
 
486
- assert.equal(firstThread.childType, 'reply');
487
- assert.equal(firstThread.parentActivityId, parent.id);
488
- assert.equal(firstThread.conversationId, conversation.id);
489
- assert.equal(firstThread.childActivities.length, 1);
598
+ assert.equal(firstThread.childType, 'reply');
599
+ assert.equal(firstThread.parentActivityId, parent.id);
600
+ assert.equal(firstThread.conversationId, conversation.id);
601
+ assert.equal(firstThread.childActivities.length, 1);
490
602
 
491
- const childActivity = firstThread.childActivities[0];
603
+ const childActivity = firstThread.childActivities[0];
492
604
 
493
- assert.equal(childActivity.objectType, 'activity');
494
- assert.equal(childActivity.object.displayName, 'thread1');
495
- }));
605
+ assert.equal(childActivity.objectType, 'activity');
606
+ assert.equal(childActivity.object.displayName, 'thread1');
607
+ }));
496
608
  });
497
609
 
498
610
  describe('#listMentions()', () => {
@@ -501,8 +613,8 @@ describe('plugin-conversation', function () {
501
613
  before('connect mccoy to mercury', () => {
502
614
  webex2 = new WebexCore({
503
615
  credentials: {
504
- authorization: mccoy.token
505
- }
616
+ authorization: mccoy.token,
617
+ },
506
618
  });
507
619
 
508
620
  return webex2.internal.mercury.connect();
@@ -512,27 +624,35 @@ describe('plugin-conversation', function () {
512
624
 
513
625
  let conversation;
514
626
 
515
- before('create conversation', () => webex.internal.conversation.create({participants})
516
- .then((c) => {
627
+ before('create conversation', () =>
628
+ webex.internal.conversation.create({participants}).then((c) => {
517
629
  conversation = c;
518
630
  assert.lengthOf(conversation.participants.items, 3);
519
- }));
520
-
521
- it('retrieves activities in which the current user was mentioned', () => webex2.internal.conversation.post(conversation, {
522
- displayName: 'Green blooded hobgloblin',
523
- content: `<webex-mention data-object-type="person" data-object-id="${spock.id}">Green blooded hobgloblin</webex-mention>`,
524
- mentions: {
525
- items: [{
526
- id: `${spock.id}`,
527
- objectType: 'person'
528
- }]
529
- }
530
- })
531
- .then((activity) => webex.internal.conversation.listMentions({sinceDate: Date.parse(activity.published) - 1})
532
- .then((mentions) => {
533
- assert.lengthOf(mentions, 1);
534
- assert.equal(mentions[0].url, activity.url);
535
- })));
631
+ })
632
+ );
633
+
634
+ it('retrieves activities in which the current user was mentioned', () =>
635
+ webex2.internal.conversation
636
+ .post(conversation, {
637
+ displayName: 'Green blooded hobgloblin',
638
+ content: `<webex-mention data-object-type="person" data-object-id="${spock.id}">Green blooded hobgloblin</webex-mention>`,
639
+ mentions: {
640
+ items: [
641
+ {
642
+ id: `${spock.id}`,
643
+ objectType: 'person',
644
+ },
645
+ ],
646
+ },
647
+ })
648
+ .then((activity) =>
649
+ webex.internal.conversation
650
+ .listMentions({sinceDate: Date.parse(activity.published) - 1})
651
+ .then((mentions) => {
652
+ assert.lengthOf(mentions, 1);
653
+ assert.equal(mentions[0].url, activity.url);
654
+ })
655
+ ));
536
656
  });
537
657
 
538
658
  // TODO: add testing for bulk_activities_fetch() with clusters later
@@ -540,44 +660,61 @@ describe('plugin-conversation', function () {
540
660
  let jenny, maria, dan, convo1, convo2, euConvo1;
541
661
  let webex3;
542
662
 
543
- before('create tests users and connect one to mercury', () => testUsers.create({count: 4})
544
- .then((users) => {
663
+ before('create tests users and connect one to mercury', () =>
664
+ testUsers.create({count: 4}).then((users) => {
545
665
  [jenny, maria, dan] = users;
546
666
 
547
667
  webex3 = new WebexCore({
548
668
  credentials: {
549
- authorization: jenny.token
550
- }
669
+ authorization: jenny.token,
670
+ },
551
671
  });
552
672
 
553
673
  return webex3.internal.mercury.connect();
554
- }));
674
+ })
675
+ );
555
676
 
556
677
  after(() => webex3 && webex3.internal.mercury.disconnect());
557
678
 
558
- before('create conversation 1', () => webex3.internal.conversation.create({participants: [jenny, maria]})
559
- .then((c1) => { convo1 = c1; }));
679
+ before('create conversation 1', () =>
680
+ webex3.internal.conversation.create({participants: [jenny, maria]}).then((c1) => {
681
+ convo1 = c1;
682
+ })
683
+ );
560
684
 
561
- before('create conversation 2', () => webex3.internal.conversation.create({participants: [jenny, dan]})
562
- .then((c2) => { convo2 = c2; }));
685
+ before('create conversation 2', () =>
686
+ webex3.internal.conversation.create({participants: [jenny, dan]}).then((c2) => {
687
+ convo2 = c2;
688
+ })
689
+ );
563
690
 
564
- before('create conversations in EU cluster', () => suluEU.webex.internal.conversation.create({
565
- displayName: 'eu test 1',
566
- participants: [jenny, suluEU, dan]
567
- })
568
- .then((c) => { euConvo1 = c; }));
691
+ before('create conversations in EU cluster', () =>
692
+ suluEU.webex.internal.conversation
693
+ .create({
694
+ displayName: 'eu test 1',
695
+ participants: [jenny, suluEU, dan],
696
+ })
697
+ .then((c) => {
698
+ euConvo1 = c;
699
+ })
700
+ );
569
701
 
570
702
  before('add comments to convo1, and check post requests successfully went through', () =>
571
- webex3.internal.conversation.post(convo1, {displayName: 'BAGELS (O)'})
703
+ webex3.internal.conversation
704
+ .post(convo1, {displayName: 'BAGELS (O)'})
572
705
  .then((c1) => {
573
706
  assert.equal(c1.object.displayName, 'BAGELS (O)');
574
707
 
575
708
  return webex3.internal.conversation.post(convo1, {displayName: 'Cream Cheese'});
576
709
  })
577
- .then((c2) => { assert.equal(c2.object.displayName, 'Cream Cheese'); }));
710
+ .then((c2) => {
711
+ assert.equal(c2.object.displayName, 'Cream Cheese');
712
+ })
713
+ );
578
714
 
579
715
  before('add comments to convo2, and check post requests successfully went through', () =>
580
- webex3.internal.conversation.post(convo2, {displayName: 'Want to head to lunch soon?'})
716
+ webex3.internal.conversation
717
+ .post(convo2, {displayName: 'Want to head to lunch soon?'})
581
718
  .then((c1) => {
582
719
  assert.equal(c1.object.displayName, 'Want to head to lunch soon?');
583
720
 
@@ -593,16 +730,20 @@ describe('plugin-conversation', function () {
593
730
 
594
731
  return webex3.internal.conversation.post(convo2, {displayName: 'Meekong Bar!'});
595
732
  })
596
- .then((c4) => { assert.equal(c4.object.displayName, 'Meekong Bar!'); }));
733
+ .then((c4) => {
734
+ assert.equal(c4.object.displayName, 'Meekong Bar!');
735
+ })
736
+ );
597
737
 
598
738
  before('add comments to euConvo1, and check post requests successfully went through', () =>
599
- suluEU.webex.internal.conversation.post(euConvo1, {displayName: 'Hello'})
600
- .then((c1) => {
601
- assert.equal(c1.object.displayName, 'Hello');
602
- }));
739
+ suluEU.webex.internal.conversation.post(euConvo1, {displayName: 'Hello'}).then((c1) => {
740
+ assert.equal(c1.object.displayName, 'Hello');
741
+ })
742
+ );
603
743
 
604
744
  it('retrieves activities from a single conversation', () =>
605
- webex3.internal.conversation.listActivities({conversationUrl: convo1.url})
745
+ webex3.internal.conversation
746
+ .listActivities({conversationUrl: convo1.url})
606
747
  .then((convoActivities) => {
607
748
  const activityURLs = [];
608
749
  const expectedActivities = [];
@@ -614,11 +755,18 @@ describe('plugin-conversation', function () {
614
755
  }
615
756
  });
616
757
 
617
- return webex3.internal.conversation.bulkActivitiesFetch(activityURLs)
758
+ return webex3.internal.conversation
759
+ .bulkActivitiesFetch(activityURLs)
618
760
  .then((bulkFetchedActivities) => {
619
761
  assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
620
- assert.equal(bulkFetchedActivities[0].object.displayName, expectedActivities[0].object.displayName);
621
- assert.equal(bulkFetchedActivities[1].object.displayName, expectedActivities[1].object.displayName);
762
+ assert.equal(
763
+ bulkFetchedActivities[0].object.displayName,
764
+ expectedActivities[0].object.displayName
765
+ );
766
+ assert.equal(
767
+ bulkFetchedActivities[1].object.displayName,
768
+ expectedActivities[1].object.displayName
769
+ );
622
770
  });
623
771
  }));
624
772
 
@@ -626,7 +774,8 @@ describe('plugin-conversation', function () {
626
774
  const activityURLs = [];
627
775
  const expectedActivities = [];
628
776
 
629
- return webex3.internal.conversation.listActivities({conversationUrl: convo1.url})
777
+ return webex3.internal.conversation
778
+ .listActivities({conversationUrl: convo1.url})
630
779
  .then((convo1Activities) => {
631
780
  // gets all post activity urls from convo1
632
781
  convo1Activities.forEach((a1) => {
@@ -645,21 +794,36 @@ describe('plugin-conversation', function () {
645
794
  expectedActivities.push(convo2Activities[i]);
646
795
  });
647
796
 
648
- return webex3.internal.conversation.bulkActivitiesFetch(activityURLs)
797
+ return webex3.internal.conversation
798
+ .bulkActivitiesFetch(activityURLs)
649
799
  .then((bulkFetchedActivities) => {
650
800
  assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
651
- assert.equal(bulkFetchedActivities[0].object.displayName, expectedActivities[0].object.displayName);
652
- assert.equal(bulkFetchedActivities[1].object.displayName, expectedActivities[1].object.displayName);
653
- assert.equal(bulkFetchedActivities[2].object.displayName, expectedActivities[2].object.displayName);
654
- assert.equal(bulkFetchedActivities[3].object.displayName, expectedActivities[3].object.displayName);
801
+ assert.equal(
802
+ bulkFetchedActivities[0].object.displayName,
803
+ expectedActivities[0].object.displayName
804
+ );
805
+ assert.equal(
806
+ bulkFetchedActivities[1].object.displayName,
807
+ expectedActivities[1].object.displayName
808
+ );
809
+ assert.equal(
810
+ bulkFetchedActivities[2].object.displayName,
811
+ expectedActivities[2].object.displayName
812
+ );
813
+ assert.equal(
814
+ bulkFetchedActivities[3].object.displayName,
815
+ expectedActivities[3].object.displayName
816
+ );
655
817
  });
656
818
  });
657
819
  });
658
820
 
659
821
  it('given a activity url that does not exist, should return []', () => {
660
- const mockURL = 'https://conversation-intb.ciscospark.com/conversation/api/v1/activities/6d8c7c90-a770-11e9-bcfb-6616ead99ac3';
822
+ const mockURL =
823
+ 'https://conversation-intb.ciscospark.com/conversation/api/v1/activities/6d8c7c90-a770-11e9-bcfb-6616ead99ac3';
661
824
 
662
- webex3.internal.conversation.bulkActivitiesFetch([mockURL])
825
+ webex3.internal.conversation
826
+ .bulkActivitiesFetch([mockURL])
663
827
  .then((bulkFetchedActivities) => {
664
828
  assert.equal(bulkFetchedActivities, []);
665
829
  });
@@ -669,9 +833,10 @@ describe('plugin-conversation', function () {
669
833
  const activityURLs = [];
670
834
  const expectedActivities = [];
671
835
 
672
- return webex3.internal.conversation.listActivities({conversationUrl: convo1.url})
836
+ return webex3.internal.conversation
837
+ .listActivities({conversationUrl: convo1.url})
673
838
  .then((convo1Activities) => {
674
- // gets all post activity urls from convo1
839
+ // gets all post activity urls from convo1
675
840
  convo1Activities.forEach((a1) => {
676
841
  if (a1.verb === 'post') {
677
842
  activityURLs.push(a1.url);
@@ -688,13 +853,26 @@ describe('plugin-conversation', function () {
688
853
  expectedActivities.push(convo2Activities[i]);
689
854
  });
690
855
 
691
- return webex3.internal.conversation.bulkActivitiesFetch(activityURLs, undefined, {url: process.env.CONVERSATION_SERVICE})
856
+ return webex3.internal.conversation
857
+ .bulkActivitiesFetch(activityURLs, undefined, {url: process.env.CONVERSATION_SERVICE})
692
858
  .then((bulkFetchedActivities) => {
693
859
  assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
694
- assert.equal(bulkFetchedActivities[0].object.displayName, expectedActivities[0].object.displayName);
695
- assert.equal(bulkFetchedActivities[1].object.displayName, expectedActivities[1].object.displayName);
696
- assert.equal(bulkFetchedActivities[2].object.displayName, expectedActivities[2].object.displayName);
697
- assert.equal(bulkFetchedActivities[3].object.displayName, expectedActivities[3].object.displayName);
860
+ assert.equal(
861
+ bulkFetchedActivities[0].object.displayName,
862
+ expectedActivities[0].object.displayName
863
+ );
864
+ assert.equal(
865
+ bulkFetchedActivities[1].object.displayName,
866
+ expectedActivities[1].object.displayName
867
+ );
868
+ assert.equal(
869
+ bulkFetchedActivities[2].object.displayName,
870
+ expectedActivities[2].object.displayName
871
+ );
872
+ assert.equal(
873
+ bulkFetchedActivities[3].object.displayName,
874
+ expectedActivities[3].object.displayName
875
+ );
698
876
  });
699
877
  });
700
878
  });
@@ -703,7 +881,8 @@ describe('plugin-conversation', function () {
703
881
  const activityURLs = [];
704
882
  const expectedActivities = [];
705
883
 
706
- return webex3.internal.conversation.listActivities({conversationUrl: euConvo1.url})
884
+ return webex3.internal.conversation
885
+ .listActivities({conversationUrl: euConvo1.url})
707
886
  .then((euConvo1Activities) => {
708
887
  const convoUrlRegex = /(.*)\/activities/;
709
888
 
@@ -716,7 +895,10 @@ describe('plugin-conversation', function () {
716
895
  })
717
896
  .then((bulkFetchedActivities) => {
718
897
  assert.lengthOf(bulkFetchedActivities, 1);
719
- assert.equal(bulkFetchedActivities[0].object.displayName, expectedActivities[0].object.displayName);
898
+ assert.equal(
899
+ bulkFetchedActivities[0].object.displayName,
900
+ expectedActivities[0].object.displayName
901
+ );
720
902
  });
721
903
  });
722
904
  });
@@ -724,84 +906,121 @@ describe('plugin-conversation', function () {
724
906
  describe('#listParentActivityIds', () => {
725
907
  let conversation, parent;
726
908
 
727
- beforeEach('create conversation with activity', () => webex.internal.conversation.create({participants})
728
- .then((c) => {
729
- conversation = c;
909
+ beforeEach('create conversation with activity', () =>
910
+ webex.internal.conversation
911
+ .create({participants})
912
+ .then((c) => {
913
+ conversation = c;
730
914
 
731
- return webex.internal.conversation.post(conversation, {displayName: 'first message'});
732
- })
733
- .then((parentAct) => {
734
- parent = parentAct;
735
- }));
915
+ return webex.internal.conversation.post(conversation, {displayName: 'first message'});
916
+ })
917
+ .then((parentAct) => {
918
+ parent = parentAct;
919
+ })
920
+ );
921
+
922
+ it('retrieves parent IDs for thread parents()', () =>
923
+ webex.internal.conversation
924
+ .post(
925
+ conversation,
926
+ {displayName: 'first thread reply'},
927
+ {
928
+ parentActivityId: parent.id,
929
+ activityType: 'reply',
930
+ }
931
+ )
932
+ .then(({parent: parentObj} = {}) => {
933
+ assert.equal(parentObj.type, 'reply');
934
+ assert.equal(parentObj.id, parent.id);
736
935
 
737
- it('retrieves parent IDs for thread parents()', () => webex.internal.conversation.post(conversation, {displayName: 'first thread reply'}, {
738
- parentActivityId: parent.id,
739
- activityType: 'reply'
740
- }).then(({parent: parentObj} = {}) => {
741
- assert.equal(parentObj.type, 'reply');
742
- assert.equal(parentObj.id, parent.id);
743
-
744
- return webex.internal.conversation.listParentActivityIds(conversation.url, {activityType: 'reply'});
745
- }).then(({reply}) => {
746
- assert.include(reply, parent.id);
747
- }));
748
-
749
- it('retrieves parent IDs for edits', () => webex.internal.conversation.post(conversation, 'edited', {
750
- parent: {
751
- id: parent.id,
752
- type: 'edit'
753
- }
754
- }).then((edit) => {
755
- assert.equal(edit.parent.type, 'edit');
756
- assert.equal(edit.parent.id, parent.id);
757
-
758
- return webex.internal.conversation.listParentActivityIds(conversation.url, {activityType: 'edit'});
759
- }).then(({edit}) => {
760
- assert.include(edit, parent.id);
761
- }));
762
-
763
- it('retrieves parent IDs for reactions', () => webex.internal.conversation.addReaction(conversation, 'heart', parent)
764
- .then((reaction) => {
765
- assert.equal(reaction.parent.type, 'reaction');
766
- assert.equal(reaction.parent.id, parent.id);
767
-
768
- return webex.internal.conversation.listParentActivityIds(conversation.url, {activityType: 'reaction'});
769
- }).then(({reaction}) => {
770
- assert.include(reaction, parent.id);
771
- }));
936
+ return webex.internal.conversation.listParentActivityIds(conversation.url, {
937
+ activityType: 'reply',
938
+ });
939
+ })
940
+ .then(({reply}) => {
941
+ assert.include(reply, parent.id);
942
+ }));
943
+
944
+ it('retrieves parent IDs for edits', () =>
945
+ webex.internal.conversation
946
+ .post(conversation, 'edited', {
947
+ parent: {
948
+ id: parent.id,
949
+ type: 'edit',
950
+ },
951
+ })
952
+ .then((edit) => {
953
+ assert.equal(edit.parent.type, 'edit');
954
+ assert.equal(edit.parent.id, parent.id);
955
+
956
+ return webex.internal.conversation.listParentActivityIds(conversation.url, {
957
+ activityType: 'edit',
958
+ });
959
+ })
960
+ .then(({edit}) => {
961
+ assert.include(edit, parent.id);
962
+ }));
963
+
964
+ it('retrieves parent IDs for reactions', () =>
965
+ webex.internal.conversation
966
+ .addReaction(conversation, 'heart', parent)
967
+ .then((reaction) => {
968
+ assert.equal(reaction.parent.type, 'reaction');
969
+ assert.equal(reaction.parent.id, parent.id);
970
+
971
+ return webex.internal.conversation.listParentActivityIds(conversation.url, {
972
+ activityType: 'reaction',
973
+ });
974
+ })
975
+ .then(({reaction}) => {
976
+ assert.include(reaction, parent.id);
977
+ }));
772
978
  });
773
979
 
774
980
  describe('#listChildActivitiesByParentId()', () => {
775
981
  let conversation, parent;
776
982
  let replies;
777
983
 
778
- before('create conversation with thread replies', () => webex.internal.conversation.create({participants})
779
- .then((c) => {
780
- conversation = c;
781
-
782
- return webex.internal.conversation.post(conversation, {displayName: 'first message'});
783
- }).then((parentAct) => {
784
- parent = parentAct;
785
-
786
- const messages = ['thread 1', 'thread 2', 'thread 3'];
787
-
788
- return Promise.all(messages.map((msg) =>
789
- webex.internal.conversation.post(conversation, msg, {
790
- parentActivityId: parent.id,
791
- activityType: 'reply'
792
- })));
793
- }).then((repliesArr) => {
794
- replies = repliesArr;
795
- }));
796
-
797
- it('retrieves thread reply activities for a given parent', () => webex.internal.conversation.listChildActivitiesByParentId(conversation.url, parent.id, 'reply')
798
- .then((response) => {
799
- const {items} = response.body;
984
+ before('create conversation with thread replies', () =>
985
+ webex.internal.conversation
986
+ .create({participants})
987
+ .then((c) => {
988
+ conversation = c;
800
989
 
801
- items.forEach((threadAct) => {
802
- assert.include(replies.map((reply) => reply.id), threadAct.id);
803
- });
804
- }));
990
+ return webex.internal.conversation.post(conversation, {displayName: 'first message'});
991
+ })
992
+ .then((parentAct) => {
993
+ parent = parentAct;
994
+
995
+ const messages = ['thread 1', 'thread 2', 'thread 3'];
996
+
997
+ return Promise.all(
998
+ messages.map((msg) =>
999
+ webex.internal.conversation.post(conversation, msg, {
1000
+ parentActivityId: parent.id,
1001
+ activityType: 'reply',
1002
+ })
1003
+ )
1004
+ );
1005
+ })
1006
+ .then((repliesArr) => {
1007
+ replies = repliesArr;
1008
+ })
1009
+ );
1010
+
1011
+ it('retrieves thread reply activities for a given parent', () =>
1012
+ webex.internal.conversation
1013
+ .listChildActivitiesByParentId(conversation.url, parent.id, 'reply')
1014
+ .then((response) => {
1015
+ const {items} = response.body;
1016
+
1017
+ items.forEach((threadAct) => {
1018
+ assert.include(
1019
+ replies.map((reply) => reply.id),
1020
+ threadAct.id
1021
+ );
1022
+ });
1023
+ }));
805
1024
  });
806
1025
 
807
1026
  describe('#_listActivitiesThreadOrdered', () => {
@@ -817,33 +1036,36 @@ describe('plugin-conversation', function () {
817
1036
  'sixth message',
818
1037
  'seventh message',
819
1038
  'eighth message',
820
- 'ninth message'
1039
+ 'ninth message',
821
1040
  ];
822
1041
 
823
- const initializeGenerator = () => webex.internal.conversation.listActivitiesThreadOrdered({
824
- conversationUrl: conversation.url,
825
- minActivities
826
- });
1042
+ const initializeGenerator = () =>
1043
+ webex.internal.conversation.listActivitiesThreadOrdered({
1044
+ conversationUrl: conversation.url,
1045
+ minActivities,
1046
+ });
827
1047
 
828
- before(() => webex.internal.conversation.create({participants})
829
- .then((c) => {
830
- conversation = c;
1048
+ before(() =>
1049
+ webex.internal.conversation
1050
+ .create({participants})
1051
+ .then((c) => {
1052
+ conversation = c;
831
1053
 
832
- return c;
833
- })
834
- .then((c) =>
835
- Promise.all(displayNames.slice(0, 5).map(postMessage(webex, c))))
836
- .then((parents) => {
837
- firstParentBatch = parents;
1054
+ return c;
1055
+ })
1056
+ .then((c) => Promise.all(displayNames.slice(0, 5).map(postMessage(webex, c))))
1057
+ .then((parents) => {
1058
+ firstParentBatch = parents;
838
1059
 
839
- return Promise.all(createThreadObjs(parents).map(postReply(webex, conversation)));
840
- })
841
- .then(() => Promise.all(displayNames.slice(4).map(postMessage(webex, conversation))))
842
- .then((parents) => {
843
- secondParentBatch = parents;
1060
+ return Promise.all(createThreadObjs(parents).map(postReply(webex, conversation)));
1061
+ })
1062
+ .then(() => Promise.all(displayNames.slice(4).map(postMessage(webex, conversation))))
1063
+ .then((parents) => {
1064
+ secondParentBatch = parents;
844
1065
 
845
- return Promise.all(createThreadObjs(parents).map(postReply(webex, conversation)));
846
- }));
1066
+ return Promise.all(createThreadObjs(parents).map(postReply(webex, conversation)));
1067
+ })
1068
+ );
847
1069
 
848
1070
  beforeEach(() => {
849
1071
  const funcs = initializeGenerator();
@@ -852,31 +1074,33 @@ describe('plugin-conversation', function () {
852
1074
  jumpToActivity = funcs.jumpToActivity;
853
1075
  });
854
1076
 
855
- it('should return more than or exactly N minimum activities', () => getOlder().then(({value}) => {
856
- assert.isAtLeast(value.length, minActivities);
857
- }));
1077
+ it('should return more than or exactly N minimum activities', () =>
1078
+ getOlder().then(({value}) => {
1079
+ assert.isAtLeast(value.length, minActivities);
1080
+ }));
858
1081
 
859
1082
  it('should return edit activity ID as activity ID when an activity has been edited', () => {
860
1083
  const lastParent = secondParentBatch[secondParentBatch.length - 1];
861
1084
 
862
1085
  const message = {
863
1086
  displayName: 'edited',
864
- content: 'edited'
1087
+ content: 'edited',
865
1088
  };
866
1089
 
867
1090
  const editingActivity = Object.assign(
868
1091
  {
869
1092
  parent: {
870
1093
  id: lastParent.id,
871
- type: 'edit'
872
- }
1094
+ type: 'edit',
1095
+ },
873
1096
  },
874
1097
  {
875
- object: message
1098
+ object: message,
876
1099
  }
877
1100
  );
878
1101
 
879
- return webex.internal.conversation.post(conversation, message, editingActivity)
1102
+ return webex.internal.conversation
1103
+ .post(conversation, message, editingActivity)
880
1104
  .then(() => getOlder())
881
1105
  .then(({value}) => {
882
1106
  const activities = value.map((act) => act.activity);
@@ -887,19 +1111,20 @@ describe('plugin-conversation', function () {
887
1111
  });
888
1112
  });
889
1113
 
890
- it('should return activities in thread order', () => getOlder().then((data) => {
891
- const {value} = data;
892
- const oldestAct = value[0].activity;
893
- const newestAct = value[value.length - 1].activity;
1114
+ it('should return activities in thread order', () =>
1115
+ getOlder().then((data) => {
1116
+ const {value} = data;
1117
+ const oldestAct = value[0].activity;
1118
+ const newestAct = value[value.length - 1].activity;
894
1119
 
895
- const oldestThreadIx = findIndex(value, ['activity.parent.type', 'reply']);
896
- const oldestParent = value[oldestThreadIx - 1].activity;
1120
+ const oldestThreadIx = findIndex(value, ['activity.parent.type', 'reply']);
1121
+ const oldestParent = value[oldestThreadIx - 1].activity;
897
1122
 
898
- assert.isTrue(oldestAct.published < newestAct.published);
1123
+ assert.isTrue(oldestAct.published < newestAct.published);
899
1124
 
900
- assert.doesNotHaveAnyKeys(oldestParent, 'parentActivityId');
901
- assert.isTrue(oldestParent.object.objectType === 'comment');
902
- }));
1125
+ assert.doesNotHaveAnyKeys(oldestParent, 'parentActivityId');
1126
+ assert.isTrue(oldestParent.object.objectType === 'comment');
1127
+ }));
903
1128
 
904
1129
  it('should return next batch when getOlder is called a second time', () => {
905
1130
  let firstBatch;
@@ -913,91 +1138,115 @@ describe('plugin-conversation', function () {
913
1138
  .then(({value}) => {
914
1139
  const secondBatch = value;
915
1140
 
916
- const oldestRootInFirstBatch = find(firstBatch, ['activity.object.objectType', 'comment']).activity;
917
- const newestRootInSecondBatch = findLast(secondBatch, ['activity.object.objectType', 'comment']).activity;
1141
+ const oldestRootInFirstBatch = find(firstBatch, [
1142
+ 'activity.object.objectType',
1143
+ 'comment',
1144
+ ]).activity;
1145
+ const newestRootInSecondBatch = findLast(secondBatch, [
1146
+ 'activity.object.objectType',
1147
+ 'comment',
1148
+ ]).activity;
918
1149
 
919
1150
  assert.isTrue(oldestRootInFirstBatch.published > newestRootInSecondBatch.published);
920
1151
  });
921
1152
  });
922
1153
 
923
1154
  it('should return done as true when no more activities can be fetched', () => {
924
- const {getOlder: getOlderWithLargeMin} = webex.internal.conversation.listActivitiesThreadOrdered({conversationId: conversation.id, minActivities: 50});
925
-
926
- return getOlderWithLargeMin()
927
- .then(({done}) => {
928
- assert.isTrue(done);
1155
+ const {getOlder: getOlderWithLargeMin} =
1156
+ webex.internal.conversation.listActivitiesThreadOrdered({
1157
+ conversationId: conversation.id,
1158
+ minActivities: 50,
929
1159
  });
1160
+
1161
+ return getOlderWithLargeMin().then(({done}) => {
1162
+ assert.isTrue(done);
1163
+ });
930
1164
  });
931
1165
 
932
1166
  describe('jumpToActivity()', () => {
933
1167
  let _listActivitiesThreadOrderedSpy;
934
1168
 
935
1169
  beforeEach(() => {
936
- _listActivitiesThreadOrderedSpy = sinon.spy(webex.internal.conversation, '_listActivitiesThreadOrdered');
1170
+ _listActivitiesThreadOrderedSpy = sinon.spy(
1171
+ webex.internal.conversation,
1172
+ '_listActivitiesThreadOrdered'
1173
+ );
937
1174
  });
938
1175
 
939
1176
  afterEach(() => {
940
1177
  webex.internal.conversation._listActivitiesThreadOrdered.restore();
941
1178
  });
942
1179
 
943
-
944
1180
  it('should return searched-for activity with surrounding activities when jumpToActivity is called with an activity', () => {
945
1181
  const search = firstParentBatch[firstParentBatch.length - 1];
946
1182
 
947
- return jumpToActivity(search)
948
- .then(({value}) => {
949
- const searchedForActivityIx = findIndex(value, ['id', search.id]);
1183
+ return jumpToActivity(search).then(({value}) => {
1184
+ const searchedForActivityIx = findIndex(value, ['id', search.id]);
950
1185
 
951
- assert.isFalse(searchedForActivityIx === -1);
952
- assert.isTrue(searchedForActivityIx > 0);
953
- assert.isTrue(searchedForActivityIx < value.length);
954
- });
1186
+ assert.isFalse(searchedForActivityIx === -1);
1187
+ assert.isTrue(searchedForActivityIx > 0);
1188
+ assert.isTrue(searchedForActivityIx < value.length);
1189
+ });
955
1190
  });
956
1191
 
957
- it('should return all activities in a space when jumping to an activity in a space with less activities than the asked-for activities limit', () => webex.internal.conversation.create({participants: [scott.id]})
958
- .then((c) => webex.internal.conversation.post(c, {displayName: 'first message'})
959
- .then((m) => webex.internal.conversation.listActivities({conversationUrl: c.url})
960
- .then((acts) => jumpToActivity(m)
961
- .then(() => acts.length))))
962
- .then((actCount) => {
963
- assert.isTrue(actCount < minActivities);
964
- }));
1192
+ it('should return all activities in a space when jumping to an activity in a space with less activities than the asked-for activities limit', () =>
1193
+ webex.internal.conversation
1194
+ .create({participants: [scott.id]})
1195
+ .then((c) =>
1196
+ webex.internal.conversation
1197
+ .post(c, {displayName: 'first message'})
1198
+ .then((m) =>
1199
+ webex.internal.conversation
1200
+ .listActivities({conversationUrl: c.url})
1201
+ .then((acts) => jumpToActivity(m).then(() => acts.length))
1202
+ )
1203
+ )
1204
+ .then((actCount) => {
1205
+ assert.isTrue(actCount < minActivities);
1206
+ }));
965
1207
 
966
- it('should return all activities in a space when jumping to an activity in a space with more activities than the asked-for activities limit', () => webex.internal.conversation.create({participants: [scott.id]})
967
- .then((c) => {
968
- const $posts = [];
1208
+ it('should return all activities in a space when jumping to an activity in a space with more activities than the asked-for activities limit', () =>
1209
+ webex.internal.conversation
1210
+ .create({participants: [scott.id]})
1211
+ .then((c) => {
1212
+ const $posts = [];
969
1213
 
970
- // eslint-disable-next-line no-plusplus
971
- for (let i = 0; i < 15; i++) {
972
- $posts.push(webex.internal.conversation.post(c, {displayName: `message ${i}`}));
973
- }
1214
+ // eslint-disable-next-line no-plusplus
1215
+ for (let i = 0; i < 15; i++) {
1216
+ $posts.push(webex.internal.conversation.post(c, {displayName: `message ${i}`}));
1217
+ }
974
1218
 
975
- return Promise.all($posts)
976
- .then(() => webex.internal.conversation.post(c, {displayName: 'message last'}));
977
- })
978
- .then((lastPost) => jumpToActivity(lastPost))
979
- .then(({value: acts}) => {
980
- assert.isAtLeast(acts.length, minActivities);
1219
+ return Promise.all($posts).then(() =>
1220
+ webex.internal.conversation.post(c, {displayName: 'message last'})
1221
+ );
1222
+ })
1223
+ .then((lastPost) => jumpToActivity(lastPost))
1224
+ .then(({value: acts}) => {
1225
+ assert.isAtLeast(acts.length, minActivities);
981
1226
 
982
- const firstAct = acts[0].activity;
1227
+ const firstAct = acts[0].activity;
983
1228
 
984
- assert.notEqual(firstAct.verb, 'create');
985
- }));
1229
+ assert.notEqual(firstAct.verb, 'create');
1230
+ }));
986
1231
 
987
1232
  it('should re-initialize _listActivitiesThreadOrdered when jumpToActivity is called with a new URL', () => {
988
1233
  let conversation2, msg;
989
1234
 
990
- return webex.internal.conversation.create({participants: [scott.id]})
1235
+ return webex.internal.conversation
1236
+ .create({participants: [scott.id]})
991
1237
  .then((c) => {
992
1238
  conversation2 = c;
993
1239
 
994
- return webex.internal.conversation.post(conversation2, {displayName: 'first message'});
1240
+ return webex.internal.conversation.post(conversation2, {
1241
+ displayName: 'first message',
1242
+ });
995
1243
  })
996
1244
  .then((m) => {
997
1245
  msg = m;
998
1246
 
999
1247
  return jumpToActivity(msg);
1000
- }).then(() => {
1248
+ })
1249
+ .then(() => {
1001
1250
  assert.isTrue(_listActivitiesThreadOrderedSpy.args[0][0].url === conversation2.url);
1002
1251
  });
1003
1252
  });