@webex/internal-plugin-team 2.59.1 → 2.59.3-next.1

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.
@@ -1,560 +1,560 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import '@webex/internal-plugin-device';
6
- import '@webex/internal-plugin-team';
7
-
8
- import {assert} from '@webex/test-helper-chai';
9
- import WebexCore from '@webex/webex-core';
10
- import {find} from 'lodash';
11
- import testUsers from '@webex/test-helper-test-users';
12
- import uuid from 'uuid';
13
-
14
- describe('plugin-team', () => {
15
- describe('Team', () => {
16
- let kirk, spock;
17
-
18
- before(() =>
19
- testUsers.create({count: 2}).then((users) => {
20
- [kirk, spock] = users;
21
-
22
- kirk.webex = new WebexCore({
23
- credentials: {
24
- authorization: kirk.token,
25
- },
26
- config: {
27
- conversation: {
28
- keepEncryptedProperties: true,
29
- },
30
- },
31
- });
32
-
33
- spock.webex = new WebexCore({
34
- credentials: {
35
- authorization: spock.token,
36
- },
37
- config: {
38
- conversation: {
39
- keepEncryptedProperties: true,
40
- },
41
- },
42
- });
43
-
44
- return Promise.all([
45
- kirk.webex.internal.mercury.connect(),
46
- spock.webex.internal.mercury.connect(),
47
- ]);
48
- })
49
- );
50
-
51
- after(() =>
52
- Promise.all([
53
- kirk && kirk.webex.internal.mercury.disconnect(),
54
- spock && spock.webex.internal.mercury.disconnect(),
55
- ])
56
- );
57
-
58
- describe('#addConversation()', () => {
59
- let groupConversation, team;
60
-
61
- before(() => {
62
- const teamPromise = kirk.webex.internal.team.create({
63
- displayName: `team-${uuid.v4()}`,
64
- participants: [kirk, spock],
65
- });
66
-
67
- const conversation = {
68
- displayName: `group-conversation-${uuid.v4()}`,
69
- participants: [kirk],
70
- };
71
-
72
- return Promise.all([
73
- teamPromise,
74
- kirk.webex.internal.conversation.create(conversation, {forceGrouped: true}),
75
- ]).then(([t, c]) => {
76
- team = t;
77
- groupConversation = c;
78
- });
79
- });
80
-
81
- it('adds an existing group conversation to a team', () =>
82
- kirk.webex.internal.team
83
- .addConversation(team, groupConversation)
84
- .then((activity) => {
85
- assert.isActivity(activity);
86
- assert.equal(activity.verb, 'add');
87
- assert.equal(activity.target.id, team.id);
88
- assert.equal(activity.object.id, groupConversation.id);
89
-
90
- return spock.webex.internal.team.get(team, {includeTeamConversations: true});
91
- })
92
- .then((t) => {
93
- assert.equal(t.conversations.items.length, 2);
94
- const teamConversation = find(t.conversations.items, {id: groupConversation.id});
95
- const generalConversation = find(t.conversations.items, {
96
- id: t.generalConversationUuid,
97
- });
98
-
99
- assert.include(teamConversation.tags, 'OPEN');
100
-
101
- // Ensure that spock can decrypt the title of the room now that
102
- // it's been added to a team he's a member of.
103
- assert.equal(generalConversation.displayName, team.displayName);
104
- assert.equal(teamConversation.displayName, groupConversation.displayName);
105
-
106
- return kirk.webex.internal.conversation.get(groupConversation);
107
- })
108
- .then((conversation) => {
109
- assert.isDefined(conversation.team);
110
- assert.equal(conversation.team.id, team.id);
111
- }));
112
- });
113
-
114
- describe('#addMember()', () => {
115
- let additionalConversation, team;
116
-
117
- before(() =>
118
- kirk.webex.internal.team
119
- .create({
120
- displayName: `team-${uuid.v4()}`,
121
- participants: [kirk],
122
- })
123
- .then((res) => {
124
- team = res;
125
-
126
- return kirk.webex.internal.team
127
- .createConversation(team, {
128
- displayName: `team-conversation-${uuid.v4()}`,
129
- participants: [kirk],
130
- })
131
- .then((conversation) => {
132
- additionalConversation = conversation;
133
- });
134
- })
135
- );
136
-
137
- it('adds a team member to a team', () =>
138
- kirk.webex.internal.team
139
- .addMember(team, spock)
140
- .then((activity) => {
141
- assert.isActivity(activity);
142
- assert.equal(activity.verb, 'add');
143
- assert.equal(activity.target.id, team.id);
144
- assert.equal(activity.object.id, spock.id);
145
-
146
- return kirk.webex.internal.team.get(team, {
147
- includeTeamMembers: true,
148
- });
149
- })
150
- .then((team) => {
151
- const spockEntry = find(team.teamMembers.items, {id: spock.id});
152
-
153
- assert.isDefined(spockEntry);
154
- assert.isUndefined(spockEntry.roomProperties);
155
-
156
- // Assert spock can decrypt team and its rooms
157
- return spock.webex.internal.team
158
- .get(team, {
159
- includeTeamConversations: true,
160
- })
161
- .then((spockTeam) => {
162
- assert.isDefined(spockTeam);
163
- assert.notEqual(spockTeam.displayName, spockTeam.encryptedDisplayName);
164
- assert.equal(spockTeam.displayName, team.displayName);
165
- assert.equal(spockTeam.conversations.items.length, 2);
166
-
167
- const spockAddtlConversation = find(spockTeam.conversations.items, {
168
- id: additionalConversation.id,
169
- });
170
-
171
- assert.isDefined(spockAddtlConversation);
172
- assert.notEqual(
173
- spockAddtlConversation.displayName,
174
- spockAddtlConversation.encryptedDisplayName
175
- );
176
- assert.equal(
177
- spockAddtlConversation.displayName,
178
- additionalConversation.displayName
179
- );
180
- assert.include(spockAddtlConversation.tags, 'NOT_JOINED');
181
- });
182
- }));
183
- });
184
-
185
- describe('#assignModerator()', () => {
186
- let team;
187
-
188
- before(() =>
189
- kirk.webex.internal.team
190
- .create({
191
- displayName: `team-${uuid.v4()}`,
192
- participants: [kirk, spock],
193
- })
194
- .then((t) => {
195
- team = t;
196
- })
197
- );
198
-
199
- it('assigns a team moderator', () =>
200
- kirk.webex.internal.team
201
- .assignModerator(team, spock)
202
- .then((activity) => {
203
- assert.isActivity(activity);
204
- assert.equal(activity.verb, 'assignModerator');
205
- assert.equal(activity.target.id, team.id);
206
- assert.equal(activity.object.id, spock.id);
207
-
208
- return kirk.webex.internal.team.get(team, {
209
- includeTeamMembers: true,
210
- });
211
- })
212
- .then((team) => {
213
- const spockEntry = find(team.teamMembers.items, {id: spock.id});
214
-
215
- assert.isDefined(spockEntry);
216
- assert.isTrue(spockEntry.roomProperties.isModerator);
217
- }));
218
- });
219
-
220
- describe('#archive()', () => {
221
- let conversation, team;
222
-
223
- before(() =>
224
- kirk.webex.internal.team
225
- .create({
226
- displayName: `team-${uuid.v4()}`,
227
- participants: [kirk],
228
- })
229
- .then((t) => {
230
- team = t;
231
-
232
- return kirk.webex.internal.team.createConversation(team, {
233
- displayName: `team-conversation-${uuid.v4()}`,
234
- participants: [kirk],
235
- });
236
- })
237
- .then((c) => {
238
- conversation = c;
239
- })
240
- );
241
-
242
- it('archives a team conversation', () => {
243
- assert.notInclude(conversation.tags, 'ARCHIVED');
244
- assert.notInclude(conversation.tags, 'HIDDEN');
245
-
246
- return kirk.webex.internal.team
247
- .archive(conversation)
248
- .then((activity) => {
249
- assert.isActivity(activity);
250
- assert.equal(activity.verb, 'archive');
251
- assert.equal(activity.target.id, conversation.id);
252
- assert.equal(activity.object.id, conversation.id);
253
-
254
- return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
255
- })
256
- .then((t) => {
257
- assert.isFalse(t.archived);
258
-
259
- conversation = find(t.conversations.items, {id: conversation.id});
260
- assert.isDefined(conversation);
261
- assert.include(conversation.tags, 'ARCHIVED');
262
- assert.include(conversation.tags, 'HIDDEN');
263
- });
264
- });
265
-
266
- it('archives a team', () => {
267
- assert.isFalse(team.archived);
268
-
269
- return kirk.webex.internal.team
270
- .archive(team)
271
- .then((activity) => {
272
- assert.isActivity(activity);
273
- assert.equal(activity.verb, 'archive');
274
- assert.equal(activity.target.id, team.id);
275
- assert.equal(activity.object.id, team.id);
276
-
277
- return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
278
- })
279
- .then((t) => {
280
- assert.isTrue(t.archived);
281
-
282
- const generalConversation = find(t.conversations.items, {
283
- id: team.generalConversationUuid,
284
- });
285
-
286
- assert.isDefined(generalConversation);
287
- assert.include(generalConversation.tags, 'ARCHIVED');
288
- assert.include(generalConversation.tags, 'HIDDEN');
289
- });
290
- });
291
- });
292
-
293
- describe('#joinConversation()', () => {
294
- let conversation, team;
295
-
296
- before(() =>
297
- kirk.webex.internal.team
298
- .create({
299
- displayName: `team-${uuid.v4()}`,
300
- participants: [kirk, spock],
301
- })
302
- .then((t) => {
303
- team = t;
304
-
305
- return kirk.webex.internal.team.createConversation(t, {
306
- displayName: `team-room-${uuid.v4()}`,
307
- participants: [kirk],
308
- });
309
- })
310
- .then((c) => {
311
- conversation = c;
312
- })
313
- );
314
-
315
- it('adds the user to an open team conversation', () =>
316
- spock.webex.internal.team
317
- .joinConversation(team, conversation, spock.id)
318
- .then((c) => assert.notInclude(c.tags, 'NOT_JOINED')));
319
- });
320
-
321
- describe('#removeConversation()', () => {
322
- let conversation, team;
323
-
324
- before(() =>
325
- kirk.webex.internal.team
326
- .create({
327
- displayName: `team-${uuid.v4()}`,
328
- participants: [kirk, spock],
329
- })
330
- .then((t) => {
331
- team = t;
332
-
333
- return kirk.webex.internal.team.createConversation(t, {
334
- displayName: `team-room-${uuid.v4()}`,
335
- participants: [kirk],
336
- });
337
- })
338
- .then((c) => {
339
- conversation = c;
340
- })
341
- );
342
-
343
- it('removes a team conversation from a team', () =>
344
- kirk.webex.internal.team
345
- .removeConversation(team, conversation)
346
- .then((activity) => {
347
- assert.isActivity(activity);
348
- assert.equal(activity.verb, 'remove');
349
- assert.equal(activity.target.id, team.id);
350
- assert.equal(activity.object.id, conversation.id);
351
-
352
- return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
353
- })
354
- .then((t) => {
355
- assert.lengthOf(t.conversations.items, 1);
356
- assert.isUndefined(find(t.conversations.items, {id: conversation.id}));
357
- }));
358
- });
359
-
360
- describe('#removeMember()', () => {
361
- let team;
362
-
363
- before(() =>
364
- kirk.webex.internal.team
365
- .create({
366
- displayName: `team-${uuid.v4()}`,
367
- participants: [kirk, spock],
368
- })
369
- .then((t) => {
370
- team = t;
371
- })
372
- );
373
-
374
- it('removes a team member from a team', () =>
375
- kirk.webex.internal.team
376
- .removeMember(team, spock)
377
- .then((activity) => {
378
- assert.isActivity(activity);
379
- assert.equal(activity.verb, 'leave');
380
- assert.equal(activity.target.id, team.id);
381
- assert.equal(activity.object.id, spock.id);
382
-
383
- return kirk.webex.internal.team.get(team, {
384
- includeTeamMembers: true,
385
- });
386
- })
387
- .then((team) => {
388
- assert.equal(team.teamMembers.items.length, 1);
389
- assert.equal(team.teamMembers.items[0].id, kirk.id);
390
- }));
391
- });
392
-
393
- describe('#unassignModerator()', () => {
394
- let team;
395
-
396
- before(() =>
397
- kirk.webex.internal.team
398
- .create({
399
- displayName: `team-${uuid.v4()}`,
400
- participants: [kirk, spock],
401
- })
402
- .then((t) => {
403
- team = t;
404
-
405
- return kirk.webex.internal.team.assignModerator(team, spock);
406
- })
407
- );
408
-
409
- it('unassigns a team moderator', () =>
410
- kirk.webex.internal.team
411
- .unassignModerator(team, spock)
412
- .then((activity) => {
413
- assert.isActivity(activity);
414
- assert.equal(activity.verb, 'unassignModerator');
415
- assert.equal(activity.target.id, team.id);
416
- assert.equal(activity.object.id, spock.id);
417
-
418
- return kirk.webex.internal.team.get(team, {
419
- includeTeamMembers: true,
420
- });
421
- })
422
- .then((team) => {
423
- const spockEntry = find(team.teamMembers.items, {id: spock.id});
424
-
425
- assert.isDefined(spockEntry);
426
- assert.isUndefined(spockEntry.roomProperties);
427
- }));
428
- });
429
-
430
- describe('#unarchive()', () => {
431
- let conversation, team;
432
-
433
- before(() =>
434
- kirk.webex.internal.team
435
- .create({
436
- displayName: `team-${uuid.v4()}`,
437
- participants: [kirk],
438
- })
439
- .then((t) => {
440
- team = t;
441
-
442
- return kirk.webex.internal.team.createConversation(team, {
443
- displayName: `team-conversation-${uuid.v4()}`,
444
- participants: [kirk],
445
- });
446
- })
447
- .then((c) => {
448
- conversation = c;
449
-
450
- return Promise.all([
451
- kirk.webex.internal.team.archive(conversation),
452
- kirk.webex.internal.team.archive(team),
453
- ]);
454
- })
455
- .then(() => kirk.webex.internal.team.get(team, {includeTeamConversations: true}))
456
- .then((t) => {
457
- team = t;
458
- conversation = find(team.conversations.items, {id: conversation.id});
459
- })
460
- );
461
-
462
- it('unarchives a team conversation', () => {
463
- assert.include(conversation.tags, 'ARCHIVED');
464
- assert.include(conversation.tags, 'HIDDEN');
465
-
466
- return kirk.webex.internal.team
467
- .unarchive(conversation)
468
- .then((activity) => {
469
- assert.isActivity(activity);
470
- assert.equal(activity.verb, 'unarchive');
471
- assert.equal(activity.target.id, conversation.id);
472
- assert.equal(activity.object.id, conversation.id);
473
-
474
- return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
475
- })
476
- .then((t) => {
477
- conversation = find(t.conversations.items, {id: conversation.id});
478
- assert.isDefined(conversation);
479
- assert.notInclude(conversation.tags, 'ARCHIVED');
480
- assert.notInclude(conversation.tags, 'HIDDEN');
481
- });
482
- });
483
-
484
- it('unarchives a team', () => {
485
- assert.isTrue(team.archived);
486
-
487
- return kirk.webex.internal.team
488
- .unarchive(team)
489
- .then((activity) => {
490
- assert.isActivity(activity);
491
- assert.equal(activity.verb, 'unarchive');
492
- assert.equal(activity.target.id, team.id);
493
- assert.equal(activity.object.id, team.id);
494
-
495
- return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
496
- })
497
- .then((t) => {
498
- assert.isFalse(t.archived);
499
-
500
- const generalConversation = find(t.conversations.items, {
501
- id: team.generalConversationUuid,
502
- });
503
-
504
- assert.isDefined(generalConversation);
505
- assert.notInclude(generalConversation.tags, 'ARCHIVED');
506
- assert.notInclude(generalConversation.tags, 'HIDDEN');
507
- });
508
- });
509
- });
510
-
511
- describe('#update()', () => {
512
- let team;
513
-
514
- before(() =>
515
- kirk.webex.internal.team
516
- .create({
517
- displayName: `team-${uuid.v4()}`,
518
- participants: [kirk],
519
- })
520
- .then((t) => {
521
- team = t;
522
- })
523
- );
524
-
525
- it('updates a team displayName', () => {
526
- const obj = {
527
- displayName: `updated-team-title-${uuid.v4()}`,
528
- objectType: 'team',
529
- };
530
-
531
- return kirk.webex.internal.team
532
- .update(team, obj)
533
- .then((activity) => {
534
- assert.isActivity(activity);
535
- assert.equal(activity.verb, 'update');
536
- assert.equal(activity.target.id, team.id);
537
- })
538
- .then(() => kirk.webex.internal.team.get(team))
539
- .then((t) => assert.equal(t.displayName, obj.displayName));
540
- });
541
-
542
- it('updates a team summary', () => {
543
- const obj = {
544
- summary: `updated-team-summary-${uuid.v4()}`,
545
- objectType: 'team',
546
- };
547
-
548
- return kirk.webex.internal.team
549
- .update(team, obj)
550
- .then((activity) => {
551
- assert.isActivity(activity);
552
- assert.equal(activity.verb, 'update');
553
- assert.equal(activity.target.id, team.id);
554
- })
555
- .then(() => kirk.webex.internal.team.get(team))
556
- .then((t) => assert.equal(t.summary, obj.summary));
557
- });
558
- });
559
- });
560
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import '@webex/internal-plugin-device';
6
+ import '@webex/internal-plugin-team';
7
+
8
+ import {assert} from '@webex/test-helper-chai';
9
+ import WebexCore from '@webex/webex-core';
10
+ import {find} from 'lodash';
11
+ import testUsers from '@webex/test-helper-test-users';
12
+ import uuid from 'uuid';
13
+
14
+ describe('plugin-team', () => {
15
+ describe('Team', () => {
16
+ let kirk, spock;
17
+
18
+ before(() =>
19
+ testUsers.create({count: 2}).then((users) => {
20
+ [kirk, spock] = users;
21
+
22
+ kirk.webex = new WebexCore({
23
+ credentials: {
24
+ authorization: kirk.token,
25
+ },
26
+ config: {
27
+ conversation: {
28
+ keepEncryptedProperties: true,
29
+ },
30
+ },
31
+ });
32
+
33
+ spock.webex = new WebexCore({
34
+ credentials: {
35
+ authorization: spock.token,
36
+ },
37
+ config: {
38
+ conversation: {
39
+ keepEncryptedProperties: true,
40
+ },
41
+ },
42
+ });
43
+
44
+ return Promise.all([
45
+ kirk.webex.internal.mercury.connect(),
46
+ spock.webex.internal.mercury.connect(),
47
+ ]);
48
+ })
49
+ );
50
+
51
+ after(() =>
52
+ Promise.all([
53
+ kirk && kirk.webex.internal.mercury.disconnect(),
54
+ spock && spock.webex.internal.mercury.disconnect(),
55
+ ])
56
+ );
57
+
58
+ describe('#addConversation()', () => {
59
+ let groupConversation, team;
60
+
61
+ before(() => {
62
+ const teamPromise = kirk.webex.internal.team.create({
63
+ displayName: `team-${uuid.v4()}`,
64
+ participants: [kirk, spock],
65
+ });
66
+
67
+ const conversation = {
68
+ displayName: `group-conversation-${uuid.v4()}`,
69
+ participants: [kirk],
70
+ };
71
+
72
+ return Promise.all([
73
+ teamPromise,
74
+ kirk.webex.internal.conversation.create(conversation, {forceGrouped: true}),
75
+ ]).then(([t, c]) => {
76
+ team = t;
77
+ groupConversation = c;
78
+ });
79
+ });
80
+
81
+ it('adds an existing group conversation to a team', () =>
82
+ kirk.webex.internal.team
83
+ .addConversation(team, groupConversation)
84
+ .then((activity) => {
85
+ assert.isActivity(activity);
86
+ assert.equal(activity.verb, 'add');
87
+ assert.equal(activity.target.id, team.id);
88
+ assert.equal(activity.object.id, groupConversation.id);
89
+
90
+ return spock.webex.internal.team.get(team, {includeTeamConversations: true});
91
+ })
92
+ .then((t) => {
93
+ assert.equal(t.conversations.items.length, 2);
94
+ const teamConversation = find(t.conversations.items, {id: groupConversation.id});
95
+ const generalConversation = find(t.conversations.items, {
96
+ id: t.generalConversationUuid,
97
+ });
98
+
99
+ assert.include(teamConversation.tags, 'OPEN');
100
+
101
+ // Ensure that spock can decrypt the title of the room now that
102
+ // it's been added to a team he's a member of.
103
+ assert.equal(generalConversation.displayName, team.displayName);
104
+ assert.equal(teamConversation.displayName, groupConversation.displayName);
105
+
106
+ return kirk.webex.internal.conversation.get(groupConversation);
107
+ })
108
+ .then((conversation) => {
109
+ assert.isDefined(conversation.team);
110
+ assert.equal(conversation.team.id, team.id);
111
+ }));
112
+ });
113
+
114
+ describe('#addMember()', () => {
115
+ let additionalConversation, team;
116
+
117
+ before(() =>
118
+ kirk.webex.internal.team
119
+ .create({
120
+ displayName: `team-${uuid.v4()}`,
121
+ participants: [kirk],
122
+ })
123
+ .then((res) => {
124
+ team = res;
125
+
126
+ return kirk.webex.internal.team
127
+ .createConversation(team, {
128
+ displayName: `team-conversation-${uuid.v4()}`,
129
+ participants: [kirk],
130
+ })
131
+ .then((conversation) => {
132
+ additionalConversation = conversation;
133
+ });
134
+ })
135
+ );
136
+
137
+ it('adds a team member to a team', () =>
138
+ kirk.webex.internal.team
139
+ .addMember(team, spock)
140
+ .then((activity) => {
141
+ assert.isActivity(activity);
142
+ assert.equal(activity.verb, 'add');
143
+ assert.equal(activity.target.id, team.id);
144
+ assert.equal(activity.object.id, spock.id);
145
+
146
+ return kirk.webex.internal.team.get(team, {
147
+ includeTeamMembers: true,
148
+ });
149
+ })
150
+ .then((team) => {
151
+ const spockEntry = find(team.teamMembers.items, {id: spock.id});
152
+
153
+ assert.isDefined(spockEntry);
154
+ assert.isUndefined(spockEntry.roomProperties);
155
+
156
+ // Assert spock can decrypt team and its rooms
157
+ return spock.webex.internal.team
158
+ .get(team, {
159
+ includeTeamConversations: true,
160
+ })
161
+ .then((spockTeam) => {
162
+ assert.isDefined(spockTeam);
163
+ assert.notEqual(spockTeam.displayName, spockTeam.encryptedDisplayName);
164
+ assert.equal(spockTeam.displayName, team.displayName);
165
+ assert.equal(spockTeam.conversations.items.length, 2);
166
+
167
+ const spockAddtlConversation = find(spockTeam.conversations.items, {
168
+ id: additionalConversation.id,
169
+ });
170
+
171
+ assert.isDefined(spockAddtlConversation);
172
+ assert.notEqual(
173
+ spockAddtlConversation.displayName,
174
+ spockAddtlConversation.encryptedDisplayName
175
+ );
176
+ assert.equal(
177
+ spockAddtlConversation.displayName,
178
+ additionalConversation.displayName
179
+ );
180
+ assert.include(spockAddtlConversation.tags, 'NOT_JOINED');
181
+ });
182
+ }));
183
+ });
184
+
185
+ describe('#assignModerator()', () => {
186
+ let team;
187
+
188
+ before(() =>
189
+ kirk.webex.internal.team
190
+ .create({
191
+ displayName: `team-${uuid.v4()}`,
192
+ participants: [kirk, spock],
193
+ })
194
+ .then((t) => {
195
+ team = t;
196
+ })
197
+ );
198
+
199
+ it('assigns a team moderator', () =>
200
+ kirk.webex.internal.team
201
+ .assignModerator(team, spock)
202
+ .then((activity) => {
203
+ assert.isActivity(activity);
204
+ assert.equal(activity.verb, 'assignModerator');
205
+ assert.equal(activity.target.id, team.id);
206
+ assert.equal(activity.object.id, spock.id);
207
+
208
+ return kirk.webex.internal.team.get(team, {
209
+ includeTeamMembers: true,
210
+ });
211
+ })
212
+ .then((team) => {
213
+ const spockEntry = find(team.teamMembers.items, {id: spock.id});
214
+
215
+ assert.isDefined(spockEntry);
216
+ assert.isTrue(spockEntry.roomProperties.isModerator);
217
+ }));
218
+ });
219
+
220
+ describe('#archive()', () => {
221
+ let conversation, team;
222
+
223
+ before(() =>
224
+ kirk.webex.internal.team
225
+ .create({
226
+ displayName: `team-${uuid.v4()}`,
227
+ participants: [kirk],
228
+ })
229
+ .then((t) => {
230
+ team = t;
231
+
232
+ return kirk.webex.internal.team.createConversation(team, {
233
+ displayName: `team-conversation-${uuid.v4()}`,
234
+ participants: [kirk],
235
+ });
236
+ })
237
+ .then((c) => {
238
+ conversation = c;
239
+ })
240
+ );
241
+
242
+ it('archives a team conversation', () => {
243
+ assert.notInclude(conversation.tags, 'ARCHIVED');
244
+ assert.notInclude(conversation.tags, 'HIDDEN');
245
+
246
+ return kirk.webex.internal.team
247
+ .archive(conversation)
248
+ .then((activity) => {
249
+ assert.isActivity(activity);
250
+ assert.equal(activity.verb, 'archive');
251
+ assert.equal(activity.target.id, conversation.id);
252
+ assert.equal(activity.object.id, conversation.id);
253
+
254
+ return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
255
+ })
256
+ .then((t) => {
257
+ assert.isFalse(t.archived);
258
+
259
+ conversation = find(t.conversations.items, {id: conversation.id});
260
+ assert.isDefined(conversation);
261
+ assert.include(conversation.tags, 'ARCHIVED');
262
+ assert.include(conversation.tags, 'HIDDEN');
263
+ });
264
+ });
265
+
266
+ it('archives a team', () => {
267
+ assert.isFalse(team.archived);
268
+
269
+ return kirk.webex.internal.team
270
+ .archive(team)
271
+ .then((activity) => {
272
+ assert.isActivity(activity);
273
+ assert.equal(activity.verb, 'archive');
274
+ assert.equal(activity.target.id, team.id);
275
+ assert.equal(activity.object.id, team.id);
276
+
277
+ return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
278
+ })
279
+ .then((t) => {
280
+ assert.isTrue(t.archived);
281
+
282
+ const generalConversation = find(t.conversations.items, {
283
+ id: team.generalConversationUuid,
284
+ });
285
+
286
+ assert.isDefined(generalConversation);
287
+ assert.include(generalConversation.tags, 'ARCHIVED');
288
+ assert.include(generalConversation.tags, 'HIDDEN');
289
+ });
290
+ });
291
+ });
292
+
293
+ describe('#joinConversation()', () => {
294
+ let conversation, team;
295
+
296
+ before(() =>
297
+ kirk.webex.internal.team
298
+ .create({
299
+ displayName: `team-${uuid.v4()}`,
300
+ participants: [kirk, spock],
301
+ })
302
+ .then((t) => {
303
+ team = t;
304
+
305
+ return kirk.webex.internal.team.createConversation(t, {
306
+ displayName: `team-room-${uuid.v4()}`,
307
+ participants: [kirk],
308
+ });
309
+ })
310
+ .then((c) => {
311
+ conversation = c;
312
+ })
313
+ );
314
+
315
+ it('adds the user to an open team conversation', () =>
316
+ spock.webex.internal.team
317
+ .joinConversation(team, conversation, spock.id)
318
+ .then((c) => assert.notInclude(c.tags, 'NOT_JOINED')));
319
+ });
320
+
321
+ describe('#removeConversation()', () => {
322
+ let conversation, team;
323
+
324
+ before(() =>
325
+ kirk.webex.internal.team
326
+ .create({
327
+ displayName: `team-${uuid.v4()}`,
328
+ participants: [kirk, spock],
329
+ })
330
+ .then((t) => {
331
+ team = t;
332
+
333
+ return kirk.webex.internal.team.createConversation(t, {
334
+ displayName: `team-room-${uuid.v4()}`,
335
+ participants: [kirk],
336
+ });
337
+ })
338
+ .then((c) => {
339
+ conversation = c;
340
+ })
341
+ );
342
+
343
+ it('removes a team conversation from a team', () =>
344
+ kirk.webex.internal.team
345
+ .removeConversation(team, conversation)
346
+ .then((activity) => {
347
+ assert.isActivity(activity);
348
+ assert.equal(activity.verb, 'remove');
349
+ assert.equal(activity.target.id, team.id);
350
+ assert.equal(activity.object.id, conversation.id);
351
+
352
+ return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
353
+ })
354
+ .then((t) => {
355
+ assert.lengthOf(t.conversations.items, 1);
356
+ assert.isUndefined(find(t.conversations.items, {id: conversation.id}));
357
+ }));
358
+ });
359
+
360
+ describe('#removeMember()', () => {
361
+ let team;
362
+
363
+ before(() =>
364
+ kirk.webex.internal.team
365
+ .create({
366
+ displayName: `team-${uuid.v4()}`,
367
+ participants: [kirk, spock],
368
+ })
369
+ .then((t) => {
370
+ team = t;
371
+ })
372
+ );
373
+
374
+ it('removes a team member from a team', () =>
375
+ kirk.webex.internal.team
376
+ .removeMember(team, spock)
377
+ .then((activity) => {
378
+ assert.isActivity(activity);
379
+ assert.equal(activity.verb, 'leave');
380
+ assert.equal(activity.target.id, team.id);
381
+ assert.equal(activity.object.id, spock.id);
382
+
383
+ return kirk.webex.internal.team.get(team, {
384
+ includeTeamMembers: true,
385
+ });
386
+ })
387
+ .then((team) => {
388
+ assert.equal(team.teamMembers.items.length, 1);
389
+ assert.equal(team.teamMembers.items[0].id, kirk.id);
390
+ }));
391
+ });
392
+
393
+ describe('#unassignModerator()', () => {
394
+ let team;
395
+
396
+ before(() =>
397
+ kirk.webex.internal.team
398
+ .create({
399
+ displayName: `team-${uuid.v4()}`,
400
+ participants: [kirk, spock],
401
+ })
402
+ .then((t) => {
403
+ team = t;
404
+
405
+ return kirk.webex.internal.team.assignModerator(team, spock);
406
+ })
407
+ );
408
+
409
+ it('unassigns a team moderator', () =>
410
+ kirk.webex.internal.team
411
+ .unassignModerator(team, spock)
412
+ .then((activity) => {
413
+ assert.isActivity(activity);
414
+ assert.equal(activity.verb, 'unassignModerator');
415
+ assert.equal(activity.target.id, team.id);
416
+ assert.equal(activity.object.id, spock.id);
417
+
418
+ return kirk.webex.internal.team.get(team, {
419
+ includeTeamMembers: true,
420
+ });
421
+ })
422
+ .then((team) => {
423
+ const spockEntry = find(team.teamMembers.items, {id: spock.id});
424
+
425
+ assert.isDefined(spockEntry);
426
+ assert.isUndefined(spockEntry.roomProperties);
427
+ }));
428
+ });
429
+
430
+ describe('#unarchive()', () => {
431
+ let conversation, team;
432
+
433
+ before(() =>
434
+ kirk.webex.internal.team
435
+ .create({
436
+ displayName: `team-${uuid.v4()}`,
437
+ participants: [kirk],
438
+ })
439
+ .then((t) => {
440
+ team = t;
441
+
442
+ return kirk.webex.internal.team.createConversation(team, {
443
+ displayName: `team-conversation-${uuid.v4()}`,
444
+ participants: [kirk],
445
+ });
446
+ })
447
+ .then((c) => {
448
+ conversation = c;
449
+
450
+ return Promise.all([
451
+ kirk.webex.internal.team.archive(conversation),
452
+ kirk.webex.internal.team.archive(team),
453
+ ]);
454
+ })
455
+ .then(() => kirk.webex.internal.team.get(team, {includeTeamConversations: true}))
456
+ .then((t) => {
457
+ team = t;
458
+ conversation = find(team.conversations.items, {id: conversation.id});
459
+ })
460
+ );
461
+
462
+ it('unarchives a team conversation', () => {
463
+ assert.include(conversation.tags, 'ARCHIVED');
464
+ assert.include(conversation.tags, 'HIDDEN');
465
+
466
+ return kirk.webex.internal.team
467
+ .unarchive(conversation)
468
+ .then((activity) => {
469
+ assert.isActivity(activity);
470
+ assert.equal(activity.verb, 'unarchive');
471
+ assert.equal(activity.target.id, conversation.id);
472
+ assert.equal(activity.object.id, conversation.id);
473
+
474
+ return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
475
+ })
476
+ .then((t) => {
477
+ conversation = find(t.conversations.items, {id: conversation.id});
478
+ assert.isDefined(conversation);
479
+ assert.notInclude(conversation.tags, 'ARCHIVED');
480
+ assert.notInclude(conversation.tags, 'HIDDEN');
481
+ });
482
+ });
483
+
484
+ it('unarchives a team', () => {
485
+ assert.isTrue(team.archived);
486
+
487
+ return kirk.webex.internal.team
488
+ .unarchive(team)
489
+ .then((activity) => {
490
+ assert.isActivity(activity);
491
+ assert.equal(activity.verb, 'unarchive');
492
+ assert.equal(activity.target.id, team.id);
493
+ assert.equal(activity.object.id, team.id);
494
+
495
+ return kirk.webex.internal.team.get(team, {includeTeamConversations: true});
496
+ })
497
+ .then((t) => {
498
+ assert.isFalse(t.archived);
499
+
500
+ const generalConversation = find(t.conversations.items, {
501
+ id: team.generalConversationUuid,
502
+ });
503
+
504
+ assert.isDefined(generalConversation);
505
+ assert.notInclude(generalConversation.tags, 'ARCHIVED');
506
+ assert.notInclude(generalConversation.tags, 'HIDDEN');
507
+ });
508
+ });
509
+ });
510
+
511
+ describe('#update()', () => {
512
+ let team;
513
+
514
+ before(() =>
515
+ kirk.webex.internal.team
516
+ .create({
517
+ displayName: `team-${uuid.v4()}`,
518
+ participants: [kirk],
519
+ })
520
+ .then((t) => {
521
+ team = t;
522
+ })
523
+ );
524
+
525
+ it('updates a team displayName', () => {
526
+ const obj = {
527
+ displayName: `updated-team-title-${uuid.v4()}`,
528
+ objectType: 'team',
529
+ };
530
+
531
+ return kirk.webex.internal.team
532
+ .update(team, obj)
533
+ .then((activity) => {
534
+ assert.isActivity(activity);
535
+ assert.equal(activity.verb, 'update');
536
+ assert.equal(activity.target.id, team.id);
537
+ })
538
+ .then(() => kirk.webex.internal.team.get(team))
539
+ .then((t) => assert.equal(t.displayName, obj.displayName));
540
+ });
541
+
542
+ it('updates a team summary', () => {
543
+ const obj = {
544
+ summary: `updated-team-summary-${uuid.v4()}`,
545
+ objectType: 'team',
546
+ };
547
+
548
+ return kirk.webex.internal.team
549
+ .update(team, obj)
550
+ .then((activity) => {
551
+ assert.isActivity(activity);
552
+ assert.equal(activity.verb, 'update');
553
+ assert.equal(activity.target.id, team.id);
554
+ })
555
+ .then(() => kirk.webex.internal.team.get(team))
556
+ .then((t) => assert.equal(t.summary, obj.summary));
557
+ });
558
+ });
559
+ });
560
+ });