@webex/internal-plugin-lyra 2.59.2 → 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,232 +1,232 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import bowser from 'bowser';
6
- import '@webex/internal-plugin-lyra';
7
- import {assert} from '@webex/test-helper-chai';
8
- import retry from '@webex/test-helper-retry';
9
- import testUsers from '@webex/test-helper-test-users';
10
- // FIXME
11
- // eslint-disable-next-line import/no-unresolved
12
- import {generateRandomString} from '@ciscospark/test-users-legacy';
13
- import WebexCore from '@webex/webex-core';
14
- import '@webex/internal-plugin-locus';
15
-
16
- describe('plugin-lyra', function () {
17
- this.timeout(30000);
18
- describe('Space', () => {
19
- let participants;
20
- let lyraMachine;
21
- let lyraSpace; // space with details of lyra URIs
22
- let spock;
23
- let conversation;
24
-
25
- before('create lyra machine', function () {
26
- this.timeout(retry.timeout(20000));
27
-
28
- return retry(() =>
29
- testUsers.create({
30
- count: 1,
31
- config: {
32
- machineType: 'LYRA_SPACE',
33
- type: 'MACHINE',
34
- password: `${generateRandomString(32)}d_wA*`,
35
- },
36
- })
37
- )
38
- .then((machines) => {
39
- lyraMachine = machines[0];
40
- lyraMachine.webex = new WebexCore({
41
- credentials: {
42
- authorization: lyraMachine.token,
43
- },
44
- });
45
-
46
- // binding to conversation only works with webex board device
47
- lyraMachine.webex.internal.device.config.defaults.deviceType = 'SPARK_BOARD';
48
- lyraMachine.webex.internal.device.config.defaults.model = 'WebexBoard Test';
49
- lyraMachine.webex.internal.device.config.defaults.localizedModel = 'WebexJSSDKTest';
50
- lyraMachine.webex.internal.device.config.defaults.systemVersion = 'WebexJSSDKTest';
51
- lyraMachine.webex.internal.device.config.defaults.systemName = 'Darling';
52
-
53
- return lyraMachine.webex.internal.mercury.connect();
54
- })
55
- .then(() => lyraMachine.webex.internal.lyra.space.get({id: lyraMachine.id}))
56
- .then((space) => {
57
- lyraMachine.space = space;
58
- lyraSpace = Object.assign({}, space, {url: `/spaces/${space.identity.id}`});
59
- });
60
- });
61
-
62
- before('create users', () =>
63
- testUsers.create({count: 2}).then((users) => {
64
- participants = users;
65
- spock = participants[0];
66
-
67
- return Promise.all(
68
- Array.map(participants, (participant) => {
69
- participant.webex = new WebexCore({
70
- credentials: {
71
- authorization: participant.token,
72
- },
73
- });
74
-
75
- return participant.webex.internal.mercury.connect();
76
- })
77
- );
78
- })
79
- );
80
-
81
- before('create conversation', () =>
82
- retry(() =>
83
- participants[0].webex.internal.conversation.create({
84
- displayName: 'Test Lyra Conversation',
85
- participants,
86
- })
87
- ).then((c) => {
88
- conversation = c;
89
-
90
- return conversation;
91
- })
92
- );
93
-
94
- describe('#list()', () => {
95
- before('ensure participant joined space', () =>
96
- spock.webex.internal.lyra.space.join(lyraSpace)
97
- );
98
-
99
- it('returns spaces', () =>
100
- spock.webex.internal.lyra.space.list().then((spaces) => {
101
- assert.lengthOf(spaces, 1);
102
- assert.deepEqual(spaces[0].identity, lyraMachine.space.identity);
103
- }));
104
- });
105
-
106
- describe('#get()', () => {
107
- it('returns space info', () =>
108
- spock.webex.internal.lyra.space
109
- .get(lyraMachine.space)
110
- .then((lyraSpace) => assert.deepEqual(lyraMachine.space.identity, lyraSpace.identity)));
111
- });
112
-
113
- describe('#join()', () => {
114
- it('adds the current user to lyra space', () =>
115
- spock.webex.internal.lyra.space
116
- .join(lyraSpace)
117
- .then(() => lyraMachine.webex.internal.lyra.space.get(lyraMachine.space))
118
- .then((lyraSpace) => {
119
- assert.lengthOf(lyraSpace.occupants.items, 1);
120
- assert.equal(lyraSpace.occupants.items[0].identity.id, spock.id);
121
- }));
122
- });
123
-
124
- describe('#leave()', () => {
125
- it('removes the current user from lyra space', () =>
126
- spock.webex.internal.lyra.space
127
- .join(lyraSpace)
128
- .then(() => spock.webex.internal.lyra.space.leave(lyraSpace))
129
- .then(() => lyraMachine.webex.internal.lyra.space.get(lyraMachine.space))
130
- .then((lyraSpace) => assert.lengthOf(lyraSpace.occupants.items, 0)));
131
-
132
- describe('when a user has multiple devices in the space', () => {
133
- before('add another device', () => {
134
- spock.webex2 = new WebexCore({
135
- credentials: {
136
- authorization: spock.token,
137
- },
138
- });
139
-
140
- return spock.webex2.internal.device
141
- .register()
142
- .then(() => spock.webex.internal.lyra.space.join(lyraSpace))
143
- .then(() => spock.webex2.internal.lyra.space.join(lyraSpace));
144
- });
145
-
146
- it('removes all devices from lyra space', () =>
147
- spock.webex.internal.lyra.space
148
- .leave(lyraSpace, {
149
- removeAllDevices: true,
150
- })
151
- .then(() => lyraMachine.webex.internal.lyra.space.get(lyraMachine.space))
152
- .then((lyraSpace) => assert.lengthOf(lyraSpace.occupants.items, 0)));
153
- });
154
- });
155
-
156
- // Skip until we can bind a conversation to lyra space by posting capabilities to Lyra.
157
-
158
- describe.skip('#bindConversation()', () => {
159
- before('ensure participant joined space', () =>
160
- spock.webex.internal.lyra.space
161
- .join(lyraSpace)
162
- .then(() =>
163
- lyraMachine.webex.internal.lyra.space.verifyOccupant(lyraMachine.space, spock.id)
164
- )
165
- .then(() => spock.webex.internal.lyra.space.bindConversation(lyraSpace, conversation))
166
- );
167
-
168
- after('remove binding', () =>
169
- spock.webex.internal.lyra.space
170
- .unbindConversation(lyraSpace, conversation)
171
- // After hooks shouldn't be able to break tests
172
- .catch((err) => console.error(err))
173
- );
174
-
175
- it('binds conversation and lyra space', () =>
176
- spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space).then(({bindings}) => {
177
- assert.lengthOf(bindings, 1);
178
- assert.equal(bindings[0].conversationUrl, conversation.url);
179
- }));
180
- });
181
-
182
- describe.skip('#unbindConversation()', () => {
183
- before('ensure participant joined space', () =>
184
- spock.webex.internal.lyra.space
185
- .join(lyraSpace)
186
- .then(() =>
187
- lyraMachine.webex.internal.lyra.space.verifyOccupant(lyraMachine.space, spock.id)
188
- )
189
- .then(() => spock.webex.internal.lyra.space.bindConversation(lyraSpace, conversation))
190
- .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
191
- .then(({bindings}) => assert.lengthOf(bindings, 1))
192
- );
193
-
194
- // Skip this feature in IE. We do not support it at this time.
195
- (bowser.msie ? it.skip : it)('removes the binding between conversation and lyra space', () =>
196
- spock.webex.internal.lyra.space
197
- .unbindConversation(lyraSpace, conversation)
198
- .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
199
- .then(({bindings}) => assert.lengthOf(bindings, 0))
200
- );
201
- });
202
-
203
- describe.skip('#deleteBinding()', () => {
204
- let bindingId;
205
-
206
- before('ensure participant joined space', () =>
207
- spock.webex.internal.lyra.space
208
- .join(lyraSpace)
209
- .then(() =>
210
- lyraMachine.webex.internal.lyra.space.verifyOccupant(lyraMachine.space, spock.id)
211
- )
212
- .then(() => spock.webex.internal.lyra.space.bindConversation(lyraSpace, conversation))
213
- .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
214
- .then(({bindings}) => {
215
- assert.lengthOf(bindings, 1);
216
- bindingId = bindings[0].bindingUrl.split('/').pop();
217
- })
218
- );
219
-
220
- // Skip this feature in IE. We do not support it at this time.
221
- (bowser.msie ? it.skip : it)('removes the binding between conversation and lyra space', () =>
222
- spock.webex.internal.lyra.space
223
- .deleteBinding(lyraMachine.space, {
224
- kmsResourceObjectUrl: conversation.kmsResourceObjectUrl,
225
- bindingId,
226
- })
227
- .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
228
- .then(({bindings}) => assert.lengthOf(bindings, 0))
229
- );
230
- });
231
- });
232
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import bowser from 'bowser';
6
+ import '@webex/internal-plugin-lyra';
7
+ import {assert} from '@webex/test-helper-chai';
8
+ import retry from '@webex/test-helper-retry';
9
+ import testUsers from '@webex/test-helper-test-users';
10
+ // FIXME
11
+ // eslint-disable-next-line import/no-unresolved
12
+ import {generateRandomString} from '@ciscospark/test-users-legacy';
13
+ import WebexCore from '@webex/webex-core';
14
+ import '@webex/internal-plugin-locus';
15
+
16
+ describe('plugin-lyra', function () {
17
+ this.timeout(30000);
18
+ describe('Space', () => {
19
+ let participants;
20
+ let lyraMachine;
21
+ let lyraSpace; // space with details of lyra URIs
22
+ let spock;
23
+ let conversation;
24
+
25
+ before('create lyra machine', function () {
26
+ this.timeout(retry.timeout(20000));
27
+
28
+ return retry(() =>
29
+ testUsers.create({
30
+ count: 1,
31
+ config: {
32
+ machineType: 'LYRA_SPACE',
33
+ type: 'MACHINE',
34
+ password: `${generateRandomString(32)}d_wA*`,
35
+ },
36
+ })
37
+ )
38
+ .then((machines) => {
39
+ lyraMachine = machines[0];
40
+ lyraMachine.webex = new WebexCore({
41
+ credentials: {
42
+ authorization: lyraMachine.token,
43
+ },
44
+ });
45
+
46
+ // binding to conversation only works with webex board device
47
+ lyraMachine.webex.internal.device.config.defaults.deviceType = 'SPARK_BOARD';
48
+ lyraMachine.webex.internal.device.config.defaults.model = 'WebexBoard Test';
49
+ lyraMachine.webex.internal.device.config.defaults.localizedModel = 'WebexJSSDKTest';
50
+ lyraMachine.webex.internal.device.config.defaults.systemVersion = 'WebexJSSDKTest';
51
+ lyraMachine.webex.internal.device.config.defaults.systemName = 'Darling';
52
+
53
+ return lyraMachine.webex.internal.mercury.connect();
54
+ })
55
+ .then(() => lyraMachine.webex.internal.lyra.space.get({id: lyraMachine.id}))
56
+ .then((space) => {
57
+ lyraMachine.space = space;
58
+ lyraSpace = Object.assign({}, space, {url: `/spaces/${space.identity.id}`});
59
+ });
60
+ });
61
+
62
+ before('create users', () =>
63
+ testUsers.create({count: 2}).then((users) => {
64
+ participants = users;
65
+ spock = participants[0];
66
+
67
+ return Promise.all(
68
+ Array.map(participants, (participant) => {
69
+ participant.webex = new WebexCore({
70
+ credentials: {
71
+ authorization: participant.token,
72
+ },
73
+ });
74
+
75
+ return participant.webex.internal.mercury.connect();
76
+ })
77
+ );
78
+ })
79
+ );
80
+
81
+ before('create conversation', () =>
82
+ retry(() =>
83
+ participants[0].webex.internal.conversation.create({
84
+ displayName: 'Test Lyra Conversation',
85
+ participants,
86
+ })
87
+ ).then((c) => {
88
+ conversation = c;
89
+
90
+ return conversation;
91
+ })
92
+ );
93
+
94
+ describe('#list()', () => {
95
+ before('ensure participant joined space', () =>
96
+ spock.webex.internal.lyra.space.join(lyraSpace)
97
+ );
98
+
99
+ it('returns spaces', () =>
100
+ spock.webex.internal.lyra.space.list().then((spaces) => {
101
+ assert.lengthOf(spaces, 1);
102
+ assert.deepEqual(spaces[0].identity, lyraMachine.space.identity);
103
+ }));
104
+ });
105
+
106
+ describe('#get()', () => {
107
+ it('returns space info', () =>
108
+ spock.webex.internal.lyra.space
109
+ .get(lyraMachine.space)
110
+ .then((lyraSpace) => assert.deepEqual(lyraMachine.space.identity, lyraSpace.identity)));
111
+ });
112
+
113
+ describe('#join()', () => {
114
+ it('adds the current user to lyra space', () =>
115
+ spock.webex.internal.lyra.space
116
+ .join(lyraSpace)
117
+ .then(() => lyraMachine.webex.internal.lyra.space.get(lyraMachine.space))
118
+ .then((lyraSpace) => {
119
+ assert.lengthOf(lyraSpace.occupants.items, 1);
120
+ assert.equal(lyraSpace.occupants.items[0].identity.id, spock.id);
121
+ }));
122
+ });
123
+
124
+ describe('#leave()', () => {
125
+ it('removes the current user from lyra space', () =>
126
+ spock.webex.internal.lyra.space
127
+ .join(lyraSpace)
128
+ .then(() => spock.webex.internal.lyra.space.leave(lyraSpace))
129
+ .then(() => lyraMachine.webex.internal.lyra.space.get(lyraMachine.space))
130
+ .then((lyraSpace) => assert.lengthOf(lyraSpace.occupants.items, 0)));
131
+
132
+ describe('when a user has multiple devices in the space', () => {
133
+ before('add another device', () => {
134
+ spock.webex2 = new WebexCore({
135
+ credentials: {
136
+ authorization: spock.token,
137
+ },
138
+ });
139
+
140
+ return spock.webex2.internal.device
141
+ .register()
142
+ .then(() => spock.webex.internal.lyra.space.join(lyraSpace))
143
+ .then(() => spock.webex2.internal.lyra.space.join(lyraSpace));
144
+ });
145
+
146
+ it('removes all devices from lyra space', () =>
147
+ spock.webex.internal.lyra.space
148
+ .leave(lyraSpace, {
149
+ removeAllDevices: true,
150
+ })
151
+ .then(() => lyraMachine.webex.internal.lyra.space.get(lyraMachine.space))
152
+ .then((lyraSpace) => assert.lengthOf(lyraSpace.occupants.items, 0)));
153
+ });
154
+ });
155
+
156
+ // Skip until we can bind a conversation to lyra space by posting capabilities to Lyra.
157
+
158
+ describe.skip('#bindConversation()', () => {
159
+ before('ensure participant joined space', () =>
160
+ spock.webex.internal.lyra.space
161
+ .join(lyraSpace)
162
+ .then(() =>
163
+ lyraMachine.webex.internal.lyra.space.verifyOccupant(lyraMachine.space, spock.id)
164
+ )
165
+ .then(() => spock.webex.internal.lyra.space.bindConversation(lyraSpace, conversation))
166
+ );
167
+
168
+ after('remove binding', () =>
169
+ spock.webex.internal.lyra.space
170
+ .unbindConversation(lyraSpace, conversation)
171
+ // After hooks shouldn't be able to break tests
172
+ .catch((err) => console.error(err))
173
+ );
174
+
175
+ it('binds conversation and lyra space', () =>
176
+ spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space).then(({bindings}) => {
177
+ assert.lengthOf(bindings, 1);
178
+ assert.equal(bindings[0].conversationUrl, conversation.url);
179
+ }));
180
+ });
181
+
182
+ describe.skip('#unbindConversation()', () => {
183
+ before('ensure participant joined space', () =>
184
+ spock.webex.internal.lyra.space
185
+ .join(lyraSpace)
186
+ .then(() =>
187
+ lyraMachine.webex.internal.lyra.space.verifyOccupant(lyraMachine.space, spock.id)
188
+ )
189
+ .then(() => spock.webex.internal.lyra.space.bindConversation(lyraSpace, conversation))
190
+ .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
191
+ .then(({bindings}) => assert.lengthOf(bindings, 1))
192
+ );
193
+
194
+ // Skip this feature in IE. We do not support it at this time.
195
+ (bowser.msie ? it.skip : it)('removes the binding between conversation and lyra space', () =>
196
+ spock.webex.internal.lyra.space
197
+ .unbindConversation(lyraSpace, conversation)
198
+ .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
199
+ .then(({bindings}) => assert.lengthOf(bindings, 0))
200
+ );
201
+ });
202
+
203
+ describe.skip('#deleteBinding()', () => {
204
+ let bindingId;
205
+
206
+ before('ensure participant joined space', () =>
207
+ spock.webex.internal.lyra.space
208
+ .join(lyraSpace)
209
+ .then(() =>
210
+ lyraMachine.webex.internal.lyra.space.verifyOccupant(lyraMachine.space, spock.id)
211
+ )
212
+ .then(() => spock.webex.internal.lyra.space.bindConversation(lyraSpace, conversation))
213
+ .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
214
+ .then(({bindings}) => {
215
+ assert.lengthOf(bindings, 1);
216
+ bindingId = bindings[0].bindingUrl.split('/').pop();
217
+ })
218
+ );
219
+
220
+ // Skip this feature in IE. We do not support it at this time.
221
+ (bowser.msie ? it.skip : it)('removes the binding between conversation and lyra space', () =>
222
+ spock.webex.internal.lyra.space
223
+ .deleteBinding(lyraMachine.space, {
224
+ kmsResourceObjectUrl: conversation.kmsResourceObjectUrl,
225
+ bindingId,
226
+ })
227
+ .then(() => spock.webex.internal.lyra.space.getCurrentBindings(lyraMachine.space))
228
+ .then(({bindings}) => assert.lengthOf(bindings, 0))
229
+ );
230
+ });
231
+ });
232
+ });
@@ -1,65 +1,65 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import {assert} from '@webex/test-helper-chai';
6
- import sinon from 'sinon';
7
- import MockWebex from '@webex/test-helper-mock-webex';
8
- import Lyra, {config as lyraConfig} from '@webex/internal-plugin-lyra';
9
-
10
- describe('plugin-lyra', () => {
11
- const lyraSpaceId = 'lyra-1337';
12
- const lyraSpaceUrl = `https://lyra/api/v1/${lyraSpaceId}`;
13
- const lyraSpace = {
14
- identity: {
15
- id: lyraSpaceId,
16
- },
17
- url: lyraSpaceUrl,
18
- };
19
-
20
- let webex;
21
-
22
- beforeAll(() => {
23
- webex = new MockWebex({
24
- children: {
25
- lyra: Lyra,
26
- },
27
- device: {
28
- url: 'deviceUrl',
29
- userId: '1234',
30
- },
31
- });
32
-
33
- webex.config.lyra = lyraConfig.lyra;
34
- });
35
-
36
- beforeEach(() => {
37
- webex.request.resetHistory();
38
- });
39
-
40
- describe('device', () => {
41
- describe('#putAudioState', () => {
42
- it('requires audioState.deviceUrl', () =>
43
- assert.isRejected(
44
- webex.internal.lyra.device.putAudioState(lyraSpace),
45
- /audioState.deviceUrl is required/
46
- ));
47
- });
48
-
49
- describe('#setVolume', () => {
50
- it('defaults to level 0', () =>
51
- webex.internal.lyra.device.setVolume(lyraSpace).then(() => {
52
- assert.calledWith(
53
- webex.request,
54
- sinon.match({
55
- method: 'POST',
56
- uri: `${lyraSpace.url}/audio/volume/actions/set/invoke`,
57
- body: {
58
- level: 0,
59
- },
60
- })
61
- );
62
- }));
63
- });
64
- });
65
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import {assert} from '@webex/test-helper-chai';
6
+ import sinon from 'sinon';
7
+ import MockWebex from '@webex/test-helper-mock-webex';
8
+ import Lyra, {config as lyraConfig} from '@webex/internal-plugin-lyra';
9
+
10
+ describe('plugin-lyra', () => {
11
+ const lyraSpaceId = 'lyra-1337';
12
+ const lyraSpaceUrl = `https://lyra/api/v1/${lyraSpaceId}`;
13
+ const lyraSpace = {
14
+ identity: {
15
+ id: lyraSpaceId,
16
+ },
17
+ url: lyraSpaceUrl,
18
+ };
19
+
20
+ let webex;
21
+
22
+ beforeAll(() => {
23
+ webex = new MockWebex({
24
+ children: {
25
+ lyra: Lyra,
26
+ },
27
+ device: {
28
+ url: 'deviceUrl',
29
+ userId: '1234',
30
+ },
31
+ });
32
+
33
+ webex.config.lyra = lyraConfig.lyra;
34
+ });
35
+
36
+ beforeEach(() => {
37
+ webex.request.resetHistory();
38
+ });
39
+
40
+ describe('device', () => {
41
+ describe('#putAudioState', () => {
42
+ it('requires audioState.deviceUrl', () =>
43
+ assert.isRejected(
44
+ webex.internal.lyra.device.putAudioState(lyraSpace),
45
+ /audioState.deviceUrl is required/
46
+ ));
47
+ });
48
+
49
+ describe('#setVolume', () => {
50
+ it('defaults to level 0', () =>
51
+ webex.internal.lyra.device.setVolume(lyraSpace).then(() => {
52
+ assert.calledWith(
53
+ webex.request,
54
+ sinon.match({
55
+ method: 'POST',
56
+ uri: `${lyraSpace.url}/audio/volume/actions/set/invoke`,
57
+ body: {
58
+ level: 0,
59
+ },
60
+ })
61
+ );
62
+ }));
63
+ });
64
+ });
65
+ });