Revert "Switch container factory to webpack"
This commit is contained in:
@@ -19,19 +19,24 @@
|
||||
modules: getModulesList([
|
||||
'js/factories/asset_index',
|
||||
'js/factories/base',
|
||||
'js/factories/container',
|
||||
'js/factories/course_create_rerun',
|
||||
'js/factories/course_info',
|
||||
'js/factories/edit_tabs',
|
||||
'js/factories/export',
|
||||
'js/factories/group_configurations',
|
||||
'js/certificates/factories/certificates_page_factory',
|
||||
'js/factories/index',
|
||||
'js/factories/library',
|
||||
'js/factories/manage_users',
|
||||
'js/factories/outline',
|
||||
'js/factories/register',
|
||||
'js/factories/settings',
|
||||
'js/factories/settings_advanced',
|
||||
'js/factories/settings_graders',
|
||||
'js/factories/videos_index'
|
||||
'js/factories/textbooks',
|
||||
'js/factories/videos_index',
|
||||
'js/factories/xblock_validation'
|
||||
]),
|
||||
/**
|
||||
* By default all the configuration for optimization happens from the command
|
||||
|
||||
@@ -1,87 +1,86 @@
|
||||
/* globals AjaxPrefix */
|
||||
|
||||
define([
|
||||
'domReady',
|
||||
'jquery',
|
||||
'underscore',
|
||||
'underscore.string',
|
||||
'backbone',
|
||||
'gettext',
|
||||
'../../common/js/components/views/feedback_notification',
|
||||
'jquery.cookie'
|
||||
], function(domReady, $, _, str, Backbone, gettext, NotificationView) {
|
||||
(function(AjaxPrefix) {
|
||||
'use strict';
|
||||
|
||||
var main, sendJSON;
|
||||
main = function() {
|
||||
AjaxPrefix.addAjaxPrefix(jQuery, function() {
|
||||
return $("meta[name='path_prefix']").attr('content');
|
||||
});
|
||||
window.CMS = window.CMS || {};
|
||||
window.CMS.URL = window.CMS.URL || {};
|
||||
window.onTouchBasedDevice = function() {
|
||||
return navigator.userAgent.match(/iPhone|iPod|iPad|Android/i);
|
||||
};
|
||||
_.extend(window.CMS, Backbone.Events);
|
||||
Backbone.emulateHTTP = true;
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRFToken': $.cookie('csrftoken')
|
||||
},
|
||||
dataType: 'json',
|
||||
content: {
|
||||
script: false
|
||||
}
|
||||
});
|
||||
$(document).ajaxError(function(event, jqXHR, ajaxSettings) {
|
||||
var msg, contentType,
|
||||
message = gettext('This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.'); // eslint-disable-line max-len
|
||||
if (ajaxSettings.notifyOnError === false) {
|
||||
return;
|
||||
}
|
||||
contentType = jqXHR.getResponseHeader('content-type');
|
||||
if (contentType && contentType.indexOf('json') > -1 && jqXHR.responseText) {
|
||||
message = JSON.parse(jqXHR.responseText).error;
|
||||
}
|
||||
msg = new NotificationView.Error({
|
||||
title: gettext("Studio's having trouble saving your work"),
|
||||
message: message
|
||||
define([
|
||||
'domReady',
|
||||
'jquery',
|
||||
'underscore.string',
|
||||
'backbone',
|
||||
'gettext',
|
||||
'../../common/js/components/views/feedback_notification',
|
||||
'jquery.cookie'
|
||||
], function(domReady, $, str, Backbone, gettext, NotificationView) {
|
||||
var main, sendJSON;
|
||||
main = function() {
|
||||
AjaxPrefix.addAjaxPrefix(jQuery, function() {
|
||||
return $("meta[name='path_prefix']").attr('content');
|
||||
});
|
||||
console.log('Studio AJAX Error', { // eslint-disable-line no-console
|
||||
url: event.currentTarget.URL,
|
||||
response: jqXHR.responseText,
|
||||
status: jqXHR.status
|
||||
});
|
||||
return msg.show();
|
||||
});
|
||||
sendJSON = function(url, data, callback, type) { // eslint-disable-line no-param-reassign
|
||||
if ($.isFunction(data)) {
|
||||
callback = data;
|
||||
data = undefined;
|
||||
}
|
||||
return $.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
window.CMS = window.CMS || {};
|
||||
window.CMS.URL = window.CMS.URL || {};
|
||||
window.onTouchBasedDevice = function() {
|
||||
return navigator.userAgent.match(/iPhone|iPod|iPad|Android/i);
|
||||
};
|
||||
_.extend(window.CMS, Backbone.Events);
|
||||
Backbone.emulateHTTP = true;
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRFToken': $.cookie('csrftoken')
|
||||
},
|
||||
dataType: 'json',
|
||||
data: JSON.stringify(data),
|
||||
success: callback,
|
||||
global: data ? data.global : true // Trigger global AJAX error handler or not
|
||||
content: {
|
||||
script: false
|
||||
}
|
||||
});
|
||||
$(document).ajaxError(function(event, jqXHR, ajaxSettings) {
|
||||
var msg, contentType,
|
||||
message = gettext('This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.'); // eslint-disable-line max-len
|
||||
if (ajaxSettings.notifyOnError === false) {
|
||||
return;
|
||||
}
|
||||
contentType = jqXHR.getResponseHeader('content-type');
|
||||
if (contentType && contentType.indexOf('json') > -1 && jqXHR.responseText) {
|
||||
message = JSON.parse(jqXHR.responseText).error;
|
||||
}
|
||||
msg = new NotificationView.Error({
|
||||
title: gettext("Studio's having trouble saving your work"),
|
||||
message: message
|
||||
});
|
||||
console.log('Studio AJAX Error', { // eslint-disable-line no-console
|
||||
url: event.currentTarget.URL,
|
||||
response: jqXHR.responseText,
|
||||
status: jqXHR.status
|
||||
});
|
||||
return msg.show();
|
||||
});
|
||||
sendJSON = function(url, data, callback, type) { // eslint-disable-line no-param-reassign
|
||||
if ($.isFunction(data)) {
|
||||
callback = data;
|
||||
data = undefined;
|
||||
}
|
||||
return $.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
dataType: 'json',
|
||||
data: JSON.stringify(data),
|
||||
success: callback,
|
||||
global: data ? data.global : true // Trigger global AJAX error handler or not
|
||||
});
|
||||
};
|
||||
$.postJSON = function(url, data, callback) { // eslint-disable-line no-param-reassign
|
||||
return sendJSON(url, data, callback, 'POST');
|
||||
};
|
||||
$.patchJSON = function(url, data, callback) { // eslint-disable-line no-param-reassign
|
||||
return sendJSON(url, data, callback, 'PATCH');
|
||||
};
|
||||
return domReady(function() {
|
||||
if (window.onTouchBasedDevice()) {
|
||||
return $('body').addClass('touch-based-device');
|
||||
}
|
||||
});
|
||||
};
|
||||
$.postJSON = function(url, data, callback) { // eslint-disable-line no-param-reassign
|
||||
return sendJSON(url, data, callback, 'POST');
|
||||
};
|
||||
$.patchJSON = function(url, data, callback) { // eslint-disable-line no-param-reassign
|
||||
return sendJSON(url, data, callback, 'PATCH');
|
||||
};
|
||||
return domReady(function() {
|
||||
if (window.onTouchBasedDevice()) {
|
||||
return $('body').addClass('touch-based-device');
|
||||
}
|
||||
return null;
|
||||
});
|
||||
};
|
||||
main();
|
||||
return main;
|
||||
});
|
||||
main();
|
||||
return main;
|
||||
});
|
||||
}).call(this, AjaxPrefix);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
(function(requirejs, requireSerial) {
|
||||
'use strict';
|
||||
|
||||
var i, specHelpers, testFiles;
|
||||
if (window) {
|
||||
define('add-a11y-deps',
|
||||
[
|
||||
@@ -21,6 +20,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
var i, specHelpers, testFiles;
|
||||
|
||||
requirejs.config({
|
||||
baseUrl: '/base/',
|
||||
paths: {
|
||||
@@ -229,6 +230,7 @@
|
||||
|
||||
testFiles = [
|
||||
'cms/js/spec/main_spec',
|
||||
'cms/js/spec/xblock/cms.runtime.v1_spec',
|
||||
'js/spec/models/course_spec',
|
||||
'js/spec/models/metadata_spec',
|
||||
'js/spec/models/section_spec',
|
||||
@@ -261,21 +263,32 @@
|
||||
'js/spec/views/previous_video_upload_list_spec',
|
||||
'js/spec/views/assets_spec',
|
||||
'js/spec/views/baseview_spec',
|
||||
'js/spec/views/container_spec',
|
||||
'js/spec/views/module_edit_spec',
|
||||
'js/spec/views/paged_container_spec',
|
||||
'js/spec/views/group_configuration_spec',
|
||||
'js/spec/views/unit_outline_spec',
|
||||
'js/spec/views/xblock_spec',
|
||||
'js/spec/views/xblock_editor_spec',
|
||||
'js/spec/views/xblock_string_field_editor_spec',
|
||||
'js/spec/views/xblock_validation_spec',
|
||||
'js/spec/views/license_spec',
|
||||
'js/spec/views/paging_spec',
|
||||
'js/spec/views/login_studio_spec',
|
||||
'js/spec/views/pages/container_spec',
|
||||
'js/spec/views/pages/container_subviews_spec',
|
||||
'js/spec/views/pages/group_configurations_spec',
|
||||
'js/spec/views/pages/course_outline_spec',
|
||||
'js/spec/views/pages/course_rerun_spec',
|
||||
'js/spec/views/pages/index_spec',
|
||||
'js/spec/views/pages/library_users_spec',
|
||||
'js/spec/views/modals/base_modal_spec',
|
||||
'js/spec/views/modals/edit_xblock_spec',
|
||||
'js/spec/views/modals/move_xblock_modal_spec',
|
||||
'js/spec/views/modals/validation_error_modal_spec',
|
||||
'js/spec/views/move_xblock_spec',
|
||||
'js/spec/views/settings/main_spec',
|
||||
'js/spec/factories/xblock_validation_spec',
|
||||
'js/certificates/spec/models/certificate_spec',
|
||||
'js/certificates/spec/views/certificate_details_spec',
|
||||
'js/certificates/spec/views/certificate_editor_spec',
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
jasmine.getFixtures().fixturesPath = '/base/templates';
|
||||
|
||||
import 'common/js/spec_helpers/jasmine-extensions';
|
||||
import 'common/js/spec_helpers/jasmine-stealth';
|
||||
import 'common/js/spec_helpers/jasmine-waituntil';
|
||||
|
||||
// These libraries are used by the tests (and the code under test)
|
||||
// but not explicitly imported
|
||||
import 'jquery.ui';
|
||||
|
||||
import _ from 'underscore';
|
||||
import str from 'underscore.string';
|
||||
import HtmlUtils from 'edx-ui-toolkit/js/utils/html-utils';
|
||||
import StringUtils from 'edx-ui-toolkit/js/utils/string-utils';
|
||||
window._ = _;
|
||||
window._.str = str;
|
||||
window.edx = window.edx || {};
|
||||
window.edx.HtmlUtils = HtmlUtils;
|
||||
window.edx.StringUtils = StringUtils;
|
||||
|
||||
// These are the tests that will be run
|
||||
import './xblock/cms.runtime.v1_spec.js';
|
||||
import '../../../js/spec/factories/xblock_validation_spec.js';
|
||||
import '../../../js/spec/views/container_spec.js';
|
||||
import '../../../js/spec/views/login_studio_spec.js';
|
||||
import '../../../js/spec/views/modals/edit_xblock_spec.js';
|
||||
import '../../../js/spec/views/module_edit_spec.js';
|
||||
import '../../../js/spec/views/move_xblock_spec.js';
|
||||
import '../../../js/spec/views/pages/container_spec.js';
|
||||
import '../../../js/spec/views/pages/container_subviews_spec.js';
|
||||
import '../../../js/spec/views/pages/course_outline_spec.js';
|
||||
import '../../../js/spec/views/xblock_editor_spec.js';
|
||||
import '../../../js/spec/views/xblock_string_field_editor_spec.js';
|
||||
|
||||
window.__karma__.start(); // eslint-disable-line no-underscore-dangle
|
||||
@@ -1,82 +1,81 @@
|
||||
import EditHelpers from 'js/spec_helpers/edit_helpers';
|
||||
import BaseModal from 'js/views/modals/base_modal';
|
||||
import 'xblock/cms.runtime.v1';
|
||||
define(['js/spec_helpers/edit_helpers', 'js/views/modals/base_modal', 'xblock/cms.runtime.v1'],
|
||||
function(EditHelpers, BaseModal) {
|
||||
'use strict';
|
||||
|
||||
describe('Studio Runtime v1', function() {
|
||||
'use strict';
|
||||
describe('Studio Runtime v1', function() {
|
||||
var runtime;
|
||||
|
||||
var runtime;
|
||||
|
||||
beforeEach(function() {
|
||||
EditHelpers.installEditTemplates();
|
||||
runtime = new window.StudioRuntime.v1();
|
||||
});
|
||||
|
||||
it('allows events to be listened to', function() {
|
||||
var canceled = false;
|
||||
runtime.listenTo('cancel', function() {
|
||||
canceled = true;
|
||||
});
|
||||
expect(canceled).toBeFalsy();
|
||||
runtime.notify('cancel', {});
|
||||
expect(canceled).toBeTruthy();
|
||||
});
|
||||
|
||||
it('shows save notifications', function() {
|
||||
var title = 'Mock saving...',
|
||||
notificationSpy = EditHelpers.createNotificationSpy();
|
||||
runtime.notify('save', {
|
||||
state: 'start',
|
||||
message: title
|
||||
});
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, title);
|
||||
runtime.notify('save', {
|
||||
state: 'end'
|
||||
});
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it('shows error messages', function() {
|
||||
var title = 'Mock Error',
|
||||
message = 'This is a mock error.',
|
||||
notificationSpy = EditHelpers.createNotificationSpy('Error');
|
||||
runtime.notify('error', {
|
||||
title: title,
|
||||
message: message
|
||||
});
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, title);
|
||||
});
|
||||
|
||||
describe('Modal Dialogs', function() {
|
||||
var MockModal, modal, showMockModal;
|
||||
|
||||
MockModal = BaseModal.extend({
|
||||
getContentHtml: function() {
|
||||
return readFixtures('mock/mock-modal.underscore');
|
||||
}
|
||||
});
|
||||
|
||||
showMockModal = function() {
|
||||
modal = new MockModal({
|
||||
title: 'Mock Modal'
|
||||
beforeEach(function() {
|
||||
EditHelpers.installEditTemplates();
|
||||
runtime = new window.StudioRuntime.v1();
|
||||
});
|
||||
modal.show();
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
EditHelpers.installEditTemplates();
|
||||
});
|
||||
it('allows events to be listened to', function() {
|
||||
var canceled = false;
|
||||
runtime.listenTo('cancel', function() {
|
||||
canceled = true;
|
||||
});
|
||||
expect(canceled).toBeFalsy();
|
||||
runtime.notify('cancel', {});
|
||||
expect(canceled).toBeTruthy();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
EditHelpers.hideModalIfShowing(modal);
|
||||
});
|
||||
it('shows save notifications', function() {
|
||||
var title = 'Mock saving...',
|
||||
notificationSpy = EditHelpers.createNotificationSpy();
|
||||
runtime.notify('save', {
|
||||
state: 'start',
|
||||
message: title
|
||||
});
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, title);
|
||||
runtime.notify('save', {
|
||||
state: 'end'
|
||||
});
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it('cancels a modal dialog', function() {
|
||||
showMockModal();
|
||||
runtime.notify('modal-shown', modal);
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
runtime.notify('cancel');
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
it('shows error messages', function() {
|
||||
var title = 'Mock Error',
|
||||
message = 'This is a mock error.',
|
||||
notificationSpy = EditHelpers.createNotificationSpy('Error');
|
||||
runtime.notify('error', {
|
||||
title: title,
|
||||
message: message
|
||||
});
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, title);
|
||||
});
|
||||
|
||||
describe('Modal Dialogs', function() {
|
||||
var MockModal, modal, showMockModal;
|
||||
|
||||
MockModal = BaseModal.extend({
|
||||
getContentHtml: function() {
|
||||
return readFixtures('mock/mock-modal.underscore');
|
||||
}
|
||||
});
|
||||
|
||||
showMockModal = function() {
|
||||
modal = new MockModal({
|
||||
title: 'Mock Modal'
|
||||
});
|
||||
modal.show();
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
EditHelpers.installEditTemplates();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
EditHelpers.hideModalIfShowing(modal);
|
||||
});
|
||||
|
||||
it('cancels a modal dialog', function() {
|
||||
showMockModal();
|
||||
runtime.notify('modal-shown', modal);
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
runtime.notify('cancel');
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user