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:
@@ -84,7 +84,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"],
|
||||
expect(@confirmationSpies.constructor).not.toHaveBeenCalled()
|
||||
expect(@collection.contains(@model)).toBeTruthy()
|
||||
# return a success response
|
||||
requests[0].respond(200)
|
||||
requests[0].respond(204)
|
||||
expect(@confirmationSpies.constructor).toHaveBeenCalled()
|
||||
expect(@confirmationSpies.show).toHaveBeenCalled()
|
||||
savingOptions = @confirmationSpies.constructor.calls.mostRecent().args[0]
|
||||
@@ -118,7 +118,7 @@ define ["jquery", "common/js/spec_helpers/ajax_helpers", "squire"],
|
||||
expect(savingOptions.title).toMatch("Saving")
|
||||
expect(@model.get("locked")).toBeFalsy()
|
||||
# return a success response
|
||||
requests[0].respond(200)
|
||||
requests[0].respond(204)
|
||||
expect(@savingSpies.hide).toHaveBeenCalled()
|
||||
expect(@model.get("locked")).toBeTruthy()
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
|
||||
savingOptions = @savingSpies.constructor.calls.mostRecent().args[0]
|
||||
expect(savingOptions.title).toMatch(/Deleting/)
|
||||
# return a success response
|
||||
requests[0].respond(200)
|
||||
requests[0].respond(204)
|
||||
expect(@savingSpies.hide).toHaveBeenCalled()
|
||||
expect(@collection.contains(@model)).toBeFalsy()
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
this.view.$(SELECTORS.signatory_panel_save).click();
|
||||
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Saving/);
|
||||
requests[0].respond(200);
|
||||
requests[0].respond(204);
|
||||
ViewHelpers.verifyNotificationHidden(notificationSpy);
|
||||
|
||||
expect(this.view.$(SELECTORS.signatory_name_value)).toContainText('New Signatory Test Name');
|
||||
|
||||
@@ -7,7 +7,8 @@ define([ // jshint ignore:line
|
||||
'js/certificates/views/certificate_preview',
|
||||
'common/js/spec_helpers/template_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) {
|
||||
'use strict';
|
||||
|
||||
@@ -331,7 +331,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat
|
||||
expect(savingOptions.title).toMatch(/Saving/);
|
||||
expect($('#unit-1')).toHaveClass('was-dropped');
|
||||
expect(request.requestBody).toEqual('{"children":["fourth-unit-id","first-unit-id"]}');
|
||||
request.respond(200);
|
||||
request.respond(204);
|
||||
expect(this.savingSpies.hide).toHaveBeenCalled();
|
||||
this.clock.tick(1001);
|
||||
expect($('#unit-1')).not.toHaveClass('was-dropped');
|
||||
@@ -360,7 +360,7 @@ define(["js/utils/drag_and_drop", "common/js/components/views/feedback_notificat
|
||||
expect(request.requestBody).toEqual(
|
||||
'{"children":["second-unit-id","first-unit-id","third-unit-id"]}'
|
||||
);
|
||||
request.respond(200);
|
||||
request.respond(204);
|
||||
this.clock.tick(1001);
|
||||
expect($('#unit-1')).not.toHaveClass('was-dropped');
|
||||
// parent
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -101,7 +101,7 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/spec_helpers
|
||||
var values_with_blank = values.slice();
|
||||
values_with_blank[i] = '';
|
||||
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')).toHaveAttr('aria-disabled', 'true');
|
||||
$('.new-library-save').click();
|
||||
|
||||
@@ -9,7 +9,7 @@ function ($, AjaxHelpers, ViewHelpers, ManageUsersFactory, ViewUtils) {
|
||||
var team_member_fixture = readFixtures("team-member.underscore");
|
||||
|
||||
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);
|
||||
expect(role_action).toBeVisible();
|
||||
role_action.click();
|
||||
|
||||
@@ -99,7 +99,7 @@ define(["jquery", "URI", "common/js/spec_helpers/ajax_helpers", "common/js/compo
|
||||
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 () {
|
||||
|
||||
@@ -229,10 +229,9 @@ Feature: LMS.Answer problems
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
When I answer a "<ProblemType>" problem "<InitialCorrectness>ly"
|
||||
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>"
|
||||
And my "<ProblemType>" answer is NOT marked "<OtherCorrectness>"
|
||||
And I reset the problem
|
||||
|
||||
Examples:
|
||||
| ProblemType | InitialCorrectness | OtherCorrectness |
|
||||
|
||||
@@ -1,181 +1,179 @@
|
||||
# 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
|
||||
| \\(?: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
|
||||
) ///i
|
||||
|
||||
MATHSPLIT = /// (
|
||||
\$\$? # 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
|
||||
) ///i
|
||||
CODESPAN = ///
|
||||
(^|[^\\]) # match beginning or any previous character other than escape delimiter ('/')
|
||||
(`+) # code span starts
|
||||
([^\n]*?[^`\n]) # code content
|
||||
\2 # code span ends
|
||||
(?!`)
|
||||
///gm
|
||||
|
||||
CODESPAN = ///
|
||||
(^|[^\\]) # match beginning or any previous character other than escape delimiter ('/')
|
||||
(`+) # code span starts
|
||||
([^\n]*?[^`\n]) # code content
|
||||
\2 # code span ends
|
||||
(?!`)
|
||||
///gm
|
||||
constructor: (inlineMark, displayMark) ->
|
||||
@inlineMark = inlineMark || "$"
|
||||
@displayMark = displayMark || "$$"
|
||||
@math = null
|
||||
@blocks = null
|
||||
|
||||
constructor: (inlineMark, displayMark) ->
|
||||
@inlineMark = inlineMark || "$"
|
||||
@displayMark = displayMark || "$$"
|
||||
@math = null
|
||||
@blocks = null
|
||||
processMath: (start, last, preProcess) ->
|
||||
block = @blocks.slice(start, last + 1).join("").replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
if MathJax.Hub.Browser.isMSIE
|
||||
block = block.replace /(%[^\n]*)\n/g, "$1<br/>\n"
|
||||
@blocks[i] = "" for i in [start+1..last]
|
||||
@blocks[start] = "@@#{@math.length}@@"
|
||||
block = preProcess(block) if preProcess
|
||||
@math.push block
|
||||
|
||||
processMath: (start, last, preProcess) ->
|
||||
block = @blocks.slice(start, last + 1).join("").replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
if MathJax.Hub.Browser.isMSIE
|
||||
block = block.replace /(%[^\n]*)\n/g, "$1<br/>\n"
|
||||
@blocks[i] = "" for i in [start+1..last]
|
||||
@blocks[start] = "@@#{@math.length}@@"
|
||||
block = preProcess(block) if preProcess
|
||||
@math.push block
|
||||
removeMath: (text) ->
|
||||
|
||||
removeMath: (text) ->
|
||||
text = text || ""
|
||||
@math = []
|
||||
start = end = last = null
|
||||
braces = 0
|
||||
|
||||
text = text || ""
|
||||
@math = []
|
||||
start = end = last = null
|
||||
braces = 0
|
||||
hasCodeSpans = /`/.test text
|
||||
if hasCodeSpans
|
||||
text = text.replace(/~/g, "~T").replace CODESPAN, ($0) -> # replace dollar sign in code span temporarily
|
||||
$0.replace /\$/g, "~D"
|
||||
deTilde = (text) ->
|
||||
text.replace /~([TD])/g, ($0, $1) ->
|
||||
{T: "~", D: "$"}[$1]
|
||||
else
|
||||
deTilde = (text) -> text
|
||||
|
||||
hasCodeSpans = /`/.test text
|
||||
if hasCodeSpans
|
||||
text = text.replace(/~/g, "~T").replace CODESPAN, ($0) -> # replace dollar sign in code span temporarily
|
||||
$0.replace /\$/g, "~D"
|
||||
deTilde = (text) ->
|
||||
text.replace /~([TD])/g, ($0, $1) ->
|
||||
{T: "~", D: "$"}[$1]
|
||||
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]
|
||||
if block.charAt(0) == "@"
|
||||
@blocks[current] = "@@#{@math.length}@@"
|
||||
@math.push block
|
||||
else if start
|
||||
if block == end
|
||||
if braces
|
||||
last = current
|
||||
else
|
||||
@processMath(start, current, deTilde)
|
||||
start = end = last = null
|
||||
else if block.match /\n.*\n/
|
||||
if last
|
||||
current = last
|
||||
@processMath(start, current, deTilde)
|
||||
for current in [1...@blocks.length] by 2
|
||||
block = @blocks[current]
|
||||
if block.charAt(0) == "@"
|
||||
@blocks[current] = "@@#{@math.length}@@"
|
||||
@math.push block
|
||||
else if start
|
||||
if block == end
|
||||
if braces
|
||||
last = current
|
||||
else
|
||||
@processMath(start, current, deTilde)
|
||||
start = end = last = null
|
||||
braces = 0
|
||||
else if block == "{"
|
||||
++braces
|
||||
else if block == "}" and braces
|
||||
--braces
|
||||
else
|
||||
if block == @inlineMark or block == @displayMark
|
||||
start = current
|
||||
end = block
|
||||
braces = 0
|
||||
else if block.substr(1, 5) == "begin"
|
||||
start = current
|
||||
end = "\\end" + block.substr(6)
|
||||
braces = 0
|
||||
else if block.match /\n.*\n/
|
||||
if last
|
||||
current = last
|
||||
@processMath(start, current, deTilde)
|
||||
start = end = last = null
|
||||
braces = 0
|
||||
else if block == "{"
|
||||
++braces
|
||||
else if block == "}" and braces
|
||||
--braces
|
||||
else
|
||||
if block == @inlineMark or block == @displayMark
|
||||
start = current
|
||||
end = block
|
||||
braces = 0
|
||||
else if block.substr(1, 5) == "begin"
|
||||
start = current
|
||||
end = "\\end" + block.substr(6)
|
||||
braces = 0
|
||||
|
||||
if last
|
||||
@processMath(start, last, deTilde)
|
||||
start = end = last = null
|
||||
if last
|
||||
@processMath(start, last, deTilde)
|
||||
start = end = last = null
|
||||
|
||||
deTilde(@blocks.join(""))
|
||||
deTilde(@blocks.join(""))
|
||||
|
||||
@removeMathWrapper: (_this) ->
|
||||
(text) -> _this.removeMath(text)
|
||||
@removeMathWrapper: (_this) ->
|
||||
(text) -> _this.removeMath(text)
|
||||
|
||||
replaceMath: (text) ->
|
||||
text = text.replace /@@(\d+)@@/g, ($0, $1) => @math[$1]
|
||||
@math = null
|
||||
text
|
||||
replaceMath: (text) ->
|
||||
text = text.replace /@@(\d+)@@/g, ($0, $1) => @math[$1]
|
||||
@math = null
|
||||
text
|
||||
|
||||
@replaceMathWrapper: (_this) ->
|
||||
(text) -> _this.replaceMath(text)
|
||||
@replaceMathWrapper: (_this) ->
|
||||
(text) -> _this.replaceMath(text)
|
||||
|
||||
if Markdown?
|
||||
if Markdown?
|
||||
|
||||
Markdown.getMathCompatibleConverter = (postProcessor) ->
|
||||
postProcessor ||= ((text) -> text)
|
||||
converter = Markdown.getSanitizingConverter()
|
||||
if MathJax?
|
||||
processor = new MathJaxProcessor()
|
||||
converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor)
|
||||
converter.hooks.chain "postConversion", (text) ->
|
||||
postProcessor(MathJaxProcessor.replaceMathWrapper(processor)(text))
|
||||
converter
|
||||
Markdown.getMathCompatibleConverter = (postProcessor) ->
|
||||
postProcessor ||= ((text) -> text)
|
||||
converter = Markdown.getSanitizingConverter()
|
||||
if MathJax?
|
||||
processor = new MathJaxProcessor()
|
||||
converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor)
|
||||
converter.hooks.chain "postConversion", (text) ->
|
||||
postProcessor(MathJaxProcessor.replaceMathWrapper(processor)(text))
|
||||
converter
|
||||
|
||||
Markdown.makeWmdEditor = (elem, appended_id, imageUploadUrl, postProcessor) ->
|
||||
$elem = $(elem)
|
||||
if not $elem.length
|
||||
console.log "warning: elem for makeWmdEditor doesn't exist"
|
||||
return
|
||||
if not $elem.find(".wmd-panel").length
|
||||
initialText = $elem.html()
|
||||
$elem.empty()
|
||||
_append = appended_id || ""
|
||||
wmdInputId = "wmd-input#{_append}"
|
||||
$wmdPreviewContainer = $("<div>").addClass("wmd-preview-container")
|
||||
.append($("<div>").addClass("wmd-preview-label").text(gettext("Preview")))
|
||||
.append($("<div>").attr("id", "wmd-preview#{_append}").addClass("wmd-panel wmd-preview"))
|
||||
$wmdPanel = $("<div>").addClass("wmd-panel")
|
||||
.append($("<div>").attr("id", "wmd-button-bar#{_append}"))
|
||||
.append($("<label>").addClass("sr").attr("for", wmdInputId).text(gettext("Post body")))
|
||||
.append($("<textarea>").addClass("wmd-input").attr("id", wmdInputId).html(initialText))
|
||||
.append($wmdPreviewContainer)
|
||||
$elem.append($wmdPanel)
|
||||
Markdown.makeWmdEditor = (elem, appended_id, imageUploadUrl, postProcessor) ->
|
||||
$elem = $(elem)
|
||||
if not $elem.length
|
||||
console.log "warning: elem for makeWmdEditor doesn't exist"
|
||||
return
|
||||
if not $elem.find(".wmd-panel").length
|
||||
initialText = $elem.html()
|
||||
$elem.empty()
|
||||
_append = appended_id || ""
|
||||
wmdInputId = "wmd-input#{_append}"
|
||||
$wmdPreviewContainer = $("<div>").addClass("wmd-preview-container")
|
||||
.append($("<div>").addClass("wmd-preview-label").text(gettext("Preview")))
|
||||
.append($("<div>").attr("id", "wmd-preview#{_append}").addClass("wmd-panel wmd-preview"))
|
||||
$wmdPanel = $("<div>").addClass("wmd-panel")
|
||||
.append($("<div>").attr("id", "wmd-button-bar#{_append}"))
|
||||
.append($("<label>").addClass("sr").attr("for", wmdInputId).text(gettext("Post body")))
|
||||
.append($("<textarea>").addClass("wmd-input").attr("id", wmdInputId).html(initialText))
|
||||
.append($wmdPreviewContainer)
|
||||
$elem.append($wmdPanel)
|
||||
|
||||
converter = Markdown.getMathCompatibleConverter(postProcessor)
|
||||
converter = Markdown.getMathCompatibleConverter(postProcessor)
|
||||
|
||||
ajaxFileUpload = (imageUploadUrl, input, startUploadHandler) ->
|
||||
$("#loading").ajaxStart(-> $(this).show()).ajaxComplete(-> $(this).hide())
|
||||
$("#upload").ajaxStart(-> $(this).hide()).ajaxComplete(-> $(this).show())
|
||||
$.ajaxFileUpload
|
||||
url: imageUploadUrl
|
||||
secureuri: false
|
||||
fileElementId: 'file-upload'
|
||||
dataType: 'json'
|
||||
success: (data, status) ->
|
||||
fileURL = data['result']['file_url']
|
||||
error = data['result']['error']
|
||||
if error != ''
|
||||
alert error
|
||||
if startUploadHandler
|
||||
$('#file-upload').unbind('change').change(startUploadHandler)
|
||||
console.log error
|
||||
else
|
||||
$(input).attr('value', fileURL)
|
||||
error: (data, status, e) ->
|
||||
alert(e)
|
||||
ajaxFileUpload = (imageUploadUrl, input, startUploadHandler) ->
|
||||
$("#loading").ajaxStart(-> $(this).show()).ajaxComplete(-> $(this).hide())
|
||||
$("#upload").ajaxStart(-> $(this).hide()).ajaxComplete(-> $(this).show())
|
||||
$.ajaxFileUpload
|
||||
url: imageUploadUrl
|
||||
secureuri: false
|
||||
fileElementId: 'file-upload'
|
||||
dataType: 'json'
|
||||
success: (data, status) ->
|
||||
fileURL = data['result']['file_url']
|
||||
error = data['result']['error']
|
||||
if error != ''
|
||||
alert error
|
||||
if startUploadHandler
|
||||
$('#file-upload').unbind('change').change(startUploadHandler)
|
||||
console.log error
|
||||
else
|
||||
$(input).attr('value', fileURL)
|
||||
error: (data, status, e) ->
|
||||
alert(e)
|
||||
if startUploadHandler
|
||||
$('#file-upload').unbind('change').change(startUploadHandler)
|
||||
|
||||
imageUploadHandler = (elem, input) ->
|
||||
ajaxFileUpload(imageUploadUrl, input, imageUploadHandler)
|
||||
imageUploadHandler = (elem, input) ->
|
||||
ajaxFileUpload(imageUploadUrl, input, imageUploadHandler)
|
||||
|
||||
editor = new Markdown.Editor(
|
||||
converter,
|
||||
appended_id, # idPostfix
|
||||
null, # help handler
|
||||
imageUploadHandler
|
||||
)
|
||||
delayRenderer = new MathJaxDelayRenderer()
|
||||
editor.hooks.chain "onPreviewPush", (text, previewSet) ->
|
||||
delayRenderer.render
|
||||
text: text
|
||||
previewSetter: previewSet
|
||||
editor.run()
|
||||
editor
|
||||
editor = new Markdown.Editor(
|
||||
converter,
|
||||
appended_id, # idPostfix
|
||||
null, # help handler
|
||||
imageUploadHandler
|
||||
)
|
||||
delayRenderer = new MathJaxDelayRenderer()
|
||||
editor.hooks.chain "onPreviewPush", (text, previewSet) ->
|
||||
delayRenderer.render
|
||||
text: text
|
||||
previewSetter: previewSet
|
||||
editor.run()
|
||||
editor
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;');
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
|
||||
parse : function(response) {
|
||||
if (_.isNull(response)) {
|
||||
if (_.isNull(response) || _.isUndefined(response)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user