diff --git a/common/lib/xmodule/xmodule/js/fixtures/video_all.html b/common/lib/xmodule/xmodule/js/fixtures/video_all.html index eec92febe9..8b168ddbfb 100644 --- a/common/lib/xmodule/xmodule/js/fixtures/video_all.html +++ b/common/lib/xmodule/xmodule/js/fixtures/video_all.html @@ -1,61 +1,63 @@
-
-
-
-
+
+
+
+
+
-
-
- - -
-
-
-
-
-
- -
-
+
+
+ + +
+
+
+
+
+
+ +
+
-
+
-

Downloads and transcripts

-
+

Downloads and transcripts

+ +
+
diff --git a/common/lib/xmodule/xmodule/js/karma_xmodule.conf.js b/common/lib/xmodule/xmodule/js/karma_xmodule.conf.js index 2c53cd4da8..ca335c5d59 100644 --- a/common/lib/xmodule/xmodule/js/karma_xmodule.conf.js +++ b/common/lib/xmodule/xmodule/js/karma_xmodule.conf.js @@ -41,6 +41,7 @@ var options = { {pattern: 'common_static/js/test/i18n.js', included: true}, {pattern: 'common_static/common/js/vendor/hls.js', included: true}, {pattern: 'public/js/split_test_staff.js', included: true}, + {pattern: 'public/js/vertical_student_view.js', included: true}, {pattern: 'src/word_cloud/d3.min.js', included: true}, // Load test utilities diff --git a/common/lib/xmodule/xmodule/js/spec/video/completion_spec.js b/common/lib/xmodule/xmodule/js/spec/video/completion_spec.js index 1b6c2fe727..c4994caae4 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/completion_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/completion_spec.js @@ -1,7 +1,7 @@ (function() { 'use strict'; describe('VideoPlayer completion', function() { - var state, oldOTBD; + var state, oldOTBD, completionAjaxCall; beforeEach(function() { oldOTBD = window.onTouchBasedDevice; @@ -13,9 +13,18 @@ recordedYoutubeIsAvailable: true, completionEnabled: true, publishCompletionUrl: 'https://example.com/publish_completion_url' - }); state.completionHandler.completeAfterTime = 20; + + completionAjaxCall = { + url: state.config.publishCompletionUrl, + type: 'POST', + contentType: 'application/json', + dataType: 'json', + data: JSON.stringify({completion: 1.0}), + success: jasmine.any(Function), + error: jasmine.any(Function) + }; }); afterEach(function() { @@ -29,15 +38,7 @@ it('calls the completion api when marking an object complete', function() { state.completionHandler.markCompletion(Date.now()); - expect($.ajax).toHaveBeenCalledWith({ - url: state.config.publishCompletionUrl, - type: 'POST', - contentType: 'application/json', - dataType: 'json', - data: JSON.stringify({completion: 1.0}), - success: jasmine.any(Function), - error: jasmine.any(Function) - }); + expect($.ajax).toHaveBeenCalledWith(completionAjaxCall); expect(state.completionHandler.isComplete).toEqual(true); }); @@ -51,6 +52,16 @@ expect(state.completionHandler.markCompletion).not.toHaveBeenCalled(); }); + it('does not call the completion api on the LMS when the video is loaded but not seen', function() { + spyOn(window, 'VerticalStudentView').and.callThrough(); + // The VerticalStudentView object is created to kick off the function that checks if + // each vertical is completable by viewing, and, if so, sends an ajax call to mark completion + // eslint-disable-next-line no-new + new window.VerticalStudentView(null, '#video_example'); + expect(window.VerticalStudentView).toHaveBeenCalled(); + expect($.ajax).not.toHaveBeenCalledWith(completionAjaxCall); + }); + it('calls the completion api on the LMS when the video ends', function() { spyOn(state.completionHandler, 'markCompletion').and.callThrough(); state.el.trigger('ended');