@webex/internal-plugin-conversation 3.0.0-beta.14 → 3.0.0-beta.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +1 -3
  2. package/dist/activities.js +8 -69
  3. package/dist/activities.js.map +1 -1
  4. package/dist/activity-thread-ordering.js +19 -79
  5. package/dist/activity-thread-ordering.js.map +1 -1
  6. package/dist/config.js +1 -7
  7. package/dist/config.js.map +1 -1
  8. package/dist/constants.js +4 -5
  9. package/dist/constants.js.map +1 -1
  10. package/dist/conversation.js +790 -1199
  11. package/dist/conversation.js.map +1 -1
  12. package/dist/convo-error.js +0 -23
  13. package/dist/convo-error.js.map +1 -1
  14. package/dist/decryption-transforms.js +35 -98
  15. package/dist/decryption-transforms.js.map +1 -1
  16. package/dist/encryption-transforms.js +11 -48
  17. package/dist/encryption-transforms.js.map +1 -1
  18. package/dist/index.js +7 -50
  19. package/dist/index.js.map +1 -1
  20. package/dist/share-activity.js +40 -106
  21. package/dist/share-activity.js.map +1 -1
  22. package/dist/to-array.js +9 -11
  23. package/dist/to-array.js.map +1 -1
  24. package/package.json +15 -15
  25. package/src/activities.js +10 -7
  26. package/src/activity-thread-ordering.js +27 -30
  27. package/src/activity-threading.md +68 -49
  28. package/src/config.js +5 -5
  29. package/src/conversation.js +621 -589
  30. package/src/decryption-transforms.js +103 -62
  31. package/src/encryption-transforms.js +103 -83
  32. package/src/index.js +82 -66
  33. package/src/share-activity.js +64 -55
  34. package/src/to-array.js +2 -2
  35. package/test/integration/spec/create.js +186 -121
  36. package/test/integration/spec/encryption.js +249 -186
  37. package/test/integration/spec/get.js +763 -514
  38. package/test/integration/spec/mercury.js +37 -27
  39. package/test/integration/spec/share.js +292 -229
  40. package/test/integration/spec/verbs.js +628 -441
  41. package/test/unit/spec/conversation.js +265 -163
  42. package/test/unit/spec/decrypt-transforms.js +112 -131
  43. package/test/unit/spec/encryption-transforms.js +24 -18
  44. package/test/unit/spec/share-activity.js +37 -40
@@ -26,24 +26,23 @@ describe('plugin-conversation', function () {
26
26
 
27
27
  webex = new WebexCore({
28
28
  credentials: {
29
- authorization: spock.token
30
- }
29
+ authorization: spock.token,
30
+ },
31
31
  });
32
32
 
33
33
  webex.config.conversation.allowedOutboundTags = {
34
- strong: []
34
+ strong: [],
35
35
  };
36
36
  webex.config.conversation.allowedInboundTags = {
37
- strong: []
37
+ strong: [],
38
38
  };
39
39
 
40
40
  mccoy.webex = new WebexCore({
41
41
  credentials: {
42
- authorization: mccoy.token
43
- }
42
+ authorization: mccoy.token,
43
+ },
44
44
  });
45
45
 
46
- // eslint-disable-next-line no-unused-expressions
47
46
  await webex.internal.mercury.connect();
48
47
  await mccoy.webex.internal.mercury.connect();
49
48
 
@@ -51,10 +50,10 @@ describe('plugin-conversation', function () {
51
50
  });
52
51
 
53
52
  after(async () => {
54
- // eslint-disable-next-line no-unused-expressions
55
- webex && await webex.internal.mercury.disconnect();
56
- // eslint-disable-next-line no-unused-expressions
57
- mccoy && await mccoy.webex.internal.mercury.disconnect();
53
+ // eslint-disable-next-line chai-friendly/no-unused-expressions
54
+ webex && (await webex.internal.mercury.disconnect());
55
+ // eslint-disable-next-line chai-friendly/no-unused-expressions
56
+ mccoy && (await mccoy.webex.internal.mercury.disconnect());
58
57
  });
59
58
 
60
59
  function makeEmailAddress() {
@@ -62,8 +61,8 @@ describe('plugin-conversation', function () {
62
61
  }
63
62
 
64
63
  describe('when there is only one other participant', () => {
65
- it('creates a 1:1 conversation', () => webex.internal.conversation.create({participants: [mccoy]})
66
- .then((conversation) => {
64
+ it('creates a 1:1 conversation', () =>
65
+ webex.internal.conversation.create({participants: [mccoy]}).then((conversation) => {
67
66
  assert.isConversation(conversation);
68
67
  assert.isOneOnOneConversation(conversation);
69
68
  assert.isNewEncryptedConversation(conversation);
@@ -73,13 +72,15 @@ describe('plugin-conversation', function () {
73
72
  }));
74
73
 
75
74
  // TODO: Issues with side boarding users too soon. Skipping until it's fixed
76
- describe.skip('when the other user doesn\'t exist', () => {
75
+ describe.skip("when the other user doesn't exist", () => {
77
76
  let email;
78
77
 
79
- beforeEach(() => { email = makeEmailAddress(); });
78
+ beforeEach(() => {
79
+ email = makeEmailAddress();
80
+ });
80
81
 
81
- it('invites the other user', () => webex.internal.conversation.create({participants: [email]})
82
- .then((conversation) => {
82
+ it('invites the other user', () =>
83
+ webex.internal.conversation.create({participants: [email]}).then((conversation) => {
83
84
  assert.isConversation(conversation);
84
85
  assert.isOneOnOneConversation(conversation);
85
86
  assert.isNewEncryptedConversation(conversation);
@@ -93,132 +94,196 @@ describe('plugin-conversation', function () {
93
94
 
94
95
  describe('when the conversation already exists', () => {
95
96
  describe('with skipOneOnOneFetch=true', () => {
96
- it('fails to create a 1:1 conversation that already exists', () => assert.isRejected(webex.internal.conversation.create({participants: [mccoy]}, {skipOneOnOneFetch: true}))
97
- .then((reason) => assert.instanceOf(reason, WebexHttpError.Conflict)));
97
+ it('fails to create a 1:1 conversation that already exists', () =>
98
+ assert
99
+ .isRejected(
100
+ webex.internal.conversation.create(
101
+ {participants: [mccoy]},
102
+ {skipOneOnOneFetch: true}
103
+ )
104
+ )
105
+ .then((reason) => assert.instanceOf(reason, WebexHttpError.Conflict)));
98
106
  });
99
107
 
100
- it('returns the preexisting conversation', () => webex.internal.conversation.create({participants: [checkov]})
101
- .then((conversation) => webex.internal.conversation.create({participants: [checkov]})
102
- .then((conversation2) => {
108
+ it('returns the preexisting conversation', () =>
109
+ webex.internal.conversation.create({participants: [checkov]}).then((conversation) =>
110
+ webex.internal.conversation.create({participants: [checkov]}).then((conversation2) => {
103
111
  assert.equal(conversation2.url, conversation.url);
104
112
  assert.lengthOf(conversation.activities.items, 1);
105
113
  assert.equal(conversation.activities.items[0].verb, 'create');
106
- })));
107
-
108
- it('returns the preexisting conversation and posts a comment', () => webex.internal.conversation.create({participants: [checkov], comment: 'hi'})
109
- .then((conversation) => webex.internal.conversation.create({participants: [checkov]})
110
- .then((conversation2) => {
111
- assert.equal(conversation2.id, conversation.id);
112
- // the first activity is "create"; get the "post"
113
- const activity = conversation.activities.items.pop();
114
-
115
- assert.equal(activity.verb, 'post');
116
- assert.equal(activity.object.displayName, 'hi');
117
- })));
118
-
119
- it('returns the preexisting conversation and posts a comment with html', () => webex.internal.conversation.create({participants: [checkov], comment: '**hi**', html: '<strong>hi</strong>'})
120
- .then((conversation) => webex.internal.conversation.create({participants: [checkov]})
121
- .then((conversation2) => {
122
- assert.equal(conversation2.id, conversation.id);
123
- // the first activity is "create"; get the "post"
124
- const activity = conversation.activities.items.pop();
125
-
126
- assert.equal(activity.verb, 'post');
127
- assert.equal(activity.object.displayName, '**hi**');
128
- assert.equal(activity.object.content, '<strong>hi</strong>');
129
- })));
114
+ })
115
+ ));
116
+
117
+ it('returns the preexisting conversation and posts a comment', () =>
118
+ webex.internal.conversation
119
+ .create({participants: [checkov], comment: 'hi'})
120
+ .then((conversation) =>
121
+ webex.internal.conversation
122
+ .create({participants: [checkov]})
123
+ .then((conversation2) => {
124
+ assert.equal(conversation2.id, conversation.id);
125
+ // the first activity is "create"; get the "post"
126
+ const activity = conversation.activities.items.pop();
127
+
128
+ assert.equal(activity.verb, 'post');
129
+ assert.equal(activity.object.displayName, 'hi');
130
+ })
131
+ ));
132
+
133
+ it('returns the preexisting conversation and posts a comment with html', () =>
134
+ webex.internal.conversation
135
+ .create({participants: [checkov], comment: '**hi**', html: '<strong>hi</strong>'})
136
+ .then((conversation) =>
137
+ webex.internal.conversation
138
+ .create({participants: [checkov]})
139
+ .then((conversation2) => {
140
+ assert.equal(conversation2.id, conversation.id);
141
+ // the first activity is "create"; get the "post"
142
+ const activity = conversation.activities.items.pop();
143
+
144
+ assert.equal(activity.verb, 'post');
145
+ assert.equal(activity.object.displayName, '**hi**');
146
+ assert.equal(activity.object.content, '<strong>hi</strong>');
147
+ })
148
+ ));
130
149
  });
131
150
 
132
151
  describe('when {forceGrouped: true} is specified', () => {
133
- it('creates a grouped conversation @canary', () => webex.internal.conversation.create({participants: [mccoy]}, {forceGrouped: true})
134
- .then((conversation) => {
135
- assert.isConversation(conversation);
136
- assert.isGroupConversation(conversation);
137
- assert.isNewEncryptedConversation(conversation);
138
-
139
- assert.lengthOf(conversation.participants.items, 2);
140
- assert.lengthOf(conversation.activities.items, 1);
141
- }));
152
+ it('creates a grouped conversation @canary', () =>
153
+ webex.internal.conversation
154
+ .create({participants: [mccoy]}, {forceGrouped: true})
155
+ .then((conversation) => {
156
+ assert.isConversation(conversation);
157
+ assert.isGroupConversation(conversation);
158
+ assert.isNewEncryptedConversation(conversation);
159
+
160
+ assert.lengthOf(conversation.participants.items, 2);
161
+ assert.lengthOf(conversation.activities.items, 1);
162
+ }));
142
163
  });
143
164
  });
144
165
 
145
166
  describe('when there is an invalid user in the participants list', () => {
146
167
  describe('with allowPartialCreation', () => {
147
- it('creates a group conversation', () => webex.internal.conversation.create({participants: [mccoy, 'invalidUser']}, {allowPartialCreation: true})
148
- .then((conversation) => {
149
- assert.isConversation(conversation);
150
- assert.isGroupConversation(conversation);
151
- assert.isNewEncryptedConversation(conversation);
152
-
153
- assert.lengthOf(conversation.participants.items, 2);
154
- assert.lengthOf(conversation.activities.items, 1);
155
- }));
156
-
157
- it('creates a group conversation with invalid uuid', () => testUsers.remove([kirk])
158
- .then(() => webex.internal.conversation.create({participants: [mccoy.id, kirk.id]}, {allowPartialCreation: true}))
159
- .then((conversation) => {
160
- assert.isConversation(conversation);
161
- assert.isGroupConversation(conversation);
162
- assert.isNewEncryptedConversation(conversation);
163
-
164
- assert.lengthOf(conversation.participants.items, 2);
165
- assert.lengthOf(conversation.activities.items, 1);
166
- }));
167
-
168
- it('fails to create a 1:1 conversation', () => assert.isRejected(webex.internal.conversation.create({participants: ['invalidUser']}, {allowPartialCreation: true}))
169
- .then((reason) => assert.instanceOf(reason, InvalidUserCreation)));
168
+ it('creates a group conversation', () =>
169
+ webex.internal.conversation
170
+ .create({participants: [mccoy, 'invalidUser']}, {allowPartialCreation: true})
171
+ .then((conversation) => {
172
+ assert.isConversation(conversation);
173
+ assert.isGroupConversation(conversation);
174
+ assert.isNewEncryptedConversation(conversation);
175
+
176
+ assert.lengthOf(conversation.participants.items, 2);
177
+ assert.lengthOf(conversation.activities.items, 1);
178
+ }));
179
+
180
+ it('creates a group conversation with invalid uuid', () =>
181
+ testUsers
182
+ .remove([kirk])
183
+ .then(() =>
184
+ webex.internal.conversation.create(
185
+ {participants: [mccoy.id, kirk.id]},
186
+ {allowPartialCreation: true}
187
+ )
188
+ )
189
+ .then((conversation) => {
190
+ assert.isConversation(conversation);
191
+ assert.isGroupConversation(conversation);
192
+ assert.isNewEncryptedConversation(conversation);
193
+
194
+ assert.lengthOf(conversation.participants.items, 2);
195
+ assert.lengthOf(conversation.activities.items, 1);
196
+ }));
197
+
198
+ it('fails to create a 1:1 conversation', () =>
199
+ assert
200
+ .isRejected(
201
+ webex.internal.conversation.create(
202
+ {participants: ['invalidUser']},
203
+ {allowPartialCreation: true}
204
+ )
205
+ )
206
+ .then((reason) => assert.instanceOf(reason, InvalidUserCreation)));
170
207
  });
171
208
 
172
209
  describe('without allowPartialCreation', () => {
173
- it('fails to create a group conversation without allowPartialCreation param', () => assert.isRejected(webex.internal.conversation.create({participants: [mccoy, 'invalidUser']})));
210
+ it('fails to create a group conversation without allowPartialCreation param', () =>
211
+ assert.isRejected(
212
+ webex.internal.conversation.create({participants: [mccoy, 'invalidUser']})
213
+ ));
174
214
  });
175
215
  });
176
216
 
177
217
  describe('when {compact: ?} is not specified', () => {
178
- it('creates a compact conversation', () => webex.internal.conversation.create({participants})
179
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 5}))
180
- .then((c) => assert.lengthOf(c.activities.items, 1)));
218
+ it('creates a compact conversation', () =>
219
+ webex.internal.conversation
220
+ .create({participants})
221
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 5}))
222
+ .then((c) => assert.lengthOf(c.activities.items, 1)));
181
223
  });
182
224
 
183
- it('creates a conversation with a name', () => webex.internal.conversation.create({displayName: 'displayName', participants})
184
- .then((c) => webex.internal.conversation.get(c))
185
- .then((c) => assert.equal(c.displayName, 'displayName')));
186
-
187
- it('creates a conversation with a comment', () => webex.internal.conversation.create({comment: 'comment', participants})
188
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
189
- .then((c) => assert.equal(c.activities.items[1].object.displayName, 'comment')));
190
-
191
- it('creates a conversation with a tag', () => webex.internal.conversation.create({tags: ['WELCOME'], participants})
192
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
193
- .then((c) => assert.equal(c.tags[0], 'WELCOME')));
194
-
195
- it('creates a favorite conversation', () => webex.internal.conversation.create({favorite: true, participants})
196
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
197
- .then((c) => assert.equal(c.tags[0], 'FAVORITE')));
198
-
199
- it('creates a conversation with a comment with html', () => webex.internal.conversation.create({comment: '**comment**', html: '<strong>comment</strong>', participants})
200
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
201
- .then((c) => {
202
- assert.equal(c.activities.items[1].object.displayName, '**comment**');
203
- assert.equal(c.activities.items[1].object.content, '<strong>comment</strong>');
204
- }));
205
-
206
- it('creates a conversation with a share', () => webex.internal.conversation.create({participants, files: [sampleTextOne]})
207
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 10}))
208
- .then((c) => {
209
- assert.equal(last(c.activities.items).verb, 'share');
210
-
211
- return webex.internal.conversation.download(last(c.activities.items).object.files.items[0]);
212
- })
213
- .then((file) => fh.isMatchingFile(file, sampleTextOne)));
214
-
215
- it('ensures the current user is in the participants list', () => webex.internal.conversation.create({comment: 'comment', participants: [mccoy, checkov]})
216
- .then((c) => webex.internal.conversation.get(c, {includeParticipants: true}))
217
- .then((c) => assert.include(map(c.participants.items, 'id'), spock.id)));
218
-
219
- it('does not allow me to create a conversation with zero participants', () => assert.isRejected(webex.internal.conversation.create({participants: []}, /`params.participants` is required/)));
225
+ it('creates a conversation with a name', () =>
226
+ webex.internal.conversation
227
+ .create({displayName: 'displayName', participants})
228
+ .then((c) => webex.internal.conversation.get(c))
229
+ .then((c) => assert.equal(c.displayName, 'displayName')));
230
+
231
+ it('creates a conversation with a comment', () =>
232
+ webex.internal.conversation
233
+ .create({comment: 'comment', participants})
234
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
235
+ .then((c) => assert.equal(c.activities.items[1].object.displayName, 'comment')));
236
+
237
+ it('creates a conversation with a tag', () =>
238
+ webex.internal.conversation
239
+ .create({tags: ['WELCOME'], participants})
240
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
241
+ .then((c) => assert.equal(c.tags[0], 'WELCOME')));
242
+
243
+ it('creates a favorite conversation', () =>
244
+ webex.internal.conversation
245
+ .create({favorite: true, participants})
246
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
247
+ .then((c) => assert.equal(c.tags[0], 'FAVORITE')));
248
+
249
+ it('creates a conversation with a comment with html', () =>
250
+ webex.internal.conversation
251
+ .create({comment: '**comment**', html: '<strong>comment</strong>', participants})
252
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
253
+ .then((c) => {
254
+ assert.equal(c.activities.items[1].object.displayName, '**comment**');
255
+ assert.equal(c.activities.items[1].object.content, '<strong>comment</strong>');
256
+ }));
220
257
 
221
- it('does not allow me to create a classified space when feature toggle is disabled for the org', () => webex.internal.conversation.create({participants: [mccoy, checkov], classificationId: 'abcde-12345-Some-UUID'})
222
- .catch((err) => assert.match(err.toString(), /Org not entitled for space classifications/)));
258
+ it('creates a conversation with a share', () =>
259
+ webex.internal.conversation
260
+ .create({participants, files: [sampleTextOne]})
261
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 10}))
262
+ .then((c) => {
263
+ assert.equal(last(c.activities.items).verb, 'share');
264
+
265
+ return webex.internal.conversation.download(
266
+ last(c.activities.items).object.files.items[0]
267
+ );
268
+ })
269
+ .then((file) => fh.isMatchingFile(file, sampleTextOne)));
270
+
271
+ it('ensures the current user is in the participants list', () =>
272
+ webex.internal.conversation
273
+ .create({comment: 'comment', participants: [mccoy, checkov]})
274
+ .then((c) => webex.internal.conversation.get(c, {includeParticipants: true}))
275
+ .then((c) => assert.include(map(c.participants.items, 'id'), spock.id)));
276
+
277
+ it('does not allow me to create a conversation with zero participants', () =>
278
+ assert.isRejected(
279
+ webex.internal.conversation.create({participants: []}, /`params.participants` is required/)
280
+ ));
281
+
282
+ it('does not allow me to create a classified space when feature toggle is disabled for the org', () =>
283
+ webex.internal.conversation
284
+ .create({participants: [mccoy, checkov], classificationId: 'abcde-12345-Some-UUID'})
285
+ .catch((err) =>
286
+ assert.match(err.toString(), /Org not entitled for space classifications/)
287
+ ));
223
288
  });
224
289
  });