cloudinary-video-player 1.6.2-edge.13
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/.eslintignore +4 -0
- package/.snyk +19 -0
- package/.travis.yml +8 -0
- package/CHANGELOG.md +329 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/cld-video-player.css +2110 -0
- package/dist/cld-video-player.js +5249 -0
- package/dist/cld-video-player.light.css +1766 -0
- package/dist/cld-video-player.light.js +1399 -0
- package/dist/cld-video-player.light.min.css +1 -0
- package/dist/cld-video-player.light.min.js +2 -0
- package/dist/cld-video-player.light.min.js.LICENSE.txt +23 -0
- package/dist/cld-video-player.min.css +1 -0
- package/dist/cld-video-player.min.js +2 -0
- package/dist/cld-video-player.min.js.LICENSE.txt +26 -0
- package/dist/fonts/cloudinary_icon_for_black_bg.svg +69 -0
- package/dist/fonts/cloudinary_icon_for_white_bg.svg +69 -0
- package/docs/360.html +102 -0
- package/docs/_template.html +93 -0
- package/docs/adaptive-streaming.html +297 -0
- package/docs/analytics.html +140 -0
- package/docs/api.html +302 -0
- package/docs/audio.html +136 -0
- package/docs/autoplay-fallback.html +138 -0
- package/docs/autoplay-on-scroll.html +107 -0
- package/docs/codec-fallback.html +158 -0
- package/docs/colors.html +135 -0
- package/docs/components.html +284 -0
- package/docs/custom-cld-errors.html +134 -0
- package/docs/floating-player.html +98 -0
- package/docs/fluid.html +117 -0
- package/docs/force-hls-subtitles-ios.html +159 -0
- package/docs/index.html +83 -0
- package/docs/interaction-area.html +398 -0
- package/docs/live-customer.html +128 -0
- package/docs/multiple-players.html +125 -0
- package/docs/playlist-by-tag-cap.html +182 -0
- package/docs/playlist-by-tag.html +133 -0
- package/docs/playlist.html +133 -0
- package/docs/poster.html +155 -0
- package/docs/raw-url.html +104 -0
- package/docs/recommendations.html +155 -0
- package/docs/scripts.js +156 -0
- package/docs/seek-thumbs.html +90 -0
- package/docs/shoppable.html +335 -0
- package/docs/subtitles-and-captions.html +267 -0
- package/docs/transformations.html +171 -0
- package/docs/ui-config.html +108 -0
- package/docs/vast-vpaid.html +149 -0
- package/env.example.js +6 -0
- package/env.js +6 -0
- package/jest-puppeteer.config.js +14 -0
- package/jest.config.js +196 -0
- package/package.json +99 -0
- package/sandbox.config.json +3 -0
- package/setupJest.js +1 -0
- package/src/assets/fonts/VideoJS.svg +120 -0
- package/src/assets/fonts/VideoJS.ttf +0 -0
- package/src/assets/fonts/VideoJS.woff +0 -0
- package/src/assets/fonts/icons.json +120 -0
- package/src/assets/icons/cloudinary_icon_for_black_bg.svg +69 -0
- package/src/assets/icons/cloudinary_icon_for_white_bg.svg +69 -0
- package/src/assets/icons/cloudinary_logo_for_dark_bg.svg +188 -0
- package/src/assets/icons/cloudinary_logo_for_white_bg.svg +188 -0
- package/src/assets/icons/info-circle.svg +17 -0
- package/src/assets/styles/ads-label.scss +16 -0
- package/src/assets/styles/components/interaction-areas.scss +158 -0
- package/src/assets/styles/components/playlist.scss +213 -0
- package/src/assets/styles/components/themedButton.scss +48 -0
- package/src/assets/styles/components/thumbnail.scss +94 -0
- package/src/assets/styles/components/title-bar.scss +67 -0
- package/src/assets/styles/components/triangle-volume-bar.scss +52 -0
- package/src/assets/styles/icons.scss +257 -0
- package/src/assets/styles/main.scss +324 -0
- package/src/assets/styles/mixins/aspect-ratio.scss +16 -0
- package/src/assets/styles/mixins/disable-transition.scss +3 -0
- package/src/assets/styles/mixins/mixins.scss +5 -0
- package/src/assets/styles/mixins/skin.scss +64 -0
- package/src/assets/styles/variables.scss +2 -0
- package/src/assets/styles/videojs-ima.scss +252 -0
- package/src/components/component-utils.js +20 -0
- package/src/components/index.js +21 -0
- package/src/components/interaction-area/interaction-area.const.js +30 -0
- package/src/components/interaction-area/interaction-area.service.js +223 -0
- package/src/components/interaction-area/interaction-area.utils.js +236 -0
- package/src/components/jumpButtons/jump-10-minus.js +21 -0
- package/src/components/jumpButtons/jump-10-plus.js +20 -0
- package/src/components/logoButton/logo-button.const.js +3 -0
- package/src/components/logoButton/logo-button.js +30 -0
- package/src/components/logoButton/logo-button.scss +15 -0
- package/src/components/playlist/components/playlist-button.js +34 -0
- package/src/components/playlist/components/playlist-next-button.js +18 -0
- package/src/components/playlist/components/playlist-previous-button.js +18 -0
- package/src/components/playlist/components/playlist.js +5 -0
- package/src/components/playlist/components/playlist.scss +15 -0
- package/src/components/playlist/components/upcoming-video-overlay.js +149 -0
- package/src/components/playlist/components/upcoming-video-overlay.scss +86 -0
- package/src/components/playlist/layout/playlist-layout-custom.js +21 -0
- package/src/components/playlist/layout/playlist-layout-horizontal.js +16 -0
- package/src/components/playlist/layout/playlist-layout-vertical.js +19 -0
- package/src/components/playlist/layout/playlist-layout.js +110 -0
- package/src/components/playlist/panel/playlist-panel-item.js +86 -0
- package/src/components/playlist/panel/playlist-panel.js +92 -0
- package/src/components/playlist/playlist-widget.js +119 -0
- package/src/components/playlist/playlist.const.js +14 -0
- package/src/components/playlist/playlist.js +413 -0
- package/src/components/playlist/thumbnail/thumbnail.js +69 -0
- package/src/components/progress-control-events-blocker/progress-control-events-blocker.js +17 -0
- package/src/components/qualitySelector/quality-selector.scss +10 -0
- package/src/components/qualitySelector/qualitySelector.js +152 -0
- package/src/components/recommendations-overlay/index.js +3 -0
- package/src/components/recommendations-overlay/recommendations-overlay-content.js +57 -0
- package/src/components/recommendations-overlay/recommendations-overlay-hide-button.js +18 -0
- package/src/components/recommendations-overlay/recommendations-overlay-item.js +35 -0
- package/src/components/recommendations-overlay/recommendations-overlay-primary-item.js +81 -0
- package/src/components/recommendations-overlay/recommendations-overlay-secondary-item.js +48 -0
- package/src/components/recommendations-overlay/recommendations-overlay-secondary-items-container.js +35 -0
- package/src/components/recommendations-overlay/recommendations-overlay.js +94 -0
- package/src/components/recommendations-overlay/recommendations-overlay.scss +182 -0
- package/src/components/shoppable-bar/layout/bar-layout.js +111 -0
- package/src/components/shoppable-bar/layout/shoppable-panel-toggle.js +64 -0
- package/src/components/shoppable-bar/layout/shoppable-products-overlay.js +87 -0
- package/src/components/shoppable-bar/panel/shoppable-panel-item.js +105 -0
- package/src/components/shoppable-bar/panel/shoppable-panel.js +172 -0
- package/src/components/shoppable-bar/shoppable-post-widget.js +110 -0
- package/src/components/shoppable-bar/shoppable-widget.const.js +52 -0
- package/src/components/shoppable-bar/shoppable-widget.js +111 -0
- package/src/components/shoppable-bar/shoppable-widget.scss +359 -0
- package/src/components/themeButton/themedButton.const.js +3 -0
- package/src/components/themeButton/themedButton.js +25 -0
- package/src/components/title-bar/title-bar.js +79 -0
- package/src/config/defaults.js +25 -0
- package/src/extended-events.js +228 -0
- package/src/index.js +18 -0
- package/src/mixins/eventable.js +54 -0
- package/src/mixins/playlistable.js +106 -0
- package/src/plugins/analytics/index.js +245 -0
- package/src/plugins/autoplay-on-scroll/index.js +86 -0
- package/src/plugins/cloudinary/common.js +216 -0
- package/src/plugins/cloudinary/event-handler-registry.js +46 -0
- package/src/plugins/cloudinary/index.js +345 -0
- package/src/plugins/cloudinary/models/audio-source/audio-source.const.js +11 -0
- package/src/plugins/cloudinary/models/audio-source/audio-source.js +82 -0
- package/src/plugins/cloudinary/models/base-source.js +107 -0
- package/src/plugins/cloudinary/models/image-source.js +26 -0
- package/src/plugins/cloudinary/models/video-source/video-source.const.js +32 -0
- package/src/plugins/cloudinary/models/video-source/video-source.js +239 -0
- package/src/plugins/cloudinary/models/video-source/video-source.utils.js +57 -0
- package/src/plugins/colors/index.js +303 -0
- package/src/plugins/context-menu/components/context-menu-item.js +12 -0
- package/src/plugins/context-menu/components/context-menu.js +63 -0
- package/src/plugins/context-menu/context-menu.scss +30 -0
- package/src/plugins/context-menu/contextMenuContent.js +53 -0
- package/src/plugins/context-menu/index.js +134 -0
- package/src/plugins/dash/index.js +26 -0
- package/src/plugins/dash/setup-audio-tracks.js +112 -0
- package/src/plugins/dash/setup-text-tracks.js +195 -0
- package/src/plugins/dash/videojs-dash.js +372 -0
- package/src/plugins/floating-player/floating-player.scss +74 -0
- package/src/plugins/floating-player/index.js +129 -0
- package/src/plugins/ima/index.js +1775 -0
- package/src/plugins/index.js +31 -0
- package/src/plugins/interactive-plugin/index.js +10 -0
- package/src/plugins/videojs-http-source-selector/components/SourceMenuButton.js +98 -0
- package/src/plugins/videojs-http-source-selector/components/SourceMenuItem.js +52 -0
- package/src/plugins/videojs-http-source-selector/plugin.js +82 -0
- package/src/plugins/videojs-http-source-selector/plugin.scss +9 -0
- package/src/plugins/vtt-thumbnails/index.js +526 -0
- package/src/plugins/vtt-thumbnails/vtt-thumbnails.scss +29 -0
- package/src/utils/api.js +32 -0
- package/src/utils/apply-with-props.js +32 -0
- package/src/utils/array.js +22 -0
- package/src/utils/assign.js +27 -0
- package/src/utils/attributes-normalizer.js +72 -0
- package/src/utils/cloudinary.js +165 -0
- package/src/utils/css-prefix.js +43 -0
- package/src/utils/dom.js +74 -0
- package/src/utils/find.js +28 -0
- package/src/utils/fontFace.js +25 -0
- package/src/utils/groupBy.js +12 -0
- package/src/utils/index.js +29 -0
- package/src/utils/matches.js +11 -0
- package/src/utils/mixin.js +5 -0
- package/src/utils/object.js +26 -0
- package/src/utils/playButton.js +9 -0
- package/src/utils/positioning.js +78 -0
- package/src/utils/querystring.js +12 -0
- package/src/utils/slicing.js +21 -0
- package/src/utils/string.js +15 -0
- package/src/utils/throttle.js +30 -0
- package/src/utils/time.js +77 -0
- package/src/utils/type-inference.js +35 -0
- package/src/validators/validators-functions.js +48 -0
- package/src/validators/validators-types.js +78 -0
- package/src/validators/validators.js +110 -0
- package/src/video-player.const.js +68 -0
- package/src/video-player.js +761 -0
- package/src/video-player.utils.js +123 -0
- package/test/adaptive-streaming.test.js +38 -0
- package/test/ads.test.js +35 -0
- package/test/analytics.test.js +111 -0
- package/test/api.test.js +111 -0
- package/test/autoplay.scroll.test.js +23 -0
- package/test/basic-ui.test.js +59 -0
- package/test/colors.test.js +58 -0
- package/test/components.test.js +21 -0
- package/test/custom-error.test.js +24 -0
- package/test/fluid.test.js +36 -0
- package/test/isValidConfig.test.js +224 -0
- package/test/mocks/cloudinary-core-mock.js +0 -0
- package/test/mocks/styleMock.js +1 -0
- package/test/multiplayer.test.js +25 -0
- package/test/playlist.test.js +60 -0
- package/test/puppeteer/vp-env.js +19 -0
- package/test/recommendations.test.js +38 -0
- package/test/title-bar.test.js +28 -0
- package/test/ui-conf.test.js +49 -0
- package/test/unit/cloudinaryConfig.test.js +22 -0
- package/test/unit/cloudinaryUtils.test.js +53 -0
- package/test/unit/utils.test.js +27 -0
- package/test/unit/videoSource.test.js +454 -0
- package/tsconfig.json +15 -0
- package/types/video-player-tests.js +12 -0
- package/types/video-player-tests.ts +31 -0
- package/types/video-player.d.ts +570 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
import Utils from './utils';
|
|
3
|
+
import defaults from './config/defaults';
|
|
4
|
+
import {
|
|
5
|
+
CLOUDINARY_PARAMS,
|
|
6
|
+
DEFAULT_HLS_OPTIONS,
|
|
7
|
+
PLAYER_PARAMS,
|
|
8
|
+
FLUID_CLASS_NAME,
|
|
9
|
+
AUTO_PLAY_MODE
|
|
10
|
+
} from './video-player.const';
|
|
11
|
+
import { isString } from './utils/type-inference';
|
|
12
|
+
|
|
13
|
+
export const addMetadataTrack = (videoJs, vttSource) => {
|
|
14
|
+
return videoJs.addRemoteTextTrack({
|
|
15
|
+
kind: 'metadata',
|
|
16
|
+
srclang: 'en',
|
|
17
|
+
src: vttSource,
|
|
18
|
+
default: true
|
|
19
|
+
}, true).track;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const isLight = (opts) => {
|
|
23
|
+
return opts.class.indexOf('cld-video-player-skin-light') > -1 || opts.skin === 'light';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getResolveVideoElement = (elem) => {
|
|
27
|
+
if (isString(elem)) {
|
|
28
|
+
let id = elem;
|
|
29
|
+
|
|
30
|
+
// Adjust for jQuery ID syntax
|
|
31
|
+
if (id.indexOf('#') === 0) {
|
|
32
|
+
id = id.slice(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
elem = document.querySelector(`#${id}`) || videojs.getPlayer(id);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
elem = null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!elem) {
|
|
42
|
+
throw new Error(`Could not find element with id ${id}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!elem.tagName) {
|
|
47
|
+
throw new Error('Must specify either an element or an element id.');
|
|
48
|
+
} else if (elem.tagName !== 'VIDEO') {
|
|
49
|
+
throw new Error('Element is not a video tag.');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return elem;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export const normalizeAutoplay = (options) => {
|
|
57
|
+
const autoplayMode = options.autoplayMode;
|
|
58
|
+
if (autoplayMode) {
|
|
59
|
+
switch (autoplayMode) {
|
|
60
|
+
case AUTO_PLAY_MODE.ALWAYS:
|
|
61
|
+
options.autoplay = true;
|
|
62
|
+
break;
|
|
63
|
+
case AUTO_PLAY_MODE.ON_SCROLL:
|
|
64
|
+
case AUTO_PLAY_MODE.NEVER:
|
|
65
|
+
default:
|
|
66
|
+
options.autoplay = false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const extractOptions = (elem, options) => {
|
|
72
|
+
const elemOptions = Utils.normalizeAttributes(elem);
|
|
73
|
+
|
|
74
|
+
if (videojs.dom.hasClass(elem, FLUID_CLASS_NAME) || videojs.dom.hasClass(elem, 'vjs-fluid')) {
|
|
75
|
+
options.fluid = true;
|
|
76
|
+
}
|
|
77
|
+
// Default HLS options < Default options < Markup options < Player options
|
|
78
|
+
options = Utils.assign({}, DEFAULT_HLS_OPTIONS, defaults, elemOptions, options);
|
|
79
|
+
|
|
80
|
+
// In case of 'autoplay on scroll', we need to make sure normal HTML5 autoplay is off
|
|
81
|
+
normalizeAutoplay(options);
|
|
82
|
+
|
|
83
|
+
// VideoPlayer specific options
|
|
84
|
+
const playerOptions = Utils.sliceAndUnsetProperties(options, ...PLAYER_PARAMS);
|
|
85
|
+
|
|
86
|
+
// Cloudinary plugin specific options
|
|
87
|
+
playerOptions.cloudinary = Utils.sliceAndUnsetProperties(playerOptions, ...CLOUDINARY_PARAMS);
|
|
88
|
+
|
|
89
|
+
// Allow explicitly passing options to videojs using the `videojs` namespace, in order
|
|
90
|
+
// to avoid param name conflicts:
|
|
91
|
+
// VideoPlayer.new({ controls: true, videojs: { controls: false })
|
|
92
|
+
if (options.videojs) {
|
|
93
|
+
Utils.assign(options, options.videojs);
|
|
94
|
+
delete options.videojs;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return { playerOptions, videojsOptions: options };
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const overrideDefaultVideojsComponents = () => {
|
|
101
|
+
const Player = videojs.getComponent('Player');
|
|
102
|
+
let children = Player.prototype.options_.children;
|
|
103
|
+
|
|
104
|
+
// Add TitleBar as default
|
|
105
|
+
children.push('titleBar');
|
|
106
|
+
children.push('upcomingVideoOverlay');
|
|
107
|
+
children.push('recommendationsOverlay');
|
|
108
|
+
|
|
109
|
+
const ControlBar = videojs.getComponent('ControlBar');
|
|
110
|
+
|
|
111
|
+
if (ControlBar) {
|
|
112
|
+
children = ControlBar.prototype.options_.children;
|
|
113
|
+
// Add space instead of the progress control (which we deattached from the controlBar, and absolutely positioned it above it)
|
|
114
|
+
// Also add a blank div underneath the progress control to stop bubbling up pointer events.
|
|
115
|
+
children.splice(children.indexOf('progressControl'), 0, 'spacer', 'progressControlEventsBlocker');
|
|
116
|
+
|
|
117
|
+
// Add 'play-previous' and 'play-next' buttons around the 'play-toggle'
|
|
118
|
+
children.splice(children.indexOf('playToggle'), 1, 'playlistPreviousButton', 'JumpBackButton', 'playToggle', 'JumpForwardButton', 'playlistNextButton');
|
|
119
|
+
|
|
120
|
+
// Position the 'logo-button' button right next to 'fullscreenToggle'
|
|
121
|
+
children.splice(children.indexOf('fullscreenToggle'), 1, 'logoButton', 'fullscreenToggle');
|
|
122
|
+
}
|
|
123
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
describe('Adaptive streaming tests', () => {
|
|
2
|
+
beforeAll(async () => {
|
|
3
|
+
jest.setTimeout(35000);
|
|
4
|
+
await page.setViewport({ width: 1280, height: 800 });
|
|
5
|
+
await page.goto('http://localhost:3000/docs/adaptive-streaming.html', { waitUntil: 'load' });
|
|
6
|
+
await page.evaluate(() => {
|
|
7
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
8
|
+
get: function () {
|
|
9
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
10
|
+
this.readyState > 2);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}, 10000);
|
|
15
|
+
it('Should not throw an error when setting new hls source', async () => {
|
|
16
|
+
jest.setTimeout(35000);
|
|
17
|
+
await page.waitFor(1000);
|
|
18
|
+
|
|
19
|
+
// async function not working without being put inside a template string,
|
|
20
|
+
// See https://github.com/puppeteer/puppeteer/issues/1665
|
|
21
|
+
const error = await page.evaluate(`(async () => {
|
|
22
|
+
let error = null;
|
|
23
|
+
|
|
24
|
+
// Get any error into error variable
|
|
25
|
+
playerHls.on('error', (e) => (error = e.Player.videojs.error()));
|
|
26
|
+
|
|
27
|
+
// Set new hls source
|
|
28
|
+
playerHls.source('snow_horses', {sourceTypes: ['hls'], transformation: { streaming_profile: 'hd' }});
|
|
29
|
+
|
|
30
|
+
// wait a second for error event
|
|
31
|
+
await new Promise(resolve=>setTimeout(resolve, 1000));
|
|
32
|
+
|
|
33
|
+
// Return null or an error object
|
|
34
|
+
return JSON.stringify(error);
|
|
35
|
+
})()`);
|
|
36
|
+
expect(JSON.parse(error)).toEqual(null); // expect no error
|
|
37
|
+
});
|
|
38
|
+
});
|
package/test/ads.test.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
describe('Ads tests', () => {
|
|
2
|
+
|
|
3
|
+
beforeEach(async () => {
|
|
4
|
+
await page.setViewport({ width: 1280, height: 800 });
|
|
5
|
+
await page.goto('http://localhost:3000/vast-vpaid.html', { waitUntil: 'load' });
|
|
6
|
+
await page.evaluate(() => {
|
|
7
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
8
|
+
get: function () {
|
|
9
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
10
|
+
this.readyState > 2);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
await page.evaluate(() => (window.ev = []));
|
|
16
|
+
await page.evaluate(() => player.on('readyforpreroll', () => {
|
|
17
|
+
window.ev.push('preroll');
|
|
18
|
+
}));
|
|
19
|
+
await page.evaluate(() => player.on('readyforpostroll', () => {
|
|
20
|
+
window.ev.push('postroll');
|
|
21
|
+
}));
|
|
22
|
+
}, 10000);
|
|
23
|
+
|
|
24
|
+
it('event test', async () => {
|
|
25
|
+
jest.setTimeout(65000);
|
|
26
|
+
await page.waitForSelector('#player_ima-ad-container', {visible: true});
|
|
27
|
+
await page.waitFor(1000);
|
|
28
|
+
const duration = await page.evaluate(() => player.duration());
|
|
29
|
+
await page.waitFor(duration * 1000 + 1000);
|
|
30
|
+
const events = await page.evaluate(() => window.ev);
|
|
31
|
+
expect(events.includes('preroll')).toEqual(true);
|
|
32
|
+
expect(events.includes('postroll')).toEqual(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const RequestInterceptor = require('puppeteer-request-spy').RequestInterceptor;
|
|
2
|
+
const RequestSpy = require('puppeteer-request-spy').RequestSpy;
|
|
3
|
+
const URL = require('url').URL;
|
|
4
|
+
|
|
5
|
+
describe('Analytics tests', () => {
|
|
6
|
+
let paramInterceptor = null;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
// parameter Interceptor
|
|
10
|
+
paramInterceptor = new RequestInterceptor((testee, keyword) => {
|
|
11
|
+
const urlObj = new URL(testee);
|
|
12
|
+
return urlObj.searchParams.get('ea') === keyword;
|
|
13
|
+
});
|
|
14
|
+
await page.setRequestInterception(true);
|
|
15
|
+
await page.setViewport({ width: 1280, height: 1800 });
|
|
16
|
+
}, 35000);
|
|
17
|
+
|
|
18
|
+
it('Analytics requests', async () => {
|
|
19
|
+
jest.setTimeout(35000);
|
|
20
|
+
const requestInterceptor = new RequestInterceptor((testee, keyword) => testee.startsWith(keyword));
|
|
21
|
+
const reqSpy = new RequestSpy('https://www.google-analytics.com/collect');
|
|
22
|
+
requestInterceptor.addSpy(reqSpy);
|
|
23
|
+
await page.on('request', requestInterceptor.intercept.bind(requestInterceptor));
|
|
24
|
+
await page.goto('http://localhost:3000/analytics.html', { waitUntil: 'load' });
|
|
25
|
+
await page.waitFor(1000);
|
|
26
|
+
expect(reqSpy.hasMatch()).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('Test pause event', async () => {
|
|
30
|
+
jest.setTimeout(35000);
|
|
31
|
+
const puseSpy = new RequestSpy('Pause');
|
|
32
|
+
paramInterceptor.addSpy(puseSpy);
|
|
33
|
+
await page.on('request', paramInterceptor.intercept.bind(paramInterceptor));
|
|
34
|
+
await page.goto('http://localhost:3000/analytics.html', { waitUntil: 'load' });
|
|
35
|
+
await page.waitFor(1000);
|
|
36
|
+
await page.click('#player > div.vjs-control-bar > button.vjs-play-control');
|
|
37
|
+
expect(puseSpy.hasMatch()).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('Test play event', async () => {
|
|
41
|
+
jest.setTimeout(35000);
|
|
42
|
+
const playSpy = new RequestSpy('Play');
|
|
43
|
+
paramInterceptor.addSpy(playSpy);
|
|
44
|
+
await page.on('request', paramInterceptor.intercept.bind(paramInterceptor));
|
|
45
|
+
await page.goto('http://localhost:3000/analytics.html', { waitUntil: 'load' });
|
|
46
|
+
await page.waitFor(1000);
|
|
47
|
+
await page.click('#player > div.vjs-control-bar > button.vjs-play-control');
|
|
48
|
+
await page.waitFor(500);
|
|
49
|
+
await page.click('#player > div.vjs-control-bar > button.vjs-play-control');
|
|
50
|
+
expect(playSpy.getMatchCount()).toBe(2);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('Test volume event', async () => {
|
|
54
|
+
jest.setTimeout(35000);
|
|
55
|
+
const spy = new RequestSpy('Volume Change');
|
|
56
|
+
paramInterceptor.addSpy(spy);
|
|
57
|
+
await page.on('request', paramInterceptor.intercept.bind(paramInterceptor));
|
|
58
|
+
await page.goto('http://localhost:3000/analytics.html', { waitUntil: 'load' });
|
|
59
|
+
await page.waitFor(1000);
|
|
60
|
+
await page.click('#player > .vjs-control-bar > .vjs-volume-panel.vjs-control.vjs-volume-panel-horizontal > button');
|
|
61
|
+
expect(spy.hasMatch()).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('Test percentage event', async () => {
|
|
65
|
+
jest.setTimeout(60000);
|
|
66
|
+
let fussyParamInterceptor = new RequestInterceptor((testee, keyword) => {
|
|
67
|
+
let urlObj = new URL(testee);
|
|
68
|
+
const event = urlObj.searchParams.get('ea');
|
|
69
|
+
return event !== null && event.includes(keyword);
|
|
70
|
+
});
|
|
71
|
+
const spy = new RequestSpy('Percents Played');
|
|
72
|
+
fussyParamInterceptor.addSpy(spy);
|
|
73
|
+
await page.on('request', fussyParamInterceptor.intercept.bind(fussyParamInterceptor));
|
|
74
|
+
await page.goto('http://localhost:3000/analytics.html', { waitUntil: 'load' });
|
|
75
|
+
await page.waitFor(1000);
|
|
76
|
+
const duration = await page.evaluate(() => player.duration());
|
|
77
|
+
await page.waitFor(duration * 1000 + 1000);
|
|
78
|
+
expect(spy.getMatchCount()).toBe(4);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('Test seek', async () => {
|
|
82
|
+
|
|
83
|
+
jest.setTimeout(35000);
|
|
84
|
+
const fussyParamInterceptor = new RequestInterceptor((testee, keyword) => {
|
|
85
|
+
const urlObj = new URL(testee);
|
|
86
|
+
const event = urlObj.searchParams.get('ea');
|
|
87
|
+
return event !== null && event.includes(keyword);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const spy = new RequestSpy('Seek');
|
|
91
|
+
fussyParamInterceptor.addSpy(spy);
|
|
92
|
+
await page.on('request', fussyParamInterceptor.intercept.bind(fussyParamInterceptor));
|
|
93
|
+
await page.goto('http://localhost:3000/analytics.html', { waitUntil: 'load' });
|
|
94
|
+
await page.waitFor(1000);
|
|
95
|
+
await page.evaluate(() => player.currentTime(player.currentTime() + 10));
|
|
96
|
+
await page.waitFor(1000);
|
|
97
|
+
expect(spy.getMatchCount()).toBe(2);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/* it('Test full screen', async () => {
|
|
101
|
+
jest.setTimeout(35000);
|
|
102
|
+
let spy = new RequestSpy('Enter Fullscreen');
|
|
103
|
+
paramInterceptor.addSpy(spy);
|
|
104
|
+
await page.on('request', paramInterceptor.intercept.bind(paramInterceptor));
|
|
105
|
+
await page.goto('http://localhost:3000/analytics.html', { waitUntil: 'load' });
|
|
106
|
+
await page.waitFor(1000);
|
|
107
|
+
await page.click('#player > .vjs-control-bar > button.vjs-fullscreen-control.vjs-control.vjs-button');
|
|
108
|
+
await page.waitFor(500);
|
|
109
|
+
expect(spy.hasMatch()).toBe(true);
|
|
110
|
+
});*/
|
|
111
|
+
});
|
package/test/api.test.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const url = 'http://localhost:3000/api.html';
|
|
2
|
+
|
|
3
|
+
describe('API player tests ', () => {
|
|
4
|
+
try {
|
|
5
|
+
beforeEach(async () => {
|
|
6
|
+
await page.setViewport({ width: 1280, height: 1800 });
|
|
7
|
+
await page.goto(url, { waitUntil: 'load' });
|
|
8
|
+
await page.evaluate(() => {
|
|
9
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
10
|
+
get: function() {
|
|
11
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
12
|
+
this.readyState > 2);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}, 10000);
|
|
17
|
+
|
|
18
|
+
it('Test forward 10 seconds', async () => {
|
|
19
|
+
jest.setTimeout(35000);
|
|
20
|
+
await page.waitForFunction('player.videojs.readyState() === 4');
|
|
21
|
+
const time = await page.$eval(
|
|
22
|
+
'#player > .vjs-control-bar > .vjs-current-time.vjs-time-control.vjs-control > .vjs-current-time-display',
|
|
23
|
+
vt => Number(vt.textContent.replace('0:', '')));
|
|
24
|
+
await page.click('#vid-seek-plus');
|
|
25
|
+
await page.waitForFunction('player.videojs.readyState() === 4');
|
|
26
|
+
const newtime = await page.$eval(
|
|
27
|
+
'#player > .vjs-control-bar > .vjs-current-time.vjs-time-control.vjs-control > .vjs-current-time-display',
|
|
28
|
+
vt => Number(vt.textContent.replace('0:', '')));
|
|
29
|
+
expect(newtime).toBeGreaterThanOrEqual(time + 10);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('Test back 10 seconds', async () => {
|
|
33
|
+
jest.setTimeout(35000);
|
|
34
|
+
await page.waitForFunction('player.videojs.readyState() === 4');
|
|
35
|
+
await page.click('#vid-seek-plus');
|
|
36
|
+
await page.waitForFunction('player.videojs.readyState() === 4');
|
|
37
|
+
await page.click('#vid-seek-minus');
|
|
38
|
+
await page.waitForFunction('player.videojs.readyState() === 4');
|
|
39
|
+
const newtime = await page.$eval(
|
|
40
|
+
'#player > .vjs-control-bar > .vjs-current-time.vjs-time-control.vjs-control > .vjs-current-time-display',
|
|
41
|
+
vt => Number(vt.textContent.replace('0:', '')));
|
|
42
|
+
expect(newtime).toEqual(0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Test mute un-mute', async () => {
|
|
46
|
+
await page.waitFor(500);
|
|
47
|
+
await page.click('#vid-mute');
|
|
48
|
+
await page.waitFor(500);
|
|
49
|
+
expect(await page.$eval('#player_html5_api', v => v.muted)).toBe(true);
|
|
50
|
+
await page.click('#vid-unmute');
|
|
51
|
+
await page.waitFor(500);
|
|
52
|
+
expect(await page.$eval('#player_html5_api', v => v.muted)).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('Test volume down', async () => {
|
|
56
|
+
await page.waitFor(500);
|
|
57
|
+
await page.click('#vid-unmute');
|
|
58
|
+
await page.waitFor(500);
|
|
59
|
+
let currentVol = await page.$eval('#player_html5_api', v => v.volume);
|
|
60
|
+
await page.click('#vid-volume-minus');
|
|
61
|
+
await page.waitFor(500);
|
|
62
|
+
expect(await page.$eval('#player_html5_api', v => v.volume)).toBe(currentVol - 0.1);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('Test volume up', async () => {
|
|
66
|
+
await page.waitFor(500);
|
|
67
|
+
await page.click('#vid-unmute');
|
|
68
|
+
await page.waitFor(500);
|
|
69
|
+
const currentVol = await page.$eval('#player_html5_api', v => v.volume);
|
|
70
|
+
await page.click('#vid-volume-plus');
|
|
71
|
+
await page.waitFor(500);
|
|
72
|
+
expect(await page.$eval('#player_html5_api', v => v.volume)).toBe(currentVol + 0.1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('Test pause', async () => {
|
|
76
|
+
await page.waitFor(500);
|
|
77
|
+
await page.click('#vid-pause');
|
|
78
|
+
await page.waitFor(500);
|
|
79
|
+
expect(await page.$eval('#player video', el => el.playing)).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('Test play', async () => {
|
|
83
|
+
await page.waitFor(500);
|
|
84
|
+
await page.click('#player > .vjs-control-bar > button.vjs-play-control.vjs-control');
|
|
85
|
+
await page.waitFor(500);
|
|
86
|
+
expect(await page.$eval('#player video', el => el.playing)).toBe(false);
|
|
87
|
+
await page.waitFor(500);
|
|
88
|
+
await page.click('#vid-play');
|
|
89
|
+
expect(await page.$eval('#player video', el => el.playing)).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('Test stop', async () => {
|
|
93
|
+
await page.waitFor(500);
|
|
94
|
+
await page.click('#vid-stop');
|
|
95
|
+
await page.waitFor(500);
|
|
96
|
+
expect(await page.$eval('#player video', el => el.playing)).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('Test hide controls', async () => {
|
|
100
|
+
await page.waitFor(500);
|
|
101
|
+
expect(await page.$eval('#player > .vjs-control-bar', p => p.offsetWidth)).toBeGreaterThan(0);
|
|
102
|
+
await page.click('#vid-toggle-controls');
|
|
103
|
+
await page.waitFor(500);
|
|
104
|
+
expect(await page.$eval('#player > .vjs-control-bar', p => p.offsetWidth)).toBe(0);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.log(err);
|
|
109
|
+
browser.close();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
describe('Auto-play tests', () => {
|
|
2
|
+
|
|
3
|
+
beforeEach(async () => {
|
|
4
|
+
await page.setViewport({width: 1280, height: 800});
|
|
5
|
+
await page.goto('http://localhost:3000/autoplay-on-scroll.html', {waitUntil: 'load'});
|
|
6
|
+
await page.evaluate(() => {
|
|
7
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
8
|
+
get: function() {
|
|
9
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
10
|
+
this.readyState > 2);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}, 10000);
|
|
15
|
+
|
|
16
|
+
it('Test scroll', async () => {
|
|
17
|
+
const player = await page.$('#player_html5_api');
|
|
18
|
+
expect(await player.isIntersectingViewport()).toEqual(false);
|
|
19
|
+
await player.tap();
|
|
20
|
+
await page.waitFor(1000);
|
|
21
|
+
expect(await page.$eval('#player_html5_api', p => p.playing)).toEqual(true);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
describe('basic player tests', () => {
|
|
2
|
+
|
|
3
|
+
beforeEach(async () => {
|
|
4
|
+
await page.setViewport({ width: 1280, height: 1300 });
|
|
5
|
+
await page.goto('http://localhost:3000/', { waitUntil: 'load' });
|
|
6
|
+
await page.evaluate(() => {
|
|
7
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
8
|
+
get: function() {
|
|
9
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}, 10000);
|
|
14
|
+
|
|
15
|
+
it('video player should load', async () => {
|
|
16
|
+
await expect(await page.$eval('video', v => v.id)).toMatch('player_html5_api');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('Video should play', async () => {
|
|
20
|
+
jest.setTimeout(35000);
|
|
21
|
+
await page.waitForSelector('.vjs-big-play-button');
|
|
22
|
+
await page.click('#player > button.vjs-big-play-button');
|
|
23
|
+
await page.waitFor(1000);
|
|
24
|
+
const playing = await page.$eval('#player video', el => el.playing);
|
|
25
|
+
await expect(playing).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('Pause button test', async () => {
|
|
29
|
+
jest.setTimeout(35000);
|
|
30
|
+
await page.waitForSelector('.vjs-big-play-button');
|
|
31
|
+
await page.click('#player > button.vjs-big-play-button');
|
|
32
|
+
await page.waitForFunction('player.videojs.readyState() === 4');
|
|
33
|
+
await page.waitFor(1000);
|
|
34
|
+
const playing1 = await page.$eval('#player video', el => el.playing);
|
|
35
|
+
await expect(playing1).toBe(true);
|
|
36
|
+
await page.click('#player > .vjs-control-bar > button.vjs-play-control.vjs-control');
|
|
37
|
+
await page.waitFor(500);
|
|
38
|
+
const playing2 = await page.$eval('#player video', el => el.playing);
|
|
39
|
+
await expect(playing2).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('Test mute', async () => {
|
|
43
|
+
await page.waitForSelector('.vjs-big-play-button');
|
|
44
|
+
await page.click('#player > button.vjs-big-play-button');
|
|
45
|
+
await page.waitFor(500);
|
|
46
|
+
expect(await page.$eval('#player video', v => v.muted)).toBe(true);
|
|
47
|
+
await page.click('#player > .vjs-control-bar > .vjs-volume-panel.vjs-control.vjs-volume-panel-horizontal > button');
|
|
48
|
+
expect(await page.$eval('#player video', v => v.muted)).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('Test video time', async () => {
|
|
52
|
+
await page.waitForSelector('.vjs-big-play-button');
|
|
53
|
+
await page.click('#player > button.vjs-big-play-button');
|
|
54
|
+
await page.waitFor(2000);
|
|
55
|
+
const time = await page.$eval('#player > .vjs-control-bar > .vjs-current-time.vjs-time-control.vjs-control > .vjs-current-time-display', vt => Number(vt.textContent.replace(':', '')));
|
|
56
|
+
await page.waitFor(2000);
|
|
57
|
+
expect(await page.$eval('#player > .vjs-control-bar > .vjs-current-time.vjs-time-control.vjs-control > .vjs-current-time-display', vt => Number(vt.textContent.replace(':', '')))).toBeGreaterThan(time);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
describe('Colors api tests', () => {
|
|
2
|
+
|
|
3
|
+
beforeAll(async () => {
|
|
4
|
+
jest.setTimeout(35000);
|
|
5
|
+
await page.setViewport({width: 1280, height: 800});
|
|
6
|
+
await page.goto('http://localhost:3000/docs/colors.html', {waitUntil: 'load'});
|
|
7
|
+
await page.evaluate(() => {
|
|
8
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
9
|
+
get: function() {
|
|
10
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
11
|
+
this.readyState > 2);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}, 10000);
|
|
16
|
+
|
|
17
|
+
it('Test colors', async () => {
|
|
18
|
+
jest.setTimeout(35000);
|
|
19
|
+
await page.waitFor(1000);
|
|
20
|
+
const playersInf = await page.evaluate(() => players.map((p) => {
|
|
21
|
+
const op = {};
|
|
22
|
+
op[p.videojs.id_] = p.videojs.options_['data-cld-colors'];
|
|
23
|
+
return op;
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
for (const player of playersInf) {
|
|
28
|
+
const id = Object.keys(player);
|
|
29
|
+
const opts = player[id];
|
|
30
|
+
const tooltipColor = rgb2hex(await page.$eval(`#${id} .vjs-time-tooltip`, e => getComputedStyle(e).color));
|
|
31
|
+
const progressColor = rgb2hex(await page.$eval(`#${id} .vjs-play-progress`, e => getComputedStyle(e).backgroundColor));
|
|
32
|
+
const titleBarColor = rgb2hex(await page.$eval(`#${id} .vjs-title-bar`, e => getComputedStyle(e).color));
|
|
33
|
+
const optColors = JSON.parse(opts);
|
|
34
|
+
expect(tooltipColor).toEqual(extendHex(optColors.base));
|
|
35
|
+
expect(progressColor).toEqual(extendHex(optColors.accent));
|
|
36
|
+
expect(titleBarColor).toEqual(extendHex(optColors.text));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function rgb2hex(rgb) {
|
|
42
|
+
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
43
|
+
|
|
44
|
+
function hex(x) {
|
|
45
|
+
// eslint-disable-next-line radix
|
|
46
|
+
return ('0' + parseInt(x).toString(16)).slice(-2);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return '#' + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function extendHex(hex) {
|
|
53
|
+
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
54
|
+
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
|
|
55
|
+
return r + r + g + g + b + b;
|
|
56
|
+
});
|
|
57
|
+
return hex.startsWith('#') ? hex : '#' + hex;
|
|
58
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
describe('Components tests', () => {
|
|
2
|
+
|
|
3
|
+
beforeEach(async () => {
|
|
4
|
+
await page.setViewport({width: 1280, height: 800});
|
|
5
|
+
await page.goto('http://localhost:3000/components.html', {waitUntil: 'load'});
|
|
6
|
+
await page.evaluate(() => {
|
|
7
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
8
|
+
get: function() {
|
|
9
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
10
|
+
this.readyState > 2);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}, 10000);
|
|
15
|
+
|
|
16
|
+
it('Test components', async () => {
|
|
17
|
+
page.waitFor(1000);
|
|
18
|
+
expect(await page.$eval('.vjs-playlist-control.vjs-playlist-next-control', (b => b.tagName))).toEqual('BUTTON');
|
|
19
|
+
expect(await page.$eval('.vjs-playlist-control.vjs-playlist-previous-control', (b => b.tagName))).toEqual('BUTTON');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
describe('custom error tests', () => {
|
|
2
|
+
|
|
3
|
+
beforeAll(async () => {
|
|
4
|
+
jest.setTimeout(35000);
|
|
5
|
+
await page.setViewport({ width: 1280, height: 800 });
|
|
6
|
+
await page.goto('http://localhost:3000/docs/custom-cld-errors.html', { waitUntil: 'load' });
|
|
7
|
+
await page.evaluate(() => {
|
|
8
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
9
|
+
get: function() {
|
|
10
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
11
|
+
this.readyState > 2);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}, 10000);
|
|
16
|
+
|
|
17
|
+
it('Test error', async () => {
|
|
18
|
+
jest.setTimeout(35000);
|
|
19
|
+
await page.waitFor(1000);
|
|
20
|
+
// eslint-disable-next-line no-undef
|
|
21
|
+
const errorMsg = await page.evaluate(() => player.videojs.error_.message);
|
|
22
|
+
expect(errorMsg).toBe('My custom error message');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
describe('Fluid tests', () => {
|
|
2
|
+
|
|
3
|
+
beforeEach(async () => {
|
|
4
|
+
await page.setViewport({width: 1280, height: 800});
|
|
5
|
+
await page.goto('http://localhost:3000/fluid.html', {waitUntil: 'load'});
|
|
6
|
+
await page.evaluate(() => {
|
|
7
|
+
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
|
|
8
|
+
get: function() {
|
|
9
|
+
return !!(this.currentTime > 0 && !this.paused && !this.ended &&
|
|
10
|
+
this.readyState > 2);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}, 10000);
|
|
15
|
+
|
|
16
|
+
it('Test fluid change', async () => {
|
|
17
|
+
await page.waitFor(1000);
|
|
18
|
+
const origWidth = await page.$eval('#player_html5_api', p => p.clientWidth);
|
|
19
|
+
await page.setViewport({ width: 800, height: 800 });
|
|
20
|
+
await page.waitFor(1000);
|
|
21
|
+
const currWidth = await page.$eval('#player_html5_api', p => p.clientWidth);
|
|
22
|
+
expect(origWidth).toBeGreaterThan(currWidth);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('Test no fluid change', async () => {
|
|
26
|
+
await page.waitFor(1000);
|
|
27
|
+
await page.click('#toggle-fluid');
|
|
28
|
+
await page.waitFor(500);
|
|
29
|
+
const origWidth = await page.$eval('#player_html5_api', p => p.clientWidth);
|
|
30
|
+
await page.setViewport({ width: 800, height: 800 });
|
|
31
|
+
await page.waitFor(1000);
|
|
32
|
+
const currWidth = await page.$eval('#player_html5_api', p => p.clientWidth);
|
|
33
|
+
expect(origWidth).toEqual(currWidth);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
});
|