diff --git a/src/xblock_video/tests/js/html5_video_spec.js b/src/xblock_video/tests/js/html5_video_spec.js
index 967034d8..67b0a909 100644
--- a/src/xblock_video/tests/js/html5_video_spec.js
+++ b/src/xblock_video/tests/js/html5_video_spec.js
@@ -85,11 +85,9 @@
});
describe('[play]', function() {
+ // Restored from openedx-platform xmodule/js/spec/video/html5_video_spec.js (removed in openedx/openedx-platform#38750)
beforeEach(function() {
- spyOn(state.videoPlayer.player.video, 'play').and.callFake(function() {
- jasmine.fireEvent(state.videoPlayer.player.video, 'play');
- return Promise.resolve();
- });
+ spyOn(state.videoPlayer.player.video, 'play').and.callThrough();
state.videoPlayer.player.playerState = STATUS.PAUSED;
state.videoPlayer.player.playVideo();
});
@@ -98,24 +96,31 @@
expect(state.videoPlayer.player.video.play).toHaveBeenCalled();
});
- it('player state was changed', function() {
- expect([STATUS.BUFFERING, STATUS.PLAYING]).toContain(
- state.videoPlayer.player.getPlayerState()
- );
+ // Restored from openedx-platform xmodule/js/spec/video/html5_video_spec.js (removed in openedx/openedx-platform#38750)
+ it('player state was changed', function(done) {
+ jasmine.waitUntil(function() {
+ return state.videoPlayer.player.getPlayerState() !== STATUS.PAUSED;
+ }).then(function() {
+ expect([STATUS.BUFFERING, STATUS.PLAYING]).toContain(
+ state.videoPlayer.player.getPlayerState()
+ );
+ }).always(done);
});
- it('callback was called', function() {
- expect(state.videoPlayer.player.callStateChangeCallback)
- .toHaveBeenCalled();
+ // Restored from openedx-platform xmodule/js/spec/video/html5_video_spec.js (removed in openedx/openedx-platform#38750)
+ it('callback was called', function(done) {
+ jasmine.waitUntil(function() {
+ return state.videoPlayer.player.getPlayerState() !== STATUS.PAUSED;
+ }).then(function() {
+ expect(state.videoPlayer.player.callStateChangeCallback)
+ .toHaveBeenCalled();
+ }).always(done);
});
});
describe('[pause]', function() {
+ // Restored from openedx-platform xmodule/js/spec/video/html5_video_spec.js (removed in openedx/openedx-platform#38750)
beforeEach(function(done) {
- spyOn(state.videoPlayer.player.video, 'play').and.callFake(function() {
- jasmine.fireEvent(state.videoPlayer.player.video, 'play');
- return Promise.resolve();
- });
spyOn(state.videoPlayer.player.video, 'pause').and.callThrough();
state.videoPlayer.player.playerState = STATUS.UNSTARTED;
state.videoPlayer.player.playVideo();
@@ -131,9 +136,10 @@
expect(state.videoPlayer.player.video.pause).toHaveBeenCalled();
});
+ // Restored from openedx-platform xmodule/js/spec/video/html5_video_spec.js (removed in openedx/openedx-platform#38750)
it('player state was changed', function(done) {
jasmine.waitUntil(function() {
- return state.videoPlayer.player.getPlayerState() === STATUS.PAUSED;
+ return state.videoPlayer.player.getPlayerState() !== STATUS.PLAYING;
}).then(function() {
expect(state.videoPlayer.player.getPlayerState())
.toBe(STATUS.PAUSED);
diff --git a/src/xblock_video/tests/js/video_player_spec.js b/src/xblock_video/tests/js/video_player_spec.js
index 3079710b..741cfb19 100644
--- a/src/xblock_video/tests/js/video_player_spec.js
+++ b/src/xblock_video/tests/js/video_player_spec.js
@@ -1,7 +1,7 @@
/* global YT */
import VideoPlayer from "../../assets/js/src/03_video_player.js";
-import HLS from 'hls';
+import Hls from 'hls.js';
import _ from 'underscore';
(function() {
@@ -979,30 +979,27 @@ import _ from 'underscore';
describe('on safari', function() {
beforeEach(function() {
- spyOn(HLS, 'isSupported').and.returnValue(false);
+ spyOn(Hls, 'isSupported').and.returnValue(false);
state = jasmine.initializeHLSPlayer();
state.canPlayHLS = true;
state.browserIsSafari = true;
});
+ // Restored from openedx-platform xmodule/js/spec/video/video_player_spec.js (removed in openedx/openedx-platform#38750)
it('can use native hls playback support', function() {
- // When HLS is not supported and browser reports Safari, native playback may be used
- // The assertion depends on init order - skip if hls.js was already chosen
- if (state.videoPlayer.player && state.videoPlayer.player.hls === undefined) {
- expect(state.videoPlayer.player.hls).toBeUndefined();
- }
+ expect(state.videoPlayer.player.hls).toBeUndefined();
});
});
});
describe('HLS Video Errors', function() {
beforeEach(function() {
- spyOn(HLS, 'isSupported').and.returnValue(false);
+ spyOn(Hls, 'isSupported').and.returnValue(false);
state = jasmine.initializeHLSPlayer({sources: ['/base/fixtures/hls/hls.m3u8']});
});
- xit('shows error message if hls is not supported', function() {
- // Skipped: error message visibility is async/env-dependent in headless Firefox
+ // Restored from openedx-platform xmodule/js/spec/video/video_player_spec.js (removed in openedx/openedx-platform#38750)
+ it('shows error message if hls is not supported', function() {
expect($('.video-hls-error')).not.toHaveClass('is-hidden');
expect($('.video-hls-error').text().trim()).toEqual(
'Your browser does not support this video format. Try using a different browser.'
diff --git a/src/xblock_video/tests/js/video_volume_control_spec.js b/src/xblock_video/tests/js/video_volume_control_spec.js
index c8693160..2fa8ea0c 100644
--- a/src/xblock_video/tests/js/video_volume_control_spec.js
+++ b/src/xblock_video/tests/js/video_volume_control_spec.js
@@ -42,8 +42,18 @@
expect(volumeControl.volume).toEqual(75);
});
- it('render the volume control', function() {
- expect($('.volume')).toExist();
+ // Restored from openedx-platform xmodule/js/spec/video/video_volume_control_spec.js (removed in openedx/openedx-platform#38750)
+ it('render the volume control', function(done) {
+ jasmine.waitUntil(function() {
+ return state.videoVolumeControl &&
+ state.videoVolumeControl.el &&
+ state.videoVolumeControl.el.closest('.secondary-controls').length === 1;
+ }).then(function() {
+ expect(state.videoVolumeControl.el).toBeInDOM();
+ done();
+ }).fail(function() {
+ done.fail('VideoVolumeControl did not render into .secondary-controls before the test timed out.');
+ });
});
it('create the slider', function() {