Skip to content

Commit 3699699

Browse files
authored
fix(VideoPlayer): fix for mocking VideoPlayerAPI in storyshots (#2692)
The CI checks were running with obfuscated Kaltura IDs since they are passed in as environment variables, so this is setting up a mock for the VideoPlayerAPI service to return back mocked data instead.
1 parent 969da0e commit 3699699

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright IBM Corp. 2020
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import mocklist from '../../../src/components/Footer/__data__/locale-list';
9+
10+
module.exports = {
11+
getLocale: jest.fn(() => Promise.resolve({ cc: 'us', lc: 'en' })),
12+
getList: jest.fn(() => Promise.resolve(mocklist)),
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright IBM Corp. 2020
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import apiResponse from '../../../../services/src/services/VideoPlayer/__tests__/data/response.json';
9+
10+
module.exports = {
11+
getThumbnailUrl: jest.fn(() => {
12+
return 'https://cdnsecakmi.kaltura.com/p/123456/thumbnail/entry_id/0_uka1msg4/width/320';
13+
}),
14+
api: jest.fn(() => Promise.resolve(apiResponse)),
15+
getVideoDuration: jest.fn(() => {
16+
return '(1:00)';
17+
}),
18+
fireEvent: jest.fn(() => {}),
19+
embedVideo: jest.fn(() => Promise.resolve()),
20+
};

packages/react/config/jest/setup.js

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ global.window.location = {
2222
href: 'http://localhost',
2323
};
2424

25+
jest.mock('@carbon/ibmdotcom-services', () => ({
26+
LocaleAPI: require('./__mocks__/LocaleAPI'),
27+
VideoPlayerAPI: require('./__mocks__/VideoPlayerAPI'),
28+
globalInit: jest.fn(() => {}),
29+
}));
30+
2531
const enzyme = require.requireActual('enzyme');
2632
const Adapter = require.requireActual('enzyme-adapter-react-16');
2733

packages/react/src/__tests__/__snapshots__/storyshots.test.js.snap

+3-2
Original file line numberDiff line numberDiff line change
@@ -5082,7 +5082,7 @@ exports[`Storyshots Components|LightboxMediaViewer Embedded Video Player 1`] = `
50825082
videoId="0_uka1msg4"
50835083
>
50845084
<div
5085-
aria-label="undefined undefined"
5085+
aria-label=" (1:00)"
50865086
className="bx--video-player"
50875087
>
50885088
<div
@@ -12199,7 +12199,7 @@ exports[`Storyshots Components|VideoPlayer Default 1`] = `
1219912199
videoId="0_uka1msg4"
1220012200
>
1220112201
<div
12202-
aria-label="undefined undefined"
12202+
aria-label=" (1:00)"
1220312203
className="bx--video-player"
1220412204
>
1220512205
<div
@@ -12215,6 +12215,7 @@ exports[`Storyshots Components|VideoPlayer Default 1`] = `
1221512215
className="bx--video-player__video-caption"
1221612216
>
1221712217

12218+
(1:00)
1221812219
</div>
1221912220
</div>
1222012221
</VideoPlayer>

packages/react/src/components/VideoPlayer/VideoPlayer.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const { prefix } = settings;
1919
* VideoPlayer component.
2020
*/
2121
const VideoPlayer = ({ inverse, showCaption, videoId, customClassName }) => {
22-
const [videoData, setVideoData] = useState({ description: '' });
22+
const [videoData, setVideoData] = useState({ description: '', name: '' });
2323
const videoPlayerId = `video-player__video-${videoId}`;
2424
const videoDuration = VideoPlayerAPI.getVideoDuration(videoData.msDuration);
2525

@@ -56,7 +56,8 @@ const VideoPlayer = ({ inverse, showCaption, videoId, customClassName }) => {
5656
data-autoid={`${stablePrefix}--${videoPlayerId}`}>
5757
<div
5858
className={`${prefix}--video-player__video`}
59-
id={`${prefix}--${videoPlayerId}`}></div>
59+
id={`${prefix}--${videoPlayerId}`}
60+
/>
6061
</div>
6162
{showCaption && (
6263
<div className={`${prefix}--video-player__video-caption`}>

packages/utilities/src/utilities/smoothScroll/smoothScroll.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const smoothScroll = (e, selector, offset = 0) => {
2727
if (e !== null) {
2828
e.preventDefault();
2929
getSelector = e.currentTarget.getAttribute('href');
30-
console.log('getSelector', getSelector);
3130
} else if (selector) {
3231
getSelector = selector;
3332
} else {

0 commit comments

Comments
 (0)