Assorted test and dependency fixes to cms-squire and cms

isRejected is deprecated.

Actually serve the slick library in LMS jasmine tests

customwmd doesn't need to wait for DOM ready event

... In order to define a class and extend the Markdown class.
This commit is contained in:
cahrens
2016-02-23 12:44:01 -05:00
committed by Brian Jacobel
parent 15f148141f
commit 4ba07bf7a4
22 changed files with 226 additions and 185 deletions

View File

@@ -56,7 +56,7 @@
if (!groupsEnabled) {
// If the user has chosen 'no', then clear the selection by setting
// it to the first option which represents no selection.
this.$('.input-cohort-group-association').val('None');
this.$('.input-cohort-group-association').val(null);
}
// Enable the select if the user has chosen groups, else disable it
this.$('.input-cohort-group-association').prop('disabled', !groupsEnabled);
@@ -69,7 +69,7 @@
getSelectedContentGroup: function() {
var selectValue = this.$('.input-cohort-group-association').val(),
ids, groupId, userPartitionId, i, contentGroup;
if (!this.hasAssociatedContentGroup() || selectValue === 'None') {
if (!this.hasAssociatedContentGroup() || _.isNull(selectValue)) {
return null;
}
ids = selectValue.split(':');
@@ -107,7 +107,7 @@
errorMessages.push(gettext('You must specify a name for the cohort'));
}
if (this.hasAssociatedContentGroup() && fieldData.group_id === null) {
if (this.$('.input-cohort-group-association').val() === 'None') {
if (_.isNull(this.$('.input-cohort-group-association').val())) {
errorMessages.push(gettext('You did not select a content group'));
} else {
// If a value was selected, then it must be for a non-existent/deleted content group

View File

@@ -17,12 +17,18 @@ var edx = edx || {};
},
clicked: function (event) {
if (event.currentTarget.checked) {
this.$el.find('#coupon_expiration_date').show();
this.show(this.$('#coupon_expiration_date'));
this.$el.find('#coupon_expiration_date').focus();
}
else {
this.$el.find('#coupon_expiration_date').hide();
this.hide(this.$('#coupon_expiration_date'));
}
},
show: function ($el) {
$el.css('display', 'inline');
},
hide: function ($el) {
$el.css('display', 'none');
}
});

View File

@@ -223,7 +223,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
clearContentGroup = function() {
cohortsView.$('.radio-no').prop('checked', true).change();
expect(cohortsView.$('.input-cohort-group-association').prop('disabled')).toBeTruthy();
expect(cohortsView.$('.input-cohort-group-association').val()).toBe('None');
expect(cohortsView.$('.input-cohort-group-association').val()).toBe(null);
};
verifyMessage = function(expectedTitle, expectedMessageType, expectedAction, hasDetails) {

View File

@@ -22,7 +22,6 @@ define(['backbone', 'jquery', 'js/instructor_dashboard/ecommerce'],
it("shows the input field when the checkbox is checked", function () {
var target = expiryCouponView.$el.find('input[type="checkbox"]');
target.attr("checked","checked");
target.click();
expect(expiryCouponView.$el.find('#coupon_expiration_date').is(':visible')).toBe(true);
});
@@ -30,7 +29,6 @@ define(['backbone', 'jquery', 'js/instructor_dashboard/ecommerce'],
it("hides the input field when the checkbox is unchecked", function () {
var target = expiryCouponView.$el.find('input[type="checkbox"]');
expect(expiryCouponView.$el.find('#coupon_expiration_date')).toHaveAttr('style','display: none;');
});
});
});

View File

@@ -298,6 +298,10 @@
exports: 'coffee/src/instructor_dashboard/student_admin',
deps: ['jquery', 'underscore', 'coffee/src/instructor_dashboard/util', 'string_utils']
},
'coffee/src/instructor_dashboard/util': {
exports: 'coffee/src/instructor_dashboard/util',
deps: ['jquery', 'underscore', 'slick.core', 'slick.grid']
},
'js/instructor_dashboard/certificates': {
exports: 'js/instructor_dashboard/certificates',
deps: ['jquery', 'gettext', 'underscore']
@@ -501,6 +505,14 @@
exports: 'Annotator',
deps: ['jquery']
},
'slick.core': {
deps: ['jquery'],
exports: 'Slick'
},
'slick.grid': {
deps: ['jquery', 'jquery.eventDrag', 'slick.core'],
exports: 'Slick'
},
// Discussions
'xmodule_js/common_static/coffee/src/discussion/utils': {
deps: [

View File

@@ -132,6 +132,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
});
it("expects all fields to behave correctly", function () {
var i, view;
requests = AjaxHelpers.requests(this);
@@ -146,9 +147,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
expect(sectionsData[0].fields.length).toBe(6);
var textFields = [sectionsData[0].fields[1], sectionsData[0].fields[2]];
for (var i = 0; i < textFields.length ; i++) {
var view = textFields[i].view;
for (i = 0; i < textFields.length ; i++) {
view = textFields[i].view;
FieldViewsSpecHelpers.verifyTextField(view, {
title: view.options.title,
valueAttribute: view.options.valueAttribute,

View File

@@ -267,13 +267,25 @@
});
it('displays an error if there is no internet connection', function () {
var clock,
oldTimeout,
timeout;
// We're defining "no internet connection" in this case as the
// request timing out. We use a combination of the sinon fake
// timer and jQuery.ajaxSetup() to force a request timeout.
clock = sinon.useFakeTimers();
oldTimeout = $.ajaxSetup().timeout;
timeout = 1;
$.ajaxSetup({timeout: timeout});
createLoginView(this);
// Submit the form, with successful validation
submitForm(true);
// Simulate an error from the LMS servers
AjaxHelpers.respondWithError(requests, 0);
// Simulate a request timeout
clock.tick(timeout + 1);
// Expect that an error is displayed and that auth complete is not triggered
expect(view.$errors).not.toHaveClass('hidden');
@@ -281,7 +293,12 @@
expect(view.$errors.text()).toContain(
'An error has occurred. Check your Internet connection and try again.'
);
// Finally, restore the old timeout and turn off the fake timer.
$.ajaxSetup({timeout: oldTimeout});
clock.restore();
});
it('displays an error if there is a server error', function () {
createLoginView(this);

View File

@@ -42,7 +42,7 @@ define([
// Simulate the server response
if ( succeeds ) {
AjaxHelpers.respondWithJson( requests, {} );
AjaxHelpers.respondWithJson( requests, {url: '/arbitrary-url/'} );
} else {
AjaxHelpers.respondWithTextError( requests, 400, SERVER_ERROR_MSG );
}

View File

@@ -240,8 +240,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
verifyEditableField(view, _.extend({
valueSelector: '.u-field-value',
valueInputSelector: '.u-field-value > input'
}, data
), requests);
}, data),
requests);
};
var verifyDropDownField = function (view, data, requests) {

View File

@@ -28,7 +28,7 @@
},
parse : function(response) {
if (_.isNull(response)) {
if (_.isNull(response) || _.isUndefined(response)) {
return {};
}

View File

@@ -218,13 +218,13 @@
this.backend = this.backends[obj.backendName] || obj.backend;
this.captureSoundPath = obj.captureSoundPath || "";
_.extend( this.backend, Backbone.Events );
this.backend.initialize({
wrapper: "#camera",
video: '#photo_id_video',
canvas: '#photo_id_canvas'
});
_.extend( this.backend, Backbone.Events );
this.listenTo( this.backend, 'error', this.handleError );
this.listenTo( this.backend, 'webcam-loaded', this.handleWebcamLoaded );
},