@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
|
@@ -26,21 +26,21 @@ 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
46
|
// eslint-disable-next-line no-unused-expressions
|
|
@@ -52,9 +52,9 @@ describe('plugin-conversation', function () {
|
|
|
52
52
|
|
|
53
53
|
after(async () => {
|
|
54
54
|
// eslint-disable-next-line no-unused-expressions
|
|
55
|
-
webex && await webex.internal.mercury.disconnect();
|
|
55
|
+
webex && (await webex.internal.mercury.disconnect());
|
|
56
56
|
// eslint-disable-next-line no-unused-expressions
|
|
57
|
-
mccoy && await mccoy.webex.internal.mercury.disconnect();
|
|
57
|
+
mccoy && (await mccoy.webex.internal.mercury.disconnect());
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
function makeEmailAddress() {
|
|
@@ -62,8 +62,8 @@ describe('plugin-conversation', function () {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
describe('when there is only one other participant', () => {
|
|
65
|
-
it('creates a 1:1 conversation', () =>
|
|
66
|
-
.then((conversation) => {
|
|
65
|
+
it('creates a 1:1 conversation', () =>
|
|
66
|
+
webex.internal.conversation.create({participants: [mccoy]}).then((conversation) => {
|
|
67
67
|
assert.isConversation(conversation);
|
|
68
68
|
assert.isOneOnOneConversation(conversation);
|
|
69
69
|
assert.isNewEncryptedConversation(conversation);
|
|
@@ -73,13 +73,15 @@ describe('plugin-conversation', function () {
|
|
|
73
73
|
}));
|
|
74
74
|
|
|
75
75
|
// TODO: Issues with side boarding users too soon. Skipping until it's fixed
|
|
76
|
-
describe.skip(
|
|
76
|
+
describe.skip("when the other user doesn't exist", () => {
|
|
77
77
|
let email;
|
|
78
78
|
|
|
79
|
-
beforeEach(() => {
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
email = makeEmailAddress();
|
|
81
|
+
});
|
|
80
82
|
|
|
81
|
-
it('invites the other user', () =>
|
|
82
|
-
.then((conversation) => {
|
|
83
|
+
it('invites the other user', () =>
|
|
84
|
+
webex.internal.conversation.create({participants: [email]}).then((conversation) => {
|
|
83
85
|
assert.isConversation(conversation);
|
|
84
86
|
assert.isOneOnOneConversation(conversation);
|
|
85
87
|
assert.isNewEncryptedConversation(conversation);
|
|
@@ -93,132 +95,196 @@ describe('plugin-conversation', function () {
|
|
|
93
95
|
|
|
94
96
|
describe('when the conversation already exists', () => {
|
|
95
97
|
describe('with skipOneOnOneFetch=true', () => {
|
|
96
|
-
it('fails to create a 1:1 conversation that already exists', () =>
|
|
97
|
-
|
|
98
|
+
it('fails to create a 1:1 conversation that already exists', () =>
|
|
99
|
+
assert
|
|
100
|
+
.isRejected(
|
|
101
|
+
webex.internal.conversation.create(
|
|
102
|
+
{participants: [mccoy]},
|
|
103
|
+
{skipOneOnOneFetch: true}
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
.then((reason) => assert.instanceOf(reason, WebexHttpError.Conflict)));
|
|
98
107
|
});
|
|
99
108
|
|
|
100
|
-
it('returns the preexisting conversation', () =>
|
|
101
|
-
|
|
102
|
-
.then((conversation2) => {
|
|
109
|
+
it('returns the preexisting conversation', () =>
|
|
110
|
+
webex.internal.conversation.create({participants: [checkov]}).then((conversation) =>
|
|
111
|
+
webex.internal.conversation.create({participants: [checkov]}).then((conversation2) => {
|
|
103
112
|
assert.equal(conversation2.url, conversation.url);
|
|
104
113
|
assert.lengthOf(conversation.activities.items, 1);
|
|
105
114
|
assert.equal(conversation.activities.items[0].verb, 'create');
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
})
|
|
116
|
+
));
|
|
117
|
+
|
|
118
|
+
it('returns the preexisting conversation and posts a comment', () =>
|
|
119
|
+
webex.internal.conversation
|
|
120
|
+
.create({participants: [checkov], comment: 'hi'})
|
|
121
|
+
.then((conversation) =>
|
|
122
|
+
webex.internal.conversation
|
|
123
|
+
.create({participants: [checkov]})
|
|
124
|
+
.then((conversation2) => {
|
|
125
|
+
assert.equal(conversation2.id, conversation.id);
|
|
126
|
+
// the first activity is "create"; get the "post"
|
|
127
|
+
const activity = conversation.activities.items.pop();
|
|
128
|
+
|
|
129
|
+
assert.equal(activity.verb, 'post');
|
|
130
|
+
assert.equal(activity.object.displayName, 'hi');
|
|
131
|
+
})
|
|
132
|
+
));
|
|
133
|
+
|
|
134
|
+
it('returns the preexisting conversation and posts a comment with html', () =>
|
|
135
|
+
webex.internal.conversation
|
|
136
|
+
.create({participants: [checkov], comment: '**hi**', html: '<strong>hi</strong>'})
|
|
137
|
+
.then((conversation) =>
|
|
138
|
+
webex.internal.conversation
|
|
139
|
+
.create({participants: [checkov]})
|
|
140
|
+
.then((conversation2) => {
|
|
141
|
+
assert.equal(conversation2.id, conversation.id);
|
|
142
|
+
// the first activity is "create"; get the "post"
|
|
143
|
+
const activity = conversation.activities.items.pop();
|
|
144
|
+
|
|
145
|
+
assert.equal(activity.verb, 'post');
|
|
146
|
+
assert.equal(activity.object.displayName, '**hi**');
|
|
147
|
+
assert.equal(activity.object.content, '<strong>hi</strong>');
|
|
148
|
+
})
|
|
149
|
+
));
|
|
130
150
|
});
|
|
131
151
|
|
|
132
152
|
describe('when {forceGrouped: true} is specified', () => {
|
|
133
|
-
it('creates a grouped conversation @canary', () =>
|
|
134
|
-
.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
it('creates a grouped conversation @canary', () =>
|
|
154
|
+
webex.internal.conversation
|
|
155
|
+
.create({participants: [mccoy]}, {forceGrouped: true})
|
|
156
|
+
.then((conversation) => {
|
|
157
|
+
assert.isConversation(conversation);
|
|
158
|
+
assert.isGroupConversation(conversation);
|
|
159
|
+
assert.isNewEncryptedConversation(conversation);
|
|
160
|
+
|
|
161
|
+
assert.lengthOf(conversation.participants.items, 2);
|
|
162
|
+
assert.lengthOf(conversation.activities.items, 1);
|
|
163
|
+
}));
|
|
142
164
|
});
|
|
143
165
|
});
|
|
144
166
|
|
|
145
167
|
describe('when there is an invalid user in the participants list', () => {
|
|
146
168
|
describe('with allowPartialCreation', () => {
|
|
147
|
-
it('creates a group conversation', () =>
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
it('creates a group conversation', () =>
|
|
170
|
+
webex.internal.conversation
|
|
171
|
+
.create({participants: [mccoy, 'invalidUser']}, {allowPartialCreation: true})
|
|
172
|
+
.then((conversation) => {
|
|
173
|
+
assert.isConversation(conversation);
|
|
174
|
+
assert.isGroupConversation(conversation);
|
|
175
|
+
assert.isNewEncryptedConversation(conversation);
|
|
176
|
+
|
|
177
|
+
assert.lengthOf(conversation.participants.items, 2);
|
|
178
|
+
assert.lengthOf(conversation.activities.items, 1);
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
it('creates a group conversation with invalid uuid', () =>
|
|
182
|
+
testUsers
|
|
183
|
+
.remove([kirk])
|
|
184
|
+
.then(() =>
|
|
185
|
+
webex.internal.conversation.create(
|
|
186
|
+
{participants: [mccoy.id, kirk.id]},
|
|
187
|
+
{allowPartialCreation: true}
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
.then((conversation) => {
|
|
191
|
+
assert.isConversation(conversation);
|
|
192
|
+
assert.isGroupConversation(conversation);
|
|
193
|
+
assert.isNewEncryptedConversation(conversation);
|
|
194
|
+
|
|
195
|
+
assert.lengthOf(conversation.participants.items, 2);
|
|
196
|
+
assert.lengthOf(conversation.activities.items, 1);
|
|
197
|
+
}));
|
|
198
|
+
|
|
199
|
+
it('fails to create a 1:1 conversation', () =>
|
|
200
|
+
assert
|
|
201
|
+
.isRejected(
|
|
202
|
+
webex.internal.conversation.create(
|
|
203
|
+
{participants: ['invalidUser']},
|
|
204
|
+
{allowPartialCreation: true}
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
.then((reason) => assert.instanceOf(reason, InvalidUserCreation)));
|
|
170
208
|
});
|
|
171
209
|
|
|
172
210
|
describe('without allowPartialCreation', () => {
|
|
173
|
-
it('fails to create a group conversation without allowPartialCreation param', () =>
|
|
211
|
+
it('fails to create a group conversation without allowPartialCreation param', () =>
|
|
212
|
+
assert.isRejected(
|
|
213
|
+
webex.internal.conversation.create({participants: [mccoy, 'invalidUser']})
|
|
214
|
+
));
|
|
174
215
|
});
|
|
175
216
|
});
|
|
176
217
|
|
|
177
218
|
describe('when {compact: ?} is not specified', () => {
|
|
178
|
-
it('creates a compact conversation', () =>
|
|
179
|
-
|
|
180
|
-
|
|
219
|
+
it('creates a compact conversation', () =>
|
|
220
|
+
webex.internal.conversation
|
|
221
|
+
.create({participants})
|
|
222
|
+
.then((c) => webex.internal.conversation.get(c, {activitiesLimit: 5}))
|
|
223
|
+
.then((c) => assert.lengthOf(c.activities.items, 1)));
|
|
181
224
|
});
|
|
182
225
|
|
|
183
|
-
it('creates a conversation with a name', () =>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
it('creates a
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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/)));
|
|
226
|
+
it('creates a conversation with a name', () =>
|
|
227
|
+
webex.internal.conversation
|
|
228
|
+
.create({displayName: 'displayName', participants})
|
|
229
|
+
.then((c) => webex.internal.conversation.get(c))
|
|
230
|
+
.then((c) => assert.equal(c.displayName, 'displayName')));
|
|
231
|
+
|
|
232
|
+
it('creates a conversation with a comment', () =>
|
|
233
|
+
webex.internal.conversation
|
|
234
|
+
.create({comment: 'comment', participants})
|
|
235
|
+
.then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
|
|
236
|
+
.then((c) => assert.equal(c.activities.items[1].object.displayName, 'comment')));
|
|
237
|
+
|
|
238
|
+
it('creates a conversation with a tag', () =>
|
|
239
|
+
webex.internal.conversation
|
|
240
|
+
.create({tags: ['WELCOME'], participants})
|
|
241
|
+
.then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
|
|
242
|
+
.then((c) => assert.equal(c.tags[0], 'WELCOME')));
|
|
243
|
+
|
|
244
|
+
it('creates a favorite conversation', () =>
|
|
245
|
+
webex.internal.conversation
|
|
246
|
+
.create({favorite: true, participants})
|
|
247
|
+
.then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
|
|
248
|
+
.then((c) => assert.equal(c.tags[0], 'FAVORITE')));
|
|
249
|
+
|
|
250
|
+
it('creates a conversation with a comment with html', () =>
|
|
251
|
+
webex.internal.conversation
|
|
252
|
+
.create({comment: '**comment**', html: '<strong>comment</strong>', participants})
|
|
253
|
+
.then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
|
|
254
|
+
.then((c) => {
|
|
255
|
+
assert.equal(c.activities.items[1].object.displayName, '**comment**');
|
|
256
|
+
assert.equal(c.activities.items[1].object.content, '<strong>comment</strong>');
|
|
257
|
+
}));
|
|
220
258
|
|
|
221
|
-
it('
|
|
222
|
-
.
|
|
259
|
+
it('creates a conversation with a share', () =>
|
|
260
|
+
webex.internal.conversation
|
|
261
|
+
.create({participants, files: [sampleTextOne]})
|
|
262
|
+
.then((c) => webex.internal.conversation.get(c, {activitiesLimit: 10}))
|
|
263
|
+
.then((c) => {
|
|
264
|
+
assert.equal(last(c.activities.items).verb, 'share');
|
|
265
|
+
|
|
266
|
+
return webex.internal.conversation.download(
|
|
267
|
+
last(c.activities.items).object.files.items[0]
|
|
268
|
+
);
|
|
269
|
+
})
|
|
270
|
+
.then((file) => fh.isMatchingFile(file, sampleTextOne)));
|
|
271
|
+
|
|
272
|
+
it('ensures the current user is in the participants list', () =>
|
|
273
|
+
webex.internal.conversation
|
|
274
|
+
.create({comment: 'comment', participants: [mccoy, checkov]})
|
|
275
|
+
.then((c) => webex.internal.conversation.get(c, {includeParticipants: true}))
|
|
276
|
+
.then((c) => assert.include(map(c.participants.items, 'id'), spock.id)));
|
|
277
|
+
|
|
278
|
+
it('does not allow me to create a conversation with zero participants', () =>
|
|
279
|
+
assert.isRejected(
|
|
280
|
+
webex.internal.conversation.create({participants: []}, /`params.participants` is required/)
|
|
281
|
+
));
|
|
282
|
+
|
|
283
|
+
it('does not allow me to create a classified space when feature toggle is disabled for the org', () =>
|
|
284
|
+
webex.internal.conversation
|
|
285
|
+
.create({participants: [mccoy, checkov], classificationId: 'abcde-12345-Some-UUID'})
|
|
286
|
+
.catch((err) =>
|
|
287
|
+
assert.match(err.toString(), /Org not entitled for space classifications/)
|
|
288
|
+
));
|
|
223
289
|
});
|
|
224
290
|
});
|