Commit 4ba07bf7 by cahrens Committed by Brian Jacobel

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.
parent 15f14814
...@@ -84,7 +84,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"], ...@@ -84,7 +84,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"],
expect(@confirmationSpies.constructor).not.toHaveBeenCalled() expect(@confirmationSpies.constructor).not.toHaveBeenCalled()
expect(@collection.contains(@model)).toBeTruthy() expect(@collection.contains(@model)).toBeTruthy()
# return a success response # return a success response
requests[0].respond(200) requests[0].respond(204)
expect(@confirmationSpies.constructor).toHaveBeenCalled() expect(@confirmationSpies.constructor).toHaveBeenCalled()
expect(@confirmationSpies.show).toHaveBeenCalled() expect(@confirmationSpies.show).toHaveBeenCalled()
savingOptions = @confirmationSpies.constructor.calls.mostRecent().args[0] savingOptions = @confirmationSpies.constructor.calls.mostRecent().args[0]
...@@ -118,7 +118,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"], ...@@ -118,7 +118,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"],
expect(savingOptions.title).toMatch("Saving") expect(savingOptions.title).toMatch("Saving")
expect(@model.get("locked")).toBeFalsy() expect(@model.get("locked")).toBeFalsy()
# return a success response # return a success response
requests[0].respond(200) requests[0].respond(204)
expect(@savingSpies.hide).toHaveBeenCalled() expect(@savingSpies.hide).toHaveBeenCalled()
expect(@model.get("locked")).toBeTruthy() expect(@model.get("locked")).toBeTruthy()
......
...@@ -87,7 +87,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js ...@@ -87,7 +87,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
savingOptions = @savingSpies.constructor.calls.mostRecent().args[0] savingOptions = @savingSpies.constructor.calls.mostRecent().args[0]
expect(savingOptions.title).toMatch(/Deleting/) expect(savingOptions.title).toMatch(/Deleting/)
# return a success response # return a success response
requests[0].respond(200) requests[0].respond(204)
expect(@savingSpies.hide).toHaveBeenCalled() expect(@savingSpies.hide).toHaveBeenCalled()
expect(@collection.contains(@model)).toBeFalsy() expect(@collection.contains(@model)).toBeFalsy()
......
...@@ -254,7 +254,7 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails ...@@ -254,7 +254,7 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
this.view.$(SELECTORS.signatory_panel_save).click(); this.view.$(SELECTORS.signatory_panel_save).click();
ViewHelpers.verifyNotificationShowing(notificationSpy, /Saving/); ViewHelpers.verifyNotificationShowing(notificationSpy, /Saving/);
requests[0].respond(200); requests[0].respond(204);
ViewHelpers.verifyNotificationHidden(notificationSpy); ViewHelpers.verifyNotificationHidden(notificationSpy);
expect(this.view.$(SELECTORS.signatory_name_value)).toContainText('New Signatory Test Name'); expect(this.view.$(SELECTORS.signatory_name_value)).toContainText('New Signatory Test Name');
......
...@@ -7,7 +7,8 @@ define([ // jshint ignore:line ...@@ -7,7 +7,8 @@ define([ // jshint ignore:line
'js/certificates/views/certificate_preview', 'js/certificates/views/certificate_preview',
'common/js/spec_helpers/template_helpers', 'common/js/spec_helpers/template_helpers',
'common/js/spec_helpers/view_helpers', 'common/js/spec_helpers/view_helpers',
'common/js/spec_helpers/ajax_helpers' 'common/js/spec_helpers/ajax_helpers',
'jasmine-stealth'
], ],
function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHelpers) { function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHelpers) {
'use strict'; 'use strict';
......
...@@ -331,7 +331,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat ...@@ -331,7 +331,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat
expect(savingOptions.title).toMatch(/Saving/); expect(savingOptions.title).toMatch(/Saving/);
expect($('#unit-1')).toHaveClass('was-dropped'); expect($('#unit-1')).toHaveClass('was-dropped');
expect(request.requestBody).toEqual('{"children":["fourth-unit-id","first-unit-id"]}'); expect(request.requestBody).toEqual('{"children":["fourth-unit-id","first-unit-id"]}');
request.respond(200); request.respond(204);
expect(this.savingSpies.hide).toHaveBeenCalled(); expect(this.savingSpies.hide).toHaveBeenCalled();
this.clock.tick(1001); this.clock.tick(1001);
expect($('#unit-1')).not.toHaveClass('was-dropped'); expect($('#unit-1')).not.toHaveClass('was-dropped');
...@@ -360,7 +360,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat ...@@ -360,7 +360,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat
expect(request.requestBody).toEqual( expect(request.requestBody).toEqual(
'{"children":["second-unit-id","first-unit-id","third-unit-id"]}' '{"children":["second-unit-id","first-unit-id","third-unit-id"]}'
); );
request.respond(200); request.respond(204);
this.clock.tick(1001); this.clock.tick(1001);
expect($('#unit-1')).not.toHaveClass('was-dropped'); expect($('#unit-1')).not.toHaveClass('was-dropped');
// parent // parent
......
...@@ -253,6 +253,16 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/components/u ...@@ -253,6 +253,16 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/components/u
]) ])
]); ]);
// Create a mock Course object as the JS now expects it.
window.course = new Course({
id: '333',
name: 'Course Name',
url_name: 'course_name',
org: 'course_org',
num: 'course_num',
revision: 'course_rev'
});
}); });
afterEach(function () { afterEach(function () {
......
...@@ -101,7 +101,7 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers ...@@ -101,7 +101,7 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers
var values_with_blank = values.slice(); var values_with_blank = values.slice();
values_with_blank[i] = ''; values_with_blank[i] = '';
fillInLibraryFields.apply(this, values_with_blank); fillInLibraryFields.apply(this, values_with_blank);
expect($('.create-library li.field.text input[value=]').parent()).toHaveClass('error'); expect($('.create-library li.field.text input').parent()).toHaveClass('error');
expect($('.new-library-save')).toHaveClass('is-disabled'); expect($('.new-library-save')).toHaveClass('is-disabled');
expect($('.new-library-save')).toHaveAttr('aria-disabled', 'true'); expect($('.new-library-save')).toHaveAttr('aria-disabled', 'true');
$('.new-library-save').click(); $('.new-library-save').click();
......
...@@ -9,7 +9,7 @@ function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) { ...@@ -9,7 +9,7 @@ function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
var team_member_fixture = readFixtures("team-member.underscore"); var team_member_fixture = readFixtures("team-member.underscore");
function setRole(email, role){ function setRole(email, role){
var user_li = $("li.user-item[data-email="+ email + "]"); var user_li = $('li.user-item[data-email="'+ email + '"]');
var role_action = $("li.action-role a.make-"+role, user_li); var role_action = $("li.action-role a.make-"+role, user_li);
expect(role_action).toBeVisible(); expect(role_action).toBeVisible();
role_action.click(); role_action.click();
......
...@@ -99,7 +99,7 @@ define(["jquery", "URI", "common/js/spec_helpers/ajax_helpers", "common/js/compo ...@@ -99,7 +99,7 @@ define(["jquery", "URI", "common/js/spec_helpers/ajax_helpers", "common/js/compo
mimetype: "application/javascript", kind: "url", data: missingJavaScriptUrl mimetype: "application/javascript", kind: "url", data: missingJavaScriptUrl
}] }]
]); ]);
expect(promise.isRejected()).toBe(true); expect(promise.state()).toBe("rejected");
}); });
it('Triggers an event to the runtime when a notification-action-button is clicked', function () { it('Triggers an event to the runtime when a notification-action-button is clicked', function () {
......
...@@ -229,10 +229,9 @@ Feature: LMS.Answer problems ...@@ -229,10 +229,9 @@ Feature: LMS.Answer problems
Given I am viewing a "<ProblemType>" problem Given I am viewing a "<ProblemType>" problem
When I answer a "<ProblemType>" problem "<InitialCorrectness>ly" When I answer a "<ProblemType>" problem "<InitialCorrectness>ly"
Then my "<ProblemType>" answer is marked "<InitialCorrectness>" Then my "<ProblemType>" answer is marked "<InitialCorrectness>"
And I input an answer on a "<ProblemType>" problem "<OtherCorrectness>ly" And I reset the problem
Then my "<ProblemType>" answer is NOT marked "<InitialCorrectness>" Then my "<ProblemType>" answer is NOT marked "<InitialCorrectness>"
And my "<ProblemType>" answer is NOT marked "<OtherCorrectness>" And my "<ProblemType>" answer is NOT marked "<OtherCorrectness>"
And I reset the problem
Examples: Examples:
| ProblemType | InitialCorrectness | OtherCorrectness | | ProblemType | InitialCorrectness | OtherCorrectness |
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
if (!groupsEnabled) { if (!groupsEnabled) {
// If the user has chosen 'no', then clear the selection by setting // If the user has chosen 'no', then clear the selection by setting
// it to the first option which represents no selection. // 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 // Enable the select if the user has chosen groups, else disable it
this.$('.input-cohort-group-association').prop('disabled', !groupsEnabled); this.$('.input-cohort-group-association').prop('disabled', !groupsEnabled);
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
getSelectedContentGroup: function() { getSelectedContentGroup: function() {
var selectValue = this.$('.input-cohort-group-association').val(), var selectValue = this.$('.input-cohort-group-association').val(),
ids, groupId, userPartitionId, i, contentGroup; ids, groupId, userPartitionId, i, contentGroup;
if (!this.hasAssociatedContentGroup() || selectValue === 'None') { if (!this.hasAssociatedContentGroup() || _.isNull(selectValue)) {
return null; return null;
} }
ids = selectValue.split(':'); ids = selectValue.split(':');
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
errorMessages.push(gettext('You must specify a name for the cohort')); errorMessages.push(gettext('You must specify a name for the cohort'));
} }
if (this.hasAssociatedContentGroup() && fieldData.group_id === null) { 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')); errorMessages.push(gettext('You did not select a content group'));
} else { } else {
// If a value was selected, then it must be for a non-existent/deleted content group // If a value was selected, then it must be for a non-existent/deleted content group
......
...@@ -17,12 +17,18 @@ var edx = edx || {}; ...@@ -17,12 +17,18 @@ var edx = edx || {};
}, },
clicked: function (event) { clicked: function (event) {
if (event.currentTarget.checked) { if (event.currentTarget.checked) {
this.$el.find('#coupon_expiration_date').show(); this.show(this.$('#coupon_expiration_date'));
this.$el.find('#coupon_expiration_date').focus(); this.$el.find('#coupon_expiration_date').focus();
} }
else { 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');
} }
}); });
......
...@@ -223,7 +223,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/ ...@@ -223,7 +223,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
clearContentGroup = function() { clearContentGroup = function() {
cohortsView.$('.radio-no').prop('checked', true).change(); cohortsView.$('.radio-no').prop('checked', true).change();
expect(cohortsView.$('.input-cohort-group-association').prop('disabled')).toBeTruthy(); 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) { verifyMessage = function(expectedTitle, expectedMessageType, expectedAction, hasDetails) {
......
...@@ -22,7 +22,6 @@ define(['backbone', 'jquery', 'js/instructor_dashboard/ecommerce'], ...@@ -22,7 +22,6 @@ define(['backbone', 'jquery', 'js/instructor_dashboard/ecommerce'],
it("shows the input field when the checkbox is checked", function () { it("shows the input field when the checkbox is checked", function () {
var target = expiryCouponView.$el.find('input[type="checkbox"]'); var target = expiryCouponView.$el.find('input[type="checkbox"]');
target.attr("checked","checked");
target.click(); target.click();
expect(expiryCouponView.$el.find('#coupon_expiration_date').is(':visible')).toBe(true); expect(expiryCouponView.$el.find('#coupon_expiration_date').is(':visible')).toBe(true);
}); });
...@@ -30,7 +29,6 @@ define(['backbone', 'jquery', 'js/instructor_dashboard/ecommerce'], ...@@ -30,7 +29,6 @@ define(['backbone', 'jquery', 'js/instructor_dashboard/ecommerce'],
it("hides the input field when the checkbox is unchecked", function () { it("hides the input field when the checkbox is unchecked", function () {
var target = expiryCouponView.$el.find('input[type="checkbox"]'); var target = expiryCouponView.$el.find('input[type="checkbox"]');
expect(expiryCouponView.$el.find('#coupon_expiration_date')).toHaveAttr('style','display: none;'); expect(expiryCouponView.$el.find('#coupon_expiration_date')).toHaveAttr('style','display: none;');
}); });
}); });
}); });
...@@ -298,6 +298,10 @@ ...@@ -298,6 +298,10 @@
exports: 'coffee/src/instructor_dashboard/student_admin', exports: 'coffee/src/instructor_dashboard/student_admin',
deps: ['jquery', 'underscore', 'coffee/src/instructor_dashboard/util', 'string_utils'] 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': { 'js/instructor_dashboard/certificates': {
exports: 'js/instructor_dashboard/certificates', exports: 'js/instructor_dashboard/certificates',
deps: ['jquery', 'gettext', 'underscore'] deps: ['jquery', 'gettext', 'underscore']
...@@ -501,6 +505,14 @@ ...@@ -501,6 +505,14 @@
exports: 'Annotator', exports: 'Annotator',
deps: ['jquery'] deps: ['jquery']
}, },
'slick.core': {
deps: ['jquery'],
exports: 'Slick'
},
'slick.grid': {
deps: ['jquery', 'jquery.eventDrag', 'slick.core'],
exports: 'Slick'
},
// Discussions // Discussions
'xmodule_js/common_static/coffee/src/discussion/utils': { 'xmodule_js/common_static/coffee/src/discussion/utils': {
deps: [ deps: [
......
...@@ -132,6 +132,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers ...@@ -132,6 +132,7 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
}); });
it("expects all fields to behave correctly", function () { it("expects all fields to behave correctly", function () {
var i, view;
requests = AjaxHelpers.requests(this); requests = AjaxHelpers.requests(this);
...@@ -146,9 +147,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers ...@@ -146,9 +147,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
expect(sectionsData[0].fields.length).toBe(6); expect(sectionsData[0].fields.length).toBe(6);
var textFields = [sectionsData[0].fields[1], sectionsData[0].fields[2]]; var textFields = [sectionsData[0].fields[1], sectionsData[0].fields[2]];
for (var i = 0; i < textFields.length ; i++) { for (i = 0; i < textFields.length ; i++) {
view = textFields[i].view;
var view = textFields[i].view;
FieldViewsSpecHelpers.verifyTextField(view, { FieldViewsSpecHelpers.verifyTextField(view, {
title: view.options.title, title: view.options.title,
valueAttribute: view.options.valueAttribute, valueAttribute: view.options.valueAttribute,
......
...@@ -267,13 +267,25 @@ ...@@ -267,13 +267,25 @@
}); });
it('displays an error if there is no internet connection', function () { 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); createLoginView(this);
// Submit the form, with successful validation // Submit the form, with successful validation
submitForm(true); submitForm(true);
// Simulate an error from the LMS servers // Simulate a request timeout
AjaxHelpers.respondWithError(requests, 0); clock.tick(timeout + 1);
// Expect that an error is displayed and that auth complete is not triggered // Expect that an error is displayed and that auth complete is not triggered
expect(view.$errors).not.toHaveClass('hidden'); expect(view.$errors).not.toHaveClass('hidden');
...@@ -281,7 +293,12 @@ ...@@ -281,7 +293,12 @@
expect(view.$errors.text()).toContain( expect(view.$errors.text()).toContain(
'An error has occurred. Check your Internet connection and try again.' '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 () { it('displays an error if there is a server error', function () {
createLoginView(this); createLoginView(this);
......
...@@ -42,7 +42,7 @@ define([ ...@@ -42,7 +42,7 @@ define([
// Simulate the server response // Simulate the server response
if ( succeeds ) { if ( succeeds ) {
AjaxHelpers.respondWithJson( requests, {} ); AjaxHelpers.respondWithJson( requests, {url: '/arbitrary-url/'} );
} else { } else {
AjaxHelpers.respondWithTextError( requests, 400, SERVER_ERROR_MSG ); AjaxHelpers.respondWithTextError( requests, 400, SERVER_ERROR_MSG );
} }
......
...@@ -240,8 +240,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers ...@@ -240,8 +240,8 @@ define(['backbone', 'jquery', 'underscore', 'common/js/spec_helpers/ajax_helpers
verifyEditableField(view, _.extend({ verifyEditableField(view, _.extend({
valueSelector: '.u-field-value', valueSelector: '.u-field-value',
valueInputSelector: '.u-field-value > input' valueInputSelector: '.u-field-value > input'
}, data }, data),
), requests); requests);
}; };
var verifyDropDownField = function (view, data, requests) { var verifyDropDownField = function (view, data, requests) {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
}, },
parse : function(response) { parse : function(response) {
if (_.isNull(response)) { if (_.isNull(response) || _.isUndefined(response)) {
return {}; return {};
} }
......
...@@ -218,13 +218,13 @@ ...@@ -218,13 +218,13 @@
this.backend = this.backends[obj.backendName] || obj.backend; this.backend = this.backends[obj.backendName] || obj.backend;
this.captureSoundPath = obj.captureSoundPath || ""; this.captureSoundPath = obj.captureSoundPath || "";
_.extend( this.backend, Backbone.Events );
this.backend.initialize({ this.backend.initialize({
wrapper: "#camera", wrapper: "#camera",
video: '#photo_id_video', video: '#photo_id_video',
canvas: '#photo_id_canvas' canvas: '#photo_id_canvas'
}); });
_.extend( this.backend, Backbone.Events );
this.listenTo( this.backend, 'error', this.handleError ); this.listenTo( this.backend, 'error', this.handleError );
this.listenTo( this.backend, 'webcam-loaded', this.handleWebcamLoaded ); this.listenTo( this.backend, 'webcam-loaded', this.handleWebcamLoaded );
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment