@webex/internal-plugin-conversation 3.0.0-beta.3 → 3.0.0-beta.300

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