@webex/internal-plugin-team 3.0.0-beta.5 → 3.0.0-beta.50
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/config.js +0 -3
- package/dist/config.js.map +1 -1
- package/dist/index.js +4 -23
- package/dist/index.js.map +1 -1
- package/dist/team.js +92 -141
- package/dist/team.js.map +1 -1
- package/package.json +11 -11
- package/src/config.js +1 -1
- package/src/index.js +49 -33
- package/src/team.js +129 -84
- package/test/integration/spec/actions.js +326 -295
- package/test/integration/spec/create.js +81 -51
- package/test/integration/spec/get.js +47 -45
- package/test/integration/spec/mercury.js +53 -43
- package/test/unit/spec/team.js +79 -26
package/test/unit/spec/team.js
CHANGED
|
@@ -21,39 +21,48 @@ describe('plugin-team', () => {
|
|
|
21
21
|
webex = new MockWebex({
|
|
22
22
|
children: {
|
|
23
23
|
team: Team,
|
|
24
|
-
user: User
|
|
25
|
-
}
|
|
24
|
+
user: User,
|
|
25
|
+
},
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
webex.internal.user.recordUUID = sinon.spy();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
describe('#create()', () => {
|
|
32
|
-
it('requires a displayName', () =>
|
|
32
|
+
it('requires a displayName', () =>
|
|
33
|
+
assert.isRejected(webex.internal.team.create({}), /`params.displayName` is required/));
|
|
33
34
|
|
|
34
|
-
it('requires a participants attribute', () =>
|
|
35
|
+
it('requires a participants attribute', () =>
|
|
36
|
+
assert.isRejected(
|
|
37
|
+
webex.internal.team.create({displayName: 'test'}),
|
|
38
|
+
/`params.participants` is required/
|
|
39
|
+
));
|
|
35
40
|
|
|
36
|
-
it('requires a participants array', () =>
|
|
41
|
+
it('requires a participants array', () =>
|
|
42
|
+
assert.isRejected(
|
|
43
|
+
webex.internal.team.create({displayName: 'test', participants: []}),
|
|
44
|
+
/`params.participants` is required/
|
|
45
|
+
));
|
|
37
46
|
});
|
|
38
47
|
|
|
39
48
|
describe('#createConversation()', () => {
|
|
40
49
|
const url = TEAM_URL;
|
|
41
50
|
const displayName = TEAM_DISPLAY_NAME;
|
|
42
51
|
|
|
43
|
-
it('requires a URL',
|
|
44
|
-
|
|
52
|
+
it('requires a URL', () =>
|
|
53
|
+
assert.isRejected(
|
|
45
54
|
webex.internal.team.createConversation({}, {}),
|
|
46
55
|
/`team.url` is required/
|
|
47
56
|
));
|
|
48
57
|
|
|
49
|
-
it('requires a displayName',
|
|
50
|
-
|
|
58
|
+
it('requires a displayName', () =>
|
|
59
|
+
assert.isRejected(
|
|
51
60
|
webex.internal.team.createConversation({url}, {}),
|
|
52
61
|
/`params.displayName` is required/
|
|
53
62
|
));
|
|
54
63
|
|
|
55
|
-
it('requires a team object with a general conversation',
|
|
56
|
-
|
|
64
|
+
it('requires a team object with a general conversation', () =>
|
|
65
|
+
assert.isRejected(
|
|
57
66
|
webex.internal.team.createConversation({url}, {displayName}),
|
|
58
67
|
/`team.generalConversationUuid` must be present/
|
|
59
68
|
));
|
|
@@ -61,40 +70,84 @@ describe('plugin-team', () => {
|
|
|
61
70
|
|
|
62
71
|
describe('#get()', () => {
|
|
63
72
|
it('requires a team url', () =>
|
|
64
|
-
assert.isRejected(
|
|
65
|
-
webex.internal.team.get({}),
|
|
66
|
-
/`team.url` is required/
|
|
67
|
-
));
|
|
73
|
+
assert.isRejected(webex.internal.team.get({}), /`team.url` is required/));
|
|
68
74
|
});
|
|
69
75
|
|
|
70
76
|
describe('#listConversations()', () => {
|
|
71
77
|
it('requires a team url', () =>
|
|
72
|
-
assert.isRejected(
|
|
73
|
-
webex.internal.team.listConversations({}),
|
|
74
|
-
/`team.url` is required/
|
|
75
|
-
));
|
|
78
|
+
assert.isRejected(webex.internal.team.listConversations({}), /`team.url` is required/));
|
|
76
79
|
});
|
|
77
80
|
|
|
78
81
|
describe('#prepareTeamConversation()', () => {
|
|
79
|
-
it('requires a KRO', () =>
|
|
82
|
+
it('requires a KRO', () =>
|
|
83
|
+
assert.isRejected(
|
|
84
|
+
webex.internal.team._prepareTeamConversation({}),
|
|
85
|
+
/Team general conversation must have a KRO/
|
|
86
|
+
));
|
|
80
87
|
});
|
|
81
88
|
|
|
82
89
|
describe('#recordUUIDs', () => {
|
|
83
|
-
it('resolves if there are no teamMembers', () =>
|
|
84
|
-
|
|
90
|
+
it('resolves if there are no teamMembers', () =>
|
|
91
|
+
webex.internal.team
|
|
92
|
+
._recordUUIDs({})
|
|
93
|
+
.then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
|
|
85
94
|
|
|
86
|
-
it(
|
|
87
|
-
|
|
95
|
+
it("resolves if there isn't teamMembers.items", () =>
|
|
96
|
+
webex.internal.team
|
|
97
|
+
._recordUUIDs({teamMembers: {}})
|
|
98
|
+
.then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
|
|
88
99
|
|
|
89
100
|
it('resolves if there is a LYRA_SPACE user', () => {
|
|
90
101
|
const user = {
|
|
91
102
|
id: uuid.v4(),
|
|
92
|
-
type: 'LYRA_SPACE'
|
|
103
|
+
type: 'LYRA_SPACE',
|
|
93
104
|
};
|
|
94
105
|
|
|
95
|
-
return webex.internal.team
|
|
106
|
+
return webex.internal.team
|
|
107
|
+
._recordUUIDs({teamMembers: {[user.id]: user}})
|
|
96
108
|
.then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0));
|
|
97
109
|
});
|
|
98
110
|
});
|
|
111
|
+
|
|
112
|
+
describe('#joinConversation', () => {
|
|
113
|
+
const conversation = {kmsResourceObjectUrl: 'convoKroUrl', id: 'convoId'};
|
|
114
|
+
const team = {url: 'teamUrl'};
|
|
115
|
+
const userId = 'userId';
|
|
116
|
+
|
|
117
|
+
beforeEach(() => {
|
|
118
|
+
webex.credentials.supertoken = {access_token: 'fake_token'};
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('requires userId to joinConversation', () =>
|
|
122
|
+
assert.isRejected(webex.internal.team.joinConversation(team, conversation), /`userId` is required/));
|
|
123
|
+
|
|
124
|
+
it('makes POST to convo service with correct body kmsMessage', () => {
|
|
125
|
+
webex.credentials.supertoken = {access_token: 'fake_token'}
|
|
126
|
+
return webex.internal.team.joinConversation(team, conversation, userId).then(() => {
|
|
127
|
+
assert.calledWith(
|
|
128
|
+
webex.request,
|
|
129
|
+
sinon.match({
|
|
130
|
+
method: 'POST',
|
|
131
|
+
uri: `${team.url}/conversations/${conversation.id}/participants`,
|
|
132
|
+
body: {
|
|
133
|
+
kmsMessage: {
|
|
134
|
+
client: {
|
|
135
|
+
clientId: webex.internal.device.url,
|
|
136
|
+
credential: {
|
|
137
|
+
bearer: webex.credentials.supertoken.access_token,
|
|
138
|
+
userId,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
method: 'create',
|
|
142
|
+
resourceUri: conversation.kmsResourceObjectUrl,
|
|
143
|
+
uri: '/authorizations',
|
|
144
|
+
userIds: [userId],
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
})
|
|
148
|
+
);
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
})
|
|
99
152
|
});
|
|
100
153
|
});
|