diff --git a/cms/static/coffee/spec/views/assets_spec.coffee b/cms/static/coffee/spec/views/assets_spec.coffee index 6c82b2e3e2..012539ac7c 100644 --- a/cms/static/coffee/spec/views/assets_spec.coffee +++ b/cms/static/coffee/spec/views/assets_spec.coffee @@ -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() diff --git a/cms/static/coffee/spec/views/textbook_spec.coffee b/cms/static/coffee/spec/views/textbook_spec.coffee index b2a251fb6d..bc855b621d 100644 --- a/cms/static/coffee/spec/views/textbook_spec.coffee +++ b/cms/static/coffee/spec/views/textbook_spec.coffee @@ -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() diff --git a/cms/static/js/certificates/spec/views/certificate_details_spec.js b/cms/static/js/certificates/spec/views/certificate_details_spec.js index 22b5781dc9..7d2a81d59d 100644 --- a/cms/static/js/certificates/spec/views/certificate_details_spec.js +++ b/cms/static/js/certificates/spec/views/certificate_details_spec.js @@ -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'); diff --git a/cms/static/js/certificates/spec/views/certificate_preview_spec.js b/cms/static/js/certificates/spec/views/certificate_preview_spec.js index 205b5fdf1c..5818e0ea01 100644 --- a/cms/static/js/certificates/spec/views/certificate_preview_spec.js +++ b/cms/static/js/certificates/spec/views/certificate_preview_spec.js @@ -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'; diff --git a/cms/static/js/spec/utils/drag_and_drop_spec.js b/cms/static/js/spec/utils/drag_and_drop_spec.js index cd061795fc..cb4b504cf1 100644 --- a/cms/static/js/spec/utils/drag_and_drop_spec.js +++ b/cms/static/js/spec/utils/drag_and_drop_spec.js @@ -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 diff --git a/cms/static/js/spec/views/pages/course_outline_spec.js b/cms/static/js/spec/views/pages/course_outline_spec.js index 9277a20282..5de589c5cf 100644 --- a/cms/static/js/spec/views/pages/course_outline_spec.js +++ b/cms/static/js/spec/views/pages/course_outline_spec.js @@ -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 () { diff --git a/cms/static/js/spec/views/pages/index_spec.js b/cms/static/js/spec/views/pages/index_spec.js index 4d857e151c..243aac1024 100644 --- a/cms/static/js/spec/views/pages/index_spec.js +++ b/cms/static/js/spec/views/pages/index_spec.js @@ -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(); diff --git a/cms/static/js/spec/views/pages/library_users_spec.js b/cms/static/js/spec/views/pages/library_users_spec.js index 107b8f47cd..3c6a4cb384 100644 --- a/cms/static/js/spec/views/pages/library_users_spec.js +++ b/cms/static/js/spec/views/pages/library_users_spec.js @@ -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(); diff --git a/cms/static/js/spec/views/xblock_spec.js b/cms/static/js/spec/views/xblock_spec.js index 9777008f05..d192517626 100644 --- a/cms/static/js/spec/views/xblock_spec.js +++ b/cms/static/js/spec/views/xblock_spec.js @@ -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 () { diff --git a/lms/djangoapps/courseware/features/problems.feature b/lms/djangoapps/courseware/features/problems.feature index 5994fcc464..a209133bbb 100644 --- a/lms/djangoapps/courseware/features/problems.feature +++ b/lms/djangoapps/courseware/features/problems.feature @@ -229,10 +229,9 @@ Feature: LMS.Answer problems Given I am viewing a "" problem When I answer a "" problem "ly" Then my "" answer is marked "" - And I input an answer on a "" problem "ly" + And I reset the problem Then my "" answer is NOT marked "" And my "" answer is NOT marked "" - And I reset the problem Examples: | ProblemType | InitialCorrectness | OtherCorrectness | diff --git a/lms/static/coffee/src/customwmd.coffee b/lms/static/coffee/src/customwmd.coffee index 0ba19fbeb3..8a23f8231e 100644 --- a/lms/static/coffee/src/customwmd.coffee +++ b/lms/static/coffee/src/customwmd.coffee @@ -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, ">") + if MathJax.Hub.Browser.isMSIE + block = block.replace /(%[^\n]*)\n/g, "$1
\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, ">") - if MathJax.Hub.Browser.isMSIE - block = block.replace /(%[^\n]*)\n/g, "$1
\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 = $("
").addClass("wmd-preview-container") - .append($("
").addClass("wmd-preview-label").text(gettext("Preview"))) - .append($("
").attr("id", "wmd-preview#{_append}").addClass("wmd-panel wmd-preview")) - $wmdPanel = $("
").addClass("wmd-panel") - .append($("
").attr("id", "wmd-button-bar#{_append}")) - .append($("