@webex/internal-plugin-avatar 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.
- package/.eslintrc.js +6 -6
- package/README.md +42 -42
- package/babel.config.js +3 -3
- package/dist/avatar-url-batcher.js +2 -2
- package/dist/avatar-url-batcher.js.map +1 -1
- package/dist/avatar-url-store.js +35 -35
- package/dist/avatar-url-store.js.map +1 -1
- package/dist/avatar.js +15 -15
- package/dist/avatar.js.map +1 -1
- package/dist/config.js +14 -14
- package/dist/config.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +19 -18
- package/process +1 -1
- package/src/avatar-url-batcher.js +124 -124
- package/src/avatar-url-store.js +111 -111
- package/src/avatar.js +148 -148
- package/src/config.js +33 -33
- package/src/index.js +17 -17
- package/test/integration/spec/avatar.js +82 -82
- package/test/unit/spec/avatar-url-batcher.js +84 -84
- package/test/unit/spec/avatar-url-store.js +154 -154
- package/test/unit/spec/avatar.js +1574 -1574
package/src/avatar.js
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {oneFlight} from '@webex/common';
|
|
6
|
-
import {detectFileType, processImage} from '@webex/helper-image';
|
|
7
|
-
import {WebexPlugin} from '@webex/webex-core';
|
|
8
|
-
import {defaults} from 'lodash';
|
|
9
|
-
|
|
10
|
-
import AvatarUrlStore from './avatar-url-store';
|
|
11
|
-
import AvatarUrlBatcher from './avatar-url-batcher';
|
|
12
|
-
|
|
13
|
-
const Avatar = WebexPlugin.extend({
|
|
14
|
-
namespace: 'Avatar',
|
|
15
|
-
|
|
16
|
-
children: {
|
|
17
|
-
batcher: AvatarUrlBatcher,
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
session: {
|
|
21
|
-
store: {
|
|
22
|
-
default() {
|
|
23
|
-
return new AvatarUrlStore();
|
|
24
|
-
},
|
|
25
|
-
type: 'any',
|
|
26
|
-
},
|
|
27
|
-
enableThumbnails: {
|
|
28
|
-
default: true,
|
|
29
|
-
type: 'boolean',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
@oneFlight({keyFactory: (uuid) => uuid})
|
|
34
|
-
_fetchAllAvatarUrlSizes(uuid, options) {
|
|
35
|
-
// fetch all possible sizes of avatar and store in cache
|
|
36
|
-
return Promise.all(
|
|
37
|
-
this.config.sizes.map((size) =>
|
|
38
|
-
this.batcher
|
|
39
|
-
.request({uuid, size})
|
|
40
|
-
.then((item) => this.store.add(defaults({cacheControl: options.cacheControl}, item)))
|
|
41
|
-
)
|
|
42
|
-
);
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @private
|
|
47
|
-
* Requests an avatar URL from the api
|
|
48
|
-
* @param {string} uuid
|
|
49
|
-
* @param {Object} options
|
|
50
|
-
* @param {integer} options.size
|
|
51
|
-
* @param {integer} options.cacheControl
|
|
52
|
-
* @returns {Promise<string>} the avatar URL
|
|
53
|
-
*/
|
|
54
|
-
@oneFlight({keyFactory: (uuid, options) => uuid + String(options && options.size)})
|
|
55
|
-
_fetchAvatarUrl(uuid, options) {
|
|
56
|
-
return this.store.get({uuid, size: options.size}).catch(() =>
|
|
57
|
-
Promise.all([
|
|
58
|
-
this._fetchAllAvatarUrlSizes(uuid, options),
|
|
59
|
-
// just in case options.size does not fall into the predefined values above
|
|
60
|
-
this.batcher.request({uuid, size: options.size}),
|
|
61
|
-
])
|
|
62
|
-
// eslint-disable-next-line no-unused-vars
|
|
63
|
-
.then(([ignore, item]) =>
|
|
64
|
-
this.store.add(defaults({cacheControl: options.cacheControl}, item))
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Retrieves an Avatar from a cache or the api on misses.
|
|
71
|
-
*
|
|
72
|
-
* @param {UserObject|string} user The user, Webex user uuid, or email
|
|
73
|
-
* @param {Object} [options]
|
|
74
|
-
* @param {integer} [options.size] In {1600, 640, 192, 135, 110, 80, 50, 40}
|
|
75
|
-
* Defaults to 80 if falsy
|
|
76
|
-
* @param {boolean} [options.hideDefaultAvatar] does not return default avatar url if true. Defaults to false
|
|
77
|
-
* @returns {Promise<string>} A promise that resolves to the avatar
|
|
78
|
-
*/
|
|
79
|
-
retrieveAvatarUrl(user, options) {
|
|
80
|
-
if (!user) {
|
|
81
|
-
return Promise.reject(new Error("'user' is a required parameter"));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
options = defaults(options, {
|
|
85
|
-
cacheControl: this.config.cacheControl,
|
|
86
|
-
size: this.config.defaultAvatarSize,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return this.webex.internal.user
|
|
90
|
-
.asUUID(user)
|
|
91
|
-
.then((uuid) => this._fetchAvatarUrl(uuid, options))
|
|
92
|
-
.then((item) => {
|
|
93
|
-
if (options.hideDefaultAvatar) {
|
|
94
|
-
return item.hasDefaultAvatar ? null : item.url;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return item.url;
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Upload a new avatar for the current user
|
|
103
|
-
*
|
|
104
|
-
* @param {Blob|File|Buffer} file The new avatar
|
|
105
|
-
* @returns {Promise} Resolves with the URL of the full-sized avatar
|
|
106
|
-
*/
|
|
107
|
-
setAvatar(file) {
|
|
108
|
-
return detectFileType(file, this.logger)
|
|
109
|
-
.then((type) =>
|
|
110
|
-
processImage({
|
|
111
|
-
file,
|
|
112
|
-
type,
|
|
113
|
-
thumbnailMaxWidth: this.config.thumbnailMaxWidth,
|
|
114
|
-
thumbnailMaxHeight: this.config.thumbnailMaxHeight,
|
|
115
|
-
enableThumbnails: this.enableThumbnails,
|
|
116
|
-
logger: this.logger,
|
|
117
|
-
isAvatar: true,
|
|
118
|
-
})
|
|
119
|
-
)
|
|
120
|
-
.then((processedImage) =>
|
|
121
|
-
this.upload({
|
|
122
|
-
api: 'avatar',
|
|
123
|
-
resource: `profile/${this.webex.internal.device.userId}/session`,
|
|
124
|
-
file: processedImage[0],
|
|
125
|
-
phases: {
|
|
126
|
-
upload: {
|
|
127
|
-
$uri: (session) => session.url,
|
|
128
|
-
},
|
|
129
|
-
finalize: {
|
|
130
|
-
method: 'PUT',
|
|
131
|
-
api: 'avatar',
|
|
132
|
-
$resource: (session) =>
|
|
133
|
-
// eslint-disable-next-line max-len
|
|
134
|
-
`profile/${this.webex.internal.device.userId}/session/${session.id}`,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
})
|
|
138
|
-
)
|
|
139
|
-
.then((res) => {
|
|
140
|
-
// invalidate user's cached avatar
|
|
141
|
-
this.store.remove({uuid: this.webex.internal.device.userId});
|
|
142
|
-
|
|
143
|
-
return res.url;
|
|
144
|
-
});
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
export default Avatar;
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {oneFlight} from '@webex/common';
|
|
6
|
+
import {detectFileType, processImage} from '@webex/helper-image';
|
|
7
|
+
import {WebexPlugin} from '@webex/webex-core';
|
|
8
|
+
import {defaults} from 'lodash';
|
|
9
|
+
|
|
10
|
+
import AvatarUrlStore from './avatar-url-store';
|
|
11
|
+
import AvatarUrlBatcher from './avatar-url-batcher';
|
|
12
|
+
|
|
13
|
+
const Avatar = WebexPlugin.extend({
|
|
14
|
+
namespace: 'Avatar',
|
|
15
|
+
|
|
16
|
+
children: {
|
|
17
|
+
batcher: AvatarUrlBatcher,
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
session: {
|
|
21
|
+
store: {
|
|
22
|
+
default() {
|
|
23
|
+
return new AvatarUrlStore();
|
|
24
|
+
},
|
|
25
|
+
type: 'any',
|
|
26
|
+
},
|
|
27
|
+
enableThumbnails: {
|
|
28
|
+
default: true,
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
@oneFlight({keyFactory: (uuid) => uuid})
|
|
34
|
+
_fetchAllAvatarUrlSizes(uuid, options) {
|
|
35
|
+
// fetch all possible sizes of avatar and store in cache
|
|
36
|
+
return Promise.all(
|
|
37
|
+
this.config.sizes.map((size) =>
|
|
38
|
+
this.batcher
|
|
39
|
+
.request({uuid, size})
|
|
40
|
+
.then((item) => this.store.add(defaults({cacheControl: options.cacheControl}, item)))
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @private
|
|
47
|
+
* Requests an avatar URL from the api
|
|
48
|
+
* @param {string} uuid
|
|
49
|
+
* @param {Object} options
|
|
50
|
+
* @param {integer} options.size
|
|
51
|
+
* @param {integer} options.cacheControl
|
|
52
|
+
* @returns {Promise<string>} the avatar URL
|
|
53
|
+
*/
|
|
54
|
+
@oneFlight({keyFactory: (uuid, options) => uuid + String(options && options.size)})
|
|
55
|
+
_fetchAvatarUrl(uuid, options) {
|
|
56
|
+
return this.store.get({uuid, size: options.size}).catch(() =>
|
|
57
|
+
Promise.all([
|
|
58
|
+
this._fetchAllAvatarUrlSizes(uuid, options),
|
|
59
|
+
// just in case options.size does not fall into the predefined values above
|
|
60
|
+
this.batcher.request({uuid, size: options.size}),
|
|
61
|
+
])
|
|
62
|
+
// eslint-disable-next-line no-unused-vars
|
|
63
|
+
.then(([ignore, item]) =>
|
|
64
|
+
this.store.add(defaults({cacheControl: options.cacheControl}, item))
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves an Avatar from a cache or the api on misses.
|
|
71
|
+
*
|
|
72
|
+
* @param {UserObject|string} user The user, Webex user uuid, or email
|
|
73
|
+
* @param {Object} [options]
|
|
74
|
+
* @param {integer} [options.size] In {1600, 640, 192, 135, 110, 80, 50, 40}
|
|
75
|
+
* Defaults to 80 if falsy
|
|
76
|
+
* @param {boolean} [options.hideDefaultAvatar] does not return default avatar url if true. Defaults to false
|
|
77
|
+
* @returns {Promise<string>} A promise that resolves to the avatar
|
|
78
|
+
*/
|
|
79
|
+
retrieveAvatarUrl(user, options) {
|
|
80
|
+
if (!user) {
|
|
81
|
+
return Promise.reject(new Error("'user' is a required parameter"));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
options = defaults(options, {
|
|
85
|
+
cacheControl: this.config.cacheControl,
|
|
86
|
+
size: this.config.defaultAvatarSize,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return this.webex.internal.user
|
|
90
|
+
.asUUID(user)
|
|
91
|
+
.then((uuid) => this._fetchAvatarUrl(uuid, options))
|
|
92
|
+
.then((item) => {
|
|
93
|
+
if (options.hideDefaultAvatar) {
|
|
94
|
+
return item.hasDefaultAvatar ? null : item.url;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return item.url;
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Upload a new avatar for the current user
|
|
103
|
+
*
|
|
104
|
+
* @param {Blob|File|Buffer} file The new avatar
|
|
105
|
+
* @returns {Promise} Resolves with the URL of the full-sized avatar
|
|
106
|
+
*/
|
|
107
|
+
setAvatar(file) {
|
|
108
|
+
return detectFileType(file, this.logger)
|
|
109
|
+
.then((type) =>
|
|
110
|
+
processImage({
|
|
111
|
+
file,
|
|
112
|
+
type,
|
|
113
|
+
thumbnailMaxWidth: this.config.thumbnailMaxWidth,
|
|
114
|
+
thumbnailMaxHeight: this.config.thumbnailMaxHeight,
|
|
115
|
+
enableThumbnails: this.enableThumbnails,
|
|
116
|
+
logger: this.logger,
|
|
117
|
+
isAvatar: true,
|
|
118
|
+
})
|
|
119
|
+
)
|
|
120
|
+
.then((processedImage) =>
|
|
121
|
+
this.upload({
|
|
122
|
+
api: 'avatar',
|
|
123
|
+
resource: `profile/${this.webex.internal.device.userId}/session`,
|
|
124
|
+
file: processedImage[0],
|
|
125
|
+
phases: {
|
|
126
|
+
upload: {
|
|
127
|
+
$uri: (session) => session.url,
|
|
128
|
+
},
|
|
129
|
+
finalize: {
|
|
130
|
+
method: 'PUT',
|
|
131
|
+
api: 'avatar',
|
|
132
|
+
$resource: (session) =>
|
|
133
|
+
// eslint-disable-next-line max-len
|
|
134
|
+
`profile/${this.webex.internal.device.userId}/session/${session.id}`,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
)
|
|
139
|
+
.then((res) => {
|
|
140
|
+
// invalidate user's cached avatar
|
|
141
|
+
this.store.remove({uuid: this.webex.internal.device.userId});
|
|
142
|
+
|
|
143
|
+
return res.url;
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export default Avatar;
|
package/src/config.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
avatar: {
|
|
7
|
-
batcherWait: 100,
|
|
8
|
-
batcherMaxCalls: 100,
|
|
9
|
-
batcherMaxWait: 1500,
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @description avatar URL store TTL, allows avatar updates to eventually be propegated
|
|
13
|
-
* @type {number} Number of seconds the avatar should remain in store
|
|
14
|
-
*/
|
|
15
|
-
cacheControl: 60 * 60,
|
|
16
|
-
/**
|
|
17
|
-
* @description default avatar size to retrieve if no size is specified
|
|
18
|
-
* @type {number}
|
|
19
|
-
*/
|
|
20
|
-
defaultAvatarSize: 80,
|
|
21
|
-
sizes: [40, 50, 80, 110, 135, 192, 640, 1600],
|
|
22
|
-
/**
|
|
23
|
-
* Max height for thumbnails generated when sharing an image
|
|
24
|
-
* @type {number}
|
|
25
|
-
*/
|
|
26
|
-
thumbnailMaxHeight: 960,
|
|
27
|
-
/**
|
|
28
|
-
* Max width for thumbnails generated when sharing an image
|
|
29
|
-
* @type {number}
|
|
30
|
-
*/
|
|
31
|
-
thumbnailMaxWidth: 640,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
avatar: {
|
|
7
|
+
batcherWait: 100,
|
|
8
|
+
batcherMaxCalls: 100,
|
|
9
|
+
batcherMaxWait: 1500,
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description avatar URL store TTL, allows avatar updates to eventually be propegated
|
|
13
|
+
* @type {number} Number of seconds the avatar should remain in store
|
|
14
|
+
*/
|
|
15
|
+
cacheControl: 60 * 60,
|
|
16
|
+
/**
|
|
17
|
+
* @description default avatar size to retrieve if no size is specified
|
|
18
|
+
* @type {number}
|
|
19
|
+
*/
|
|
20
|
+
defaultAvatarSize: 80,
|
|
21
|
+
sizes: [40, 50, 80, 110, 135, 192, 640, 1600],
|
|
22
|
+
/**
|
|
23
|
+
* Max height for thumbnails generated when sharing an image
|
|
24
|
+
* @type {number}
|
|
25
|
+
*/
|
|
26
|
+
thumbnailMaxHeight: 960,
|
|
27
|
+
/**
|
|
28
|
+
* Max width for thumbnails generated when sharing an image
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
thumbnailMaxWidth: 640,
|
|
32
|
+
},
|
|
33
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-user';
|
|
6
|
-
import '@webex/internal-plugin-device';
|
|
7
|
-
|
|
8
|
-
import {registerInternalPlugin} from '@webex/webex-core';
|
|
9
|
-
|
|
10
|
-
import Avatar from './avatar';
|
|
11
|
-
import config from './config';
|
|
12
|
-
|
|
13
|
-
registerInternalPlugin('avatar', Avatar, {
|
|
14
|
-
config,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export {default} from './avatar';
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@webex/internal-plugin-user';
|
|
6
|
+
import '@webex/internal-plugin-device';
|
|
7
|
+
|
|
8
|
+
import {registerInternalPlugin} from '@webex/webex-core';
|
|
9
|
+
|
|
10
|
+
import Avatar from './avatar';
|
|
11
|
+
import config from './config';
|
|
12
|
+
|
|
13
|
+
registerInternalPlugin('avatar', Avatar, {
|
|
14
|
+
config,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export {default} from './avatar';
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-avatar';
|
|
6
|
-
|
|
7
|
-
// import {assert} from '@webex/test-helper-chai';
|
|
8
|
-
// import sinon from 'sinon';
|
|
9
|
-
import fh from '@webex/test-helper-file';
|
|
10
|
-
import WebexCore from '@webex/webex-core';
|
|
11
|
-
import testUsers from '@webex/test-helper-test-users';
|
|
12
|
-
|
|
13
|
-
describe('plugin-avatar', () => {
|
|
14
|
-
let mccoy, webex, spock;
|
|
15
|
-
|
|
16
|
-
before('create users', () =>
|
|
17
|
-
testUsers.create({count: 2}).then((users) => {
|
|
18
|
-
[spock, mccoy] = users;
|
|
19
|
-
|
|
20
|
-
webex = new WebexCore({
|
|
21
|
-
credentials: {
|
|
22
|
-
authorization: spock.token,
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
mccoy.webex = new WebexCore({
|
|
27
|
-
credentials: {
|
|
28
|
-
authorization: mccoy.token,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
before('register with wdm', () =>
|
|
35
|
-
Promise.all([webex.internal.device.register(), mccoy.webex.internal.device.register()])
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
let sampleImageSmallOnePng = 'sample-image-small-one.png';
|
|
39
|
-
|
|
40
|
-
before(() =>
|
|
41
|
-
fh.fetch(sampleImageSmallOnePng).then((file) => {
|
|
42
|
-
sampleImageSmallOnePng = file;
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
// describe('#setAvatar()', () => {
|
|
47
|
-
// it('sets a user\'s avatar', () => webex.internal.avatar.setAvatar(sampleImageSmallOnePng)
|
|
48
|
-
// .then((avatarUrl) => {
|
|
49
|
-
// // Note: not downloading the avatar because rackspace CDN is too flaky
|
|
50
|
-
// assert.isDefined(avatarUrl);
|
|
51
|
-
// assert.match(avatarUrl, /^https?:\/\//);
|
|
52
|
-
// }));
|
|
53
|
-
//
|
|
54
|
-
// it('invalidates current user`s cached avatar after uploading a new one', () => {
|
|
55
|
-
// webex.internal.avatar.store.remove = sinon.spy();
|
|
56
|
-
// return webex.internal.avatar.setAvatar(sampleImageSmallOnePng)
|
|
57
|
-
// .then(() => assert.calledWith(webex.internal.avatar.store.remove, {uuid: webex.internal.device.userId}));
|
|
58
|
-
// });
|
|
59
|
-
// });
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
// describe('#retrieveAvatarUrl()', () => {
|
|
63
|
-
// before(() => Promise.all([
|
|
64
|
-
// webex.internal.avatar.setAvatar(sampleImageSmallOnePng),
|
|
65
|
-
// mccoy.webex.internal.avatar.setAvatar(sampleImageSmallOnePng)
|
|
66
|
-
// ]));
|
|
67
|
-
//
|
|
68
|
-
// it('retrieves an avatar url by email address', () => webex.internal.avatar.retrieveAvatarUrl(spock.email)
|
|
69
|
-
// .then((avatarUrl) => {
|
|
70
|
-
// // Note: not downloading the avatar because rackspace CDN is too flaky
|
|
71
|
-
// assert.isDefined(avatarUrl);
|
|
72
|
-
// assert.match(avatarUrl, /^https?:\/\//);
|
|
73
|
-
// }));
|
|
74
|
-
//
|
|
75
|
-
// it('retrieves an avatar url by uuid', () => webex.internal.avatar.retrieveAvatarUrl(mccoy.webex.internal.device.userId)
|
|
76
|
-
// .then((avatarUrl) => {
|
|
77
|
-
// // Note: not downloading the avatar because rackspace CDN is too flaky
|
|
78
|
-
// assert.isDefined(avatarUrl);
|
|
79
|
-
// assert.match(avatarUrl, /^https?:\/\//);
|
|
80
|
-
// }));
|
|
81
|
-
// });
|
|
82
|
-
});
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@webex/internal-plugin-avatar';
|
|
6
|
+
|
|
7
|
+
// import {assert} from '@webex/test-helper-chai';
|
|
8
|
+
// import sinon from 'sinon';
|
|
9
|
+
import fh from '@webex/test-helper-file';
|
|
10
|
+
import WebexCore from '@webex/webex-core';
|
|
11
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
12
|
+
|
|
13
|
+
describe('plugin-avatar', () => {
|
|
14
|
+
let mccoy, webex, spock;
|
|
15
|
+
|
|
16
|
+
before('create users', () =>
|
|
17
|
+
testUsers.create({count: 2}).then((users) => {
|
|
18
|
+
[spock, mccoy] = users;
|
|
19
|
+
|
|
20
|
+
webex = new WebexCore({
|
|
21
|
+
credentials: {
|
|
22
|
+
authorization: spock.token,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
mccoy.webex = new WebexCore({
|
|
27
|
+
credentials: {
|
|
28
|
+
authorization: mccoy.token,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
before('register with wdm', () =>
|
|
35
|
+
Promise.all([webex.internal.device.register(), mccoy.webex.internal.device.register()])
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
let sampleImageSmallOnePng = 'sample-image-small-one.png';
|
|
39
|
+
|
|
40
|
+
before(() =>
|
|
41
|
+
fh.fetch(sampleImageSmallOnePng).then((file) => {
|
|
42
|
+
sampleImageSmallOnePng = file;
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// describe('#setAvatar()', () => {
|
|
47
|
+
// it('sets a user\'s avatar', () => webex.internal.avatar.setAvatar(sampleImageSmallOnePng)
|
|
48
|
+
// .then((avatarUrl) => {
|
|
49
|
+
// // Note: not downloading the avatar because rackspace CDN is too flaky
|
|
50
|
+
// assert.isDefined(avatarUrl);
|
|
51
|
+
// assert.match(avatarUrl, /^https?:\/\//);
|
|
52
|
+
// }));
|
|
53
|
+
//
|
|
54
|
+
// it('invalidates current user`s cached avatar after uploading a new one', () => {
|
|
55
|
+
// webex.internal.avatar.store.remove = sinon.spy();
|
|
56
|
+
// return webex.internal.avatar.setAvatar(sampleImageSmallOnePng)
|
|
57
|
+
// .then(() => assert.calledWith(webex.internal.avatar.store.remove, {uuid: webex.internal.device.userId}));
|
|
58
|
+
// });
|
|
59
|
+
// });
|
|
60
|
+
//
|
|
61
|
+
//
|
|
62
|
+
// describe('#retrieveAvatarUrl()', () => {
|
|
63
|
+
// before(() => Promise.all([
|
|
64
|
+
// webex.internal.avatar.setAvatar(sampleImageSmallOnePng),
|
|
65
|
+
// mccoy.webex.internal.avatar.setAvatar(sampleImageSmallOnePng)
|
|
66
|
+
// ]));
|
|
67
|
+
//
|
|
68
|
+
// it('retrieves an avatar url by email address', () => webex.internal.avatar.retrieveAvatarUrl(spock.email)
|
|
69
|
+
// .then((avatarUrl) => {
|
|
70
|
+
// // Note: not downloading the avatar because rackspace CDN is too flaky
|
|
71
|
+
// assert.isDefined(avatarUrl);
|
|
72
|
+
// assert.match(avatarUrl, /^https?:\/\//);
|
|
73
|
+
// }));
|
|
74
|
+
//
|
|
75
|
+
// it('retrieves an avatar url by uuid', () => webex.internal.avatar.retrieveAvatarUrl(mccoy.webex.internal.device.userId)
|
|
76
|
+
// .then((avatarUrl) => {
|
|
77
|
+
// // Note: not downloading the avatar because rackspace CDN is too flaky
|
|
78
|
+
// assert.isDefined(avatarUrl);
|
|
79
|
+
// assert.match(avatarUrl, /^https?:\/\//);
|
|
80
|
+
// }));
|
|
81
|
+
// });
|
|
82
|
+
});
|