@webex/internal-plugin-conversation 3.0.0-beta.8 → 3.0.0-bnr.0
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
|
@@ -21,8 +21,7 @@ import {flaky, skipInNode, browserOnly} from '@webex/test-helper-mocha';
|
|
|
21
21
|
* @returns {Promise<mixed>}
|
|
22
22
|
*/
|
|
23
23
|
function returnFirstArg(fn) {
|
|
24
|
-
return (result) => Promise.resolve(fn(result))
|
|
25
|
-
.then(() => result);
|
|
24
|
+
return (result) => Promise.resolve(fn(result)).then(() => result);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
describe('plugin-conversation', function () {
|
|
@@ -30,8 +29,8 @@ describe('plugin-conversation', function () {
|
|
|
30
29
|
describe('share', () => {
|
|
31
30
|
let mccoy, participants, webex, spock;
|
|
32
31
|
|
|
33
|
-
before(() =>
|
|
34
|
-
.then(async (users) => {
|
|
32
|
+
before(() =>
|
|
33
|
+
testUsers.create({count: 3}).then(async (users) => {
|
|
35
34
|
participants = users;
|
|
36
35
|
[spock, mccoy] = participants;
|
|
37
36
|
|
|
@@ -40,26 +39,29 @@ describe('plugin-conversation', function () {
|
|
|
40
39
|
|
|
41
40
|
webex = new WebexCore({
|
|
42
41
|
credentials: {
|
|
43
|
-
authorization: spock.token
|
|
44
|
-
}
|
|
42
|
+
authorization: spock.token,
|
|
43
|
+
},
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
mccoy.webex = new WebexCore({
|
|
48
47
|
credentials: {
|
|
49
|
-
authorization: mccoy.token
|
|
50
|
-
}
|
|
48
|
+
authorization: mccoy.token,
|
|
49
|
+
},
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
return Promise.all([
|
|
54
53
|
webex.internal.mercury.connect(),
|
|
55
|
-
mccoy.webex.internal.mercury.connect()
|
|
54
|
+
mccoy.webex.internal.mercury.connect(),
|
|
56
55
|
]);
|
|
57
|
-
})
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
58
|
|
|
59
|
-
after(() =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
after(() =>
|
|
60
|
+
Promise.all([
|
|
61
|
+
webex && webex.internal.mercury.disconnect(),
|
|
62
|
+
mccoy && mccoy.webex.internal.mercury.disconnect(),
|
|
63
|
+
])
|
|
64
|
+
);
|
|
63
65
|
|
|
64
66
|
let conversation;
|
|
65
67
|
|
|
@@ -68,8 +70,9 @@ describe('plugin-conversation', function () {
|
|
|
68
70
|
return Promise.resolve();
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
return webex.internal.conversation.create({participants})
|
|
72
|
-
|
|
73
|
+
return webex.internal.conversation.create({participants}).then((c) => {
|
|
74
|
+
conversation = c;
|
|
75
|
+
});
|
|
73
76
|
});
|
|
74
77
|
|
|
75
78
|
let hashTestText = '#test.txt';
|
|
@@ -82,17 +85,17 @@ describe('plugin-conversation', function () {
|
|
|
82
85
|
let sampleTextTwo = 'sample-text-two.txt';
|
|
83
86
|
const sampleGif = 'sample-gif.gif';
|
|
84
87
|
|
|
85
|
-
before(() =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.then((res) => {
|
|
88
|
+
before(() =>
|
|
89
|
+
Promise.all([
|
|
90
|
+
fh.fetchWithoutMagic(hashTestText),
|
|
91
|
+
fh.fetchWithoutMagic(sampleImageSmallOnePng),
|
|
92
|
+
fh.fetchWithoutMagic(sampleImageSmallTwoPng),
|
|
93
|
+
fh.fetchWithoutMagic(sampleImageLargeJpg),
|
|
94
|
+
fh.fetchWithoutMagic(sampleImageLargeNoEXIFJpg),
|
|
95
|
+
fh.fetchWithoutMagic(samplePowerpointTwoPagePpt),
|
|
96
|
+
fh.fetchWithoutMagic(sampleTextOne),
|
|
97
|
+
fh.fetchWithoutMagic(sampleTextTwo),
|
|
98
|
+
]).then((res) => {
|
|
96
99
|
[
|
|
97
100
|
hashTestText,
|
|
98
101
|
sampleImageSmallOnePng,
|
|
@@ -101,46 +104,15 @@ describe('plugin-conversation', function () {
|
|
|
101
104
|
sampleImageLargeNoEXIFJpg,
|
|
102
105
|
samplePowerpointTwoPagePpt,
|
|
103
106
|
sampleTextOne,
|
|
104
|
-
sampleTextTwo
|
|
107
|
+
sampleTextTwo,
|
|
105
108
|
] = res;
|
|
106
|
-
})
|
|
109
|
+
})
|
|
110
|
+
);
|
|
107
111
|
|
|
108
112
|
describe('#share()', () => {
|
|
109
|
-
it('shares the specified file to the specified conversation', () =>
|
|
110
|
-
.
|
|
111
|
-
|
|
112
|
-
assert.isEncryptedActivity(activity);
|
|
113
|
-
assert.isFileItem(activity.object.files.items[0]);
|
|
114
|
-
|
|
115
|
-
return webex.internal.conversation.download(activity.object.files.items[0]);
|
|
116
|
-
})
|
|
117
|
-
.then(returnFirstArg((f) => assert.match(f.type, /text\/plain/)))
|
|
118
|
-
.then((f) => fh.isMatchingFile(f, sampleTextOne)
|
|
119
|
-
.then((result) => assert.isTrue(result))));
|
|
120
|
-
|
|
121
|
-
it('shares the specified set of files to the specified conversation', () => webex.internal.conversation.share(conversation, [sampleTextOne, sampleTextTwo])
|
|
122
|
-
.then((activity) => {
|
|
123
|
-
assert.isActivity(activity);
|
|
124
|
-
assert.isEncryptedActivity(activity);
|
|
125
|
-
assert.isFileItem(activity.object.files.items[0]);
|
|
126
|
-
assert.isFileItem(activity.object.files.items[1]);
|
|
127
|
-
|
|
128
|
-
return Promise.all([
|
|
129
|
-
webex.internal.conversation.download(activity.object.files.items[0])
|
|
130
|
-
.then(returnFirstArg((f) => assert.match(f.type, /text\/plain/))),
|
|
131
|
-
webex.internal.conversation.download(activity.object.files.items[1])
|
|
132
|
-
.then(returnFirstArg((f) => assert.match(f.type, /text\/plain/)))
|
|
133
|
-
]);
|
|
134
|
-
})
|
|
135
|
-
.then(([file0, file1]) => Promise.all([
|
|
136
|
-
fh.isMatchingFile(file0, sampleTextOne)
|
|
137
|
-
.then((result) => assert.isTrue(result)),
|
|
138
|
-
fh.isMatchingFile(file1, sampleTextTwo)
|
|
139
|
-
.then((result) => assert.isTrue(result))
|
|
140
|
-
])));
|
|
141
|
-
|
|
142
|
-
describe('files with special characters', () => {
|
|
143
|
-
it('shares the specified file to the specified conversation', () => webex.internal.conversation.share(conversation, [hashTestText])
|
|
113
|
+
it('shares the specified file to the specified conversation', () =>
|
|
114
|
+
webex.internal.conversation
|
|
115
|
+
.share(conversation, [sampleTextOne])
|
|
144
116
|
.then((activity) => {
|
|
145
117
|
assert.isActivity(activity);
|
|
146
118
|
assert.isEncryptedActivity(activity);
|
|
@@ -148,82 +120,138 @@ describe('plugin-conversation', function () {
|
|
|
148
120
|
|
|
149
121
|
return webex.internal.conversation.download(activity.object.files.items[0]);
|
|
150
122
|
})
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
123
|
+
.then(returnFirstArg((f) => assert.match(f.type, /text\/plain/)))
|
|
124
|
+
.then((f) =>
|
|
125
|
+
fh.isMatchingFile(f, sampleTextOne).then((result) => assert.isTrue(result))
|
|
126
|
+
));
|
|
127
|
+
|
|
128
|
+
it('shares the specified set of files to the specified conversation', () =>
|
|
129
|
+
webex.internal.conversation
|
|
130
|
+
.share(conversation, [sampleTextOne, sampleTextTwo])
|
|
131
|
+
.then((activity) => {
|
|
132
|
+
assert.isActivity(activity);
|
|
133
|
+
assert.isEncryptedActivity(activity);
|
|
134
|
+
assert.isFileItem(activity.object.files.items[0]);
|
|
135
|
+
assert.isFileItem(activity.object.files.items[1]);
|
|
136
|
+
|
|
137
|
+
return Promise.all([
|
|
138
|
+
webex.internal.conversation
|
|
139
|
+
.download(activity.object.files.items[0])
|
|
140
|
+
.then(returnFirstArg((f) => assert.match(f.type, /text\/plain/))),
|
|
141
|
+
webex.internal.conversation
|
|
142
|
+
.download(activity.object.files.items[1])
|
|
143
|
+
.then(returnFirstArg((f) => assert.match(f.type, /text\/plain/))),
|
|
144
|
+
]);
|
|
145
|
+
})
|
|
146
|
+
.then(([file0, file1]) =>
|
|
147
|
+
Promise.all([
|
|
148
|
+
fh.isMatchingFile(file0, sampleTextOne).then((result) => assert.isTrue(result)),
|
|
149
|
+
fh.isMatchingFile(file1, sampleTextTwo).then((result) => assert.isTrue(result)),
|
|
150
|
+
])
|
|
151
|
+
));
|
|
160
152
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
describe('files with special characters', () => {
|
|
154
|
+
it('shares the specified file to the specified conversation', () =>
|
|
155
|
+
webex.internal.conversation
|
|
156
|
+
.share(conversation, [hashTestText])
|
|
157
|
+
.then((activity) => {
|
|
158
|
+
assert.isActivity(activity);
|
|
159
|
+
assert.isEncryptedActivity(activity);
|
|
160
|
+
assert.isFileItem(activity.object.files.items[0]);
|
|
161
|
+
|
|
162
|
+
return webex.internal.conversation.download(activity.object.files.items[0]);
|
|
163
|
+
})
|
|
164
|
+
// in node, this'll be 'text/plain', in a browser, it'll be
|
|
165
|
+
// 'text/html'. I'm pretty sure it's caused by the # convincing
|
|
166
|
+
// express it's a hashroute and treating it as html. The discrepancy
|
|
167
|
+
// has no bearing on the test's validity. Further, we need to use
|
|
168
|
+
// match rather than equal because some browser append the charset.
|
|
169
|
+
.then(returnFirstArg((f) => assert.match(f.type, hashTestText.type || /text\/plain/)))
|
|
170
|
+
.then((f) =>
|
|
171
|
+
fh.isMatchingFile(f, hashTestText).then((result) => assert.isTrue(result))
|
|
172
|
+
));
|
|
173
|
+
});
|
|
165
174
|
|
|
166
|
-
|
|
175
|
+
it('shares an image with no EXIF data to the specified conversation and correctly error handles', () =>
|
|
176
|
+
webex.internal.conversation
|
|
177
|
+
.share(conversation, [sampleImageLargeNoEXIFJpg])
|
|
178
|
+
.then((activity) => {
|
|
179
|
+
assert.isActivity(activity);
|
|
180
|
+
assert.isEncryptedActivity(activity);
|
|
167
181
|
|
|
168
|
-
|
|
182
|
+
const fileItem = activity.object.files.items[0];
|
|
169
183
|
|
|
170
|
-
|
|
184
|
+
assert.isFileItem(fileItem);
|
|
171
185
|
|
|
172
|
-
|
|
173
|
-
assert.equal(thumbnailItem.width, 640);
|
|
174
|
-
assert.isAbove(thumbnailItem.height, 358);
|
|
175
|
-
assert.isBelow(thumbnailItem.height, 361);
|
|
186
|
+
const thumbnailItem = activity.object.files.items[0].image;
|
|
176
187
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
.then((result) => assert.isTrue(result))));
|
|
188
|
+
assert.isThumbnailItem(thumbnailItem);
|
|
189
|
+
assert.equal(thumbnailItem.width, 640);
|
|
190
|
+
assert.isAbove(thumbnailItem.height, 358);
|
|
191
|
+
assert.isBelow(thumbnailItem.height, 361);
|
|
182
192
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
assert.
|
|
186
|
-
|
|
193
|
+
return webex.internal.conversation.download(activity.object.files.items[0]);
|
|
194
|
+
})
|
|
195
|
+
.then(returnFirstArg((f) => assert.equal(f.type, 'image/jpeg')))
|
|
196
|
+
.then((f) =>
|
|
197
|
+
fh.isMatchingFile(f, sampleImageLargeNoEXIFJpg).then((result) => assert.isTrue(result))
|
|
198
|
+
));
|
|
199
|
+
|
|
200
|
+
it('shares the specified image to the specified conversation', () =>
|
|
201
|
+
webex.internal.conversation
|
|
202
|
+
.share(conversation, [sampleImageLargeJpg])
|
|
203
|
+
.then((activity) => {
|
|
204
|
+
assert.isActivity(activity);
|
|
205
|
+
assert.isEncryptedActivity(activity);
|
|
187
206
|
|
|
188
|
-
|
|
207
|
+
const fileItem = activity.object.files.items[0];
|
|
189
208
|
|
|
190
|
-
|
|
209
|
+
assert.isFileItem(fileItem);
|
|
191
210
|
|
|
192
|
-
|
|
211
|
+
const thumbnailItem = activity.object.files.items[0].image;
|
|
193
212
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
213
|
+
assert.isThumbnailItem(thumbnailItem);
|
|
214
|
+
assert.equal(thumbnailItem.width, 640);
|
|
215
|
+
assert.isAbove(thumbnailItem.height, 330);
|
|
216
|
+
assert.isBelow(thumbnailItem.height, 361);
|
|
198
217
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
218
|
+
return webex.internal.conversation.download(activity.object.files.items[0]);
|
|
219
|
+
})
|
|
220
|
+
.then(returnFirstArg((f) => assert.equal(f.type, 'image/jpeg')))
|
|
221
|
+
.then((f) =>
|
|
222
|
+
fh.isMatchingFile(f, sampleImageLargeJpg).then((result) => assert.isTrue(result))
|
|
223
|
+
));
|
|
224
|
+
|
|
225
|
+
it('shares the specified set of images the specified conversation', () =>
|
|
226
|
+
webex.internal.conversation
|
|
227
|
+
.share(conversation, [sampleImageSmallOnePng, sampleImageSmallTwoPng])
|
|
228
|
+
.then((activity) => {
|
|
229
|
+
assert.isActivity(activity);
|
|
230
|
+
assert.isEncryptedActivity(activity);
|
|
231
|
+
assert.isFileItem(activity.object.files.items[0]);
|
|
232
|
+
assert.isFileItem(activity.object.files.items[1]);
|
|
233
|
+
assert.isThumbnailItem(activity.object.files.items[0].image);
|
|
234
|
+
assert.isThumbnailItem(activity.object.files.items[1].image);
|
|
235
|
+
|
|
236
|
+
return Promise.all([
|
|
237
|
+
webex.internal.conversation
|
|
238
|
+
.download(activity.object.files.items[0])
|
|
239
|
+
.then(returnFirstArg((f) => assert.equal(f.type, 'image/png'))),
|
|
240
|
+
webex.internal.conversation
|
|
241
|
+
.download(activity.object.files.items[1])
|
|
242
|
+
.then(returnFirstArg((f) => assert.equal(f.type, 'image/png'))),
|
|
243
|
+
]);
|
|
244
|
+
})
|
|
245
|
+
.then(([file0, file1]) =>
|
|
246
|
+
Promise.all([
|
|
247
|
+
fh
|
|
248
|
+
.isMatchingFile(file0, sampleImageSmallOnePng)
|
|
249
|
+
.then((result) => assert.isTrue(result)),
|
|
250
|
+
fh
|
|
251
|
+
.isMatchingFile(file1, sampleImageSmallTwoPng)
|
|
252
|
+
.then((result) => assert.isTrue(result)),
|
|
253
|
+
])
|
|
254
|
+
));
|
|
227
255
|
|
|
228
256
|
describe('when it shares a transcodable file', () => {
|
|
229
257
|
let activities;
|
|
@@ -238,7 +266,9 @@ describe('plugin-conversation', function () {
|
|
|
238
266
|
blockUntilTranscode = new Defer();
|
|
239
267
|
});
|
|
240
268
|
|
|
241
|
-
afterEach(
|
|
269
|
+
afterEach(
|
|
270
|
+
() => webex && webex.internal.mercury.off('event:conversation.activity', onMessage)
|
|
271
|
+
);
|
|
242
272
|
|
|
243
273
|
function onMessage(message) {
|
|
244
274
|
activities.push(message.data.activity);
|
|
@@ -248,7 +278,10 @@ describe('plugin-conversation', function () {
|
|
|
248
278
|
}
|
|
249
279
|
|
|
250
280
|
if (objectUrl) {
|
|
251
|
-
const updateActivity = find(
|
|
281
|
+
const updateActivity = find(
|
|
282
|
+
activities,
|
|
283
|
+
(activity) => activity.verb === 'update' && activity.object.url === objectUrl
|
|
284
|
+
);
|
|
252
285
|
|
|
253
286
|
if (updateActivity) {
|
|
254
287
|
blockUntilTranscode.resolve(updateActivity);
|
|
@@ -258,43 +291,54 @@ describe('plugin-conversation', function () {
|
|
|
258
291
|
|
|
259
292
|
// doesn't seem like we get mercury event back to update transcoded file in time
|
|
260
293
|
// https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-166178
|
|
261
|
-
it.skip('mercury receives an update', () =>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
assert.equal(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
294
|
+
it.skip('mercury receives an update', () =>
|
|
295
|
+
webex.internal.conversation
|
|
296
|
+
.share(conversation, {
|
|
297
|
+
object: {
|
|
298
|
+
files: [samplePowerpointTwoPagePpt],
|
|
299
|
+
},
|
|
300
|
+
clientTempId,
|
|
301
|
+
})
|
|
302
|
+
.then((activity) => {
|
|
303
|
+
assert.equal(activity.clientTempId, clientTempId);
|
|
304
|
+
activities.push(activity);
|
|
305
|
+
|
|
306
|
+
return webex.internal.conversation
|
|
307
|
+
.download(activity.object.files.items[0])
|
|
308
|
+
.then((f) => assert.equal(f.type, 'application/vnd.ms-powerpoint'))
|
|
309
|
+
.then(() => blockUntilTranscode.promise)
|
|
310
|
+
.then((updateActivity) => {
|
|
311
|
+
assert.equal(updateActivity.object.url, activity.object.url);
|
|
312
|
+
assert.lengthOf(
|
|
313
|
+
updateActivity.object.files.items[0].transcodedCollection.items[0].files.items,
|
|
314
|
+
2
|
|
315
|
+
);
|
|
316
|
+
// Prove that the newly transcoded file can be downloaded and
|
|
317
|
+
// decrypted
|
|
318
|
+
const firstItem =
|
|
319
|
+
updateActivity.object.files.items[0].transcodedCollection.items[0].files
|
|
320
|
+
.items[0];
|
|
321
|
+
|
|
322
|
+
return webex.internal.conversation.download(firstItem);
|
|
323
|
+
});
|
|
324
|
+
}));
|
|
284
325
|
});
|
|
285
326
|
|
|
286
327
|
it('shares a whiteboard', () => {
|
|
287
328
|
const activity = webex.internal.conversation.makeShare(conversation);
|
|
288
329
|
|
|
289
330
|
activity.add(sampleImageSmallOnePng, {
|
|
290
|
-
actions: [
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
331
|
+
actions: [
|
|
332
|
+
{
|
|
333
|
+
type: 'edit',
|
|
334
|
+
mimeType: 'application/x-cisco-webex-whiteboard',
|
|
335
|
+
url: 'https://boards.example.com/boards/1',
|
|
336
|
+
},
|
|
337
|
+
],
|
|
295
338
|
});
|
|
296
339
|
|
|
297
|
-
return webex.internal.conversation
|
|
340
|
+
return webex.internal.conversation
|
|
341
|
+
.share(conversation, activity)
|
|
298
342
|
.then((share) => {
|
|
299
343
|
assert.isActivity(share);
|
|
300
344
|
assert.isEncryptedActivity(share);
|
|
@@ -303,40 +347,53 @@ describe('plugin-conversation', function () {
|
|
|
303
347
|
assert.equal(share.object.contentCategory, 'documents');
|
|
304
348
|
assert.isArray(share.object.files.items[0].actions);
|
|
305
349
|
assert.equal(share.object.files.items[0].actions[0].type, 'edit');
|
|
306
|
-
assert.equal(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
350
|
+
assert.equal(
|
|
351
|
+
share.object.files.items[0].actions[0].mimeType,
|
|
352
|
+
'application/x-cisco-webex-whiteboard'
|
|
353
|
+
);
|
|
354
|
+
assert.equal(
|
|
355
|
+
share.object.files.items[0].actions[0].url,
|
|
356
|
+
'https://boards.example.com/boards/1'
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
return webex.internal.conversation
|
|
360
|
+
.download(share.object.files.items[0])
|
|
310
361
|
.then(returnFirstArg((f) => assert.equal(f.type, 'image/png')));
|
|
311
362
|
})
|
|
312
|
-
.then((file0) =>
|
|
313
|
-
.then((result) => assert.isTrue(result))
|
|
363
|
+
.then((file0) =>
|
|
364
|
+
fh.isMatchingFile(file0, sampleImageSmallOnePng).then((result) => assert.isTrue(result))
|
|
365
|
+
);
|
|
314
366
|
});
|
|
315
367
|
});
|
|
316
368
|
|
|
317
369
|
describe('#makeShare', () => {
|
|
318
370
|
// http-core doesn't current do upload progress events in node, so this
|
|
319
371
|
// test is browser-only for now
|
|
320
|
-
skipInNode(flaky(it, process.env.SKIP_FLAKY_TESTS))(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
372
|
+
skipInNode(flaky(it, process.env.SKIP_FLAKY_TESTS))(
|
|
373
|
+
'provides an interface for file upload events',
|
|
374
|
+
() => {
|
|
375
|
+
const spy = sinon.spy();
|
|
376
|
+
const share = webex.internal.conversation.makeShare(conversation);
|
|
377
|
+
const emitter = share.add(sampleImageSmallOnePng);
|
|
378
|
+
|
|
379
|
+
emitter.on('progress', spy);
|
|
380
|
+
|
|
381
|
+
return webex.internal.conversation
|
|
382
|
+
.share(conversation, share)
|
|
383
|
+
.then(() => assert.called(spy));
|
|
384
|
+
}
|
|
385
|
+
);
|
|
330
386
|
|
|
331
387
|
it('shares a file with a name', () => {
|
|
332
388
|
const share = webex.internal.conversation.makeShare(conversation);
|
|
333
389
|
|
|
334
390
|
share.add(sampleImageSmallOnePng);
|
|
335
391
|
share.object = {
|
|
336
|
-
displayName: 'a name'
|
|
392
|
+
displayName: 'a name',
|
|
337
393
|
};
|
|
338
394
|
|
|
339
|
-
return webex.internal.conversation
|
|
395
|
+
return webex.internal.conversation
|
|
396
|
+
.share(conversation, share)
|
|
340
397
|
.then((activity) => {
|
|
341
398
|
assert.equal(activity.object.displayName, 'a name');
|
|
342
399
|
|
|
@@ -353,10 +410,11 @@ describe('plugin-conversation', function () {
|
|
|
353
410
|
share.add(sampleImageSmallTwoPng);
|
|
354
411
|
share.remove(sampleImageSmallOnePng);
|
|
355
412
|
share.object = {
|
|
356
|
-
displayName: 'a name'
|
|
413
|
+
displayName: 'a name',
|
|
357
414
|
};
|
|
358
415
|
|
|
359
|
-
return webex.internal.conversation
|
|
416
|
+
return webex.internal.conversation
|
|
417
|
+
.share(conversation, share)
|
|
360
418
|
.then((activity) => {
|
|
361
419
|
assert.equal(activity.object.displayName, 'a name');
|
|
362
420
|
assert.lengthOf(activity.object.files.items, 1);
|
|
@@ -372,19 +430,20 @@ describe('plugin-conversation', function () {
|
|
|
372
430
|
|
|
373
431
|
share.add(sampleImageSmallOnePng);
|
|
374
432
|
share.object = {
|
|
375
|
-
displayName: 'a name'
|
|
433
|
+
displayName: 'a name',
|
|
376
434
|
};
|
|
377
435
|
|
|
378
436
|
let parentActivityId;
|
|
379
437
|
|
|
380
|
-
return webex.internal.conversation
|
|
438
|
+
return webex.internal.conversation
|
|
439
|
+
.share(conversation, share)
|
|
381
440
|
.then((activity) => {
|
|
382
441
|
assert.equal(activity.object.displayName, 'a name');
|
|
383
442
|
const threadShare = webex.internal.conversation.makeShare(conversation);
|
|
384
443
|
|
|
385
444
|
threadShare.add(sampleImageSmallOnePng);
|
|
386
445
|
threadShare.object = {
|
|
387
|
-
displayName: 'a thread share name'
|
|
446
|
+
displayName: 'a thread share name',
|
|
388
447
|
};
|
|
389
448
|
threadShare.activityType = 'reply';
|
|
390
449
|
threadShare.parentActivityId = activity.id;
|
|
@@ -409,8 +468,8 @@ describe('plugin-conversation', function () {
|
|
|
409
468
|
let blob, buffer;
|
|
410
469
|
|
|
411
470
|
// Read file as buffer
|
|
412
|
-
browserOnly(before)(() =>
|
|
413
|
-
.then((file) => {
|
|
471
|
+
browserOnly(before)(() =>
|
|
472
|
+
fh.fetch(sampleGif).then((file) => {
|
|
414
473
|
blob = file;
|
|
415
474
|
|
|
416
475
|
return new Promise((resolve) => {
|
|
@@ -423,52 +482,56 @@ describe('plugin-conversation', function () {
|
|
|
423
482
|
};
|
|
424
483
|
fileReader.readAsArrayBuffer(blob);
|
|
425
484
|
});
|
|
426
|
-
})
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
value:
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
485
|
+
})
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
browserOnly(it)(
|
|
489
|
+
'if the giphy does not exist, then we check it gets added to this.uploads',
|
|
490
|
+
(done) => {
|
|
491
|
+
// eslint-disable-next-line no-undef
|
|
492
|
+
const file = new File([buffer], blob.name, {type: 'image/gif'});
|
|
493
|
+
|
|
494
|
+
const originalGiphyURL = 'https://media1.giphy.com/media/nXxOjZrbnbRxS/giphy.gif';
|
|
495
|
+
const originalGiphyStillURL = 'https://media1.giphy.com/media/nXxOjZrbnbRxS/giphy_s.gif';
|
|
496
|
+
const url = 'https://giphy.com';
|
|
497
|
+
|
|
498
|
+
// simulate in web client where
|
|
499
|
+
Object.defineProperty(file, 'url', {value: originalGiphyURL});
|
|
500
|
+
// define thumbnail
|
|
501
|
+
Object.defineProperty(file, 'image', {
|
|
502
|
+
value: {
|
|
503
|
+
height: file.width,
|
|
504
|
+
width: file.height,
|
|
505
|
+
url: originalGiphyStillURL,
|
|
506
|
+
},
|
|
507
|
+
});
|
|
448
508
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
assert.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
509
|
+
const share = webex.internal.conversation.makeShare(conversation);
|
|
510
|
+
|
|
511
|
+
// Check that initially there were no uploads
|
|
512
|
+
assert.isTrue(share.uploads.size === 0);
|
|
513
|
+
share.addGif(file).then(() => {
|
|
514
|
+
assert.equal(share.uploads.size, 1);
|
|
515
|
+
assert.equal(share.uploads.get(file).objectType, 'file');
|
|
516
|
+
assert.equal(share.uploads.get(file).displayName, sampleGif);
|
|
517
|
+
assert.equal(share.uploads.get(file).mimeType, 'image/gif');
|
|
518
|
+
assert.equal(share.uploads.get(file).fileSize, 473119);
|
|
519
|
+
assert.equal(share.uploads.get(file).width, 200);
|
|
520
|
+
assert.equal(share.uploads.get(file).height, 270);
|
|
521
|
+
assert.equal(share.uploads.get(file).url, url);
|
|
522
|
+
assert.exists(share.uploads.get(file).scr);
|
|
523
|
+
assert.equal(share.uploads.get(file).scr.loc, originalGiphyURL);
|
|
524
|
+
|
|
525
|
+
assert.exists(share.uploads.get(file).image);
|
|
526
|
+
assert.equal(share.uploads.get(file).image.width, 200);
|
|
527
|
+
assert.equal(share.uploads.get(file).image.height, 270);
|
|
528
|
+
assert.equal(share.uploads.get(file).image.url, url);
|
|
529
|
+
assert.exists(share.uploads.get(file).image.scr);
|
|
530
|
+
assert.equal(share.uploads.get(file).image.scr.loc, originalGiphyStillURL);
|
|
531
|
+
});
|
|
532
|
+
done();
|
|
533
|
+
}
|
|
534
|
+
);
|
|
472
535
|
});
|
|
473
536
|
});
|
|
474
537
|
});
|