@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.
- package/README.md +1 -3
- package/dist/activities.js +8 -69
- package/dist/activities.js.map +1 -1
- package/dist/activity-thread-ordering.js +19 -79
- package/dist/activity-thread-ordering.js.map +1 -1
- package/dist/config.js +1 -7
- package/dist/config.js.map +1 -1
- package/dist/constants.js +4 -5
- package/dist/constants.js.map +1 -1
- package/dist/conversation.js +790 -1199
- package/dist/conversation.js.map +1 -1
- package/dist/convo-error.js +0 -23
- package/dist/convo-error.js.map +1 -1
- package/dist/decryption-transforms.js +35 -98
- package/dist/decryption-transforms.js.map +1 -1
- package/dist/encryption-transforms.js +11 -48
- package/dist/encryption-transforms.js.map +1 -1
- package/dist/index.js +7 -50
- package/dist/index.js.map +1 -1
- package/dist/share-activity.js +40 -106
- package/dist/share-activity.js.map +1 -1
- package/dist/to-array.js +9 -11
- package/dist/to-array.js.map +1 -1
- package/package.json +15 -15
- package/src/activities.js +10 -7
- package/src/activity-thread-ordering.js +27 -30
- package/src/activity-threading.md +68 -49
- package/src/config.js +5 -5
- package/src/conversation.js +621 -589
- package/src/decryption-transforms.js +103 -62
- package/src/encryption-transforms.js +103 -83
- package/src/index.js +82 -66
- package/src/share-activity.js +64 -55
- package/src/to-array.js +2 -2
- package/test/integration/spec/create.js +184 -118
- package/test/integration/spec/encryption.js +250 -186
- package/test/integration/spec/get.js +763 -514
- package/test/integration/spec/mercury.js +37 -27
- package/test/integration/spec/share.js +292 -229
- package/test/integration/spec/verbs.js +628 -441
- package/test/unit/spec/conversation.js +265 -163
- package/test/unit/spec/decrypt-transforms.js +112 -131
- package/test/unit/spec/encryption-transforms.js +24 -18
- package/test/unit/spec/share-activity.js +37 -40
|
@@ -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
|
-
|
|
36
|
-
|
|
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', () =>
|
|
53
|
-
|
|
54
|
-
|
|
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(
|
|
82
|
-
.
|
|
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(() =>
|
|
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', () =>
|
|
93
|
-
.then((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', () =>
|
|
96
|
-
.then((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', () =>
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
115
|
-
|
|
122
|
+
item.options = {
|
|
123
|
+
params: {
|
|
124
|
+
allow: 'invalidOption',
|
|
125
|
+
},
|
|
126
|
+
};
|
|
116
127
|
|
|
117
|
-
|
|
118
|
-
|
|
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('
|
|
123
|
-
.
|
|
124
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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', () =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
.
|
|
165
|
-
.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
|
209
|
+
return webex.internal.conversation
|
|
210
|
+
.download({url: makeLocalUrl('/sample-image-small-one.png')})
|
|
175
211
|
.on('progress', spy)
|
|
176
|
-
.then((f) =>
|
|
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', () =>
|
|
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
|
-
|
|
198
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
235
|
+
return webex.internal.conversation.download(fileItem, {shouldNotAddExifData: true});
|
|
236
|
+
})
|
|
237
|
+
.then((f) => {
|
|
238
|
+
assert.equal(fileItem.orientation, undefined);
|
|
203
239
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
240
|
+
return fh.isMatchingFile(f, sampleImagePortraitJpeg);
|
|
241
|
+
})
|
|
242
|
+
.then((result) => assert.isTrue(result)));
|
|
207
243
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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', () =>
|
|
223
|
-
|
|
224
|
-
.then((c) => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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', () =>
|
|
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', () =>
|
|
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', () =>
|
|
248
|
-
.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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', () =>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
269
|
-
|
|
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
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
.then(() =>
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
350
|
+
.then((c) => {
|
|
351
|
+
conversation2 = c;
|
|
352
|
+
})
|
|
353
|
+
);
|
|
316
354
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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.
|
|
333
|
-
|
|
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', () =>
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
c1.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
.
|
|
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', () =>
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
c1.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
.
|
|
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
|
-
|
|
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', () =>
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
.
|
|
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', () =>
|
|
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
|
-
|
|
407
|
-
.
|
|
408
|
-
|
|
409
|
-
|
|
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', () =>
|
|
418
|
-
.then((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', () =>
|
|
421
|
-
.
|
|
422
|
-
|
|
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
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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', () =>
|
|
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
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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', () =>
|
|
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
|
|
475
|
-
|
|
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()', () =>
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
603
|
+
const childActivity = firstThread.childActivities[0];
|
|
492
604
|
|
|
493
|
-
|
|
494
|
-
|
|
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', () =>
|
|
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
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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', () =>
|
|
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', () =>
|
|
559
|
-
.then((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', () =>
|
|
562
|
-
.then((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', () =>
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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
|
|
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) => {
|
|
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
|
|
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) => {
|
|
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
|
-
.
|
|
601
|
-
|
|
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
|
|
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
|
|
758
|
+
return webex3.internal.conversation
|
|
759
|
+
.bulkActivitiesFetch(activityURLs)
|
|
618
760
|
.then((bulkFetchedActivities) => {
|
|
619
761
|
assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
|
|
620
|
-
assert.equal(
|
|
621
|
-
|
|
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
|
|
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
|
|
797
|
+
return webex3.internal.conversation
|
|
798
|
+
.bulkActivitiesFetch(activityURLs)
|
|
649
799
|
.then((bulkFetchedActivities) => {
|
|
650
800
|
assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
|
|
651
|
-
assert.equal(
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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 =
|
|
822
|
+
const mockURL =
|
|
823
|
+
'https://conversation-intb.ciscospark.com/conversation/api/v1/activities/6d8c7c90-a770-11e9-bcfb-6616ead99ac3';
|
|
661
824
|
|
|
662
|
-
webex3.internal.conversation
|
|
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
|
|
836
|
+
return webex3.internal.conversation
|
|
837
|
+
.listActivities({conversationUrl: convo1.url})
|
|
673
838
|
.then((convo1Activities) => {
|
|
674
|
-
|
|
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
|
|
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(
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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
|
|
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(
|
|
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', () =>
|
|
728
|
-
.
|
|
729
|
-
|
|
909
|
+
beforeEach('create conversation with activity', () =>
|
|
910
|
+
webex.internal.conversation
|
|
911
|
+
.create({participants})
|
|
912
|
+
.then((c) => {
|
|
913
|
+
conversation = c;
|
|
730
914
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
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
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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', () =>
|
|
779
|
-
.
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
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
|
-
|
|
802
|
-
|
|
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 = () =>
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1042
|
+
const initializeGenerator = () =>
|
|
1043
|
+
webex.internal.conversation.listActivitiesThreadOrdered({
|
|
1044
|
+
conversationUrl: conversation.url,
|
|
1045
|
+
minActivities,
|
|
1046
|
+
});
|
|
827
1047
|
|
|
828
|
-
before(() =>
|
|
829
|
-
.
|
|
830
|
-
|
|
1048
|
+
before(() =>
|
|
1049
|
+
webex.internal.conversation
|
|
1050
|
+
.create({participants})
|
|
1051
|
+
.then((c) => {
|
|
1052
|
+
conversation = c;
|
|
831
1053
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
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
|
-
|
|
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', () =>
|
|
856
|
-
|
|
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
|
|
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', () =>
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
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
|
-
|
|
896
|
-
|
|
1120
|
+
const oldestThreadIx = findIndex(value, ['activity.parent.type', 'reply']);
|
|
1121
|
+
const oldestParent = value[oldestThreadIx - 1].activity;
|
|
897
1122
|
|
|
898
|
-
|
|
1123
|
+
assert.isTrue(oldestAct.published < newestAct.published);
|
|
899
1124
|
|
|
900
|
-
|
|
901
|
-
|
|
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, [
|
|
917
|
-
|
|
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} =
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
952
|
-
|
|
953
|
-
|
|
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', () =>
|
|
958
|
-
|
|
959
|
-
.
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
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', () =>
|
|
967
|
-
.
|
|
968
|
-
|
|
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
|
-
|
|
971
|
-
|
|
972
|
-
|
|
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
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
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
|
-
|
|
1227
|
+
const firstAct = acts[0].activity;
|
|
983
1228
|
|
|
984
|
-
|
|
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
|
|
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, {
|
|
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
|
-
})
|
|
1248
|
+
})
|
|
1249
|
+
.then(() => {
|
|
1001
1250
|
assert.isTrue(_listActivitiesThreadOrderedSpy.args[0][0].url === conversation2.url);
|
|
1002
1251
|
});
|
|
1003
1252
|
});
|