Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
291f543
chore: Original JS files copied from xmodule/js/src/video directory
farhan Apr 24, 2025
d67c6d7
refactor: Migrate video block js files from js/src to assets
farhan Jul 18, 2025
06ff9c0
fix: karma js tests fix:
salman2013 Sep 15, 2025
a0609f8
fix: fix conflicts
salman2013 Sep 17, 2025
3903c51
fix: do some improvements discuss during code review
salman2013 Sep 19, 2025
ec18bee
fix: fix the variable as per comment
salman2013 Sep 22, 2025
a22103f
fix: put comment on disable test
salman2013 Sep 22, 2025
f467e4e
fix: improve some test logic for video_events_plugin_spec.js
salman2013 Sep 24, 2025
8ecfb9b
fix: fix space
salman2013 Sep 24, 2025
07f849c
fix: fix test for the auto-advance feature
salman2013 Sep 24, 2025
c9a0abf
fix: fix tests for video_caption
salman2013 Sep 24, 2025
7a0d574
fix: fix the test for video speed control
salman2013 Sep 25, 2025
ac9784e
fix: karma js tests fix:
salman2013 Sep 15, 2025
a1e527f
fix: fix conflicts
salman2013 Sep 17, 2025
efc1c93
fix: do some improvements discuss during code review
salman2013 Sep 19, 2025
0774eac
fix: fix the variable as per comment
salman2013 Sep 22, 2025
80e6ba5
fix: put comment on disable test
salman2013 Sep 22, 2025
e27d2ee
fix: improve some test logic for video_events_plugin_spec.js
salman2013 Sep 24, 2025
ed0c397
fix: fix space
salman2013 Sep 24, 2025
6204ed6
fix: fix test for the auto-advance feature
salman2013 Sep 24, 2025
a7b61ad
fix: fix tests for video_caption
salman2013 Sep 24, 2025
2e9e46e
fix: fix the test for video speed control
salman2013 Sep 25, 2025
10ddb13
fix: enable the test case again
salman2013 Sep 30, 2025
c30f0d1
Merge branch 'salman/karma-test-fix' of github.com:salman2013/edx-pla…
salman2013 Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion common/static/common/js/karma.common.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ function getBaseConfig(config, useRequireJs) {
base: 'Firefox',
prefs: {
'app.update.auto': false,
'app.update.enabled': false
'app.update.enabled': false,
'media.autoplay.default': 0, // allow autoplay
'media.autoplay.blocking_policy': 0, // disable autoplay blocking
'media.autoplay.allow-extension-background-pages': true,
'media.autoplay.enabled.user-gestures-needed': false,
}
},
ChromeDocker: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"watch-sass": "scripts/watch_sass.sh",
"test": "npm run test-jest && npm run test-karma",
"test-jest": "jest",
"test-karma": "npm run test-karma-vanilla && npm run test-karma-require && echo 'WARNING: Skipped broken webpack tests. For details, see: https://github.com/openedx/edx-platform/issues/35956'",
"test-karma": "npm run test-karma-vanilla && npm run test-karma-require && npm run test-xmodule-webpack && echo 'WARNING: Skipped broken webpack tests. For details, see: https://github.com/openedx/edx-platform/issues/35956'",
"test-karma-vanilla": "npm run test-cms-vanilla && npm run test-xmodule-vanilla && npm run test-common-vanilla",
"test-karma-require": "npm run test-cms-require && npm run test-common-require",
"test-karma-webpack": "npm run test-cms-webpack && npm run test-lms-webpack && npm run test-xmodule-webpack",
Expand Down
2 changes: 2 additions & 0 deletions webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,11 @@ module.exports = Merge.merge({
$: 'jQuery',
backbone: 'Backbone',
canvas: 'canvas',
fs: 'fs',
gettext: 'gettext',
jquery: 'jQuery',
logger: 'Logger',
path: 'path',
underscore: '_',
URI: 'URI',
XBlockToXModuleShim: 'XBlockToXModuleShim',
Expand Down
1 change: 0 additions & 1 deletion xmodule/assets/video/public/js/04_video_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import * as Time from './utils/time.js';


// VideoControl module.
let VideoControl = function(state) {
let dfd = $.Deferred();
Expand Down
13 changes: 12 additions & 1 deletion xmodule/js/karma_runner_webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ import '../../common/static/common/js/spec_helpers/jasmine-waituntil.js';
import '../../common/static/common/js/spec_helpers/jasmine-extensions.js';
import '../../common/static/common/js/vendor/sinon.js';

import HtmlUtils from 'edx-ui-toolkit/js/utils/html-utils';
import StringUtils from 'edx-ui-toolkit/js/utils/string-utils';


// These libraries are used by the tests (and the code under test)
// but not explicitly imported
import 'jquery.ui';

// These
import './src/video/10_main.js';
import '../assets/video/public/js/10_main.js';
import './spec/helper.js';
import './spec/video_helper.js';

Expand Down Expand Up @@ -71,11 +75,18 @@ import './spec/video/video_transcript_feedback_spec.js';
import './spec/video/video_volume_control_spec.js';
import './spec/time_spec.js';


// overwrite the loaded method and manually start the karma after a delay
// Somehow the code initialized in jQuery's onready doesn't get called before karma auto starts

// eslint-disable-next-line no-unused-expressions
'use strict';

window._ = _;
window.edx = window.edx || {};
window.edx.HtmlUtils = HtmlUtils;
window.edx.StringUtils = StringUtils;

window.__karma__.loaded = function() {
setTimeout(function() {
window.__karma__.start();
Expand Down
4 changes: 2 additions & 2 deletions xmodule/js/karma_xmodule_webpack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var options = {
specFiles: [],

fixtureFiles: [
{pattern: 'fixtures/*.*'},
{pattern: 'fixtures/hls/**/*.*'}
{pattern: path.join(__dirname, 'fixtures/*.*')},
{pattern: path.join(__dirname, 'fixtures/hls/**/*.*')}
],

runFiles: [
Expand Down
3 changes: 2 additions & 1 deletion xmodule/js/spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@
}

jasmine.stubRequests();
state = new window.Video('#example');
let runtime = jasmine.createSpyObj('TestRuntime', ['handlerUrl']);
state = new window.Video(runtime, '#example');

state.resizer = (function() {
var methods = [
Expand Down
2 changes: 1 addition & 1 deletion xmodule/js/spec/time_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as Time from 'time.js';
import * as Time from '../../assets/video/public/js/utils/time.js';

describe('Time', function() {
describe('format', function() {
Expand Down
128 changes: 62 additions & 66 deletions xmodule/js/spec/video/async_process_spec.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,77 @@
(function(require) {
require(
['video/00_async_process.js'],
function(AsyncProcess) {
var getArrayNthLength = function(n, multiplier) {
var result = [],
mul = multiplier || 1;
import AsyncProcess from '../../../assets/video/public/js/00_async_process.js';

for (var i = 0; i < n; i++) {
result[i] = i * mul;
}
let getArrayNthLength = function(n, multiplier) {
let result = [],
mul = multiplier || 1;

return result;
},
items = getArrayNthLength(1000);
for (let i = 0; i < n; i++) {
result[i] = i * mul;
}

describe('AsyncProcess', function() {
it('Array is processed successfully', function(done) {
var processedArray,
expectedArray = getArrayNthLength(1000, 2),
process = function(item) {
return 2 * item;
};
return result;
},
items = getArrayNthLength(1000);

AsyncProcess.array(items, process).done(function(result) {
processedArray = result;
});
describe('AsyncProcess', function() {
it('Array is processed successfully', function(done) {
var processedArray,
expectedArray = getArrayNthLength(1000, 2),
process = function(item) {
return 2 * item;
};

jasmine.waitUntil(function() {
return processedArray;
}).then(function() {
expect(processedArray).toEqual(expectedArray);
}).always(done);
});
AsyncProcess.array(items, process).done(function(result) {
processedArray = result;
});

it('If non-array is passed, error callback is called', function(done) {
var isError,
process = function() {};
jasmine.waitUntil(function() {
return processedArray;
}).then(function() {
expect(processedArray).toEqual(expectedArray);
}).always(done);
});

AsyncProcess.array('string', process).fail(function() {
isError = true;
});
it('If non-array is passed, error callback is called', function(done) {
var isError,
process = function() {};

jasmine.waitUntil(function() {
return isError;
}).then(function() {
expect(isError).toBeTruthy();
}).always(done);
});
AsyncProcess.array('string', process).fail(function() {
isError = true;
});

it('If an empty array is passed, returns initial array', function(done) {
var processedArray,
process = function() {};
jasmine.waitUntil(function() {
return isError;
}).then(function() {
expect(isError).toBeTruthy();
}).always(done);
});

AsyncProcess.array([], process).done(function(result) {
processedArray = result;
});
it('If an empty array is passed, returns initial array', function(done) {
var processedArray,
process = function() {};

jasmine.waitUntil(function() {
return processedArray;
}).then(function() {
expect(processedArray).toEqual([]);
}).always(done);
});
AsyncProcess.array([], process).done(function(result) {
processedArray = result;
});

it('If no process function passed, returns initial array', function(done) {
var processedArray;
jasmine.waitUntil(function() {
return processedArray;
}).then(function() {
expect(processedArray).toEqual([]);
}).always(done);
});

AsyncProcess.array(items).done(function(result) {
processedArray = result;
});
it('If no process function passed, returns initial array', function(done) {
var processedArray;

jasmine.waitUntil(function() {
return processedArray;
}).then(function() {
expect(processedArray).toEqual(items);
}).always(done);
});
});
AsyncProcess.array(items).done(function(result) {
processedArray = result;
});
}(require));

jasmine.waitUntil(function() {
return processedArray;
}).then(function() {
expect(processedArray).toEqual(items);
}).always(done);
});
});
Loading
Loading