@webex/internal-plugin-conversation 3.0.0-beta.9 → 3.0.0-bnr.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/activities.js +8 -69
- package/dist/activities.js.map +1 -1
- package/dist/activity-thread-ordering.js +19 -79
- package/dist/activity-thread-ordering.js.map +1 -1
- package/dist/config.js +1 -7
- package/dist/config.js.map +1 -1
- package/dist/constants.js +4 -5
- package/dist/constants.js.map +1 -1
- package/dist/conversation.js +790 -1199
- package/dist/conversation.js.map +1 -1
- package/dist/convo-error.js +0 -23
- package/dist/convo-error.js.map +1 -1
- package/dist/decryption-transforms.js +35 -98
- package/dist/decryption-transforms.js.map +1 -1
- package/dist/encryption-transforms.js +11 -48
- package/dist/encryption-transforms.js.map +1 -1
- package/dist/index.js +7 -50
- package/dist/index.js.map +1 -1
- package/dist/internal-plugin-conversation.d.ts +21 -0
- package/dist/share-activity.js +40 -106
- package/dist/share-activity.js.map +1 -1
- package/dist/to-array.js +9 -11
- package/dist/to-array.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/activities.d.ts +32 -0
- package/dist/types/activity-thread-ordering.d.ts +18 -0
- package/dist/types/config.d.ts +19 -0
- package/dist/types/constants.d.ts +5 -0
- package/dist/types/conversation.d.ts +2 -0
- package/dist/types/convo-error.d.ts +10 -0
- package/dist/types/decryption-transforms.d.ts +1 -0
- package/dist/types/encryption-transforms.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/share-activity.d.ts +7 -0
- package/dist/types/to-array.d.ts +9 -0
- package/package.json +15 -15
- package/src/activities.js +10 -7
- package/src/activity-thread-ordering.js +27 -30
- package/src/activity-threading.md +68 -49
- package/src/config.js +5 -5
- package/src/conversation.js +621 -589
- package/src/decryption-transforms.js +103 -62
- package/src/encryption-transforms.js +103 -83
- package/src/index.js +82 -66
- package/src/share-activity.js +64 -55
- package/src/to-array.js +2 -2
- package/test/integration/spec/create.js +184 -118
- package/test/integration/spec/encryption.js +250 -186
- package/test/integration/spec/get.js +761 -513
- package/test/integration/spec/mercury.js +37 -27
- package/test/integration/spec/share.js +292 -229
- package/test/integration/spec/verbs.js +628 -441
- package/test/unit/spec/conversation.js +265 -163
- package/test/unit/spec/decrypt-transforms.js +112 -131
- package/test/unit/spec/encryption-transforms.js +24 -18
- package/test/unit/spec/share-activity.js +37 -40
|
@@ -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,337 @@ 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
|
describe('with conversation from remote clusters', () => {
|
|
382
471
|
let conversation3, conversation4;
|
|
383
472
|
|
|
384
|
-
before('create conversations in EU cluster', () =>
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
.
|
|
395
|
-
|
|
473
|
+
before('create conversations in EU cluster', () =>
|
|
474
|
+
Promise.all([
|
|
475
|
+
suluEU.webex.internal.conversation
|
|
476
|
+
.create({
|
|
477
|
+
displayName: 'eu test 1',
|
|
478
|
+
participants,
|
|
479
|
+
})
|
|
480
|
+
.then((c) => {
|
|
481
|
+
conversation3 = c;
|
|
482
|
+
}),
|
|
483
|
+
suluEU.webex.internal.conversation
|
|
484
|
+
.create({
|
|
485
|
+
displayName: 'eu test 2',
|
|
486
|
+
participants: [checkov.id, spock.id],
|
|
487
|
+
})
|
|
488
|
+
.then((c) => {
|
|
489
|
+
conversation4 = c;
|
|
490
|
+
}),
|
|
491
|
+
])
|
|
492
|
+
);
|
|
396
493
|
|
|
397
|
-
it('retrieves local + remote cluster conversations', () =>
|
|
398
|
-
.then((conversations) => {
|
|
494
|
+
it('retrieves local + remote cluster conversations', () =>
|
|
495
|
+
webex.internal.conversation.list().then((conversations) => {
|
|
399
496
|
assert.include(map(conversations, 'url'), conversation1.url);
|
|
400
497
|
assert.include(map(conversations, 'url'), conversation2.url);
|
|
401
498
|
assert.include(map(conversations, 'url'), conversation3.url);
|
|
402
499
|
assert.include(map(conversations, 'url'), conversation4.url);
|
|
403
500
|
}));
|
|
404
501
|
|
|
405
|
-
it('retrieves only remote cluter conversations if user does not have any local conversations',
|
|
406
|
-
|
|
407
|
-
.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}));
|
|
502
|
+
it('retrieves only remote cluter conversations if user does not have any local conversations', () =>
|
|
503
|
+
checkov.webex.internal.conversation.list().then((conversations) => {
|
|
504
|
+
assert.include(map(conversations, 'url'), conversation4.url);
|
|
505
|
+
assert.lengthOf(conversations, 1);
|
|
506
|
+
}));
|
|
411
507
|
});
|
|
412
508
|
});
|
|
413
509
|
|
|
414
510
|
describe('#listLeft()', () => {
|
|
415
511
|
let conversation;
|
|
416
512
|
|
|
417
|
-
before('create conversation', () =>
|
|
418
|
-
.then((c) => {
|
|
513
|
+
before('create conversation', () =>
|
|
514
|
+
webex.internal.conversation.create({participants}).then((c) => {
|
|
515
|
+
conversation = c;
|
|
516
|
+
})
|
|
517
|
+
);
|
|
419
518
|
|
|
420
|
-
it('retrieves the conversations the current user has left', () =>
|
|
421
|
-
.
|
|
422
|
-
|
|
519
|
+
it('retrieves the conversations the current user has left', () =>
|
|
520
|
+
webex.internal.conversation
|
|
521
|
+
.listLeft()
|
|
522
|
+
.then((c) => {
|
|
523
|
+
assert.lengthOf(c, 0);
|
|
423
524
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
525
|
+
return webex.internal.conversation.leave(conversation);
|
|
526
|
+
})
|
|
527
|
+
.then(() => webex.internal.conversation.listLeft())
|
|
528
|
+
.then((c) => {
|
|
529
|
+
assert.lengthOf(c, 1);
|
|
530
|
+
assert.equal(c[0].id, conversation.id);
|
|
531
|
+
}));
|
|
431
532
|
});
|
|
432
533
|
|
|
433
534
|
describe('#listActivities()', () => {
|
|
434
535
|
let conversation;
|
|
435
536
|
|
|
436
|
-
before('create conversation with activity', () =>
|
|
437
|
-
.then((c) => {
|
|
537
|
+
before('create conversation with activity', () =>
|
|
538
|
+
webex.internal.conversation.create({participants}).then((c) => {
|
|
438
539
|
conversation = c;
|
|
439
540
|
assert.lengthOf(conversation.participants.items, 3);
|
|
440
541
|
|
|
441
542
|
return webex.internal.conversation.post(conversation, {displayName: 'first message'});
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
543
|
+
})
|
|
544
|
+
);
|
|
545
|
+
|
|
546
|
+
it('retrieves activities for the specified conversation', () =>
|
|
547
|
+
webex.internal.conversation
|
|
548
|
+
.listActivities({conversationUrl: conversation.url})
|
|
549
|
+
.then((activities) => {
|
|
550
|
+
assert.isArray(activities);
|
|
551
|
+
assert.lengthOf(activities, 2);
|
|
552
|
+
}));
|
|
449
553
|
});
|
|
450
554
|
|
|
451
555
|
describe('#listThreads()', () => {
|
|
@@ -454,8 +558,8 @@ describe('plugin-conversation', function () {
|
|
|
454
558
|
before('connect mccoy to mercury', () => {
|
|
455
559
|
webex2 = new WebexCore({
|
|
456
560
|
credentials: {
|
|
457
|
-
authorization: mccoy.token
|
|
458
|
-
}
|
|
561
|
+
authorization: mccoy.token,
|
|
562
|
+
},
|
|
459
563
|
});
|
|
460
564
|
|
|
461
565
|
return webex2.internal.mercury.connect();
|
|
@@ -466,33 +570,40 @@ describe('plugin-conversation', function () {
|
|
|
466
570
|
let conversation;
|
|
467
571
|
let parent;
|
|
468
572
|
|
|
469
|
-
before('create conversation', () =>
|
|
470
|
-
.then((c) => {
|
|
573
|
+
before('create conversation', () =>
|
|
574
|
+
webex.internal.conversation.create({participants}).then((c) => {
|
|
471
575
|
conversation = c;
|
|
472
576
|
assert.lengthOf(conversation.participants.items, 3);
|
|
473
577
|
|
|
474
|
-
return webex2.internal.conversation
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
578
|
+
return webex2.internal.conversation
|
|
579
|
+
.post(conversation, {displayName: 'first message'})
|
|
580
|
+
.then((parentActivity) => {
|
|
581
|
+
parent = parentActivity;
|
|
582
|
+
});
|
|
583
|
+
})
|
|
584
|
+
);
|
|
478
585
|
|
|
479
|
-
it('retrieves threads()', () =>
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
586
|
+
it('retrieves threads()', () =>
|
|
587
|
+
webex2.internal.conversation
|
|
588
|
+
.post(conversation, 'thread1', {
|
|
589
|
+
parentActivityId: parent.id,
|
|
590
|
+
activityType: 'reply',
|
|
591
|
+
})
|
|
592
|
+
.then(() => webex2.internal.conversation.listThreads())
|
|
593
|
+
.then((thread) => {
|
|
594
|
+
assert.equal(thread.length, 1);
|
|
595
|
+
const firstThread = thread[0];
|
|
485
596
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
597
|
+
assert.equal(firstThread.childType, 'reply');
|
|
598
|
+
assert.equal(firstThread.parentActivityId, parent.id);
|
|
599
|
+
assert.equal(firstThread.conversationId, conversation.id);
|
|
600
|
+
assert.equal(firstThread.childActivities.length, 1);
|
|
490
601
|
|
|
491
|
-
|
|
602
|
+
const childActivity = firstThread.childActivities[0];
|
|
492
603
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
604
|
+
assert.equal(childActivity.objectType, 'activity');
|
|
605
|
+
assert.equal(childActivity.object.displayName, 'thread1');
|
|
606
|
+
}));
|
|
496
607
|
});
|
|
497
608
|
|
|
498
609
|
describe('#listMentions()', () => {
|
|
@@ -501,8 +612,8 @@ describe('plugin-conversation', function () {
|
|
|
501
612
|
before('connect mccoy to mercury', () => {
|
|
502
613
|
webex2 = new WebexCore({
|
|
503
614
|
credentials: {
|
|
504
|
-
authorization: mccoy.token
|
|
505
|
-
}
|
|
615
|
+
authorization: mccoy.token,
|
|
616
|
+
},
|
|
506
617
|
});
|
|
507
618
|
|
|
508
619
|
return webex2.internal.mercury.connect();
|
|
@@ -512,27 +623,35 @@ describe('plugin-conversation', function () {
|
|
|
512
623
|
|
|
513
624
|
let conversation;
|
|
514
625
|
|
|
515
|
-
before('create conversation', () =>
|
|
516
|
-
.then((c) => {
|
|
626
|
+
before('create conversation', () =>
|
|
627
|
+
webex.internal.conversation.create({participants}).then((c) => {
|
|
517
628
|
conversation = c;
|
|
518
629
|
assert.lengthOf(conversation.participants.items, 3);
|
|
519
|
-
})
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
})
|
|
630
|
+
})
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
it('retrieves activities in which the current user was mentioned', () =>
|
|
634
|
+
webex2.internal.conversation
|
|
635
|
+
.post(conversation, {
|
|
636
|
+
displayName: 'Green blooded hobgloblin',
|
|
637
|
+
content: `<webex-mention data-object-type="person" data-object-id="${spock.id}">Green blooded hobgloblin</webex-mention>`,
|
|
638
|
+
mentions: {
|
|
639
|
+
items: [
|
|
640
|
+
{
|
|
641
|
+
id: `${spock.id}`,
|
|
642
|
+
objectType: 'person',
|
|
643
|
+
},
|
|
644
|
+
],
|
|
645
|
+
},
|
|
646
|
+
})
|
|
647
|
+
.then((activity) =>
|
|
648
|
+
webex.internal.conversation
|
|
649
|
+
.listMentions({sinceDate: Date.parse(activity.published) - 1})
|
|
650
|
+
.then((mentions) => {
|
|
651
|
+
assert.lengthOf(mentions, 1);
|
|
652
|
+
assert.equal(mentions[0].url, activity.url);
|
|
653
|
+
})
|
|
654
|
+
));
|
|
536
655
|
});
|
|
537
656
|
|
|
538
657
|
// TODO: add testing for bulk_activities_fetch() with clusters later
|
|
@@ -540,44 +659,61 @@ describe('plugin-conversation', function () {
|
|
|
540
659
|
let jenny, maria, dan, convo1, convo2, euConvo1;
|
|
541
660
|
let webex3;
|
|
542
661
|
|
|
543
|
-
before('create tests users and connect one to mercury', () =>
|
|
544
|
-
.then((users) => {
|
|
662
|
+
before('create tests users and connect one to mercury', () =>
|
|
663
|
+
testUsers.create({count: 4}).then((users) => {
|
|
545
664
|
[jenny, maria, dan] = users;
|
|
546
665
|
|
|
547
666
|
webex3 = new WebexCore({
|
|
548
667
|
credentials: {
|
|
549
|
-
authorization: jenny.token
|
|
550
|
-
}
|
|
668
|
+
authorization: jenny.token,
|
|
669
|
+
},
|
|
551
670
|
});
|
|
552
671
|
|
|
553
672
|
return webex3.internal.mercury.connect();
|
|
554
|
-
})
|
|
673
|
+
})
|
|
674
|
+
);
|
|
555
675
|
|
|
556
676
|
after(() => webex3 && webex3.internal.mercury.disconnect());
|
|
557
677
|
|
|
558
|
-
before('create conversation 1', () =>
|
|
559
|
-
.then((c1) => {
|
|
678
|
+
before('create conversation 1', () =>
|
|
679
|
+
webex3.internal.conversation.create({participants: [jenny, maria]}).then((c1) => {
|
|
680
|
+
convo1 = c1;
|
|
681
|
+
})
|
|
682
|
+
);
|
|
560
683
|
|
|
561
|
-
before('create conversation 2', () =>
|
|
562
|
-
.then((c2) => {
|
|
684
|
+
before('create conversation 2', () =>
|
|
685
|
+
webex3.internal.conversation.create({participants: [jenny, dan]}).then((c2) => {
|
|
686
|
+
convo2 = c2;
|
|
687
|
+
})
|
|
688
|
+
);
|
|
563
689
|
|
|
564
|
-
before('create conversations in EU cluster', () =>
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
690
|
+
before('create conversations in EU cluster', () =>
|
|
691
|
+
suluEU.webex.internal.conversation
|
|
692
|
+
.create({
|
|
693
|
+
displayName: 'eu test 1',
|
|
694
|
+
participants: [jenny, suluEU, dan],
|
|
695
|
+
})
|
|
696
|
+
.then((c) => {
|
|
697
|
+
euConvo1 = c;
|
|
698
|
+
})
|
|
699
|
+
);
|
|
569
700
|
|
|
570
701
|
before('add comments to convo1, and check post requests successfully went through', () =>
|
|
571
|
-
webex3.internal.conversation
|
|
702
|
+
webex3.internal.conversation
|
|
703
|
+
.post(convo1, {displayName: 'BAGELS (O)'})
|
|
572
704
|
.then((c1) => {
|
|
573
705
|
assert.equal(c1.object.displayName, 'BAGELS (O)');
|
|
574
706
|
|
|
575
707
|
return webex3.internal.conversation.post(convo1, {displayName: 'Cream Cheese'});
|
|
576
708
|
})
|
|
577
|
-
.then((c2) => {
|
|
709
|
+
.then((c2) => {
|
|
710
|
+
assert.equal(c2.object.displayName, 'Cream Cheese');
|
|
711
|
+
})
|
|
712
|
+
);
|
|
578
713
|
|
|
579
714
|
before('add comments to convo2, and check post requests successfully went through', () =>
|
|
580
|
-
webex3.internal.conversation
|
|
715
|
+
webex3.internal.conversation
|
|
716
|
+
.post(convo2, {displayName: 'Want to head to lunch soon?'})
|
|
581
717
|
.then((c1) => {
|
|
582
718
|
assert.equal(c1.object.displayName, 'Want to head to lunch soon?');
|
|
583
719
|
|
|
@@ -593,16 +729,20 @@ describe('plugin-conversation', function () {
|
|
|
593
729
|
|
|
594
730
|
return webex3.internal.conversation.post(convo2, {displayName: 'Meekong Bar!'});
|
|
595
731
|
})
|
|
596
|
-
.then((c4) => {
|
|
732
|
+
.then((c4) => {
|
|
733
|
+
assert.equal(c4.object.displayName, 'Meekong Bar!');
|
|
734
|
+
})
|
|
735
|
+
);
|
|
597
736
|
|
|
598
737
|
before('add comments to euConvo1, and check post requests successfully went through', () =>
|
|
599
|
-
suluEU.webex.internal.conversation.post(euConvo1, {displayName: 'Hello'})
|
|
600
|
-
.
|
|
601
|
-
|
|
602
|
-
|
|
738
|
+
suluEU.webex.internal.conversation.post(euConvo1, {displayName: 'Hello'}).then((c1) => {
|
|
739
|
+
assert.equal(c1.object.displayName, 'Hello');
|
|
740
|
+
})
|
|
741
|
+
);
|
|
603
742
|
|
|
604
743
|
it('retrieves activities from a single conversation', () =>
|
|
605
|
-
webex3.internal.conversation
|
|
744
|
+
webex3.internal.conversation
|
|
745
|
+
.listActivities({conversationUrl: convo1.url})
|
|
606
746
|
.then((convoActivities) => {
|
|
607
747
|
const activityURLs = [];
|
|
608
748
|
const expectedActivities = [];
|
|
@@ -614,11 +754,18 @@ describe('plugin-conversation', function () {
|
|
|
614
754
|
}
|
|
615
755
|
});
|
|
616
756
|
|
|
617
|
-
return webex3.internal.conversation
|
|
757
|
+
return webex3.internal.conversation
|
|
758
|
+
.bulkActivitiesFetch(activityURLs)
|
|
618
759
|
.then((bulkFetchedActivities) => {
|
|
619
760
|
assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
|
|
620
|
-
assert.equal(
|
|
621
|
-
|
|
761
|
+
assert.equal(
|
|
762
|
+
bulkFetchedActivities[0].object.displayName,
|
|
763
|
+
expectedActivities[0].object.displayName
|
|
764
|
+
);
|
|
765
|
+
assert.equal(
|
|
766
|
+
bulkFetchedActivities[1].object.displayName,
|
|
767
|
+
expectedActivities[1].object.displayName
|
|
768
|
+
);
|
|
622
769
|
});
|
|
623
770
|
}));
|
|
624
771
|
|
|
@@ -626,7 +773,8 @@ describe('plugin-conversation', function () {
|
|
|
626
773
|
const activityURLs = [];
|
|
627
774
|
const expectedActivities = [];
|
|
628
775
|
|
|
629
|
-
return webex3.internal.conversation
|
|
776
|
+
return webex3.internal.conversation
|
|
777
|
+
.listActivities({conversationUrl: convo1.url})
|
|
630
778
|
.then((convo1Activities) => {
|
|
631
779
|
// gets all post activity urls from convo1
|
|
632
780
|
convo1Activities.forEach((a1) => {
|
|
@@ -645,21 +793,36 @@ describe('plugin-conversation', function () {
|
|
|
645
793
|
expectedActivities.push(convo2Activities[i]);
|
|
646
794
|
});
|
|
647
795
|
|
|
648
|
-
return webex3.internal.conversation
|
|
796
|
+
return webex3.internal.conversation
|
|
797
|
+
.bulkActivitiesFetch(activityURLs)
|
|
649
798
|
.then((bulkFetchedActivities) => {
|
|
650
799
|
assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
|
|
651
|
-
assert.equal(
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
800
|
+
assert.equal(
|
|
801
|
+
bulkFetchedActivities[0].object.displayName,
|
|
802
|
+
expectedActivities[0].object.displayName
|
|
803
|
+
);
|
|
804
|
+
assert.equal(
|
|
805
|
+
bulkFetchedActivities[1].object.displayName,
|
|
806
|
+
expectedActivities[1].object.displayName
|
|
807
|
+
);
|
|
808
|
+
assert.equal(
|
|
809
|
+
bulkFetchedActivities[2].object.displayName,
|
|
810
|
+
expectedActivities[2].object.displayName
|
|
811
|
+
);
|
|
812
|
+
assert.equal(
|
|
813
|
+
bulkFetchedActivities[3].object.displayName,
|
|
814
|
+
expectedActivities[3].object.displayName
|
|
815
|
+
);
|
|
655
816
|
});
|
|
656
817
|
});
|
|
657
818
|
});
|
|
658
819
|
|
|
659
820
|
it('given a activity url that does not exist, should return []', () => {
|
|
660
|
-
const mockURL =
|
|
821
|
+
const mockURL =
|
|
822
|
+
'https://conversation-intb.ciscospark.com/conversation/api/v1/activities/6d8c7c90-a770-11e9-bcfb-6616ead99ac3';
|
|
661
823
|
|
|
662
|
-
webex3.internal.conversation
|
|
824
|
+
webex3.internal.conversation
|
|
825
|
+
.bulkActivitiesFetch([mockURL])
|
|
663
826
|
.then((bulkFetchedActivities) => {
|
|
664
827
|
assert.equal(bulkFetchedActivities, []);
|
|
665
828
|
});
|
|
@@ -669,9 +832,10 @@ describe('plugin-conversation', function () {
|
|
|
669
832
|
const activityURLs = [];
|
|
670
833
|
const expectedActivities = [];
|
|
671
834
|
|
|
672
|
-
return webex3.internal.conversation
|
|
835
|
+
return webex3.internal.conversation
|
|
836
|
+
.listActivities({conversationUrl: convo1.url})
|
|
673
837
|
.then((convo1Activities) => {
|
|
674
|
-
|
|
838
|
+
// gets all post activity urls from convo1
|
|
675
839
|
convo1Activities.forEach((a1) => {
|
|
676
840
|
if (a1.verb === 'post') {
|
|
677
841
|
activityURLs.push(a1.url);
|
|
@@ -688,13 +852,26 @@ describe('plugin-conversation', function () {
|
|
|
688
852
|
expectedActivities.push(convo2Activities[i]);
|
|
689
853
|
});
|
|
690
854
|
|
|
691
|
-
return webex3.internal.conversation
|
|
855
|
+
return webex3.internal.conversation
|
|
856
|
+
.bulkActivitiesFetch(activityURLs, undefined, {url: process.env.CONVERSATION_SERVICE})
|
|
692
857
|
.then((bulkFetchedActivities) => {
|
|
693
858
|
assert.lengthOf(bulkFetchedActivities, expectedActivities.length);
|
|
694
|
-
assert.equal(
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
859
|
+
assert.equal(
|
|
860
|
+
bulkFetchedActivities[0].object.displayName,
|
|
861
|
+
expectedActivities[0].object.displayName
|
|
862
|
+
);
|
|
863
|
+
assert.equal(
|
|
864
|
+
bulkFetchedActivities[1].object.displayName,
|
|
865
|
+
expectedActivities[1].object.displayName
|
|
866
|
+
);
|
|
867
|
+
assert.equal(
|
|
868
|
+
bulkFetchedActivities[2].object.displayName,
|
|
869
|
+
expectedActivities[2].object.displayName
|
|
870
|
+
);
|
|
871
|
+
assert.equal(
|
|
872
|
+
bulkFetchedActivities[3].object.displayName,
|
|
873
|
+
expectedActivities[3].object.displayName
|
|
874
|
+
);
|
|
698
875
|
});
|
|
699
876
|
});
|
|
700
877
|
});
|
|
@@ -703,7 +880,8 @@ describe('plugin-conversation', function () {
|
|
|
703
880
|
const activityURLs = [];
|
|
704
881
|
const expectedActivities = [];
|
|
705
882
|
|
|
706
|
-
return webex3.internal.conversation
|
|
883
|
+
return webex3.internal.conversation
|
|
884
|
+
.listActivities({conversationUrl: euConvo1.url})
|
|
707
885
|
.then((euConvo1Activities) => {
|
|
708
886
|
const convoUrlRegex = /(.*)\/activities/;
|
|
709
887
|
|
|
@@ -716,7 +894,10 @@ describe('plugin-conversation', function () {
|
|
|
716
894
|
})
|
|
717
895
|
.then((bulkFetchedActivities) => {
|
|
718
896
|
assert.lengthOf(bulkFetchedActivities, 1);
|
|
719
|
-
assert.equal(
|
|
897
|
+
assert.equal(
|
|
898
|
+
bulkFetchedActivities[0].object.displayName,
|
|
899
|
+
expectedActivities[0].object.displayName
|
|
900
|
+
);
|
|
720
901
|
});
|
|
721
902
|
});
|
|
722
903
|
});
|
|
@@ -724,84 +905,121 @@ describe('plugin-conversation', function () {
|
|
|
724
905
|
describe('#listParentActivityIds', () => {
|
|
725
906
|
let conversation, parent;
|
|
726
907
|
|
|
727
|
-
beforeEach('create conversation with activity', () =>
|
|
728
|
-
.
|
|
729
|
-
|
|
908
|
+
beforeEach('create conversation with activity', () =>
|
|
909
|
+
webex.internal.conversation
|
|
910
|
+
.create({participants})
|
|
911
|
+
.then((c) => {
|
|
912
|
+
conversation = c;
|
|
730
913
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
914
|
+
return webex.internal.conversation.post(conversation, {displayName: 'first message'});
|
|
915
|
+
})
|
|
916
|
+
.then((parentAct) => {
|
|
917
|
+
parent = parentAct;
|
|
918
|
+
})
|
|
919
|
+
);
|
|
920
|
+
|
|
921
|
+
it('retrieves parent IDs for thread parents()', () =>
|
|
922
|
+
webex.internal.conversation
|
|
923
|
+
.post(
|
|
924
|
+
conversation,
|
|
925
|
+
{displayName: 'first thread reply'},
|
|
926
|
+
{
|
|
927
|
+
parentActivityId: parent.id,
|
|
928
|
+
activityType: 'reply',
|
|
929
|
+
}
|
|
930
|
+
)
|
|
931
|
+
.then(({parent: parentObj} = {}) => {
|
|
932
|
+
assert.equal(parentObj.type, 'reply');
|
|
933
|
+
assert.equal(parentObj.id, parent.id);
|
|
736
934
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
return webex.internal.conversation.listParentActivityIds(conversation.url, {activityType: 'reply'});
|
|
745
|
-
}).then(({reply}) => {
|
|
746
|
-
assert.include(reply, parent.id);
|
|
747
|
-
}));
|
|
748
|
-
|
|
749
|
-
it('retrieves parent IDs for edits', () => webex.internal.conversation.post(conversation, 'edited', {
|
|
750
|
-
parent: {
|
|
751
|
-
id: parent.id,
|
|
752
|
-
type: 'edit'
|
|
753
|
-
}
|
|
754
|
-
}).then((edit) => {
|
|
755
|
-
assert.equal(edit.parent.type, 'edit');
|
|
756
|
-
assert.equal(edit.parent.id, parent.id);
|
|
757
|
-
|
|
758
|
-
return webex.internal.conversation.listParentActivityIds(conversation.url, {activityType: 'edit'});
|
|
759
|
-
}).then(({edit}) => {
|
|
760
|
-
assert.include(edit, parent.id);
|
|
761
|
-
}));
|
|
762
|
-
|
|
763
|
-
it('retrieves parent IDs for reactions', () => webex.internal.conversation.addReaction(conversation, 'heart', parent)
|
|
764
|
-
.then((reaction) => {
|
|
765
|
-
assert.equal(reaction.parent.type, 'reaction');
|
|
766
|
-
assert.equal(reaction.parent.id, parent.id);
|
|
767
|
-
|
|
768
|
-
return webex.internal.conversation.listParentActivityIds(conversation.url, {activityType: 'reaction'});
|
|
769
|
-
}).then(({reaction}) => {
|
|
770
|
-
assert.include(reaction, parent.id);
|
|
771
|
-
}));
|
|
772
|
-
});
|
|
935
|
+
return webex.internal.conversation.listParentActivityIds(conversation.url, {
|
|
936
|
+
activityType: 'reply',
|
|
937
|
+
});
|
|
938
|
+
})
|
|
939
|
+
.then(({reply}) => {
|
|
940
|
+
assert.include(reply, parent.id);
|
|
941
|
+
}));
|
|
773
942
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
943
|
+
it('retrieves parent IDs for edits', () =>
|
|
944
|
+
webex.internal.conversation
|
|
945
|
+
.post(conversation, 'edited', {
|
|
946
|
+
parent: {
|
|
947
|
+
id: parent.id,
|
|
948
|
+
type: 'edit',
|
|
949
|
+
},
|
|
950
|
+
})
|
|
951
|
+
.then((edit) => {
|
|
952
|
+
assert.equal(edit.parent.type, 'edit');
|
|
953
|
+
assert.equal(edit.parent.id, parent.id);
|
|
777
954
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
955
|
+
return webex.internal.conversation.listParentActivityIds(conversation.url, {
|
|
956
|
+
activityType: 'edit',
|
|
957
|
+
});
|
|
958
|
+
})
|
|
959
|
+
.then(({edit}) => {
|
|
960
|
+
assert.include(edit, parent.id);
|
|
961
|
+
}));
|
|
781
962
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
963
|
+
it('retrieves parent IDs for reactions', () =>
|
|
964
|
+
webex.internal.conversation
|
|
965
|
+
.addReaction(conversation, 'heart', parent)
|
|
966
|
+
.then((reaction) => {
|
|
967
|
+
assert.equal(reaction.parent.type, 'reaction');
|
|
968
|
+
assert.equal(reaction.parent.id, parent.id);
|
|
785
969
|
|
|
786
|
-
|
|
970
|
+
return webex.internal.conversation.listParentActivityIds(conversation.url, {
|
|
971
|
+
activityType: 'reaction',
|
|
972
|
+
});
|
|
973
|
+
})
|
|
974
|
+
.then(({reaction}) => {
|
|
975
|
+
assert.include(reaction, parent.id);
|
|
976
|
+
}));
|
|
977
|
+
});
|
|
787
978
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
activityType: 'reply'
|
|
792
|
-
})));
|
|
793
|
-
}).then((repliesArr) => {
|
|
794
|
-
replies = repliesArr;
|
|
795
|
-
}));
|
|
979
|
+
describe('#listChildActivitiesByParentId()', () => {
|
|
980
|
+
let conversation, parent;
|
|
981
|
+
let replies;
|
|
796
982
|
|
|
797
|
-
|
|
798
|
-
.
|
|
799
|
-
|
|
983
|
+
before('create conversation with thread replies', () =>
|
|
984
|
+
webex.internal.conversation
|
|
985
|
+
.create({participants})
|
|
986
|
+
.then((c) => {
|
|
987
|
+
conversation = c;
|
|
800
988
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
989
|
+
return webex.internal.conversation.post(conversation, {displayName: 'first message'});
|
|
990
|
+
})
|
|
991
|
+
.then((parentAct) => {
|
|
992
|
+
parent = parentAct;
|
|
993
|
+
|
|
994
|
+
const messages = ['thread 1', 'thread 2', 'thread 3'];
|
|
995
|
+
|
|
996
|
+
return Promise.all(
|
|
997
|
+
messages.map((msg) =>
|
|
998
|
+
webex.internal.conversation.post(conversation, msg, {
|
|
999
|
+
parentActivityId: parent.id,
|
|
1000
|
+
activityType: 'reply',
|
|
1001
|
+
})
|
|
1002
|
+
)
|
|
1003
|
+
);
|
|
1004
|
+
})
|
|
1005
|
+
.then((repliesArr) => {
|
|
1006
|
+
replies = repliesArr;
|
|
1007
|
+
})
|
|
1008
|
+
);
|
|
1009
|
+
|
|
1010
|
+
it('retrieves thread reply activities for a given parent', () =>
|
|
1011
|
+
webex.internal.conversation
|
|
1012
|
+
.listChildActivitiesByParentId(conversation.url, parent.id, 'reply')
|
|
1013
|
+
.then((response) => {
|
|
1014
|
+
const {items} = response.body;
|
|
1015
|
+
|
|
1016
|
+
items.forEach((threadAct) => {
|
|
1017
|
+
assert.include(
|
|
1018
|
+
replies.map((reply) => reply.id),
|
|
1019
|
+
threadAct.id
|
|
1020
|
+
);
|
|
1021
|
+
});
|
|
1022
|
+
}));
|
|
805
1023
|
});
|
|
806
1024
|
|
|
807
1025
|
describe('#_listActivitiesThreadOrdered', () => {
|
|
@@ -817,33 +1035,36 @@ describe('plugin-conversation', function () {
|
|
|
817
1035
|
'sixth message',
|
|
818
1036
|
'seventh message',
|
|
819
1037
|
'eighth message',
|
|
820
|
-
'ninth message'
|
|
1038
|
+
'ninth message',
|
|
821
1039
|
];
|
|
822
1040
|
|
|
823
|
-
const initializeGenerator = () =>
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1041
|
+
const initializeGenerator = () =>
|
|
1042
|
+
webex.internal.conversation.listActivitiesThreadOrdered({
|
|
1043
|
+
conversationUrl: conversation.url,
|
|
1044
|
+
minActivities,
|
|
1045
|
+
});
|
|
827
1046
|
|
|
828
|
-
before(() =>
|
|
829
|
-
.
|
|
830
|
-
|
|
1047
|
+
before(() =>
|
|
1048
|
+
webex.internal.conversation
|
|
1049
|
+
.create({participants})
|
|
1050
|
+
.then((c) => {
|
|
1051
|
+
conversation = c;
|
|
831
1052
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
firstParentBatch = parents;
|
|
1053
|
+
return c;
|
|
1054
|
+
})
|
|
1055
|
+
.then((c) => Promise.all(displayNames.slice(0, 5).map(postMessage(webex, c))))
|
|
1056
|
+
.then((parents) => {
|
|
1057
|
+
firstParentBatch = parents;
|
|
838
1058
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
1059
|
+
return Promise.all(createThreadObjs(parents).map(postReply(webex, conversation)));
|
|
1060
|
+
})
|
|
1061
|
+
.then(() => Promise.all(displayNames.slice(4).map(postMessage(webex, conversation))))
|
|
1062
|
+
.then((parents) => {
|
|
1063
|
+
secondParentBatch = parents;
|
|
844
1064
|
|
|
845
|
-
|
|
846
|
-
|
|
1065
|
+
return Promise.all(createThreadObjs(parents).map(postReply(webex, conversation)));
|
|
1066
|
+
})
|
|
1067
|
+
);
|
|
847
1068
|
|
|
848
1069
|
beforeEach(() => {
|
|
849
1070
|
const funcs = initializeGenerator();
|
|
@@ -852,31 +1073,33 @@ describe('plugin-conversation', function () {
|
|
|
852
1073
|
jumpToActivity = funcs.jumpToActivity;
|
|
853
1074
|
});
|
|
854
1075
|
|
|
855
|
-
it('should return more than or exactly N minimum activities', () =>
|
|
856
|
-
|
|
857
|
-
|
|
1076
|
+
it('should return more than or exactly N minimum activities', () =>
|
|
1077
|
+
getOlder().then(({value}) => {
|
|
1078
|
+
assert.isAtLeast(value.length, minActivities);
|
|
1079
|
+
}));
|
|
858
1080
|
|
|
859
1081
|
it('should return edit activity ID as activity ID when an activity has been edited', () => {
|
|
860
1082
|
const lastParent = secondParentBatch[secondParentBatch.length - 1];
|
|
861
1083
|
|
|
862
1084
|
const message = {
|
|
863
1085
|
displayName: 'edited',
|
|
864
|
-
content: 'edited'
|
|
1086
|
+
content: 'edited',
|
|
865
1087
|
};
|
|
866
1088
|
|
|
867
1089
|
const editingActivity = Object.assign(
|
|
868
1090
|
{
|
|
869
1091
|
parent: {
|
|
870
1092
|
id: lastParent.id,
|
|
871
|
-
type: 'edit'
|
|
872
|
-
}
|
|
1093
|
+
type: 'edit',
|
|
1094
|
+
},
|
|
873
1095
|
},
|
|
874
1096
|
{
|
|
875
|
-
object: message
|
|
1097
|
+
object: message,
|
|
876
1098
|
}
|
|
877
1099
|
);
|
|
878
1100
|
|
|
879
|
-
return webex.internal.conversation
|
|
1101
|
+
return webex.internal.conversation
|
|
1102
|
+
.post(conversation, message, editingActivity)
|
|
880
1103
|
.then(() => getOlder())
|
|
881
1104
|
.then(({value}) => {
|
|
882
1105
|
const activities = value.map((act) => act.activity);
|
|
@@ -887,19 +1110,20 @@ describe('plugin-conversation', function () {
|
|
|
887
1110
|
});
|
|
888
1111
|
});
|
|
889
1112
|
|
|
890
|
-
it('should return activities in thread order', () =>
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1113
|
+
it('should return activities in thread order', () =>
|
|
1114
|
+
getOlder().then((data) => {
|
|
1115
|
+
const {value} = data;
|
|
1116
|
+
const oldestAct = value[0].activity;
|
|
1117
|
+
const newestAct = value[value.length - 1].activity;
|
|
894
1118
|
|
|
895
|
-
|
|
896
|
-
|
|
1119
|
+
const oldestThreadIx = findIndex(value, ['activity.parent.type', 'reply']);
|
|
1120
|
+
const oldestParent = value[oldestThreadIx - 1].activity;
|
|
897
1121
|
|
|
898
|
-
|
|
1122
|
+
assert.isTrue(oldestAct.published < newestAct.published);
|
|
899
1123
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1124
|
+
assert.doesNotHaveAnyKeys(oldestParent, 'parentActivityId');
|
|
1125
|
+
assert.isTrue(oldestParent.object.objectType === 'comment');
|
|
1126
|
+
}));
|
|
903
1127
|
|
|
904
1128
|
it('should return next batch when getOlder is called a second time', () => {
|
|
905
1129
|
let firstBatch;
|
|
@@ -913,91 +1137,115 @@ describe('plugin-conversation', function () {
|
|
|
913
1137
|
.then(({value}) => {
|
|
914
1138
|
const secondBatch = value;
|
|
915
1139
|
|
|
916
|
-
const oldestRootInFirstBatch = find(firstBatch, [
|
|
917
|
-
|
|
1140
|
+
const oldestRootInFirstBatch = find(firstBatch, [
|
|
1141
|
+
'activity.object.objectType',
|
|
1142
|
+
'comment',
|
|
1143
|
+
]).activity;
|
|
1144
|
+
const newestRootInSecondBatch = findLast(secondBatch, [
|
|
1145
|
+
'activity.object.objectType',
|
|
1146
|
+
'comment',
|
|
1147
|
+
]).activity;
|
|
918
1148
|
|
|
919
1149
|
assert.isTrue(oldestRootInFirstBatch.published > newestRootInSecondBatch.published);
|
|
920
1150
|
});
|
|
921
1151
|
});
|
|
922
1152
|
|
|
923
1153
|
it('should return done as true when no more activities can be fetched', () => {
|
|
924
|
-
const {getOlder: getOlderWithLargeMin} =
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
assert.isTrue(done);
|
|
1154
|
+
const {getOlder: getOlderWithLargeMin} =
|
|
1155
|
+
webex.internal.conversation.listActivitiesThreadOrdered({
|
|
1156
|
+
conversationId: conversation.id,
|
|
1157
|
+
minActivities: 50,
|
|
929
1158
|
});
|
|
1159
|
+
|
|
1160
|
+
return getOlderWithLargeMin().then(({done}) => {
|
|
1161
|
+
assert.isTrue(done);
|
|
1162
|
+
});
|
|
930
1163
|
});
|
|
931
1164
|
|
|
932
1165
|
describe('jumpToActivity()', () => {
|
|
933
1166
|
let _listActivitiesThreadOrderedSpy;
|
|
934
1167
|
|
|
935
1168
|
beforeEach(() => {
|
|
936
|
-
_listActivitiesThreadOrderedSpy = sinon.spy(
|
|
1169
|
+
_listActivitiesThreadOrderedSpy = sinon.spy(
|
|
1170
|
+
webex.internal.conversation,
|
|
1171
|
+
'_listActivitiesThreadOrdered'
|
|
1172
|
+
);
|
|
937
1173
|
});
|
|
938
1174
|
|
|
939
1175
|
afterEach(() => {
|
|
940
1176
|
webex.internal.conversation._listActivitiesThreadOrdered.restore();
|
|
941
1177
|
});
|
|
942
1178
|
|
|
943
|
-
|
|
944
1179
|
it('should return searched-for activity with surrounding activities when jumpToActivity is called with an activity', () => {
|
|
945
1180
|
const search = firstParentBatch[firstParentBatch.length - 1];
|
|
946
1181
|
|
|
947
|
-
return jumpToActivity(search)
|
|
948
|
-
|
|
949
|
-
const searchedForActivityIx = findIndex(value, ['id', search.id]);
|
|
1182
|
+
return jumpToActivity(search).then(({value}) => {
|
|
1183
|
+
const searchedForActivityIx = findIndex(value, ['id', search.id]);
|
|
950
1184
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1185
|
+
assert.isFalse(searchedForActivityIx === -1);
|
|
1186
|
+
assert.isTrue(searchedForActivityIx > 0);
|
|
1187
|
+
assert.isTrue(searchedForActivityIx < value.length);
|
|
1188
|
+
});
|
|
955
1189
|
});
|
|
956
1190
|
|
|
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
|
-
|
|
1191
|
+
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', () =>
|
|
1192
|
+
webex.internal.conversation
|
|
1193
|
+
.create({participants: [scott.id]})
|
|
1194
|
+
.then((c) =>
|
|
1195
|
+
webex.internal.conversation
|
|
1196
|
+
.post(c, {displayName: 'first message'})
|
|
1197
|
+
.then((m) =>
|
|
1198
|
+
webex.internal.conversation
|
|
1199
|
+
.listActivities({conversationUrl: c.url})
|
|
1200
|
+
.then((acts) => jumpToActivity(m).then(() => acts.length))
|
|
1201
|
+
)
|
|
1202
|
+
)
|
|
1203
|
+
.then((actCount) => {
|
|
1204
|
+
assert.isTrue(actCount < minActivities);
|
|
1205
|
+
}));
|
|
965
1206
|
|
|
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
|
-
|
|
1207
|
+
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', () =>
|
|
1208
|
+
webex.internal.conversation
|
|
1209
|
+
.create({participants: [scott.id]})
|
|
1210
|
+
.then((c) => {
|
|
1211
|
+
const $posts = [];
|
|
969
1212
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1213
|
+
// eslint-disable-next-line no-plusplus
|
|
1214
|
+
for (let i = 0; i < 15; i++) {
|
|
1215
|
+
$posts.push(webex.internal.conversation.post(c, {displayName: `message ${i}`}));
|
|
1216
|
+
}
|
|
974
1217
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1218
|
+
return Promise.all($posts).then(() =>
|
|
1219
|
+
webex.internal.conversation.post(c, {displayName: 'message last'})
|
|
1220
|
+
);
|
|
1221
|
+
})
|
|
1222
|
+
.then((lastPost) => jumpToActivity(lastPost))
|
|
1223
|
+
.then(({value: acts}) => {
|
|
1224
|
+
assert.isAtLeast(acts.length, minActivities);
|
|
981
1225
|
|
|
982
|
-
|
|
1226
|
+
const firstAct = acts[0].activity;
|
|
983
1227
|
|
|
984
|
-
|
|
985
|
-
|
|
1228
|
+
assert.notEqual(firstAct.verb, 'create');
|
|
1229
|
+
}));
|
|
986
1230
|
|
|
987
1231
|
it('should re-initialize _listActivitiesThreadOrdered when jumpToActivity is called with a new URL', () => {
|
|
988
1232
|
let conversation2, msg;
|
|
989
1233
|
|
|
990
|
-
return webex.internal.conversation
|
|
1234
|
+
return webex.internal.conversation
|
|
1235
|
+
.create({participants: [scott.id]})
|
|
991
1236
|
.then((c) => {
|
|
992
1237
|
conversation2 = c;
|
|
993
1238
|
|
|
994
|
-
return webex.internal.conversation.post(conversation2, {
|
|
1239
|
+
return webex.internal.conversation.post(conversation2, {
|
|
1240
|
+
displayName: 'first message',
|
|
1241
|
+
});
|
|
995
1242
|
})
|
|
996
1243
|
.then((m) => {
|
|
997
1244
|
msg = m;
|
|
998
1245
|
|
|
999
1246
|
return jumpToActivity(msg);
|
|
1000
|
-
})
|
|
1247
|
+
})
|
|
1248
|
+
.then(() => {
|
|
1001
1249
|
assert.isTrue(_listActivitiesThreadOrderedSpy.args[0][0].url === conversation2.url);
|
|
1002
1250
|
});
|
|
1003
1251
|
});
|