@webex/internal-plugin-team 3.0.0-beta.3 → 3.0.0-beta.30

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.
@@ -14,23 +14,24 @@ import uuid from 'uuid';
14
14
  describe('plugin-team', () => {
15
15
  let displayName, kirk, participants, webex, spock, summary, team;
16
16
 
17
- before(() => testUsers.create({count: 3})
18
- .then((users) => {
17
+ before(() =>
18
+ testUsers.create({count: 3}).then((users) => {
19
19
  participants = [kirk, spock] = users;
20
20
 
21
21
  kirk.webex = webex = new WebexCore({
22
22
  credentials: {
23
- authorization: kirk.token
23
+ authorization: kirk.token,
24
24
  },
25
25
  config: {
26
26
  conversation: {
27
- keepEncryptedProperties: true
28
- }
29
- }
27
+ keepEncryptedProperties: true,
28
+ },
29
+ },
30
30
  });
31
31
 
32
32
  return webex.internal.mercury.connect();
33
- }));
33
+ })
34
+ );
34
35
 
35
36
  beforeEach(() => {
36
37
  displayName = `team-conv-name-${uuid.v4()}`;
@@ -40,8 +41,8 @@ describe('plugin-team', () => {
40
41
  after(() => kirk && kirk.webex.internal.mercury.disconnect());
41
42
 
42
43
  describe('#create()', () => {
43
- it('creates a team with a multiple participants', () => webex.internal.team.create({displayName, participants: [kirk, spock]})
44
- .then((team) => {
44
+ it('creates a team with a multiple participants', () =>
45
+ webex.internal.team.create({displayName, participants: [kirk, spock]}).then((team) => {
45
46
  assert.isInternalTeam(team);
46
47
  assert.isNewEncryptedInternalTeam(team);
47
48
  assert.lengthOf(team.teamMembers.items, 2);
@@ -58,8 +59,8 @@ describe('plugin-team', () => {
58
59
  assert.isUndefined(spockEntry.roomProperties);
59
60
  }));
60
61
 
61
- it('creates a team with a name and summary', () => webex.internal.team.create({displayName, summary, participants: [kirk]})
62
- .then((team) => {
62
+ it('creates a team with a name and summary', () =>
63
+ webex.internal.team.create({displayName, summary, participants: [kirk]}).then((team) => {
63
64
  assert.isInternalTeam(team);
64
65
  assert.isNewEncryptedInternalTeam(team);
65
66
  assert.lengthOf(team.teamMembers.items, 1);
@@ -68,8 +69,8 @@ describe('plugin-team', () => {
68
69
  assert.equal(team.summary, summary);
69
70
  }));
70
71
 
71
- it('creates a team with a name but without a summary', () => webex.internal.team.create({displayName, participants: [kirk]})
72
- .then((team) => {
72
+ it('creates a team with a name but without a summary', () =>
73
+ webex.internal.team.create({displayName, participants: [kirk]}).then((team) => {
73
74
  assert.isInternalTeam(team);
74
75
  assert.isNewEncryptedInternalTeam(team);
75
76
  assert.lengthOf(team.teamMembers.items, 1);
@@ -80,49 +81,78 @@ describe('plugin-team', () => {
80
81
  });
81
82
 
82
83
  describe('#createConversation()', () => {
83
- before(() => webex.internal.team.create({displayName, participants})
84
- .then((t) => {
84
+ before(() =>
85
+ webex.internal.team.create({displayName, participants}).then((t) => {
85
86
  team = t;
86
- }));
87
+ })
88
+ );
87
89
 
88
90
  beforeEach(() => {
89
91
  displayName = `team-conv-name-${uuid.v4()}`;
90
92
  });
91
93
 
92
- it('creates a team conversation with a single participant', () => webex.internal.team.createConversation(team, {displayName, participants: [kirk]})
93
- .then((tc) => {
94
- assert.isInternalTeamConversation(tc);
95
- assert.equal(tc.displayName, displayName);
96
-
97
- assert.lengthOf(tc.participants.items, 1);
98
- }));
99
-
100
- it('creates a team conversation with multiple participants', () => webex.internal.team.createConversation(team, {displayName, participants: [kirk, spock]})
101
- .then((tc) => {
102
- assert.isInternalTeamConversation(tc);
103
- assert.lengthOf(tc.participants.items, 2);
104
- }));
105
-
106
- it('creates a team conversation containing all team members via `includeAllTeamMembers` parameter', () => webex.internal.team.createConversation(team, {displayName, participants: [kirk]}, {includeAllTeamMembers: true})
107
- .then((tc) => {
108
- assert.isInternalTeamConversation(tc);
109
- assert.lengthOf(tc.participants.items, 3);
110
- }));
111
-
112
- it('decrypts the \'add\' activity appended to the general conversation after team room is created', () => webex.internal.team.createConversation(team, {displayName, participants: [kirk]}, {includeAllTeamMembers: true})
113
- .then((tc) => webex.internal.conversation.get(find(team.conversations.items, {id: team.generalConversationUuid}), {
114
- activitiesLimit: 10
115
- })
116
- .then((teamGeneral) => {
117
- assert.isConversation(teamGeneral);
118
- const addActivity = findLast(teamGeneral.activities.items, (activity) => activity.verb === 'add' && activity.object.objectType === 'conversation' && activity.object.id === tc.id);
119
-
120
- assert.isDefined(addActivity);
121
- assert.equal(addActivity.object.displayName, tc.displayName);
122
-
123
- assert.isDefined(addActivity.object.encryptedDisplayName);
124
- assert.notEqual(addActivity.object.displayName, addActivity.object.encryptedDisplayName);
125
- assert.equal(addActivity.object.displayName, displayName);
126
- })));
94
+ it('creates a team conversation with a single participant', () =>
95
+ webex.internal.team
96
+ .createConversation(team, {displayName, participants: [kirk]})
97
+ .then((tc) => {
98
+ assert.isInternalTeamConversation(tc);
99
+ assert.equal(tc.displayName, displayName);
100
+
101
+ assert.lengthOf(tc.participants.items, 1);
102
+ }));
103
+
104
+ it('creates a team conversation with multiple participants', () =>
105
+ webex.internal.team
106
+ .createConversation(team, {displayName, participants: [kirk, spock]})
107
+ .then((tc) => {
108
+ assert.isInternalTeamConversation(tc);
109
+ assert.lengthOf(tc.participants.items, 2);
110
+ }));
111
+
112
+ it('creates a team conversation containing all team members via `includeAllTeamMembers` parameter', () =>
113
+ webex.internal.team
114
+ .createConversation(
115
+ team,
116
+ {displayName, participants: [kirk]},
117
+ {includeAllTeamMembers: true}
118
+ )
119
+ .then((tc) => {
120
+ assert.isInternalTeamConversation(tc);
121
+ assert.lengthOf(tc.participants.items, 3);
122
+ }));
123
+
124
+ it("decrypts the 'add' activity appended to the general conversation after team room is created", () =>
125
+ webex.internal.team
126
+ .createConversation(
127
+ team,
128
+ {displayName, participants: [kirk]},
129
+ {includeAllTeamMembers: true}
130
+ )
131
+ .then((tc) =>
132
+ webex.internal.conversation
133
+ .get(find(team.conversations.items, {id: team.generalConversationUuid}), {
134
+ activitiesLimit: 10,
135
+ })
136
+ .then((teamGeneral) => {
137
+ assert.isConversation(teamGeneral);
138
+ const addActivity = findLast(
139
+ teamGeneral.activities.items,
140
+ (activity) =>
141
+ activity.verb === 'add' &&
142
+ activity.object.objectType === 'conversation' &&
143
+ activity.object.id === tc.id
144
+ );
145
+
146
+ assert.isDefined(addActivity);
147
+ assert.equal(addActivity.object.displayName, tc.displayName);
148
+
149
+ assert.isDefined(addActivity.object.encryptedDisplayName);
150
+ assert.notEqual(
151
+ addActivity.object.displayName,
152
+ addActivity.object.encryptedDisplayName
153
+ );
154
+ assert.equal(addActivity.object.displayName, displayName);
155
+ })
156
+ ));
127
157
  });
128
158
  });
@@ -12,64 +12,66 @@ import testUsers from '@webex/test-helper-test-users';
12
12
  import uuid from 'uuid';
13
13
 
14
14
  function ensureGeneral(team, conversations) {
15
- assert.isConversation(find(conversations, (conversation) => team.generalConversationUuid === conversation.id && conversation.tags.includes('TEAM')));
15
+ assert.isConversation(
16
+ find(
17
+ conversations,
18
+ (conversation) =>
19
+ team.generalConversationUuid === conversation.id && conversation.tags.includes('TEAM')
20
+ )
21
+ );
16
22
  }
17
23
 
18
24
  describe('plugin-team', () => {
19
25
  let kirk, spock, team0, team1, teamConvo0, teamConvo1;
20
26
 
21
- before(() => testUsers.create({count: 2})
22
- .then((users) => {
27
+ before(() =>
28
+ testUsers.create({count: 2}).then((users) => {
23
29
  [kirk, spock] = users;
24
30
 
25
31
  kirk.webex = new WebexCore({
26
32
  credentials: {
27
- authorization: kirk.token
33
+ authorization: kirk.token,
28
34
  },
29
35
  config: {
30
36
  conversation: {
31
- keepEncryptedProperties: true
32
- }
33
- }
37
+ keepEncryptedProperties: true,
38
+ },
39
+ },
34
40
  });
35
41
 
36
42
  spock.webex = new WebexCore({
37
43
  credentials: {
38
- authorization: spock.token
44
+ authorization: spock.token,
39
45
  },
40
46
  config: {
41
47
  conversation: {
42
- keepEncryptedProperties: true
43
- }
44
- }
48
+ keepEncryptedProperties: true,
49
+ },
50
+ },
45
51
  });
46
52
 
47
53
  return Promise.all([
48
54
  kirk.webex.internal.mercury.connect(),
49
- spock.webex.internal.mercury.connect()
55
+ spock.webex.internal.mercury.connect(),
50
56
  ]);
51
- }));
57
+ })
58
+ );
52
59
 
53
60
  before(() => {
54
61
  team0 = {
55
62
  displayName: 'test-team-0',
56
63
  summary: 'test-team-0-summary',
57
- participants: [
58
- kirk,
59
- spock
60
- ]
64
+ participants: [kirk, spock],
61
65
  };
62
66
 
63
67
  team1 = {
64
68
  displayName: 'test-team-1',
65
- participants: [
66
- kirk
67
- ]
69
+ participants: [kirk],
68
70
  };
69
71
 
70
72
  return Promise.all([
71
73
  kirk.webex.internal.team.create(team0),
72
- kirk.webex.internal.team.create(team1)
74
+ kirk.webex.internal.team.create(team1),
73
75
  ])
74
76
  .then((teams) => {
75
77
  team0 = teams[0];
@@ -77,15 +79,13 @@ describe('plugin-team', () => {
77
79
 
78
80
  const emptyRoom = {
79
81
  displayName: `team-conversation-${uuid.v4()}`,
80
- participants: [
81
- kirk
82
- ]
82
+ participants: [kirk],
83
83
  };
84
84
 
85
85
  // Create two conversations for team 0
86
86
  return Promise.all([
87
87
  kirk.webex.internal.team.createConversation(team0, emptyRoom),
88
- kirk.webex.internal.team.createConversation(team0, emptyRoom)
88
+ kirk.webex.internal.team.createConversation(team0, emptyRoom),
89
89
  ]);
90
90
  })
91
91
  .then((conversations) => {
@@ -93,14 +93,16 @@ describe('plugin-team', () => {
93
93
  });
94
94
  });
95
95
 
96
- after(() => Promise.all([
97
- kirk && kirk.webex.internal.mercury.disconnect(),
98
- spock && spock.webex.internal.mercury.disconnect()
99
- ]));
96
+ after(() =>
97
+ Promise.all([
98
+ kirk && kirk.webex.internal.mercury.disconnect(),
99
+ spock && spock.webex.internal.mercury.disconnect(),
100
+ ])
101
+ );
100
102
 
101
103
  describe('#get()', () => {
102
- it('retrieves a team', () => kirk.webex.internal.team.get(team0)
103
- .then((t) => {
104
+ it('retrieves a team', () =>
105
+ kirk.webex.internal.team.get(team0).then((t) => {
104
106
  assert.isInternalTeam(t);
105
107
  assert.equal(t.id, team0.id);
106
108
  assert.match(t.teamColor, team0.teamColor);
@@ -112,16 +114,16 @@ describe('plugin-team', () => {
112
114
  assert.lengthOf(t.conversations.items, 0);
113
115
  }));
114
116
 
115
- it('retrieves a team with teamMembers', () => kirk.webex.internal.team.get(team0, {includeTeamMembers: true})
116
- .then((t) => {
117
+ it('retrieves a team with teamMembers', () =>
118
+ kirk.webex.internal.team.get(team0, {includeTeamMembers: true}).then((t) => {
117
119
  assert.isInternalTeam(t);
118
120
  assert.equal(t.id, team0.id);
119
121
  assert.lengthOf(t.teamMembers.items, team0.teamMembers.items.length);
120
122
  assert.lengthOf(t.conversations.items, 0);
121
123
  }));
122
124
 
123
- it('retrieves a team with conversations', () => kirk.webex.internal.team.get(team0, {includeTeamConversations: true})
124
- .then((t) => {
125
+ it('retrieves a team with conversations', () =>
126
+ kirk.webex.internal.team.get(team0, {includeTeamConversations: true}).then((t) => {
125
127
  assert.isInternalTeam(t);
126
128
  assert.equal(t.id, team0.id);
127
129
  assert.lengthOf(t.teamMembers.items, 0);
@@ -134,8 +136,8 @@ describe('plugin-team', () => {
134
136
  });
135
137
 
136
138
  describe('#listConversations()', () => {
137
- it('retrieves and decrypts conversations for a team', () => kirk.webex.internal.team.listConversations(team0)
138
- .then((conversations) => {
139
+ it('retrieves and decrypts conversations for a team', () =>
140
+ kirk.webex.internal.team.listConversations(team0).then((conversations) => {
139
141
  assert.lengthOf(conversations, 3);
140
142
  ensureGeneral(team0, conversations);
141
143
  assert.include(map(conversations, 'url'), teamConvo0.url);
@@ -147,8 +149,8 @@ describe('plugin-team', () => {
147
149
  });
148
150
  }));
149
151
 
150
- it('retrieves and decypts conversations for a team (including unjoined)', () => spock.webex.internal.team.listConversations(team0)
151
- .then((conversations) => {
152
+ it('retrieves and decypts conversations for a team (including unjoined)', () =>
153
+ spock.webex.internal.team.listConversations(team0).then((conversations) => {
152
154
  assert.lengthOf(conversations, 3);
153
155
  ensureGeneral(team0, conversations);
154
156
  assert.include(map(conversations, 'url'), teamConvo0.url);
@@ -162,8 +164,8 @@ describe('plugin-team', () => {
162
164
  });
163
165
 
164
166
  describe('#list()', () => {
165
- it('retrieves a list of teams', () => kirk.webex.internal.team.list()
166
- .then((teams) => {
167
+ it('retrieves a list of teams', () =>
168
+ kirk.webex.internal.team.list().then((teams) => {
167
169
  assert.equal(teams.length, 2);
168
170
 
169
171
  every(teams, (team) => {
@@ -172,8 +174,8 @@ describe('plugin-team', () => {
172
174
  });
173
175
  }));
174
176
 
175
- it('retrieves a list of teams with teamMembers', () => kirk.webex.internal.team.list({includeTeamMembers: true})
176
- .then((teams) => {
177
+ it('retrieves a list of teams with teamMembers', () =>
178
+ kirk.webex.internal.team.list({includeTeamMembers: true}).then((teams) => {
177
179
  assert.equal(teams.length, 2);
178
180
 
179
181
  every(teams, (team) => {
@@ -182,8 +184,8 @@ describe('plugin-team', () => {
182
184
  });
183
185
  }));
184
186
 
185
- it('retrieves a list of teams with conversations', () => kirk.webex.internal.team.list({includeTeamConversations: true})
186
- .then((teams) => {
187
+ it('retrieves a list of teams with conversations', () =>
188
+ kirk.webex.internal.team.list({includeTeamConversations: true}).then((teams) => {
187
189
  assert.equal(teams.length, 2);
188
190
 
189
191
  every(teams, (team) => {
@@ -16,82 +16,92 @@ describe('plugin-team', () => {
16
16
  describe('Team', () => {
17
17
  let kirk, spock;
18
18
 
19
- before('create users', () => testUsers.create({count: 2})
20
- .then((users) => {
19
+ before('create users', () =>
20
+ testUsers.create({count: 2}).then((users) => {
21
21
  [kirk, spock] = users;
22
22
 
23
23
  kirk.webex = new WebexCore({
24
24
  credentials: {
25
- authorization: kirk.token
25
+ authorization: kirk.token,
26
26
  },
27
27
  config: {
28
28
  conversation: {
29
- keepEncryptedProperties: true
30
- }
31
- }
29
+ keepEncryptedProperties: true,
30
+ },
31
+ },
32
32
  });
33
33
 
34
34
  spock.webex = new WebexCore({
35
35
  credentials: {
36
- authorization: spock.token
36
+ authorization: spock.token,
37
37
  },
38
38
  config: {
39
39
  conversation: {
40
- keepEncryptedProperties: true
41
- }
42
- }
40
+ keepEncryptedProperties: true,
41
+ },
42
+ },
43
43
  });
44
44
 
45
45
  return Promise.all([
46
46
  kirk.webex.internal.mercury.connect(),
47
- spock.webex.internal.mercury.connect()
47
+ spock.webex.internal.mercury.connect(),
48
48
  ]);
49
- }));
49
+ })
50
+ );
50
51
 
51
- after(() => Promise.all([
52
- kirk && kirk.webex.internal.mercury.disconnect(),
53
- spock && spock.webex.internal.mercury.disconnect()
54
- ]));
52
+ after(() =>
53
+ Promise.all([
54
+ kirk && kirk.webex.internal.mercury.disconnect(),
55
+ spock && spock.webex.internal.mercury.disconnect(),
56
+ ])
57
+ );
55
58
 
56
59
  describe('when mercury event is received', () => {
57
60
  let teamConvo, team;
58
61
 
59
- before('create team', () => kirk.webex.internal.team.create({
60
- displayName: `team-${uuid.v4()}`,
61
- participants: [
62
- kirk,
63
- spock
64
- ]
65
- })
66
- .then((t) => {
67
- team = t;
68
- }));
62
+ before('create team', () =>
63
+ kirk.webex.internal.team
64
+ .create({
65
+ displayName: `team-${uuid.v4()}`,
66
+ participants: [kirk, spock],
67
+ })
68
+ .then((t) => {
69
+ team = t;
70
+ })
71
+ );
69
72
 
70
- before('create team conversation', () => kirk.webex.internal.team.createConversation(team, {
71
- displayName: `team-conversation-${uuid.v4()}`,
72
- participants: [
73
- kirk
74
- ]
75
- })
76
- .then((c) => {
77
- teamConvo = c;
78
- }));
73
+ before('create team conversation', () =>
74
+ kirk.webex.internal.team
75
+ .createConversation(team, {
76
+ displayName: `team-conversation-${uuid.v4()}`,
77
+ participants: [kirk],
78
+ })
79
+ .then((c) => {
80
+ teamConvo = c;
81
+ })
82
+ );
79
83
 
80
84
  it('updates the displayName of an unjoined team convo', () => {
81
85
  const update = {
82
86
  displayName: `updated-team-convo--${uuid.v4()}`,
83
- objectType: 'conversation'
87
+ objectType: 'conversation',
84
88
  };
85
89
 
86
- const activityChecker = (activity) => activity.verb === 'update' && get(activity, 'object.objectType') === 'teamRoomStatus';
90
+ const activityChecker = (activity) =>
91
+ activity.verb === 'update' && get(activity, 'object.objectType') === 'teamRoomStatus';
87
92
 
88
93
  return Promise.all([
89
- expectActivity(20000, 'event:conversation.activity', spock.webex.internal.mercury, activityChecker, 'teamRoomStatus update expected'),
90
- kirk.webex.internal.team.update(teamConvo, update)
91
- ])
92
- .then(([activity]) => {
93
- assert.equal(activity.object.activityEvent.object.displayName, update.displayName);
94
- });
94
+ expectActivity(
95
+ 20000,
96
+ 'event:conversation.activity',
97
+ spock.webex.internal.mercury,
98
+ activityChecker,
99
+ 'teamRoomStatus update expected'
100
+ ),
101
+ kirk.webex.internal.team.update(teamConvo, update),
102
+ ]).then(([activity]) => {
103
+ assert.equal(activity.object.activityEvent.object.displayName, update.displayName);
104
+ });
95
105
  });
96
106
  });
97
107
  });