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 |
......
# Mostly adapted from math.stackexchange.com: http://cdn.sstatic.net/js/mathjax-editing-new.js # Mostly adapted from math.stackexchange.com: http://cdn.sstatic.net/js/mathjax-editing-new.js
$ -> class MathJaxProcessor
class MathJaxProcessor MATHSPLIT = /// (
\$\$? # normal inline or display delimiter
MATHSPLIT = /// ( | \\(?:begin|end)\{[a-z]*\*?\} # \begin{} \end{} style
\$\$? # normal inline or display delimiter | \\[\\{}$]
| \\(?:begin|end)\{[a-z]*\*?\} # \begin{} \end{} style | [{}]
| \\[\\{}$] | (?:\n\s*)+ # only treat as math when there's single new line
| [{}] | @@\d+@@ # delimiter similar to the one used internally
| (?:\n\s*)+ # only treat as math when there's single new line ) ///i
| @@\d+@@ # delimiter similar to the one used internally
) ///i CODESPAN = ///
(^|[^\\]) # match beginning or any previous character other than escape delimiter ('/')
CODESPAN = /// (`+) # code span starts
(^|[^\\]) # match beginning or any previous character other than escape delimiter ('/') ([^\n]*?[^`\n]) # code content
(`+) # code span starts \2 # code span ends
([^\n]*?[^`\n]) # code content (?!`)
\2 # code span ends ///gm
(?!`)
///gm constructor: (inlineMark, displayMark) ->
@inlineMark = inlineMark || "$"
constructor: (inlineMark, displayMark) -> @displayMark = displayMark || "$$"
@inlineMark = inlineMark || "$" @math = null
@displayMark = displayMark || "$$" @blocks = null
@math = null
@blocks = null processMath: (start, last, preProcess) ->
block = @blocks.slice(start, last + 1).join("").replace(/&/g, "&amp;")
processMath: (start, last, preProcess) -> .replace(/</g, "&lt;")
block = @blocks.slice(start, last + 1).join("").replace(/&/g, "&amp;") .replace(/>/g, "&gt;")
.replace(/</g, "&lt;") if MathJax.Hub.Browser.isMSIE
.replace(/>/g, "&gt;") block = block.replace /(%[^\n]*)\n/g, "$1<br/>\n"
if MathJax.Hub.Browser.isMSIE @blocks[i] = "" for i in [start+1..last]
block = block.replace /(%[^\n]*)\n/g, "$1<br/>\n" @blocks[start] = "@@#{@math.length}@@"
@blocks[i] = "" for i in [start+1..last] block = preProcess(block) if preProcess
@blocks[start] = "@@#{@math.length}@@" @math.push block
block = preProcess(block) if preProcess
@math.push block removeMath: (text) ->
removeMath: (text) -> text = text || ""
@math = []
text = text || "" start = end = last = null
@math = [] braces = 0
start = end = last = null
braces = 0 hasCodeSpans = /`/.test text
if hasCodeSpans
hasCodeSpans = /`/.test text text = text.replace(/~/g, "~T").replace CODESPAN, ($0) -> # replace dollar sign in code span temporarily
if hasCodeSpans $0.replace /\$/g, "~D"
text = text.replace(/~/g, "~T").replace CODESPAN, ($0) -> # replace dollar sign in code span temporarily deTilde = (text) ->
$0.replace /\$/g, "~D" text.replace /~([TD])/g, ($0, $1) ->
deTilde = (text) -> {T: "~", D: "$"}[$1]
text.replace /~([TD])/g, ($0, $1) -> else
{T: "~", D: "$"}[$1] deTilde = (text) -> text
else
deTilde = (text) -> text @blocks = _split(text.replace(/\r\n?/g, "\n"), MATHSPLIT)
@blocks = _split(text.replace(/\r\n?/g, "\n"), MATHSPLIT) for current in [1...@blocks.length] by 2
block = @blocks[current]
for current in [1...@blocks.length] by 2 if block.charAt(0) == "@"
block = @blocks[current] @blocks[current] = "@@#{@math.length}@@"
if block.charAt(0) == "@" @math.push block
@blocks[current] = "@@#{@math.length}@@" else if start
@math.push block if block == end
else if start if braces
if block == end last = current
if braces else
last = current @processMath(start, current, deTilde)
else
@processMath(start, current, deTilde)
start = end = last = null
else if block.match /\n.*\n/
if last
current = last
@processMath(start, current, deTilde)
start = end = last = null start = end = last = null
braces = 0 else if block.match /\n.*\n/
else if block == "{" if last
++braces current = last
else if block == "}" and braces @processMath(start, current, deTilde)
--braces start = end = last = null
else braces = 0
if block == @inlineMark or block == @displayMark else if block == "{"
start = current ++braces
end = block else if block == "}" and braces
braces = 0 --braces
else if block.substr(1, 5) == "begin" else
start = current if block == @inlineMark or block == @displayMark
end = "\\end" + block.substr(6) start = current
braces = 0 end = block
braces = 0
if last else if block.substr(1, 5) == "begin"
@processMath(start, last, deTilde) start = current
start = end = last = null end = "\\end" + block.substr(6)
braces = 0
deTilde(@blocks.join(""))
if last
@removeMathWrapper: (_this) -> @processMath(start, last, deTilde)
(text) -> _this.removeMath(text) start = end = last = null
replaceMath: (text) -> deTilde(@blocks.join(""))
text = text.replace /@@(\d+)@@/g, ($0, $1) => @math[$1]
@math = null @removeMathWrapper: (_this) ->
text (text) -> _this.removeMath(text)
@replaceMathWrapper: (_this) -> replaceMath: (text) ->
(text) -> _this.replaceMath(text) text = text.replace /@@(\d+)@@/g, ($0, $1) => @math[$1]
@math = null
if Markdown? text
Markdown.getMathCompatibleConverter = (postProcessor) -> @replaceMathWrapper: (_this) ->
postProcessor ||= ((text) -> text) (text) -> _this.replaceMath(text)
converter = Markdown.getSanitizingConverter()
if MathJax? if Markdown?
processor = new MathJaxProcessor()
converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor) Markdown.getMathCompatibleConverter = (postProcessor) ->
converter.hooks.chain "postConversion", (text) -> postProcessor ||= ((text) -> text)
postProcessor(MathJaxProcessor.replaceMathWrapper(processor)(text)) converter = Markdown.getSanitizingConverter()
converter if MathJax?
processor = new MathJaxProcessor()
Markdown.makeWmdEditor = (elem, appended_id, imageUploadUrl, postProcessor) -> converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor)
$elem = $(elem) converter.hooks.chain "postConversion", (text) ->
if not $elem.length postProcessor(MathJaxProcessor.replaceMathWrapper(processor)(text))
console.log "warning: elem for makeWmdEditor doesn't exist" converter
return
if not $elem.find(".wmd-panel").length Markdown.makeWmdEditor = (elem, appended_id, imageUploadUrl, postProcessor) ->
initialText = $elem.html() $elem = $(elem)
$elem.empty() if not $elem.length
_append = appended_id || "" console.log "warning: elem for makeWmdEditor doesn't exist"
wmdInputId = "wmd-input#{_append}" return
$wmdPreviewContainer = $("<div>").addClass("wmd-preview-container") if not $elem.find(".wmd-panel").length
.append($("<div>").addClass("wmd-preview-label").text(gettext("Preview"))) initialText = $elem.html()
.append($("<div>").attr("id", "wmd-preview#{_append}").addClass("wmd-panel wmd-preview")) $elem.empty()
$wmdPanel = $("<div>").addClass("wmd-panel") _append = appended_id || ""
.append($("<div>").attr("id", "wmd-button-bar#{_append}")) wmdInputId = "wmd-input#{_append}"
.append($("<label>").addClass("sr").attr("for", wmdInputId).text(gettext("Post body"))) $wmdPreviewContainer = $("<div>").addClass("wmd-preview-container")
.append($("<textarea>").addClass("wmd-input").attr("id", wmdInputId).html(initialText)) .append($("<div>").addClass("wmd-preview-label").text(gettext("Preview")))
.append($wmdPreviewContainer) .append($("<div>").attr("id", "wmd-preview#{_append}").addClass("wmd-panel wmd-preview"))
$elem.append($wmdPanel) $wmdPanel = $("<div>").addClass("wmd-panel")
.append($("<div>").attr("id", "wmd-button-bar#{_append}"))
converter = Markdown.getMathCompatibleConverter(postProcessor) .append($("<label>").addClass("sr").attr("for", wmdInputId).text(gettext("Post body")))
.append($("<textarea>").addClass("wmd-input").attr("id", wmdInputId).html(initialText))
ajaxFileUpload = (imageUploadUrl, input, startUploadHandler) -> .append($wmdPreviewContainer)
$("#loading").ajaxStart(-> $(this).show()).ajaxComplete(-> $(this).hide()) $elem.append($wmdPanel)
$("#upload").ajaxStart(-> $(this).hide()).ajaxComplete(-> $(this).show())
$.ajaxFileUpload converter = Markdown.getMathCompatibleConverter(postProcessor)
url: imageUploadUrl
secureuri: false ajaxFileUpload = (imageUploadUrl, input, startUploadHandler) ->
fileElementId: 'file-upload' $("#loading").ajaxStart(-> $(this).show()).ajaxComplete(-> $(this).hide())
dataType: 'json' $("#upload").ajaxStart(-> $(this).hide()).ajaxComplete(-> $(this).show())
success: (data, status) -> $.ajaxFileUpload
fileURL = data['result']['file_url'] url: imageUploadUrl
error = data['result']['error'] secureuri: false
if error != '' fileElementId: 'file-upload'
alert error dataType: 'json'
if startUploadHandler success: (data, status) ->
$('#file-upload').unbind('change').change(startUploadHandler) fileURL = data['result']['file_url']
console.log error error = data['result']['error']
else if error != ''
$(input).attr('value', fileURL) alert error
error: (data, status, e) ->
alert(e)
if startUploadHandler if startUploadHandler
$('#file-upload').unbind('change').change(startUploadHandler) $('#file-upload').unbind('change').change(startUploadHandler)
console.log error
imageUploadHandler = (elem, input) -> else
ajaxFileUpload(imageUploadUrl, input, imageUploadHandler) $(input).attr('value', fileURL)
error: (data, status, e) ->
editor = new Markdown.Editor( alert(e)
converter, if startUploadHandler
appended_id, # idPostfix $('#file-upload').unbind('change').change(startUploadHandler)
null, # help handler
imageUploadHandler imageUploadHandler = (elem, input) ->
) ajaxFileUpload(imageUploadUrl, input, imageUploadHandler)
delayRenderer = new MathJaxDelayRenderer()
editor.hooks.chain "onPreviewPush", (text, previewSet) -> editor = new Markdown.Editor(
delayRenderer.render converter,
text: text appended_id, # idPostfix
previewSetter: previewSet null, # help handler
editor.run() imageUploadHandler
editor )
delayRenderer = new MathJaxDelayRenderer()
editor.hooks.chain "onPreviewPush", (text, previewSet) ->
delayRenderer.render
text: text
previewSetter: previewSet
editor.run()
editor
...@@ -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