@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.
- 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 +791 -1202
- 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 +17 -49
- 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 -591
- package/src/decryption-transforms.js +103 -62
- package/src/encryption-transforms.js +111 -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 +186 -121
- package/test/integration/spec/encryption.js +249 -186
- package/test/integration/spec/get.js +764 -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 +47 -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,106 @@ 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
|
-
.then((
|
|
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
|
+
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
|
|
210
|
+
return webex.internal.conversation
|
|
211
|
+
.download({url: makeLocalUrl('/sample-image-small-one.png')})
|
|
175
212
|
.on('progress', spy)
|
|
176
|
-
.then((f) =>
|
|
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', () =>
|
|
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
|
-
|
|
198
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
236
|
+
return webex.internal.conversation.download(fileItem, {shouldNotAddExifData: true});
|
|
237
|
+
})
|
|
238
|
+
.then((f) => {
|
|
239
|
+
assert.equal(fileItem.orientation, undefined);
|
|
203
240
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
241
|
+
return fh.isMatchingFile(f, sampleImagePortraitJpeg);
|
|
242
|
+
})
|
|
243
|
+
.then((result) => assert.isTrue(result)));
|
|
207
244
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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', () =>
|
|
223
|
-
|
|
224
|
-
.then((c) => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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', () =>
|
|
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', () =>
|
|
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', () =>
|
|
248
|
-
.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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', () =>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
269
|
-
|
|
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
|
|
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;
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
351
|
+
.then((c) => {
|
|
352
|
+
conversation2 = c;
|
|
353
|
+
})
|
|
354
|
+
);
|
|
316
355
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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.
|
|
333
|
-
|
|
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', () =>
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
c1.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
.
|
|
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', () =>
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
c1.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
.
|
|
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
|
-
|
|
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', () =>
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
.
|
|
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', () =>
|
|
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
|
-
|
|
407
|
-
.
|
|
408
|
-
|
|
409
|
-
|
|
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', () =>
|
|
418
|
-
.then((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', () =>
|
|
421
|
-
.
|
|
422
|
-
|
|
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
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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', () =>
|
|
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
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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', () =>
|
|
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
|
|
475
|
-
|
|
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()', () =>
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
604
|
+
const childActivity = firstThread.childActivities[0];
|
|
492
605
|
|
|
493
|
-
|
|
494
|
-
|
|
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', () =>
|
|
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
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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', () =>
|
|
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', () =>
|
|
559
|
-
.then((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', () =>
|
|
562
|
-
.then((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', () =>
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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
|
|
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) => {
|
|
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
|
|
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) => {
|
|
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
|
-
.
|
|
601
|
-
|
|
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
|
|
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
|
|
759
|
+
return webex3.internal.conversation
|
|
760
|
+
.bulkActivitiesFetch(activityURLs)
|
|
618
761
|
.then((bulkFetchedActivities) => {
|
|
619
762
|
assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
|
|
620
|
-
assert.equal(
|
|
621
|
-
|
|
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
|
|
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
|
|
798
|
+
return webex3.internal.conversation
|
|
799
|
+
.bulkActivitiesFetch(activityURLs)
|
|
649
800
|
.then((bulkFetchedActivities) => {
|
|
650
801
|
assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
|
|
651
|
-
assert.equal(
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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 =
|
|
823
|
+
const mockURL =
|
|
824
|
+
'https://conversation-intb.ciscospark.com/conversation/api/v1/activities/6d8c7c90-a770-11e9-bcfb-6616ead99ac3';
|
|
661
825
|
|
|
662
|
-
webex3.internal.conversation
|
|
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
|
|
837
|
+
return webex3.internal.conversation
|
|
838
|
+
.listActivities({conversationUrl: convo1.url})
|
|
673
839
|
.then((convo1Activities) => {
|
|
674
|
-
|
|
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
|
|
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(
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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
|
|
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(
|
|
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', () =>
|
|
728
|
-
.
|
|
729
|
-
|
|
910
|
+
beforeEach('create conversation with activity', () =>
|
|
911
|
+
webex.internal.conversation
|
|
912
|
+
.create({participants})
|
|
913
|
+
.then((c) => {
|
|
914
|
+
conversation = c;
|
|
730
915
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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', () =>
|
|
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;
|
|
985
|
+
before('create conversation with thread replies', () =>
|
|
986
|
+
webex.internal.conversation
|
|
987
|
+
.create({participants})
|
|
988
|
+
.then((c) => {
|
|
989
|
+
conversation = c;
|
|
800
990
|
|
|
801
|
-
|
|
802
|
-
|
|
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 = () =>
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1043
|
+
const initializeGenerator = () =>
|
|
1044
|
+
webex.internal.conversation.listActivitiesThreadOrdered({
|
|
1045
|
+
conversationUrl: conversation.url,
|
|
1046
|
+
minActivities,
|
|
1047
|
+
});
|
|
827
1048
|
|
|
828
|
-
before(() =>
|
|
829
|
-
.
|
|
830
|
-
|
|
1049
|
+
before(() =>
|
|
1050
|
+
webex.internal.conversation
|
|
1051
|
+
.create({participants})
|
|
1052
|
+
.then((c) => {
|
|
1053
|
+
conversation = c;
|
|
831
1054
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
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
|
-
|
|
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', () =>
|
|
856
|
-
|
|
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
|
|
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', () =>
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
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
|
-
|
|
896
|
-
|
|
1121
|
+
const oldestThreadIx = findIndex(value, ['activity.parent.type', 'reply']);
|
|
1122
|
+
const oldestParent = value[oldestThreadIx - 1].activity;
|
|
897
1123
|
|
|
898
|
-
|
|
1124
|
+
assert.isTrue(oldestAct.published < newestAct.published);
|
|
899
1125
|
|
|
900
|
-
|
|
901
|
-
|
|
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, [
|
|
917
|
-
|
|
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} =
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
952
|
-
|
|
953
|
-
|
|
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', () =>
|
|
958
|
-
|
|
959
|
-
.
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
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', () =>
|
|
967
|
-
.
|
|
968
|
-
|
|
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
|
-
|
|
971
|
-
|
|
972
|
-
|
|
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
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
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
|
-
|
|
1228
|
+
const firstAct = acts[0].activity;
|
|
983
1229
|
|
|
984
|
-
|
|
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
|
|
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, {
|
|
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
|
-
})
|
|
1249
|
+
})
|
|
1250
|
+
.then(() => {
|
|
1001
1251
|
assert.isTrue(_listActivitiesThreadOrderedSpy.args[0][0].url === conversation2.url);
|
|
1002
1252
|
});
|
|
1003
1253
|
});
|