Support adding students to a cohort via the instructor dashboard.
TNL-163
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
require ["jquery", "backbone", "coffee/src/main", "js/spec_helpers/create_sinon", "jasmine-stealth", "jquery.cookie"],
|
||||
($, Backbone, main, create_sinon) ->
|
||||
require ["jquery", "backbone", "coffee/src/main", "js/common_helpers/ajax_helpers", "jasmine-stealth", "jquery.cookie"],
|
||||
($, Backbone, main, AjaxHelpers) ->
|
||||
describe "CMS", ->
|
||||
it "should initialize URL", ->
|
||||
expect(window.CMS.URL).toBeDefined()
|
||||
@@ -28,7 +28,7 @@ require ["jquery", "backbone", "coffee/src/main", "js/spec_helpers/create_sinon"
|
||||
appendSetFixtures(sandbox({id: "page-notification"}))
|
||||
|
||||
it "successful AJAX request does not pop an error notification", ->
|
||||
server = create_sinon['server'](200, this)
|
||||
server = AjaxHelpers['server'](200, this)
|
||||
|
||||
expect($("#page-notification")).toBeEmpty()
|
||||
$.ajax("/test")
|
||||
@@ -37,7 +37,7 @@ require ["jquery", "backbone", "coffee/src/main", "js/spec_helpers/create_sinon"
|
||||
expect($("#page-notification")).toBeEmpty()
|
||||
|
||||
it "AJAX request with error should pop an error notification", ->
|
||||
server = create_sinon['server'](500, this)
|
||||
server = AjaxHelpers['server'](500, this)
|
||||
|
||||
$.ajax("/test")
|
||||
server.respond()
|
||||
@@ -45,7 +45,7 @@ require ["jquery", "backbone", "coffee/src/main", "js/spec_helpers/create_sinon"
|
||||
expect($("#page-notification")).toContain('div.wrapper-notification-error')
|
||||
|
||||
it "can override AJAX request with error so it does not pop an error notification", ->
|
||||
server = create_sinon['server'](500, this)
|
||||
server = AjaxHelpers['server'](500, this)
|
||||
|
||||
$.ajax
|
||||
url: "/test"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define ["js/models/section", "js/spec_helpers/create_sinon", "js/utils/module"], (Section, create_sinon, ModuleUtils) ->
|
||||
define ["js/models/section", "js/common_helpers/ajax_helpers", "js/utils/module"], (Section, AjaxHelpers, ModuleUtils) ->
|
||||
describe "Section", ->
|
||||
describe "basic", ->
|
||||
beforeEach ->
|
||||
@@ -34,7 +34,7 @@ define ["js/models/section", "js/spec_helpers/create_sinon", "js/utils/module"],
|
||||
})
|
||||
|
||||
it "show/hide a notification when it saves to the server", ->
|
||||
server = create_sinon['server'](200, this)
|
||||
server = AjaxHelpers['server'](200, this)
|
||||
|
||||
@model.save()
|
||||
expect(Section.prototype.showNotification).toHaveBeenCalled()
|
||||
@@ -43,7 +43,7 @@ define ["js/models/section", "js/spec_helpers/create_sinon", "js/utils/module"],
|
||||
|
||||
it "don't hide notification when saving fails", ->
|
||||
# this is handled by the global AJAX error handler
|
||||
server = create_sinon['server'](500, this)
|
||||
server = AjaxHelpers['server'](500, this)
|
||||
|
||||
@model.save()
|
||||
server.respond()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
($, jasmine, create_sinon, Squire) ->
|
||||
define ["jquery", "jasmine", "js/common_helpers/ajax_helpers", "squire"],
|
||||
($, jasmine, AjaxHelpers, Squire) ->
|
||||
|
||||
feedbackTpl = readFixtures('system-feedback.underscore')
|
||||
assetLibraryTpl = readFixtures('asset-library.underscore')
|
||||
@@ -72,7 +72,7 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
|
||||
describe "AJAX", ->
|
||||
it "should destroy itself on confirmation", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render().$(".remove-asset-button").click()
|
||||
ctorOptions = @promptSpies.constructor.mostRecentCall.args[0]
|
||||
@@ -92,7 +92,7 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
expect(@collection.contains(@model)).toBeFalsy()
|
||||
|
||||
it "should not destroy itself if server errors", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render().$(".remove-asset-button").click()
|
||||
ctorOptions = @promptSpies.constructor.mostRecentCall.args[0]
|
||||
@@ -106,7 +106,7 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
expect(@collection.contains(@model)).toBeTruthy()
|
||||
|
||||
it "should lock the asset on confirmation", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render().$(".lock-checkbox").click()
|
||||
# AJAX request has been sent, but not yet returned
|
||||
@@ -123,7 +123,7 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
expect(@model.get("locked")).toBeTruthy()
|
||||
|
||||
it "should not lock the asset if server errors", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render().$(".lock-checkbox").click()
|
||||
# return an error response
|
||||
@@ -207,7 +207,7 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
thumbnail: null
|
||||
id: 'idx'
|
||||
@view.addAsset(model)
|
||||
create_sinon.respondWithJson(requests,
|
||||
AjaxHelpers.respondWithJson(requests,
|
||||
{
|
||||
assets: [
|
||||
@mockAsset1, @mockAsset2,
|
||||
@@ -231,9 +231,9 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
describe "Basic", ->
|
||||
# Separate setup method to work-around mis-parenting of beforeEach methods
|
||||
setup = ->
|
||||
requests = create_sinon.requests(this)
|
||||
requests = AjaxHelpers.requests(this)
|
||||
@view.setPage(0)
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
return requests
|
||||
|
||||
$.fn.fileupload = ->
|
||||
@@ -270,11 +270,11 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
expect($('.ui-loading').is(':visible')).toBe(false)
|
||||
|
||||
it "should hide the status indicator if an error occurs while loading", ->
|
||||
requests = create_sinon.requests(this)
|
||||
requests = AjaxHelpers.requests(this)
|
||||
appendSetFixtures('<div class="ui-loading"/>')
|
||||
expect($('.ui-loading').is(':visible')).toBe(true)
|
||||
@view.setPage(0)
|
||||
create_sinon.respondWithError(requests)
|
||||
AjaxHelpers.respondWithError(requests)
|
||||
expect($('.ui-loading').is(':visible')).toBe(false)
|
||||
|
||||
it "should render both assets", ->
|
||||
@@ -316,9 +316,9 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
describe "Sorting", ->
|
||||
# Separate setup method to work-around mis-parenting of beforeEach methods
|
||||
setup = ->
|
||||
requests = create_sinon.requests(this)
|
||||
requests = AjaxHelpers.requests(this)
|
||||
@view.setPage(0)
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
return requests
|
||||
|
||||
it "should have the correct default sort order", ->
|
||||
@@ -331,30 +331,30 @@ define ["jquery", "jasmine", "js/spec_helpers/create_sinon", "squire"],
|
||||
expect(@view.sortDisplayName()).toBe("Date Added")
|
||||
expect(@view.collection.sortDirection).toBe("desc")
|
||||
@view.$("#js-asset-date-col").click()
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
expect(@view.sortDisplayName()).toBe("Date Added")
|
||||
expect(@view.collection.sortDirection).toBe("asc")
|
||||
@view.$("#js-asset-date-col").click()
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
expect(@view.sortDisplayName()).toBe("Date Added")
|
||||
expect(@view.collection.sortDirection).toBe("desc")
|
||||
|
||||
it "should switch the sort order when clicking on a different column", ->
|
||||
requests = setup.call(this)
|
||||
@view.$("#js-asset-name-col").click()
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
expect(@view.sortDisplayName()).toBe("Name")
|
||||
expect(@view.collection.sortDirection).toBe("asc")
|
||||
@view.$("#js-asset-name-col").click()
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
expect(@view.sortDisplayName()).toBe("Name")
|
||||
expect(@view.collection.sortDirection).toBe("desc")
|
||||
|
||||
it "should switch sort to most recent date added when a new asset is added", ->
|
||||
requests = setup.call(this)
|
||||
@view.$("#js-asset-name-col").click()
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
addMockAsset.call(this, requests)
|
||||
create_sinon.respondWithJson(requests, @mockAssetsResponse)
|
||||
AjaxHelpers.respondWithJson(requests, @mockAssetsResponse)
|
||||
expect(@view.sortDisplayName()).toBe("Date Added")
|
||||
expect(@view.collection.sortDirection).toBe("desc")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define ["js/views/course_info_handout", "js/views/course_info_update", "js/models/module_info", "js/collections/course_update", "js/spec_helpers/create_sinon"],
|
||||
(CourseInfoHandoutsView, CourseInfoUpdateView, ModuleInfo, CourseUpdateCollection, create_sinon) ->
|
||||
define ["js/views/course_info_handout", "js/views/course_info_update", "js/models/module_info", "js/collections/course_update", "js/common_helpers/ajax_helpers"],
|
||||
(CourseInfoHandoutsView, CourseInfoUpdateView, ModuleInfo, CourseUpdateCollection, AjaxHelpers) ->
|
||||
|
||||
describe "Course Updates and Handouts", ->
|
||||
courseInfoPage = """
|
||||
@@ -101,7 +101,7 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
|
||||
modalCover.click()
|
||||
|
||||
it "does not rewrite links on save", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
# Create a new update, verifying that the model is created
|
||||
# in the collection and save is called.
|
||||
@@ -168,7 +168,7 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
|
||||
@handoutsEdit.render()
|
||||
|
||||
it "does not rewrite links on save", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
# Enter something in the handouts section, verifying that the model is saved
|
||||
# when "Save" is clicked.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/course",
|
||||
"js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks",
|
||||
"js/views/edit_chapter", "js/views/feedback_prompt", "js/views/feedback_notification",
|
||||
"js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers", "jasmine-stealth"],
|
||||
(Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTexbook, EditChapter, Prompt, Notification, create_sinon, modal_helpers) ->
|
||||
"js/common_helpers/ajax_helpers", "js/spec_helpers/modal_helpers", "jasmine-stealth"],
|
||||
(Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTexbook, EditChapter, Prompt, Notification, AjaxHelpers, modal_helpers) ->
|
||||
feedbackTpl = readFixtures('system-feedback.underscore')
|
||||
|
||||
beforeEach ->
|
||||
@@ -83,7 +83,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
|
||||
delete CMS.URL.TEXTBOOKS
|
||||
|
||||
it "should destroy itself on confirmation", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render().$(".delete").click()
|
||||
ctorOptions = @promptSpies.constructor.mostRecentCall.args[0]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers"], (FileUpload, UploadDialog, Chapter, create_sinon, modal_helpers) ->
|
||||
define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "js/common_helpers/ajax_helpers", "js/spec_helpers/modal_helpers"], (FileUpload, UploadDialog, Chapter, AjaxHelpers, modal_helpers) ->
|
||||
|
||||
feedbackTpl = readFixtures('system-feedback.underscore')
|
||||
|
||||
@@ -98,7 +98,7 @@ define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "js/spec_h
|
||||
@clock.restore()
|
||||
|
||||
it "can upload correctly", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render()
|
||||
@view.upload()
|
||||
@@ -115,7 +115,7 @@ define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "js/spec_h
|
||||
expect(@dialogResponse.pop()).toEqual("dummy_response")
|
||||
|
||||
it "can handle upload errors", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render()
|
||||
@view.upload()
|
||||
@@ -124,7 +124,7 @@ define ["js/models/uploads", "js/views/uploads", "js/models/chapter", "js/spec_h
|
||||
expect(@view.remove).not.toHaveBeenCalled()
|
||||
|
||||
it "removes itself after two seconds on successful upload", ->
|
||||
requests = create_sinon["requests"](this)
|
||||
requests = AjaxHelpers["requests"](this)
|
||||
|
||||
@view.render()
|
||||
@view.upload()
|
||||
|
||||
1
cms/static/js/common_helpers
Symbolic link
1
cms/static/js/common_helpers
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../common/static/js/spec_helpers
|
||||
@@ -1,5 +1,5 @@
|
||||
define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/spec_helpers/create_sinon", "jquery", "underscore"],
|
||||
function (ContentDragger, Notification, create_sinon, $, _) {
|
||||
define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/common_helpers/ajax_helpers", "jquery", "underscore"],
|
||||
function (ContentDragger, Notification, AjaxHelpers, $, _) {
|
||||
describe("Overview drag and drop functionality", function () {
|
||||
beforeEach(function () {
|
||||
setFixtures(readFixtures('mock/mock-outline.underscore'));
|
||||
@@ -310,7 +310,7 @@ define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/spec_hel
|
||||
});
|
||||
it("should send an update on reorder from one parent to another", function () {
|
||||
var requests, savingOptions;
|
||||
requests = create_sinon["requests"](this);
|
||||
requests = AjaxHelpers["requests"](this);
|
||||
ContentDragger.dragState.dropDestination = $('#unit-4');
|
||||
ContentDragger.dragState.attachMethod = "after";
|
||||
ContentDragger.dragState.parentList = $('#subsection-2');
|
||||
@@ -341,7 +341,7 @@ define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/spec_hel
|
||||
expect($('#subsection-2').data('refresh')).toHaveBeenCalled();
|
||||
});
|
||||
it("should send an update on reorder within the same parent", function () {
|
||||
var requests = create_sinon["requests"](this);
|
||||
var requests = AjaxHelpers["requests"](this);
|
||||
ContentDragger.dragState.dropDestination = $('#unit-2');
|
||||
ContentDragger.dragState.attachMethod = "after";
|
||||
ContentDragger.dragState.parentList = $('#subsection-1');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
define(
|
||||
[
|
||||
'jquery', 'underscore', 'js/spec_helpers/create_sinon', 'squire'
|
||||
'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'squire'
|
||||
],
|
||||
function ($, _, create_sinon, Squire) {
|
||||
function ($, _, AjaxHelpers, Squire) {
|
||||
'use strict';
|
||||
describe('FileUploader', function () {
|
||||
var FileUploaderTemplate = readFixtures(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
define(
|
||||
[
|
||||
'jquery', 'underscore', 'js/spec_helpers/create_sinon', 'squire'
|
||||
'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'squire'
|
||||
],
|
||||
function ($, _, create_sinon, Squire) {
|
||||
function ($, _, AjaxHelpers, Squire) {
|
||||
'use strict';
|
||||
// TODO: fix BLD-1100 Disabled due to intermittent failure on master and in PR builds
|
||||
xdescribe('VideoTranslations', function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([ "jquery", "js/spec_helpers/create_sinon", "js/views/asset", "js/views/assets",
|
||||
define([ "jquery", "js/common_helpers/ajax_helpers", "js/views/asset", "js/views/assets",
|
||||
"js/models/asset", "js/collections/asset", "js/spec_helpers/view_helpers" ],
|
||||
function ($, create_sinon, AssetView, AssetsView, AssetModel, AssetCollection, view_helpers) {
|
||||
function ($, AjaxHelpers, AssetView, AssetsView, AssetModel, AssetCollection, ViewHelpers) {
|
||||
|
||||
describe("Assets", function() {
|
||||
var assetsView, mockEmptyAssetsResponse, mockAssetUploadResponse,
|
||||
@@ -64,18 +64,18 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/views/asset", "js/views/a
|
||||
var setup;
|
||||
setup = function() {
|
||||
var requests;
|
||||
requests = create_sinon.requests(this);
|
||||
requests = AjaxHelpers.requests(this);
|
||||
assetsView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyAssetsResponse);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyAssetsResponse);
|
||||
return requests;
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
view_helpers.installMockAnalytics();
|
||||
ViewHelpers.installMockAnalytics();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
view_helpers.removeMockAnalytics();
|
||||
ViewHelpers.removeMockAnalytics();
|
||||
});
|
||||
|
||||
it('shows the upload modal when clicked on "Upload your first asset" button', function () {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
define(["jquery", "underscore", "js/views/baseview", "js/utils/handle_iframe_binding", "sinon",
|
||||
"js/spec_helpers/edit_helpers"],
|
||||
function ($, _, BaseView, IframeBinding, sinon, view_helpers) {
|
||||
define(["jquery", "underscore", "js/views/baseview", "js/utils/handle_iframe_binding", "sinon"],
|
||||
function ($, _, BaseView, IframeBinding, sinon) {
|
||||
|
||||
describe("BaseView", function() {
|
||||
var baseViewPrototype;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers",
|
||||
define([ "jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/container", "js/models/xblock_info", "jquery.simulate",
|
||||
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
function ($, create_sinon, edit_helpers, ContainerView, XBlockInfo) {
|
||||
function ($, AjaxHelpers, EditHelpers, ContainerView, XBlockInfo) {
|
||||
|
||||
describe("Container View", function () {
|
||||
|
||||
@@ -30,14 +30,14 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers
|
||||
|
||||
respondWithMockXBlockFragment = function (requests, response) {
|
||||
var requestIndex = requests.length - 1;
|
||||
create_sinon.respondWithJson(requests, response, requestIndex);
|
||||
AjaxHelpers.respondWithJson(requests, response, requestIndex);
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installMockXBlock();
|
||||
edit_helpers.installViewTemplates();
|
||||
EditHelpers.installMockXBlock();
|
||||
EditHelpers.installViewTemplates();
|
||||
appendSetFixtures('<div class="wrapper-xblock level-page studio-xblock-wrapper" data-locator="' + rootLocator + '"></div>');
|
||||
notificationSpy = edit_helpers.createNotificationSpy();
|
||||
notificationSpy = EditHelpers.createNotificationSpy();
|
||||
model = new XBlockInfo({
|
||||
id: rootLocator,
|
||||
display_name: 'Test AB Test',
|
||||
@@ -52,12 +52,12 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
edit_helpers.uninstallMockXBlock();
|
||||
EditHelpers.uninstallMockXBlock();
|
||||
containerView.remove();
|
||||
});
|
||||
|
||||
init = function (caller) {
|
||||
var requests = create_sinon.requests(caller);
|
||||
var requests = AjaxHelpers.requests(caller);
|
||||
containerView.render();
|
||||
|
||||
respondWithMockXBlockFragment(requests, {
|
||||
@@ -188,11 +188,11 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers
|
||||
|
||||
// Drag the first component in Group B to the first group.
|
||||
dragComponentAbove(groupBComponent1, groupAComponent1);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
respondToRequest(requests, 0, 200);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
respondToRequest(requests, 1, 200);
|
||||
edit_helpers.verifyNotificationHidden(notificationSpy);
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it('does not hide saving message if failure', function () {
|
||||
@@ -200,9 +200,9 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers
|
||||
|
||||
// Drag the first component in Group B to the first group.
|
||||
dragComponentAbove(groupBComponent1, groupAComponent1);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
respondToRequest(requests, 0, 500);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, 'Saving');
|
||||
|
||||
// Since the first reorder call failed, the removal will not be called.
|
||||
verifyNumReorderCalls(requests, 1);
|
||||
|
||||
@@ -5,13 +5,13 @@ define([
|
||||
'js/views/group_configurations_list', 'js/views/group_configuration_edit',
|
||||
'js/views/group_configuration_item', 'js/models/group',
|
||||
'js/collections/group', 'js/views/group_edit',
|
||||
'js/views/feedback_notification', 'js/spec_helpers/create_sinon',
|
||||
'js/spec_helpers/edit_helpers', 'jasmine-stealth'
|
||||
'js/views/feedback_notification', 'js/common_helpers/ajax_helpers', 'js/common_helpers/template_helpers',
|
||||
'js/spec_helpers/view_helpers', 'jasmine-stealth'
|
||||
], function(
|
||||
_, Course, GroupConfigurationModel, GroupConfigurationCollection,
|
||||
GroupConfigurationDetails, GroupConfigurationsList, GroupConfigurationEdit,
|
||||
GroupConfigurationItem, GroupModel, GroupCollection, GroupEdit,
|
||||
Notification, create_sinon, view_helpers
|
||||
Notification, AjaxHelpers, TemplateHelpers, ViewHelpers
|
||||
) {
|
||||
'use strict';
|
||||
var SELECTORS = {
|
||||
@@ -92,7 +92,7 @@ define([
|
||||
|
||||
describe('GroupConfigurationDetails', function() {
|
||||
beforeEach(function() {
|
||||
view_helpers.installTemplate('group-configuration-details', true);
|
||||
TemplateHelpers.installTemplate('group-configuration-details', true);
|
||||
|
||||
this.model = new GroupConfigurationModel({
|
||||
name: 'Configuration',
|
||||
@@ -270,8 +270,8 @@ define([
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
view_helpers.installViewTemplates();
|
||||
view_helpers.installTemplates([
|
||||
ViewHelpers.installViewTemplates();
|
||||
TemplateHelpers.installTemplates([
|
||||
'group-configuration-edit', 'group-edit'
|
||||
]);
|
||||
|
||||
@@ -304,8 +304,8 @@ define([
|
||||
});
|
||||
|
||||
it('should save properly', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
notificationSpy = view_helpers.createNotificationSpy(),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
notificationSpy = ViewHelpers.createNotificationSpy(),
|
||||
groups;
|
||||
|
||||
this.view.$('.action-add-group').click();
|
||||
@@ -315,9 +315,9 @@ define([
|
||||
});
|
||||
|
||||
this.view.$('form').submit();
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Saving/);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Saving/);
|
||||
requests[0].respond(200);
|
||||
view_helpers.verifyNotificationHidden(notificationSpy);
|
||||
ViewHelpers.verifyNotificationHidden(notificationSpy);
|
||||
|
||||
expect(this.model).toBeCorrectValuesInModel({
|
||||
name: 'New Configuration',
|
||||
@@ -331,14 +331,14 @@ define([
|
||||
});
|
||||
|
||||
it('does not hide saving message if failure', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
notificationSpy = view_helpers.createNotificationSpy();
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
|
||||
setValuesToInputs(this.view, { inputName: 'New Configuration' });
|
||||
this.view.$('form').submit();
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Saving/);
|
||||
create_sinon.respondWithError(requests);
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Saving/);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Saving/);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Saving/);
|
||||
});
|
||||
|
||||
it('does not save on cancel', function() {
|
||||
@@ -373,7 +373,7 @@ define([
|
||||
});
|
||||
|
||||
it('should be possible to correct validation errors', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
|
||||
// Set incorrect value
|
||||
setValuesToInputs(this.view, { inputName: '' });
|
||||
@@ -494,7 +494,7 @@ define([
|
||||
var emptyMessage = 'You haven\'t created any group configurations yet.';
|
||||
|
||||
beforeEach(function() {
|
||||
view_helpers.installTemplate('no-group-configurations', true);
|
||||
TemplateHelpers.installTemplate('no-group-configurations', true);
|
||||
|
||||
this.model = new GroupConfigurationModel({ id: 0 });
|
||||
this.collection = new GroupConfigurationCollection();
|
||||
@@ -533,7 +533,7 @@ define([
|
||||
var clickDeleteItem;
|
||||
|
||||
beforeEach(function() {
|
||||
view_helpers.installTemplates([
|
||||
TemplateHelpers.installTemplates([
|
||||
'group-configuration-edit', 'group-configuration-details'
|
||||
], true);
|
||||
this.model = new GroupConfigurationModel({ id: 0 });
|
||||
@@ -547,9 +547,9 @@ define([
|
||||
|
||||
clickDeleteItem = function (view, promptSpy) {
|
||||
view.$('.delete').click();
|
||||
view_helpers.verifyPromptShowing(promptSpy, /Delete this Group Configuration/);
|
||||
view_helpers.confirmPrompt(promptSpy);
|
||||
view_helpers.verifyPromptHidden(promptSpy);
|
||||
ViewHelpers.verifyPromptShowing(promptSpy, /Delete this Group Configuration/);
|
||||
ViewHelpers.confirmPrompt(promptSpy);
|
||||
ViewHelpers.verifyPromptHidden(promptSpy);
|
||||
};
|
||||
|
||||
it('should render properly', function() {
|
||||
@@ -564,43 +564,43 @@ define([
|
||||
});
|
||||
|
||||
it('should destroy itself on confirmation of deleting', function () {
|
||||
var requests = create_sinon.requests(this),
|
||||
promptSpy = view_helpers.createPromptSpy(),
|
||||
notificationSpy = view_helpers.createNotificationSpy();
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
promptSpy = ViewHelpers.createPromptSpy(),
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
|
||||
clickDeleteItem(this.view, promptSpy);
|
||||
// Backbone.emulateHTTP is enabled in our system, so setting this
|
||||
// option will fake PUT, PATCH and DELETE requests with a HTTP POST,
|
||||
// setting the X-HTTP-Method-Override header with the true method.
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/group_configurations/0');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/group_configurations/0');
|
||||
expect(_.last(requests).requestHeaders['X-HTTP-Method-Override']).toBe('DELETE');
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
create_sinon.respondToDelete(requests);
|
||||
view_helpers.verifyNotificationHidden(notificationSpy);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
AjaxHelpers.respondToDelete(requests);
|
||||
ViewHelpers.verifyNotificationHidden(notificationSpy);
|
||||
expect($(SELECTORS.itemView)).not.toExist();
|
||||
});
|
||||
|
||||
it('does not hide deleting message if failure', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
promptSpy = view_helpers.createPromptSpy(),
|
||||
notificationSpy = view_helpers.createNotificationSpy();
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
promptSpy = ViewHelpers.createPromptSpy(),
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
|
||||
clickDeleteItem(this.view, promptSpy);
|
||||
// Backbone.emulateHTTP is enabled in our system, so setting this
|
||||
// option will fake PUT, PATCH and DELETE requests with a HTTP POST,
|
||||
// setting the X-HTTP-Method-Override header with the true method.
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/group_configurations/0');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/group_configurations/0');
|
||||
expect(_.last(requests).requestHeaders['X-HTTP-Method-Override']).toBe('DELETE');
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
create_sinon.respondWithError(requests);
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
expect($(SELECTORS.itemView)).toExist();
|
||||
});
|
||||
});
|
||||
|
||||
describe('GroupEdit', function() {
|
||||
beforeEach(function() {
|
||||
view_helpers.installTemplate('group-edit', true);
|
||||
TemplateHelpers.installTemplate('group-edit', true);
|
||||
|
||||
this.model = new GroupModel({
|
||||
name: 'Group A'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(["jquery", "underscore", "js/views/modals/base_modal", "js/spec_helpers/modal_helpers"],
|
||||
function ($, _, BaseModal, modal_helpers) {
|
||||
function ($, _, BaseModal, ModelHelpers) {
|
||||
|
||||
describe("BaseModal", function() {
|
||||
var MockModal, modal, showMockModal;
|
||||
@@ -18,29 +18,29 @@ define(["jquery", "underscore", "js/views/modals/base_modal", "js/spec_helpers/m
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
modal_helpers.installModalTemplates();
|
||||
ModelHelpers.installModalTemplates();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
modal_helpers.hideModalIfShowing(modal);
|
||||
ModelHelpers.hideModalIfShowing(modal);
|
||||
});
|
||||
|
||||
describe("Single Modal", function() {
|
||||
it('is visible after show is called', function () {
|
||||
showMockModal();
|
||||
expect(modal_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
expect(ModelHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('is removed after hide is called', function () {
|
||||
showMockModal();
|
||||
modal.hide();
|
||||
expect(modal_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(ModelHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('is removed after cancel is clicked', function () {
|
||||
showMockModal();
|
||||
modal_helpers.cancelModal(modal);
|
||||
expect(modal_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
ModelHelpers.cancelModal(modal);
|
||||
expect(ModelHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,32 +57,32 @@ define(["jquery", "underscore", "js/views/modals/base_modal", "js/spec_helpers/m
|
||||
};
|
||||
|
||||
afterEach(function() {
|
||||
if (nestedModal && modal_helpers.isShowingModal(nestedModal)) {
|
||||
if (nestedModal && ModelHelpers.isShowingModal(nestedModal)) {
|
||||
nestedModal.hide();
|
||||
}
|
||||
});
|
||||
|
||||
it('is visible after show is called', function () {
|
||||
showNestedModal();
|
||||
expect(modal_helpers.isShowingModal(nestedModal)).toBeTruthy();
|
||||
expect(ModelHelpers.isShowingModal(nestedModal)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('is removed after hide is called', function () {
|
||||
showNestedModal();
|
||||
nestedModal.hide();
|
||||
expect(modal_helpers.isShowingModal(nestedModal)).toBeFalsy();
|
||||
expect(ModelHelpers.isShowingModal(nestedModal)).toBeFalsy();
|
||||
|
||||
// Verify that the parent modal is still showing
|
||||
expect(modal_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
expect(ModelHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('is removed after cancel is clicked', function () {
|
||||
showNestedModal();
|
||||
modal_helpers.cancelModal(nestedModal);
|
||||
expect(modal_helpers.isShowingModal(nestedModal)).toBeFalsy();
|
||||
ModelHelpers.cancelModal(nestedModal);
|
||||
expect(ModelHelpers.isShowingModal(nestedModal)).toBeFalsy();
|
||||
|
||||
// Verify that the parent modal is still showing
|
||||
expect(modal_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
expect(ModelHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers",
|
||||
define(["jquery", "underscore", "js/common_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/modals/edit_xblock", "js/models/xblock_info"],
|
||||
function ($, _, create_sinon, edit_helpers, EditXBlockModal, XBlockInfo) {
|
||||
function ($, _, AjaxHelpers, EditHelpers, EditXBlockModal, XBlockInfo) {
|
||||
|
||||
describe("EditXBlockModal", function() {
|
||||
var model, modal, showModal;
|
||||
|
||||
showModal = function(requests, mockHtml, options) {
|
||||
var xblockElement = $('.xblock');
|
||||
return edit_helpers.showEditModal(requests, xblockElement, model, mockHtml, options);
|
||||
return EditHelpers.showEditModal(requests, xblockElement, model, mockHtml, options);
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installEditTemplates();
|
||||
EditHelpers.installEditTemplates();
|
||||
appendSetFixtures('<div class="xblock" data-locator="mock-xblock"></div>');
|
||||
model = new XBlockInfo({
|
||||
id: 'testCourse/branch/draft/block/verticalFFF',
|
||||
@@ -21,7 +21,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
edit_helpers.cancelModalIfShowing();
|
||||
EditHelpers.cancelModalIfShowing();
|
||||
});
|
||||
|
||||
describe("XBlock Editor", function() {
|
||||
@@ -30,42 +30,42 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
mockXBlockEditorHtml = readFixtures('mock/mock-xblock-editor.underscore');
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installMockXBlock();
|
||||
EditHelpers.installMockXBlock();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
edit_helpers.uninstallMockXBlock();
|
||||
EditHelpers.uninstallMockXBlock();
|
||||
});
|
||||
|
||||
it('can show itself', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXBlockEditorHtml);
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
edit_helpers.cancelModal(modal);
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
EditHelpers.cancelModal(modal);
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('does not show the "Save" button', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXBlockEditorHtml);
|
||||
expect(modal.$('.action-save')).not.toBeVisible();
|
||||
expect(modal.$('.action-cancel').text()).toBe('OK');
|
||||
});
|
||||
|
||||
it('shows the correct title', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXBlockEditorHtml);
|
||||
expect(modal.$('.modal-window-title').text()).toBe('Editing: Component');
|
||||
});
|
||||
|
||||
it('does not show any editor mode buttons', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXBlockEditorHtml);
|
||||
expect(modal.$('.editor-modes a').length).toBe(0);
|
||||
});
|
||||
|
||||
it('hides itself and refreshes after save notification', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
refreshed = false,
|
||||
refresh = function() {
|
||||
refreshed = true;
|
||||
@@ -73,19 +73,19 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
modal = showModal(requests, mockXBlockEditorHtml, { refresh: refresh });
|
||||
modal.editorView.notifyRuntime('save', { state: 'start' });
|
||||
modal.editorView.notifyRuntime('save', { state: 'end' });
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(refreshed).toBeTruthy();
|
||||
});
|
||||
|
||||
it('hides itself and does not refresh after cancel notification', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
refreshed = false,
|
||||
refresh = function() {
|
||||
refreshed = true;
|
||||
};
|
||||
modal = showModal(requests, mockXBlockEditorHtml, { refresh: refresh });
|
||||
modal.editorView.notifyRuntime('cancel');
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(refreshed).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
mockCustomButtonsHtml = readFixtures('mock/mock-xblock-editor-with-custom-buttons.underscore');
|
||||
|
||||
it('hides the modal\'s button bar', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockCustomButtonsHtml);
|
||||
expect(modal.$('.modal-actions')).toBeHidden();
|
||||
});
|
||||
@@ -108,29 +108,29 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
mockXModuleEditorHtml = readFixtures('mock/mock-xmodule-editor.underscore');
|
||||
|
||||
beforeEach(function() {
|
||||
edit_helpers.installMockXModule();
|
||||
EditHelpers.installMockXModule();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
edit_helpers.uninstallMockXModule();
|
||||
EditHelpers.uninstallMockXModule();
|
||||
});
|
||||
|
||||
it('can render itself', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXModuleEditorHtml);
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
edit_helpers.cancelModal(modal);
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
EditHelpers.cancelModal(modal);
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('shows the correct title', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXModuleEditorHtml);
|
||||
expect(modal.$('.modal-window-title').text()).toBe('Editing: Component');
|
||||
});
|
||||
|
||||
it('shows the correct default buttons', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
editorButton,
|
||||
settingsButton;
|
||||
modal = showModal(requests, mockXModuleEditorHtml);
|
||||
@@ -144,7 +144,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
});
|
||||
|
||||
it('can switch tabs', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
editorButton,
|
||||
settingsButton;
|
||||
modal = showModal(requests, mockXModuleEditorHtml);
|
||||
@@ -164,13 +164,13 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
mockCustomTabsHtml = readFixtures('mock/mock-xmodule-editor-with-custom-tabs.underscore');
|
||||
|
||||
it('hides the modal\'s header', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockCustomTabsHtml);
|
||||
expect(modal.$('.modal-header')).toBeHidden();
|
||||
});
|
||||
|
||||
it('shows the correct title', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockCustomTabsHtml);
|
||||
expect(modal.$('.component-name').text()).toBe('Editing: Component');
|
||||
});
|
||||
@@ -183,23 +183,23 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
mockXModuleEditorHtml = readFixtures('mock/mock-xmodule-settings-only-editor.underscore');
|
||||
|
||||
beforeEach(function() {
|
||||
edit_helpers.installMockXModule();
|
||||
EditHelpers.installMockXModule();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
edit_helpers.uninstallMockXModule();
|
||||
EditHelpers.uninstallMockXModule();
|
||||
});
|
||||
|
||||
it('can render itself', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXModuleEditorHtml);
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
edit_helpers.cancelModal(modal);
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
EditHelpers.cancelModal(modal);
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('does not show any mode buttons', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
modal = showModal(requests, mockXModuleEditorHtml);
|
||||
expect(modal.$('.editor-modes li').length).toBe(0);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(['jquery', 'underscore', 'js/spec_helpers/validation_helpers', 'js/views/modals/validation_error_modal'],
|
||||
function ($, _, validation_helpers, ValidationErrorModal) {
|
||||
function ($, _, ValidationHelpers, ValidationErrorModal) {
|
||||
|
||||
describe('ValidationErrorModal', function() {
|
||||
var modal, showModal;
|
||||
@@ -14,24 +14,24 @@ define(['jquery', 'underscore', 'js/spec_helpers/validation_helpers', 'js/views/
|
||||
/* Before each, install templates required for the base modal
|
||||
and validation error modal. */
|
||||
beforeEach(function () {
|
||||
validation_helpers.installValidationTemplates();
|
||||
ValidationHelpers.installValidationTemplates();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
validation_helpers.hideModalIfShowing(modal);
|
||||
ValidationHelpers.hideModalIfShowing(modal);
|
||||
});
|
||||
|
||||
it('is visible after show is called', function () {
|
||||
showModal([]);
|
||||
expect(validation_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
expect(ValidationHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('displays none if no error given', function () {
|
||||
var errorObjects = [];
|
||||
|
||||
showModal(errorObjects);
|
||||
expect(validation_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
validation_helpers.checkErrorContents(modal, errorObjects);
|
||||
expect(ValidationHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
ValidationHelpers.checkErrorContents(modal, errorObjects);
|
||||
});
|
||||
|
||||
it('correctly displays json error message objects', function () {
|
||||
@@ -47,8 +47,8 @@ define(['jquery', 'underscore', 'js/spec_helpers/validation_helpers', 'js/views/
|
||||
];
|
||||
|
||||
showModal(errorObjects);
|
||||
expect(validation_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
validation_helpers.checkErrorContents(modal, errorObjects);
|
||||
expect(ValidationHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
ValidationHelpers.checkErrorContents(modal, errorObjects);
|
||||
});
|
||||
|
||||
it('run callback when undo changes button is clicked', function () {
|
||||
@@ -69,8 +69,8 @@ define(['jquery', 'underscore', 'js/spec_helpers/validation_helpers', 'js/views/
|
||||
|
||||
// Show Modal and click undo changes
|
||||
showModal(errorObjects, callback);
|
||||
expect(validation_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
validation_helpers.undoChanges(modal);
|
||||
expect(ValidationHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
ValidationHelpers.undoChanges(modal);
|
||||
|
||||
// Wait for the callback to be fired
|
||||
waitsFor(function () {
|
||||
@@ -79,7 +79,7 @@ define(['jquery', 'underscore', 'js/spec_helpers/validation_helpers', 'js/views/
|
||||
|
||||
// After checking callback fire, check modal hide
|
||||
runs(function () {
|
||||
expect(validation_helpers.isShowingModal(modal)).toBe(false);
|
||||
expect(ValidationHelpers.isShowingModal(modal)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers",
|
||||
define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_helpers",
|
||||
"js/common_helpers/template_helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/pages/container", "js/models/xblock_info", "jquery.simulate"],
|
||||
function ($, _, str, create_sinon, edit_helpers, ContainerPage, XBlockInfo) {
|
||||
function ($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, ContainerPage, XBlockInfo) {
|
||||
|
||||
describe("ContainerPage", function() {
|
||||
var lastRequest, renderContainerPage, expectComponents, respondWithHtml,
|
||||
@@ -15,12 +16,12 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
beforeEach(function () {
|
||||
var newDisplayName = 'New Display Name';
|
||||
|
||||
edit_helpers.installEditTemplates();
|
||||
edit_helpers.installTemplate('xblock-string-field-editor');
|
||||
edit_helpers.installTemplate('container-message');
|
||||
EditHelpers.installEditTemplates();
|
||||
TemplateHelpers.installTemplate('xblock-string-field-editor');
|
||||
TemplateHelpers.installTemplate('container-message');
|
||||
appendSetFixtures(mockContainerPage);
|
||||
|
||||
edit_helpers.installMockXBlock({
|
||||
EditHelpers.installMockXBlock({
|
||||
data: "<p>Some HTML</p>",
|
||||
metadata: {
|
||||
display_name: newDisplayName
|
||||
@@ -37,14 +38,14 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
edit_helpers.uninstallMockXBlock();
|
||||
EditHelpers.uninstallMockXBlock();
|
||||
});
|
||||
|
||||
lastRequest = function() { return requests[requests.length - 1]; };
|
||||
|
||||
respondWithHtml = function(html) {
|
||||
var requestIndex = requests.length - 1;
|
||||
create_sinon.respondWithJson(
|
||||
AjaxHelpers.respondWithJson(
|
||||
requests,
|
||||
{ html: html, "resources": [] },
|
||||
requestIndex
|
||||
@@ -52,10 +53,10 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
};
|
||||
|
||||
renderContainerPage = function(test, html, options) {
|
||||
requests = create_sinon.requests(test);
|
||||
requests = AjaxHelpers.requests(test);
|
||||
containerPage = new ContainerPage(_.extend(options || {}, {
|
||||
model: model,
|
||||
templates: edit_helpers.mockComponentTemplates,
|
||||
templates: EditHelpers.mockComponentTemplates,
|
||||
el: $('#content')
|
||||
}));
|
||||
containerPage.render();
|
||||
@@ -79,7 +80,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
it('shows a loading indicator', function() {
|
||||
requests = create_sinon.requests(this);
|
||||
requests = AjaxHelpers.requests(this);
|
||||
containerPage.render();
|
||||
expect(containerPage.$('.ui-loading')).not.toHaveClass('is-hidden');
|
||||
respondWithHtml(mockContainerXBlockHtml);
|
||||
@@ -113,7 +114,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
getDisplayNameWrapper;
|
||||
|
||||
afterEach(function() {
|
||||
edit_helpers.cancelModalIfShowing();
|
||||
EditHelpers.cancelModalIfShowing();
|
||||
});
|
||||
|
||||
getDisplayNameWrapper = function() {
|
||||
@@ -131,30 +132,30 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
// Expect a request to be made to show the studio view for the container
|
||||
expect(str.startsWith(lastRequest().url, '/xblock/locator-container/studio_view')).toBeTruthy();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockContainerXBlockHtml,
|
||||
resources: []
|
||||
});
|
||||
expect(edit_helpers.isShowingModal()).toBeTruthy();
|
||||
expect(EditHelpers.isShowingModal()).toBeTruthy();
|
||||
|
||||
// Expect the correct title to be shown
|
||||
expect(edit_helpers.getModalTitle()).toBe('Editing: Test Container');
|
||||
expect(EditHelpers.getModalTitle()).toBe('Editing: Test Container');
|
||||
|
||||
// Press the save button and respond with a success message to the save
|
||||
edit_helpers.pressModalButton('.action-save');
|
||||
create_sinon.respondWithJson(requests, { });
|
||||
expect(edit_helpers.isShowingModal()).toBeFalsy();
|
||||
EditHelpers.pressModalButton('.action-save');
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
expect(EditHelpers.isShowingModal()).toBeFalsy();
|
||||
|
||||
// Expect the last request be to refresh the container page
|
||||
expect(str.startsWith(lastRequest().url,
|
||||
'/xblock/locator-container/container_preview')).toBeTruthy();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockUpdatedContainerXBlockHtml,
|
||||
resources: []
|
||||
});
|
||||
|
||||
// Respond to the subsequent xblock info fetch request.
|
||||
create_sinon.respondWithJson(requests, {"display_name": updatedDisplayName});
|
||||
AjaxHelpers.respondWithJson(requests, {"display_name": updatedDisplayName});
|
||||
|
||||
// Expect the title to have been updated
|
||||
expect(displayNameElement.text().trim()).toBe(updatedDisplayName);
|
||||
@@ -164,20 +165,20 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
var displayNameInput, displayNameWrapper;
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
displayNameWrapper = getDisplayNameWrapper();
|
||||
displayNameInput = edit_helpers.inlineEdit(displayNameWrapper, updatedDisplayName);
|
||||
displayNameInput = EditHelpers.inlineEdit(displayNameWrapper, updatedDisplayName);
|
||||
displayNameInput.change();
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, { });
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
// This is the response for the subsequent fetch operation.
|
||||
create_sinon.respondWithJson(requests, {"display_name": updatedDisplayName});
|
||||
edit_helpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
AjaxHelpers.respondWithJson(requests, {"display_name": updatedDisplayName});
|
||||
EditHelpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
expect(containerPage.model.get('display_name')).toBe(updatedDisplayName);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Editing an xblock", function() {
|
||||
afterEach(function() {
|
||||
edit_helpers.cancelModalIfShowing();
|
||||
EditHelpers.cancelModalIfShowing();
|
||||
});
|
||||
|
||||
it('can show an edit modal for a child xblock', function() {
|
||||
@@ -189,11 +190,11 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
editButtons[0].click();
|
||||
// Make sure that the correct xblock is requested to be edited
|
||||
expect(str.startsWith(lastRequest().url, '/xblock/locator-component-A1/studio_view')).toBeTruthy();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXBlockEditorHtml,
|
||||
resources: []
|
||||
});
|
||||
expect(edit_helpers.isShowingModal()).toBeTruthy();
|
||||
expect(EditHelpers.isShowingModal()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can show an edit modal for a child xblock with broken JavaScript', function() {
|
||||
@@ -201,11 +202,11 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
renderContainerPage(this, mockBadContainerXBlockHtml);
|
||||
editButtons = containerPage.$('.wrapper-xblock .edit-button');
|
||||
editButtons[0].click();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXBlockEditorHtml,
|
||||
resources: []
|
||||
});
|
||||
expect(edit_helpers.isShowingModal()).toBeTruthy();
|
||||
expect(EditHelpers.isShowingModal()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -214,7 +215,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
newDisplayName = 'New Display Name';
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installMockXModule({
|
||||
EditHelpers.installMockXModule({
|
||||
data: "<p>Some HTML</p>",
|
||||
metadata: {
|
||||
display_name: newDisplayName
|
||||
@@ -223,8 +224,8 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
edit_helpers.uninstallMockXModule();
|
||||
edit_helpers.cancelModalIfShowing();
|
||||
EditHelpers.uninstallMockXModule();
|
||||
EditHelpers.cancelModalIfShowing();
|
||||
});
|
||||
|
||||
it('can save changes to settings', function() {
|
||||
@@ -235,7 +236,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
// The container should have rendered six mock xblocks
|
||||
expect(editButtons.length).toBe(6);
|
||||
editButtons[0].click();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXModuleEditor,
|
||||
resources: []
|
||||
});
|
||||
@@ -249,7 +250,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
// Press the save button
|
||||
modal.find('.action-save').click();
|
||||
// Respond to the save
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
id: model.id
|
||||
});
|
||||
|
||||
@@ -278,7 +279,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
promptSpy;
|
||||
|
||||
beforeEach(function() {
|
||||
promptSpy = edit_helpers.createPromptSpy();
|
||||
promptSpy = EditHelpers.createPromptSpy();
|
||||
});
|
||||
|
||||
clickDelete = function(componentIndex, clickNo) {
|
||||
@@ -291,20 +292,20 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
deleteButtons[componentIndex].click();
|
||||
|
||||
// click the 'yes' or 'no' button in the prompt
|
||||
edit_helpers.confirmPrompt(promptSpy, clickNo);
|
||||
EditHelpers.confirmPrompt(promptSpy, clickNo);
|
||||
};
|
||||
|
||||
deleteComponent = function(componentIndex) {
|
||||
clickDelete(componentIndex);
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
|
||||
// second to last request contains given component's id (to delete the component)
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE',
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE',
|
||||
'/xblock/locator-component-' + GROUP_TO_TEST + (componentIndex + 1),
|
||||
null, requests.length - 2);
|
||||
|
||||
// final request to refresh the xblock info
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
};
|
||||
|
||||
deleteComponentWithSuccess = function(componentIndex) {
|
||||
@@ -335,13 +336,13 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
it("can delete an xblock with broken JavaScript", function() {
|
||||
renderContainerPage(this, mockBadContainerXBlockHtml);
|
||||
containerPage.$('.delete-button').first().click();
|
||||
edit_helpers.confirmPrompt(promptSpy);
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
EditHelpers.confirmPrompt(promptSpy);
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
// expect the second to last request to be a delete of the xblock
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', '/xblock/locator-broken-javascript',
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', '/xblock/locator-broken-javascript',
|
||||
null, requests.length - 2);
|
||||
// expect the last request to be a fetch of the xblock info for the parent container
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
});
|
||||
|
||||
it('does not delete when clicking No in prompt', function () {
|
||||
@@ -361,21 +362,21 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
it('shows a notification during the delete operation', function() {
|
||||
var notificationSpy = edit_helpers.createNotificationSpy();
|
||||
var notificationSpy = EditHelpers.createNotificationSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickDelete(0);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
edit_helpers.verifyNotificationHidden(notificationSpy);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it('does not delete an xblock upon failure', function () {
|
||||
var notificationSpy = edit_helpers.createNotificationSpy();
|
||||
var notificationSpy = EditHelpers.createNotificationSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickDelete(0);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
create_sinon.respondWithError(requests);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Deleting/);
|
||||
expectComponents(getGroupElement(), allComponentsInGroup);
|
||||
});
|
||||
});
|
||||
@@ -400,13 +401,13 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
clickDuplicate(componentIndex);
|
||||
|
||||
// verify content of request
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'duplicate_source_locator': 'locator-component-' + GROUP_TO_TEST + (componentIndex + 1),
|
||||
'parent_locator': 'locator-group-' + GROUP_TO_TEST
|
||||
});
|
||||
|
||||
// send the response
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
'locator': 'locator-duplicated-component'
|
||||
});
|
||||
|
||||
@@ -432,31 +433,31 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
it("can duplicate an xblock with broken JavaScript", function() {
|
||||
renderContainerPage(this, mockBadContainerXBlockHtml);
|
||||
containerPage.$('.duplicate-button').first().click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'duplicate_source_locator': 'locator-broken-javascript',
|
||||
'parent_locator': 'locator-container'
|
||||
});
|
||||
});
|
||||
|
||||
it('shows a notification when duplicating', function () {
|
||||
var notificationSpy = edit_helpers.createNotificationSpy();
|
||||
var notificationSpy = EditHelpers.createNotificationSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickDuplicate(0);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Duplicating/);
|
||||
create_sinon.respondWithJson(requests, {"locator": "new_item"});
|
||||
edit_helpers.verifyNotificationHidden(notificationSpy);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Duplicating/);
|
||||
AjaxHelpers.respondWithJson(requests, {"locator": "new_item"});
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it('does not duplicate an xblock upon failure', function () {
|
||||
var notificationSpy = edit_helpers.createNotificationSpy();
|
||||
var notificationSpy = EditHelpers.createNotificationSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
refreshXBlockSpies = spyOn(containerPage, "refreshXBlock");
|
||||
clickDuplicate(0);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Duplicating/);
|
||||
create_sinon.respondWithError(requests);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Duplicating/);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
expectComponents(getGroupElement(), allComponentsInGroup);
|
||||
expect(refreshXBlockSpies).not.toHaveBeenCalled();
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Duplicating/);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Duplicating/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -470,7 +471,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
it('sends the correct JSON to the server', function () {
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickNewComponent(0);
|
||||
edit_helpers.verifyXBlockRequest(requests, {
|
||||
EditHelpers.verifyXBlockRequest(requests, {
|
||||
"category": "discussion",
|
||||
"type": "discussion",
|
||||
"parent_locator": "locator-group-A"
|
||||
@@ -478,12 +479,12 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
it('shows a notification while creating', function () {
|
||||
var notificationSpy = edit_helpers.createNotificationSpy();
|
||||
var notificationSpy = EditHelpers.createNotificationSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickNewComponent(0);
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Adding/);
|
||||
create_sinon.respondWithJson(requests, { });
|
||||
edit_helpers.verifyNotificationHidden(notificationSpy);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Adding/);
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it('does not insert component upon failure', function () {
|
||||
@@ -491,7 +492,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
clickNewComponent(0);
|
||||
requestCount = requests.length;
|
||||
create_sinon.respondWithError(requests);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
// No new requests should be made to refresh the view
|
||||
expect(requests.length).toBe(requestCount);
|
||||
expectComponents(getGroupElement(), allComponentsInGroup);
|
||||
@@ -511,8 +512,8 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
showTemplatePicker();
|
||||
xblockCount = containerPage.$('.studio-xblock-wrapper').length;
|
||||
containerPage.$('.new-component-html a')[templateIndex].click();
|
||||
edit_helpers.verifyXBlockRequest(requests, expectedRequest);
|
||||
create_sinon.respondWithJson(requests, {"locator": "new_item"});
|
||||
EditHelpers.verifyXBlockRequest(requests, expectedRequest);
|
||||
AjaxHelpers.respondWithJson(requests, {"locator": "new_item"});
|
||||
respondWithHtml(mockXBlockHtml);
|
||||
expect(containerPage.$('.studio-xblock-wrapper').length).toBe(xblockCount + 1);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers",
|
||||
define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_helpers",
|
||||
"js/common_helpers/template_helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/feedback_prompt", "js/views/pages/container", "js/views/pages/container_subviews",
|
||||
"js/models/xblock_info", "js/views/utils/xblock_utils"],
|
||||
function ($, _, str, create_sinon, edit_helpers, Prompt, ContainerPage, ContainerSubviews,
|
||||
function ($, _, str, AjaxHelpers, TemplateHelpers, EditHelpers, Prompt, ContainerPage, ContainerSubviews,
|
||||
XBlockInfo, XBlockUtils) {
|
||||
var VisibilityState = XBlockUtils.VisibilityState;
|
||||
|
||||
@@ -13,11 +14,11 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
mockContainerXBlockHtml = readFixtures('mock/mock-empty-container-xblock.underscore');
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installTemplate('xblock-string-field-editor');
|
||||
edit_helpers.installTemplate('publish-xblock');
|
||||
edit_helpers.installTemplate('publish-history');
|
||||
edit_helpers.installTemplate('unit-outline');
|
||||
edit_helpers.installTemplate('container-message');
|
||||
TemplateHelpers.installTemplate('xblock-string-field-editor');
|
||||
TemplateHelpers.installTemplate('publish-xblock');
|
||||
TemplateHelpers.installTemplate('publish-history');
|
||||
TemplateHelpers.installTemplate('unit-outline');
|
||||
TemplateHelpers.installTemplate('container-message');
|
||||
appendSetFixtures(mockContainerPage);
|
||||
});
|
||||
|
||||
@@ -38,11 +39,11 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
};
|
||||
|
||||
createContainerPage = function (test, options) {
|
||||
requests = create_sinon.requests(test);
|
||||
requests = AjaxHelpers.requests(test);
|
||||
model = new XBlockInfo(createXBlockInfo(options), { parse: true });
|
||||
containerPage = new ContainerPage({
|
||||
model: model,
|
||||
templates: edit_helpers.mockComponentTemplates,
|
||||
templates: EditHelpers.mockComponentTemplates,
|
||||
el: $('#content'),
|
||||
isUnitPage: true
|
||||
});
|
||||
@@ -56,7 +57,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
respondWithHtml = function(html) {
|
||||
var requestIndex = requests.length - 1;
|
||||
create_sinon.respondWithJson(
|
||||
AjaxHelpers.respondWithJson(
|
||||
requests,
|
||||
{ html: html, "resources": [] },
|
||||
requestIndex
|
||||
@@ -64,7 +65,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
};
|
||||
|
||||
respondWithJson = function(json, requestIndex) {
|
||||
create_sinon.respondWithJson(
|
||||
AjaxHelpers.respondWithJson(
|
||||
requests,
|
||||
json,
|
||||
requestIndex
|
||||
@@ -142,7 +143,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
expect(promptSpies.constructor).toHaveBeenCalled();
|
||||
promptSpies.constructor.mostRecentCall.args[0].actions.primary.click(promptSpies);
|
||||
|
||||
create_sinon.expectJsonRequest(requests, "POST", "/xblock/locator-container",
|
||||
AjaxHelpers.expectJsonRequest(requests, "POST", "/xblock/locator-container",
|
||||
{"publish": "discard_changes"}
|
||||
);
|
||||
};
|
||||
@@ -219,7 +220,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
it('can publish private content', function () {
|
||||
var notificationSpy = edit_helpers.createNotificationSpy();
|
||||
var notificationSpy = EditHelpers.createNotificationSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
expect(containerPage.$(bitPublishingCss)).not.toHaveClass(hasWarningsClass);
|
||||
expect(containerPage.$(bitPublishingCss)).not.toHaveClass(readyClass);
|
||||
@@ -227,17 +228,17 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
// Click publish
|
||||
containerPage.$(publishButtonCss).click();
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, /Publishing/);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, /Publishing/);
|
||||
|
||||
create_sinon.expectJsonRequest(requests, "POST", "/xblock/locator-container",
|
||||
AjaxHelpers.expectJsonRequest(requests, "POST", "/xblock/locator-container",
|
||||
{"publish": "make_public"}
|
||||
);
|
||||
|
||||
// Response to publish call
|
||||
respondWithJson({"id": "locator-container", "data": null, "metadata":{}});
|
||||
edit_helpers.verifyNotificationHidden(notificationSpy);
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
|
||||
create_sinon.expectJsonRequest(requests, "GET", "/xblock/locator-container");
|
||||
AjaxHelpers.expectJsonRequest(requests, "GET", "/xblock/locator-container");
|
||||
// Response to fetch
|
||||
respondWithJson(createXBlockInfo({
|
||||
published: true, has_changes: false, visibility_state: VisibilityState.ready
|
||||
@@ -258,7 +259,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
var numRequests = requests.length;
|
||||
// Respond with failure
|
||||
create_sinon.respondWithError(requests);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
|
||||
expect(requests.length).toEqual(numRequests);
|
||||
|
||||
@@ -271,7 +272,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
it('can discard changes', function () {
|
||||
var notificationSpy, renderPageSpy, numRequests;
|
||||
createContainerPage(this);
|
||||
notificationSpy = edit_helpers.createNotificationSpy();
|
||||
notificationSpy = EditHelpers.createNotificationSpy();
|
||||
renderPageSpy = spyOn(containerPage.xblockPublisher, 'renderPage').andCallThrough();
|
||||
|
||||
sendDiscardChangesToServer();
|
||||
@@ -279,7 +280,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
// Respond with success.
|
||||
respondWithJson({"id": "locator-container"});
|
||||
edit_helpers.verifyNotificationHidden(notificationSpy);
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
|
||||
// Verify other requests are sent to the server to update page state.
|
||||
// Response to fetch, specifying the very next request (as multiple requests will be sent to server)
|
||||
@@ -297,7 +298,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
numRequests = requests.length;
|
||||
|
||||
// Respond with failure
|
||||
create_sinon.respondWithError(requests);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
|
||||
expect(requests.length).toEqual(numRequests);
|
||||
expect(containerPage.$(discardChangesButtonCss)).not.toHaveClass('is-disabled');
|
||||
@@ -393,14 +394,14 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
// If removing explicit staff lock with no implicit staff lock, click 'Yes' to confirm
|
||||
if (!isStaffOnly && !containerPage.model.get('ancestor_has_staff_lock')) {
|
||||
edit_helpers.confirmPrompt(promptSpy);
|
||||
EditHelpers.confirmPrompt(promptSpy);
|
||||
}
|
||||
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/locator-container', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/locator-container', {
|
||||
publish: 'republish',
|
||||
metadata: { visible_to_staff_only: isStaffOnly ? true : null }
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
data: null,
|
||||
id: "locator-container",
|
||||
metadata: {
|
||||
@@ -408,13 +409,13 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
}
|
||||
});
|
||||
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/locator-container');
|
||||
if (isStaffOnly || containerPage.model.get('ancestor_has_staff_lock')) {
|
||||
newVisibilityState = VisibilityState.staffOnly;
|
||||
} else {
|
||||
newVisibilityState = VisibilityState.live;
|
||||
}
|
||||
create_sinon.respondWithJson(requests, createXBlockInfo({
|
||||
AjaxHelpers.respondWithJson(requests, createXBlockInfo({
|
||||
published: containerPage.model.get('published'),
|
||||
has_explicit_staff_lock: isStaffOnly,
|
||||
visibility_state: newVisibilityState,
|
||||
@@ -423,11 +424,12 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
};
|
||||
|
||||
verifyStaffOnly = function(isStaffOnly) {
|
||||
var visibilityCopy = containerPage.$('.wrapper-visibility .copy').text().trim();
|
||||
if (isStaffOnly) {
|
||||
expect(containerPage.$('.wrapper-visibility .copy').text()).toContain('Staff Only');
|
||||
expect(visibilityCopy).toContain('Staff Only');
|
||||
expect(containerPage.$(bitPublishingCss)).toHaveClass(staffOnlyClass);
|
||||
} else {
|
||||
expect(containerPage.$('.wrapper-visibility .copy').text().trim()).toBe('Staff and Students');
|
||||
expect(visibilityCopy).toBe('Staff and Students');
|
||||
expect(containerPage.$(bitPublishingCss)).not.toHaveClass(staffOnlyClass);
|
||||
verifyExplicitStaffOnly(false);
|
||||
verifyImplicitStaffOnly(false);
|
||||
@@ -506,7 +508,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
it("can remove explicit staff only setting without having implicit staff only", function() {
|
||||
promptSpy = edit_helpers.createPromptSpy();
|
||||
promptSpy = EditHelpers.createPromptSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml, {
|
||||
visibility_state: VisibilityState.staffOnly,
|
||||
has_explicit_staff_lock: true,
|
||||
@@ -517,7 +519,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
|
||||
it("can remove explicit staff only setting while having implicit staff only", function() {
|
||||
promptSpy = edit_helpers.createPromptSpy();
|
||||
promptSpy = EditHelpers.createPromptSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml, {
|
||||
visibility_state: VisibilityState.staffOnly,
|
||||
ancestor_has_staff_lock: true,
|
||||
@@ -532,7 +534,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
it("does not refresh if removing staff only is canceled", function() {
|
||||
var requestCount;
|
||||
promptSpy = edit_helpers.createPromptSpy();
|
||||
promptSpy = EditHelpers.createPromptSpy();
|
||||
renderContainerPage(this, mockContainerXBlockHtml, {
|
||||
visibility_state: VisibilityState.staffOnly,
|
||||
has_explicit_staff_lock: true,
|
||||
@@ -540,7 +542,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
});
|
||||
requestCount = requests.length;
|
||||
containerPage.$('.action-staff-lock').click();
|
||||
edit_helpers.confirmPrompt(promptSpy, true); // Click 'No' to cancel
|
||||
EditHelpers.confirmPrompt(promptSpy, true); // Click 'No' to cancel
|
||||
expect(requests.length).toBe(requestCount);
|
||||
verifyExplicitStaffOnly(true);
|
||||
verifyStaffOnly(true);
|
||||
@@ -551,7 +553,7 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
renderContainerPage(this, mockContainerXBlockHtml);
|
||||
containerPage.$('.lock-checkbox').click();
|
||||
requestCount = requests.length;
|
||||
create_sinon.respondWithError(requests);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
expect(requests.length).toBe(requestCount);
|
||||
verifyStaffOnly(false);
|
||||
});
|
||||
@@ -588,7 +590,8 @@ define(["jquery", "underscore", "underscore.string", "js/spec_helpers/create_sin
|
||||
|
||||
describe("Message Area", function() {
|
||||
var messageSelector = '.container-message .warning',
|
||||
warningMessage = 'Caution: The last published version of this unit is live. By publishing changes you will change the student experience.';
|
||||
warningMessage = 'Caution: The last published version of this unit is live. ' +
|
||||
'By publishing changes you will change the student experience.';
|
||||
|
||||
it('is empty for a unit that is not currently visible to students', function() {
|
||||
renderContainerPage(this, mockContainerXBlockHtml, {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers", "js/views/utils/view_utils",
|
||||
"js/views/pages/course_outline", "js/models/xblock_outline_info", "js/utils/date_utils", "js/spec_helpers/edit_helpers"],
|
||||
function ($, create_sinon, view_helpers, ViewUtils, CourseOutlinePage, XBlockOutlineInfo, DateUtils, edit_helpers) {
|
||||
define(["jquery", "js/common_helpers/ajax_helpers", "js/views/utils/view_utils", "js/views/pages/course_outline",
|
||||
"js/models/xblock_outline_info", "js/utils/date_utils", "js/spec_helpers/edit_helpers",
|
||||
"js/common_helpers/template_helpers"],
|
||||
function($, AjaxHelpers, ViewUtils, CourseOutlinePage, XBlockOutlineInfo, DateUtils, EditHelpers, TemplateHelpers) {
|
||||
|
||||
describe("CourseOutlinePage", function() {
|
||||
var createCourseOutlinePage, displayNameInput, model, outlinePage, requests,
|
||||
getItemsOfType, getItemHeaders, verifyItemsExpanded, expandItemsAndVerifyState, collapseItemsAndVerifyState,
|
||||
createMockCourseJSON, createMockSectionJSON, createMockSubsectionJSON, verifyTypePublishable,
|
||||
mockCourseJSON, mockEmptyCourseJSON, mockSingleSectionCourseJSON, createMockVerticalJSON,
|
||||
getItemsOfType, getItemHeaders, verifyItemsExpanded, expandItemsAndVerifyState,
|
||||
collapseItemsAndVerifyState, createMockCourseJSON, createMockSectionJSON, createMockSubsectionJSON,
|
||||
verifyTypePublishable, mockCourseJSON, mockEmptyCourseJSON, mockSingleSectionCourseJSON,
|
||||
createMockVerticalJSON,
|
||||
mockOutlinePage = readFixtures('mock/mock-course-outline-page.underscore'),
|
||||
mockRerunNotification = readFixtures('mock/mock-course-rerun-notification.underscore');
|
||||
|
||||
@@ -114,7 +116,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
};
|
||||
|
||||
createCourseOutlinePage = function(test, courseJSON, createOnly) {
|
||||
requests = create_sinon.requests(test);
|
||||
requests = AjaxHelpers.requests(test);
|
||||
model = new XBlockOutlineInfo(courseJSON, { parse: true });
|
||||
outlinePage = new CourseOutlinePage({
|
||||
model: model,
|
||||
@@ -148,12 +150,12 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
createCourseOutlinePageAndShowUnit(this, mockCourseJSON);
|
||||
getItemHeaders(type).find('.publish-button').click();
|
||||
$(".wrapper-modal-window .action-publish").click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/mock-' + type, {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/mock-' + type, {
|
||||
publish : 'make_public'
|
||||
});
|
||||
expect(requests[0].requestHeaders['X-HTTP-Method-Override']).toBe('PATCH');
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
});
|
||||
|
||||
it('should show publish button if it is not published and not changed', function() {
|
||||
@@ -191,9 +193,9 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
view_helpers.installMockAnalytics();
|
||||
view_helpers.installViewTemplates();
|
||||
view_helpers.installTemplates([
|
||||
EditHelpers.installMockAnalytics();
|
||||
EditHelpers.installViewTemplates();
|
||||
TemplateHelpers.installTemplates([
|
||||
'course-outline', 'xblock-string-field-editor', 'modal-button',
|
||||
'basic-modal', 'course-outline-modal', 'release-date-editor',
|
||||
'due-date-editor', 'grading-editor', 'publish-editor',
|
||||
@@ -214,8 +216,8 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
view_helpers.removeMockAnalytics();
|
||||
edit_helpers.cancelModalIfShowing();
|
||||
EditHelpers.removeMockAnalytics();
|
||||
EditHelpers.cancelModalIfShowing();
|
||||
// Clean up after the $.datepicker
|
||||
$("#start_date").datepicker( "destroy" );
|
||||
$("#due_date").datepicker( "destroy" );
|
||||
@@ -250,8 +252,8 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
createCourseOutlinePage(this, mockEmptyCourseJSON);
|
||||
expect($('.wrapper-alert-announcement')).not.toHaveClass('is-hidden');
|
||||
$('.dismiss-button').click();
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', 'dummy_dismiss_url');
|
||||
create_sinon.respondToDelete(requests);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', 'dummy_dismiss_url');
|
||||
AjaxHelpers.respondToDelete(requests);
|
||||
expect($('.wrapper-alert-announcement')).toHaveClass('is-hidden');
|
||||
});
|
||||
});
|
||||
@@ -260,17 +262,17 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
it('can add a section', function() {
|
||||
createCourseOutlinePage(this, mockEmptyCourseJSON);
|
||||
outlinePage.$('.nav-actions .button-new').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
"locator": 'mock-section',
|
||||
"courseKey": 'slashes:MockCourse'
|
||||
});
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
create_sinon.respondWithJson(requests, mockSingleSectionCourseJSON);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
AjaxHelpers.respondWithJson(requests, mockSingleSectionCourseJSON);
|
||||
expect(outlinePage.$('.no-content')).not.toExist();
|
||||
expect(outlinePage.$('.list-sections li.outline-section').data('locator')).toEqual('mock-section');
|
||||
});
|
||||
@@ -279,18 +281,18 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
var sectionElements;
|
||||
createCourseOutlinePage(this, mockSingleSectionCourseJSON);
|
||||
outlinePage.$('.nav-actions .button-new').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
"locator": 'mock-section-2',
|
||||
"courseKey": 'slashes:MockCourse'
|
||||
});
|
||||
// Expect the UI to just fetch the new section and repaint it
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section-2');
|
||||
create_sinon.respondWithJson(requests,
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section-2');
|
||||
AjaxHelpers.respondWithJson(requests,
|
||||
createMockSectionJSON({id: 'mock-section-2', display_name: 'Mock Section 2'}));
|
||||
sectionElements = getItemsOfType('section');
|
||||
expect(sectionElements.length).toBe(2);
|
||||
@@ -318,17 +320,17 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
it('can add a section', function() {
|
||||
createCourseOutlinePage(this, mockEmptyCourseJSON);
|
||||
$('.no-content .button-new').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
"locator": "mock-section",
|
||||
"courseKey": "slashes:MockCourse"
|
||||
});
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
create_sinon.respondWithJson(requests, mockSingleSectionCourseJSON);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
AjaxHelpers.respondWithJson(requests, mockSingleSectionCourseJSON);
|
||||
expect(outlinePage.$('.no-content')).not.toExist();
|
||||
expect(outlinePage.$('.list-sections li.outline-section').data('locator')).toEqual('mock-section');
|
||||
});
|
||||
@@ -337,13 +339,13 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
var requestCount;
|
||||
createCourseOutlinePage(this, mockEmptyCourseJSON);
|
||||
$('.no-content .button-new').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'chapter',
|
||||
'display_name': 'Section',
|
||||
'parent_locator': 'mock-course'
|
||||
});
|
||||
requestCount = requests.length;
|
||||
create_sinon.respondWithError(requests);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
expect(requests.length).toBe(requestCount); // No additional requests should be made
|
||||
expect(outlinePage.$('.no-content')).not.toHaveClass('is-hidden');
|
||||
expect(outlinePage.$('.no-content .button-new')).toExist();
|
||||
@@ -358,43 +360,43 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
};
|
||||
|
||||
it('can be deleted', function() {
|
||||
var promptSpy = view_helpers.createPromptSpy(), requestCount;
|
||||
var promptSpy = EditHelpers.createPromptSpy(), requestCount;
|
||||
createCourseOutlinePage(this, createMockCourseJSON({}, [
|
||||
createMockSectionJSON(),
|
||||
createMockSectionJSON({id: 'mock-section-2', display_name: 'Mock Section 2'})
|
||||
]));
|
||||
getItemHeaders('section').find('.delete-button').first().click();
|
||||
view_helpers.confirmPrompt(promptSpy);
|
||||
EditHelpers.confirmPrompt(promptSpy);
|
||||
requestCount = requests.length;
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', '/xblock/mock-section');
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', '/xblock/mock-section');
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
expect(requests.length).toBe(requestCount); // No fetch should be performed
|
||||
expect(outlinePage.$('[data-locator="mock-section"]')).not.toExist();
|
||||
expect(outlinePage.$('[data-locator="mock-section-2"]')).toExist();
|
||||
});
|
||||
|
||||
it('can be deleted if it is the only section', function() {
|
||||
var promptSpy = view_helpers.createPromptSpy();
|
||||
var promptSpy = EditHelpers.createPromptSpy();
|
||||
createCourseOutlinePage(this, mockSingleSectionCourseJSON);
|
||||
getItemHeaders('section').find('.delete-button').click();
|
||||
view_helpers.confirmPrompt(promptSpy);
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', '/xblock/mock-section');
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
create_sinon.respondWithJson(requests, mockEmptyCourseJSON);
|
||||
EditHelpers.confirmPrompt(promptSpy);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', '/xblock/mock-section');
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-course');
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyCourseJSON);
|
||||
expect(outlinePage.$('.no-content')).not.toHaveClass('is-hidden');
|
||||
expect(outlinePage.$('.no-content .button-new')).toExist();
|
||||
});
|
||||
|
||||
it('remains visible if its deletion fails', function() {
|
||||
var promptSpy = view_helpers.createPromptSpy(),
|
||||
var promptSpy = EditHelpers.createPromptSpy(),
|
||||
requestCount;
|
||||
createCourseOutlinePage(this, mockSingleSectionCourseJSON);
|
||||
getItemHeaders('section').find('.delete-button').click();
|
||||
view_helpers.confirmPrompt(promptSpy);
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', '/xblock/mock-section');
|
||||
EditHelpers.confirmPrompt(promptSpy);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', '/xblock/mock-section');
|
||||
requestCount = requests.length;
|
||||
create_sinon.respondWithError(requests);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
expect(requests.length).toBe(requestCount); // No additional requests should be made
|
||||
expect(outlinePage.$('.list-sections li.outline-section').data('locator')).toEqual('mock-section');
|
||||
});
|
||||
@@ -402,18 +404,18 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
it('can add a subsection', function() {
|
||||
createCourseOutlinePage(this, mockCourseJSON);
|
||||
getItemsOfType('section').find('> .outline-content > .add-subsection .button-new').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'sequential',
|
||||
'display_name': 'Subsection',
|
||||
'parent_locator': 'mock-section'
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
"locator": "new-mock-subsection",
|
||||
"courseKey": "slashes:MockCourse"
|
||||
});
|
||||
// Note: verification of the server response and the UI's handling of it
|
||||
// is handled in the acceptance tests.
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
|
||||
});
|
||||
|
||||
@@ -423,13 +425,13 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
sectionModel;
|
||||
createCourseOutlinePage(this, mockCourseJSON);
|
||||
displayNameWrapper = getDisplayNameWrapper();
|
||||
displayNameInput = view_helpers.inlineEdit(displayNameWrapper, updatedDisplayName);
|
||||
displayNameInput = EditHelpers.inlineEdit(displayNameWrapper, updatedDisplayName);
|
||||
displayNameInput.change();
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, { });
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
// This is the response for the subsequent fetch operation.
|
||||
create_sinon.respondWithJson(requests, {"display_name": updatedDisplayName});
|
||||
view_helpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
AjaxHelpers.respondWithJson(requests, {"display_name": updatedDisplayName});
|
||||
EditHelpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
sectionModel = outlinePage.model.get('child_info').children[0];
|
||||
expect(sectionModel.get('display_name')).toBe(updatedDisplayName);
|
||||
});
|
||||
@@ -455,7 +457,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
// Staff lock controls are always visible
|
||||
expect($("#staff_lock")).toExist();
|
||||
$(".wrapper-modal-window .action-save").click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/mock-section', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/mock-section', {
|
||||
"metadata":{
|
||||
"start":"2015-01-02T00:00:00.000Z"
|
||||
}
|
||||
@@ -463,7 +465,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
expect(requests[0].requestHeaders['X-HTTP-Method-Override']).toBe('PATCH');
|
||||
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
var mockResponseSectionJSON = createMockSectionJSON({
|
||||
release_date: 'Jan 02, 2015 at 00:00 UTC'
|
||||
}, [
|
||||
@@ -474,10 +476,10 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
})
|
||||
])
|
||||
]);
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section')
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
expect(requests.length).toBe(2);
|
||||
// This is the response for the subsequent fetch operation for the section.
|
||||
create_sinon.respondWithJson(requests, mockResponseSectionJSON);
|
||||
AjaxHelpers.respondWithJson(requests, mockResponseSectionJSON);
|
||||
|
||||
expect($(".outline-section .status-release-value")).toContainText("Jan 02, 2015 at 00:00 UTC");
|
||||
});
|
||||
@@ -507,7 +509,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
]),
|
||||
createMockSectionJSON({has_changes: true}, [
|
||||
createMockSubsectionJSON({has_changes: true}, [
|
||||
createMockVerticalJSON({has_changes: true}),
|
||||
createMockVerticalJSON({has_changes: true})
|
||||
])
|
||||
])
|
||||
]), modalWindow;
|
||||
@@ -518,7 +520,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
expect(modalWindow.find('.outline-unit').length).toBe(3);
|
||||
expect(_.compact(_.map(modalWindow.find('.outline-unit').text().split("\n"), $.trim))).toEqual(
|
||||
['Unit 100', 'Unit 50', 'Unit 1']
|
||||
)
|
||||
);
|
||||
expect(modalWindow.find('.outline-subsection').length).toBe(2);
|
||||
});
|
||||
});
|
||||
@@ -538,7 +540,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
};
|
||||
|
||||
// Contains hard-coded dates because dates are presented in different formats.
|
||||
var mockServerValuesJson = createMockSectionJSON({
|
||||
mockServerValuesJson = createMockSectionJSON({
|
||||
release_date: 'Jan 01, 2970 at 05:00 UTC'
|
||||
}, [
|
||||
createMockSubsectionJSON({
|
||||
@@ -559,15 +561,15 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
]);
|
||||
|
||||
it('can be deleted', function() {
|
||||
var promptSpy = view_helpers.createPromptSpy();
|
||||
var promptSpy = EditHelpers.createPromptSpy();
|
||||
createCourseOutlinePage(this, mockCourseJSON);
|
||||
getItemHeaders('subsection').find('.delete-button').click();
|
||||
view_helpers.confirmPrompt(promptSpy);
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', '/xblock/mock-subsection');
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
EditHelpers.confirmPrompt(promptSpy);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', '/xblock/mock-subsection');
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
// Note: verification of the server response and the UI's handling of it
|
||||
// is handled in the acceptance tests.
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
});
|
||||
|
||||
it('can add a unit', function() {
|
||||
@@ -575,12 +577,12 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
createCourseOutlinePage(this, mockCourseJSON);
|
||||
redirectSpy = spyOn(ViewUtils, 'redirect');
|
||||
getItemsOfType('subsection').find('> .outline-content > .add-unit .button-new').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
'category': 'vertical',
|
||||
'display_name': 'Unit',
|
||||
'parent_locator': 'mock-subsection'
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
"locator": "new-mock-unit",
|
||||
"courseKey": "slashes:MockCourse"
|
||||
});
|
||||
@@ -593,12 +595,12 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
subsectionModel;
|
||||
createCourseOutlinePage(this, mockCourseJSON);
|
||||
displayNameWrapper = getDisplayNameWrapper();
|
||||
displayNameInput = view_helpers.inlineEdit(displayNameWrapper, updatedDisplayName);
|
||||
displayNameInput = EditHelpers.inlineEdit(displayNameWrapper, updatedDisplayName);
|
||||
displayNameInput.change();
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, { });
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
// This is the response for the subsequent fetch operation for the section.
|
||||
create_sinon.respondWithJson(requests,
|
||||
AjaxHelpers.respondWithJson(requests,
|
||||
createMockSectionJSON({}, [
|
||||
createMockSubsectionJSON({
|
||||
display_name: updatedDisplayName
|
||||
@@ -607,7 +609,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
);
|
||||
// Find the display name again in the refreshed DOM and verify it
|
||||
displayNameWrapper = getItemHeaders('subsection').find('.wrapper-xblock-field');
|
||||
view_helpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
EditHelpers.verifyInlineEditChange(displayNameWrapper, updatedDisplayName);
|
||||
subsectionModel = outlinePage.model.get('child_info').children[0].get('child_info').children[0];
|
||||
expect(subsectionModel.get('display_name')).toBe(updatedDisplayName);
|
||||
});
|
||||
@@ -625,7 +627,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
outlinePage.$('.outline-subsection .configure-button').click();
|
||||
setEditModalValues("7/9/2014", "7/10/2014", "Lab", true);
|
||||
$(".wrapper-modal-window .action-save").click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/mock-subsection', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/mock-subsection', {
|
||||
"graderType":"Lab",
|
||||
"publish": "republish",
|
||||
"metadata":{
|
||||
@@ -637,16 +639,24 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
expect(requests[0].requestHeaders['X-HTTP-Method-Override']).toBe('PATCH');
|
||||
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section')
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
expect(requests.length).toBe(2);
|
||||
// This is the response for the subsequent fetch operation for the section.
|
||||
create_sinon.respondWithJson(requests, mockServerValuesJson);
|
||||
AjaxHelpers.respondWithJson(requests, mockServerValuesJson);
|
||||
|
||||
expect($(".outline-subsection .status-release-value")).toContainText("Jul 09, 2014 at 00:00 UTC");
|
||||
expect($(".outline-subsection .status-grading-date")).toContainText("Due: Jul 10, 2014 at 00:00 UTC");
|
||||
expect($(".outline-subsection .status-grading-value")).toContainText("Lab");
|
||||
expect($(".outline-subsection .status-message-copy")).toContainText("Contains staff only content");
|
||||
expect($(".outline-subsection .status-release-value")).toContainText(
|
||||
"Jul 09, 2014 at 00:00 UTC"
|
||||
);
|
||||
expect($(".outline-subsection .status-grading-date")).toContainText(
|
||||
"Due: Jul 10, 2014 at 00:00 UTC"
|
||||
);
|
||||
expect($(".outline-subsection .status-grading-value")).toContainText(
|
||||
"Lab"
|
||||
);
|
||||
expect($(".outline-subsection .status-message-copy")).toContainText(
|
||||
"Contains staff only content"
|
||||
);
|
||||
|
||||
expect($(".outline-item .outline-subsection .status-grading-value")).toContainText("Lab");
|
||||
outlinePage.$('.outline-item .outline-subsection .configure-button').click();
|
||||
@@ -663,14 +673,22 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
$(".wrapper-modal-window .action-save").click();
|
||||
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
// This is the response for the subsequent fetch operation.
|
||||
create_sinon.respondWithJson(requests, mockServerValuesJson);
|
||||
AjaxHelpers.respondWithJson(requests, mockServerValuesJson);
|
||||
|
||||
expect($(".outline-subsection .status-release-value")).toContainText("Jul 09, 2014 at 00:00 UTC");
|
||||
expect($(".outline-subsection .status-grading-date")).toContainText("Due: Jul 10, 2014 at 00:00 UTC");
|
||||
expect($(".outline-subsection .status-grading-value")).toContainText("Lab");
|
||||
expect($(".outline-subsection .status-message-copy")).toContainText("Contains staff only content");
|
||||
expect($(".outline-subsection .status-release-value")).toContainText(
|
||||
"Jul 09, 2014 at 00:00 UTC"
|
||||
);
|
||||
expect($(".outline-subsection .status-grading-date")).toContainText(
|
||||
"Due: Jul 10, 2014 at 00:00 UTC"
|
||||
);
|
||||
expect($(".outline-subsection .status-grading-value")).toContainText(
|
||||
"Lab"
|
||||
);
|
||||
expect($(".outline-subsection .status-message-copy")).toContainText(
|
||||
"Contains staff only content"
|
||||
);
|
||||
|
||||
outlinePage.$('.outline-subsection .configure-button').click();
|
||||
expect($("#start_date").val()).toBe('7/9/2014');
|
||||
@@ -689,15 +707,19 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
$(".wrapper-modal-window .action-save").click();
|
||||
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
// This is the response for the subsequent fetch operation.
|
||||
create_sinon.respondWithJson(requests,
|
||||
AjaxHelpers.respondWithJson(requests,
|
||||
createMockSectionJSON({}, [createMockSubsectionJSON()])
|
||||
);
|
||||
expect($(".outline-subsection .status-release-value")).not.toContainText("Jul 09, 2014 at 00:00 UTC");
|
||||
expect($(".outline-subsection .status-release-value")).not.toContainText(
|
||||
"Jul 09, 2014 at 00:00 UTC"
|
||||
);
|
||||
expect($(".outline-subsection .status-grading-date")).not.toExist();
|
||||
expect($(".outline-subsection .status-grading-value")).not.toExist();
|
||||
expect($(".outline-subsection .status-message-copy")).not.toContainText("Contains staff only content");
|
||||
expect($(".outline-subsection .status-message-copy")).not.toContainText(
|
||||
"Contains staff only content"
|
||||
);
|
||||
});
|
||||
|
||||
verifyTypePublishable('subsection', function (options) {
|
||||
@@ -731,7 +753,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
expect(modalWindow.find('.outline-unit').length).toBe(2);
|
||||
expect(_.compact(_.map(modalWindow.find('.outline-unit').text().split("\n"), $.trim))).toEqual(
|
||||
['Unit 100', 'Unit 50']
|
||||
)
|
||||
);
|
||||
expect(modalWindow.find('.outline-subsection')).not.toExist();
|
||||
});
|
||||
});
|
||||
@@ -739,16 +761,16 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
// Note: most tests for units can be found in Bok Choy
|
||||
describe("Unit", function() {
|
||||
it('can be deleted', function() {
|
||||
var promptSpy = view_helpers.createPromptSpy();
|
||||
var promptSpy = EditHelpers.createPromptSpy();
|
||||
createCourseOutlinePage(this, mockCourseJSON);
|
||||
expandItemsAndVerifyState('subsection');
|
||||
getItemHeaders('unit').find('.delete-button').click();
|
||||
view_helpers.confirmPrompt(promptSpy);
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', '/xblock/mock-unit');
|
||||
create_sinon.respondWithJson(requests, {});
|
||||
EditHelpers.confirmPrompt(promptSpy);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', '/xblock/mock-unit');
|
||||
AjaxHelpers.respondWithJson(requests, {});
|
||||
// Note: verification of the server response and the UI's handling of it
|
||||
// is handled in the acceptance tests.
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/outline/mock-section');
|
||||
});
|
||||
|
||||
it('has a link to the unit page', function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers", "js/views/course_rerun",
|
||||
define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helpers", "js/views/course_rerun",
|
||||
"js/views/utils/create_course_utils", "js/views/utils/view_utils", "jquery.simulate"],
|
||||
function ($, create_sinon, view_helpers, CourseRerunUtils, CreateCourseUtilsFactory, ViewUtils) {
|
||||
function ($, AjaxHelpers, ViewHelpers, CourseRerunUtils, CreateCourseUtilsFactory, ViewUtils) {
|
||||
describe("Create course rerun page", function () {
|
||||
var selectors = {
|
||||
org: '.rerun-course-org',
|
||||
@@ -36,14 +36,14 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
view_helpers.installMockAnalytics();
|
||||
ViewHelpers.installMockAnalytics();
|
||||
window.source_course_key = 'test_course_key';
|
||||
appendSetFixtures(mockCreateCourseRerunHTML);
|
||||
CourseRerunUtils.onReady();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
view_helpers.removeMockAnalytics();
|
||||
ViewHelpers.removeMockAnalytics();
|
||||
delete window.source_course_key;
|
||||
});
|
||||
|
||||
@@ -156,11 +156,11 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
});
|
||||
|
||||
it("saves course reruns", function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
var redirectSpy = spyOn(ViewUtils, 'redirect')
|
||||
fillInFields('DemoX', 'DM101', '2014', 'Demo course');
|
||||
$(selectors.save).click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/course/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/course/', {
|
||||
source_course_key: 'test_course_key',
|
||||
org: 'DemoX',
|
||||
number: 'DM101',
|
||||
@@ -170,17 +170,17 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
expect($(selectors.save)).toHaveClass(classes.disabled);
|
||||
expect($(selectors.save)).toHaveClass(classes.processing);
|
||||
expect($(selectors.cancel)).toHaveClass(classes.hidden);
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
url: 'dummy_test_url'
|
||||
});
|
||||
expect(redirectSpy).toHaveBeenCalledWith('dummy_test_url');
|
||||
});
|
||||
|
||||
it("displays an error when saving fails", function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
fillInFields('DemoX', 'DM101', '2014', 'Demo course');
|
||||
$(selectors.save).click();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
ErrMsg: 'error message'
|
||||
});
|
||||
expect($(selectors.errorWrapper)).not.toHaveClass(classes.hidden);
|
||||
@@ -190,7 +190,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
});
|
||||
|
||||
it("does not save if there are validation errors", function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
fillInFields('DemoX', 'DM101', '', 'Demo course');
|
||||
$(selectors.save).click();
|
||||
expect(requests.length).toBe(0);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([
|
||||
'jquery', 'underscore', 'js/views/pages/group_configurations',
|
||||
'js/collections/group_configuration', 'js/models/group_configuration', 'js/spec_helpers/edit_helpers'
|
||||
], function ($, _, GroupConfigurationsPage, GroupConfigurationCollection, GroupConfigurationModel, view_helpers) {
|
||||
'js/collections/group_configuration', 'js/common_helpers/template_helpers'
|
||||
], function ($, _, GroupConfigurationsPage, GroupConfigurationCollection, TemplateHelpers) {
|
||||
'use strict';
|
||||
describe('GroupConfigurationsPage', function() {
|
||||
var mockGroupConfigurationsPage = readFixtures(
|
||||
@@ -35,7 +35,7 @@ define([
|
||||
|
||||
beforeEach(function () {
|
||||
setFixtures(mockGroupConfigurationsPage);
|
||||
view_helpers.installTemplates([
|
||||
TemplateHelpers.installTemplates([
|
||||
'no-group-configurations', 'group-configuration-edit',
|
||||
'group-configuration-details'
|
||||
]);
|
||||
@@ -83,7 +83,7 @@ define([
|
||||
describe('Check that Group Configuration will focus and expand depending on content of url hash', function() {
|
||||
beforeEach(function () {
|
||||
spyOn($.fn, 'focus');
|
||||
view_helpers.installTemplate('group-configuration-details');
|
||||
TemplateHelpers.installTemplate('group-configuration-details');
|
||||
this.view = initializePage(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers", "js/index",
|
||||
define(["jquery", "js/common_helpers/ajax_helpers", "js/spec_helpers/view_helpers", "js/index",
|
||||
"js/views/utils/view_utils"],
|
||||
function ($, create_sinon, view_helpers, IndexUtils, ViewUtils) {
|
||||
function ($, AjaxHelpers, ViewHelpers, IndexUtils, ViewUtils) {
|
||||
describe("Course listing page", function () {
|
||||
var mockIndexPageHTML = readFixtures('mock/mock-index-page.underscore'), fillInFields;
|
||||
|
||||
@@ -12,49 +12,49 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
view_helpers.installMockAnalytics();
|
||||
ViewHelpers.installMockAnalytics();
|
||||
appendSetFixtures(mockIndexPageHTML);
|
||||
IndexUtils.onReady();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
view_helpers.removeMockAnalytics();
|
||||
ViewHelpers.removeMockAnalytics();
|
||||
delete window.source_course_key;
|
||||
});
|
||||
|
||||
it("can dismiss notifications", function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
var reloadSpy = spyOn(ViewUtils, 'reload');
|
||||
$('.dismiss-button').click();
|
||||
create_sinon.expectJsonRequest(requests, 'DELETE', 'dummy_dismiss_url');
|
||||
create_sinon.respondToDelete(requests);
|
||||
AjaxHelpers.expectJsonRequest(requests, 'DELETE', 'dummy_dismiss_url');
|
||||
AjaxHelpers.respondToDelete(requests);
|
||||
expect(reloadSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("saves new courses", function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
var redirectSpy = spyOn(ViewUtils, 'redirect');
|
||||
$('.new-course-button').click()
|
||||
fillInFields('DemoX', 'DM101', '2014', 'Demo course');
|
||||
$('.new-course-save').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/course/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/course/', {
|
||||
org: 'DemoX',
|
||||
number: 'DM101',
|
||||
run: '2014',
|
||||
display_name: 'Demo course'
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
url: 'dummy_test_url'
|
||||
});
|
||||
expect(redirectSpy).toHaveBeenCalledWith('dummy_test_url');
|
||||
});
|
||||
|
||||
it("displays an error when saving fails", function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
$('.new-course-button').click();
|
||||
fillInFields('DemoX', 'DM101', '2014', 'Demo course');
|
||||
$('.new-course-save').click();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
ErrMsg: 'error message'
|
||||
});
|
||||
expect($('.wrap-error')).toHaveClass('is-shown');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
define([ "jquery", "js/common_helpers/ajax_helpers", "URI",
|
||||
"js/views/paging", "js/views/paging_header", "js/views/paging_footer",
|
||||
"js/models/asset", "js/collections/asset" ],
|
||||
function ($, create_sinon, URI, PagingView, PagingHeader, PagingFooter, AssetModel, AssetCollection) {
|
||||
function ($, AjaxHelpers, URI, PagingView, PagingHeader, PagingFooter, AssetModel, AssetCollection) {
|
||||
|
||||
var createMockAsset = function(index) {
|
||||
var id = 'asset_' + index;
|
||||
@@ -50,7 +50,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
var queryParameters = url.query(true); // Returns an object with each query parameter stored as a value
|
||||
var page = queryParameters.page;
|
||||
var response = page === "0" ? mockFirstPage : mockSecondPage;
|
||||
create_sinon.respondWithJson(requests, response, requestIndex);
|
||||
AjaxHelpers.respondWithJson(requests, response, requestIndex);
|
||||
};
|
||||
|
||||
var MockPagingView = PagingView.extend({
|
||||
@@ -77,7 +77,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
describe("PagingView", function () {
|
||||
describe("setPage", function () {
|
||||
it('can set the current page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingView.collection.currentPage).toBe(0);
|
||||
@@ -87,7 +87,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('should not change page after a server error', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingView.setPage(1);
|
||||
@@ -98,7 +98,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
|
||||
describe("nextPage", function () {
|
||||
it('does not move forward after a server error', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingView.nextPage();
|
||||
@@ -107,7 +107,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('can move to the next page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingView.nextPage();
|
||||
@@ -116,7 +116,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('can not move forward from the final page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
pagingView.nextPage();
|
||||
@@ -127,7 +127,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
describe("previousPage", function () {
|
||||
|
||||
it('can move back a page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
pagingView.previousPage();
|
||||
@@ -136,7 +136,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('can not move back from the first page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingView.previousPage();
|
||||
@@ -144,7 +144,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('does not move back after a server error', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
pagingView.previousPage();
|
||||
@@ -156,7 +156,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
describe("toggleSortOrder", function () {
|
||||
|
||||
it('can toggle direction of the current sort', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
expect(pagingView.collection.sortDirection).toBe('desc');
|
||||
pagingView.toggleSortOrder('date-col');
|
||||
respondWithMockAssets(requests);
|
||||
@@ -167,7 +167,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('sets the correct default sort direction for a column', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.toggleSortOrder('name-col');
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingView.sortDisplayName()).toBe('Name');
|
||||
@@ -214,7 +214,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('does not move forward if a server error occurs', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingHeader.$('.next-page-link').click();
|
||||
@@ -223,7 +223,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('can move to the next page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingHeader.$('.next-page-link').click();
|
||||
@@ -232,23 +232,23 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('should be enabled when there is at least one more page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.next-page-link')).not.toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be disabled on the final page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.next-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be disabled on an empty page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingHeader.$('.next-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
});
|
||||
@@ -261,7 +261,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('does not move back if a server error occurs', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
pagingHeader.$('.previous-page-link').click();
|
||||
@@ -270,7 +270,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('can go back a page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
pagingHeader.$('.previous-page-link').click();
|
||||
@@ -279,30 +279,30 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('should be disabled on the first page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.previous-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be enabled on the second page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.previous-page-link')).not.toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be disabled for an empty page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingHeader.$('.previous-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
});
|
||||
|
||||
describe("Page metadata section", function() {
|
||||
it('shows the correct metadata for the current page', function () {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
message;
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
@@ -313,7 +313,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('shows the correct metadata when sorted ascending', function () {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
message;
|
||||
pagingView.setPage(0);
|
||||
pagingView.toggleSortOrder('name-col');
|
||||
@@ -327,60 +327,60 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
|
||||
describe("Asset count label", function () {
|
||||
it('should show correct count on first page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.count-current-shown')).toHaveHtml('1-3');
|
||||
});
|
||||
|
||||
it('should show correct count on second page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.count-current-shown')).toHaveHtml('4-4');
|
||||
});
|
||||
|
||||
it('should show correct count for an empty collection', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingHeader.$('.count-current-shown')).toHaveHtml('0-0');
|
||||
});
|
||||
});
|
||||
|
||||
describe("Asset total label", function () {
|
||||
it('should show correct total on the first page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.count-total')).toHaveText('4 total');
|
||||
});
|
||||
|
||||
it('should show correct total on the second page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.count-total')).toHaveText('4 total');
|
||||
});
|
||||
|
||||
it('should show zero total for an empty collection', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingHeader.$('.count-total')).toHaveText('0 total');
|
||||
});
|
||||
});
|
||||
|
||||
describe("Sort order label", function () {
|
||||
it('should show correct initial sort order', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.sort-order')).toHaveText('Date');
|
||||
});
|
||||
|
||||
it('should show updated sort order', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.toggleSortOrder('name-col');
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingHeader.$('.sort-order')).toHaveText('Name');
|
||||
@@ -405,7 +405,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('does not move forward if a server error occurs', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingFooter.$('.next-page-link').click();
|
||||
@@ -414,7 +414,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('can move to the next page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingFooter.$('.next-page-link').click();
|
||||
@@ -423,23 +423,23 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('should be enabled when there is at least one more page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.next-page-link')).not.toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be disabled on the final page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.next-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be disabled on an empty page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingFooter.$('.next-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
});
|
||||
@@ -452,7 +452,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('does not move back if a server error occurs', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
pagingFooter.$('.previous-page-link').click();
|
||||
@@ -461,7 +461,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('can go back a page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
pagingFooter.$('.previous-page-link').click();
|
||||
@@ -470,62 +470,62 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('should be disabled on the first page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.previous-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be enabled on the second page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.previous-page-link')).not.toHaveClass('is-disabled');
|
||||
});
|
||||
|
||||
it('should be disabled for an empty page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingFooter.$('.previous-page-link')).toHaveClass('is-disabled');
|
||||
});
|
||||
});
|
||||
|
||||
describe("Current page label", function () {
|
||||
it('should show 1 on the first page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.current-page')).toHaveText('1');
|
||||
});
|
||||
|
||||
it('should show 2 on the second page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(1);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.current-page')).toHaveText('2');
|
||||
});
|
||||
|
||||
it('should show 1 for an empty collection', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingFooter.$('.current-page')).toHaveText('1');
|
||||
});
|
||||
});
|
||||
|
||||
describe("Page total label", function () {
|
||||
it('should show the correct value with more than one page', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.total-pages')).toHaveText('2');
|
||||
});
|
||||
|
||||
it('should show page 1 when there are no assets', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
create_sinon.respondWithJson(requests, mockEmptyPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockEmptyPage);
|
||||
expect(pagingFooter.$('.total-pages')).toHaveText('1');
|
||||
});
|
||||
});
|
||||
@@ -538,14 +538,14 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('should initially have a blank page input', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
expect(pagingFooter.$('.page-number-input')).toHaveValue('');
|
||||
});
|
||||
|
||||
it('should handle invalid page requests', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingFooter.$('.page-number-input').val('abc');
|
||||
@@ -555,18 +555,18 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI",
|
||||
});
|
||||
|
||||
it('should switch pages via the input field', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingFooter.$('.page-number-input').val('2');
|
||||
pagingFooter.$('.page-number-input').trigger('change');
|
||||
create_sinon.respondWithJson(requests, mockSecondPage);
|
||||
AjaxHelpers.respondWithJson(requests, mockSecondPage);
|
||||
expect(pagingView.collection.currentPage).toBe(1);
|
||||
expect(pagingFooter.$('.page-number-input')).toHaveValue('');
|
||||
});
|
||||
|
||||
it('should handle AJAX failures when switching pages via the input field', function () {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
pagingView.setPage(0);
|
||||
respondWithMockAssets(requests);
|
||||
pagingFooter.$('.page-number-input').val('2');
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers", "js/views/utils/view_utils",
|
||||
"js/views/unit_outline", "js/models/xblock_info"],
|
||||
function ($, create_sinon, view_helpers, ViewUtils, UnitOutlineView, XBlockInfo) {
|
||||
define(["jquery", "js/common_helpers/ajax_helpers", "js/common_helpers/template_helpers",
|
||||
"js/spec_helpers/view_helpers", "js/views/utils/view_utils", "js/views/unit_outline", "js/models/xblock_info"],
|
||||
function ($, AjaxHelpers, TemplateHelpers, ViewHelpers, ViewUtils, UnitOutlineView, XBlockInfo) {
|
||||
|
||||
describe("UnitOutlineView", function() {
|
||||
var createUnitOutlineView, createMockXBlockInfo,
|
||||
requests, model, unitOutlineView;
|
||||
|
||||
createUnitOutlineView = function(test, unitJSON, createOnly) {
|
||||
requests = create_sinon.requests(test);
|
||||
requests = AjaxHelpers.requests(test);
|
||||
model = new XBlockInfo(unitJSON, { parse: true });
|
||||
unitOutlineView = new UnitOutlineView({
|
||||
model: model,
|
||||
@@ -71,14 +71,14 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
view_helpers.installMockAnalytics();
|
||||
view_helpers.installViewTemplates();
|
||||
view_helpers.installTemplate('unit-outline');
|
||||
ViewHelpers.installMockAnalytics();
|
||||
ViewHelpers.installViewTemplates();
|
||||
TemplateHelpers.installTemplate('unit-outline');
|
||||
appendSetFixtures('<div class="wrapper-unit-overview"></div>');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
view_helpers.removeMockAnalytics();
|
||||
ViewHelpers.removeMockAnalytics();
|
||||
});
|
||||
|
||||
it('can render itself', function() {
|
||||
@@ -93,12 +93,12 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
createUnitOutlineView(this, createMockXBlockInfo('Mock Unit'));
|
||||
redirectSpy = spyOn(ViewUtils, 'redirect');
|
||||
unitOutlineView.$('.outline-subsection > .outline-content > .add-unit .button-new').click();
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/', {
|
||||
category: 'vertical',
|
||||
display_name: 'Unit',
|
||||
parent_locator: 'mock-subsection'
|
||||
});
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
locator: "new-mock-unit",
|
||||
courseKey: "slashes:MockCourse"
|
||||
});
|
||||
@@ -106,11 +106,11 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
});
|
||||
|
||||
it('refreshes when the XBlockInfo model syncs', function() {
|
||||
var updatedDisplayName = 'Mock Unit Updated', unitHeader;
|
||||
var updatedDisplayName = 'Mock Unit Updated';
|
||||
createUnitOutlineView(this, createMockXBlockInfo('Mock Unit'));
|
||||
unitOutlineView.refresh();
|
||||
create_sinon.expectJsonRequest(requests, 'GET', '/xblock/mock-unit');
|
||||
create_sinon.respondWithJson(requests,
|
||||
AjaxHelpers.expectJsonRequest(requests, 'GET', '/xblock/mock-unit');
|
||||
AjaxHelpers.respondWithJson(requests,
|
||||
createMockXBlockInfo(updatedDisplayName));
|
||||
expect(unitOutlineView.$('.outline-unit .unit-title').first().text().trim()).toBe(updatedDisplayName);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
define(["jquery", "underscore", "js/views/baseview", "js/views/utils/view_utils", "js/spec_helpers/edit_helpers"],
|
||||
function ($, _, BaseView, ViewUtils, view_helpers) {
|
||||
function ($, _, BaseView, ViewUtils, ViewHelpers) {
|
||||
|
||||
describe("ViewUtils", function() {
|
||||
describe("disabled element while running", function() {
|
||||
@@ -22,22 +22,22 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/utils/view_utils"
|
||||
var testMessage = "Testing...",
|
||||
deferred = new $.Deferred(),
|
||||
promise = deferred.promise(),
|
||||
notificationSpy = view_helpers.createNotificationSpy();
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
ViewUtils.runOperationShowingMessage(testMessage, function() { return promise; });
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Testing/);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Testing/);
|
||||
deferred.resolve();
|
||||
view_helpers.verifyNotificationHidden(notificationSpy);
|
||||
ViewHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it("shows progress notification and leaves it showing upon failure", function() {
|
||||
var testMessage = "Testing...",
|
||||
deferred = new $.Deferred(),
|
||||
promise = deferred.promise(),
|
||||
notificationSpy = view_helpers.createNotificationSpy();
|
||||
notificationSpy = ViewHelpers.createNotificationSpy();
|
||||
ViewUtils.runOperationShowingMessage(testMessage, function() { return promise; });
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Testing/);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Testing/);
|
||||
deferred.fail();
|
||||
view_helpers.verifyNotificationShowing(notificationSpy, /Testing/);
|
||||
ViewHelpers.verifyNotificationShowing(notificationSpy, /Testing/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([ "jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers",
|
||||
define([ "jquery", "underscore", "js/common_helpers/ajax_helpers", "js/spec_helpers/edit_helpers",
|
||||
"js/views/xblock_editor", "js/models/xblock_info"],
|
||||
function ($, _, create_sinon, edit_helpers, XBlockEditorView, XBlockInfo) {
|
||||
function ($, _, AjaxHelpers, EditHelpers, XBlockEditorView, XBlockInfo) {
|
||||
|
||||
describe("XBlockEditorView", function() {
|
||||
var model, editor, testDisplayName, mockSaveResponse;
|
||||
@@ -14,7 +14,7 @@ define([ "jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helper
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installEditTemplates();
|
||||
EditHelpers.installEditTemplates();
|
||||
model = new XBlockInfo({
|
||||
id: 'testCourse/branch/draft/block/verticalFFF',
|
||||
display_name: 'Test Unit',
|
||||
@@ -29,19 +29,19 @@ define([ "jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helper
|
||||
var mockXBlockEditorHtml;
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installMockXBlock();
|
||||
EditHelpers.installMockXBlock();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
edit_helpers.uninstallMockXBlock();
|
||||
EditHelpers.uninstallMockXBlock();
|
||||
});
|
||||
|
||||
mockXBlockEditorHtml = readFixtures('mock/mock-xblock-editor.underscore');
|
||||
|
||||
it('can render itself', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
editor.render();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXBlockEditorHtml,
|
||||
resources: []
|
||||
});
|
||||
@@ -57,17 +57,17 @@ define([ "jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helper
|
||||
mockXModuleEditorHtml = readFixtures('mock/mock-xmodule-editor.underscore');
|
||||
|
||||
beforeEach(function() {
|
||||
edit_helpers.installMockXModule(mockSaveResponse);
|
||||
EditHelpers.installMockXModule(mockSaveResponse);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
edit_helpers.uninstallMockXModule();
|
||||
EditHelpers.uninstallMockXModule();
|
||||
});
|
||||
|
||||
it('can render itself', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
editor.render();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXModuleEditorHtml,
|
||||
resources: []
|
||||
});
|
||||
@@ -77,9 +77,9 @@ define([ "jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helper
|
||||
});
|
||||
|
||||
it('saves any custom metadata', function() {
|
||||
var requests = create_sinon.requests(this), request, response;
|
||||
var requests = AjaxHelpers.requests(this), request, response;
|
||||
editor.render();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXModuleEditorHtml,
|
||||
resources: []
|
||||
});
|
||||
@@ -93,11 +93,11 @@ define([ "jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helper
|
||||
});
|
||||
|
||||
it('can render a module with only settings', function() {
|
||||
var requests = create_sinon.requests(this), mockXModuleEditorHtml;
|
||||
var requests = AjaxHelpers.requests(this), mockXModuleEditorHtml;
|
||||
mockXModuleEditorHtml = readFixtures('mock/mock-xmodule-settings-only-editor.underscore');
|
||||
|
||||
editor.render();
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockXModuleEditorHtml,
|
||||
resources: []
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js/models/xblock_info",
|
||||
define([ "jquery", "js/common_helpers/ajax_helpers", "URI", "js/views/xblock", "js/models/xblock_info",
|
||||
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
function ($, create_sinon, URI, XBlockView, XBlockInfo) {
|
||||
function ($, AjaxHelpers, URI, XBlockView, XBlockInfo) {
|
||||
|
||||
describe("XBlockView", function() {
|
||||
var model, xblockView, mockXBlockHtml, respondWithMockXBlockFragment;
|
||||
@@ -20,11 +20,11 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js
|
||||
|
||||
respondWithMockXBlockFragment = function(requests, response) {
|
||||
var requestIndex = requests.length - 1;
|
||||
create_sinon.respondWithJson(requests, response, requestIndex);
|
||||
AjaxHelpers.respondWithJson(requests, response, requestIndex);
|
||||
};
|
||||
|
||||
it('can render a nested xblock', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
xblockView.render();
|
||||
respondWithMockXBlockFragment(requests, {
|
||||
html: mockXBlockHtml,
|
||||
@@ -57,12 +57,12 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js
|
||||
};
|
||||
|
||||
it('can render an xblock with no CSS or JavaScript', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
postXBlockRequest(requests, []);
|
||||
});
|
||||
|
||||
it('can render an xblock with required CSS', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
mockCssText = "// Just a comment",
|
||||
mockCssUrl = "mock.css",
|
||||
headHtml;
|
||||
@@ -76,7 +76,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js
|
||||
});
|
||||
|
||||
it('can render an xblock with required JavaScript', function() {
|
||||
var requests = create_sinon.requests(this);
|
||||
var requests = AjaxHelpers.requests(this);
|
||||
postXBlockRequest(requests, [
|
||||
["hash3", { mimetype: "application/javascript", kind: "text", data: "window.test = 100;" }]
|
||||
]);
|
||||
@@ -84,7 +84,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js
|
||||
});
|
||||
|
||||
it('can render an xblock with required HTML', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
mockHeadTag = "<title>Test Title</title>";
|
||||
postXBlockRequest(requests, [
|
||||
["hash4", { mimetype: "text/html", placement: "head", data: mockHeadTag }]
|
||||
@@ -93,7 +93,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js
|
||||
});
|
||||
|
||||
it('aborts rendering when a dependent script fails to load', function() {
|
||||
var requests = create_sinon.requests(this),
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
mockJavaScriptUrl = "mock.js",
|
||||
promise;
|
||||
spyOn($, 'getScript').andReturn($.Deferred().reject().promise());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers", "js/spec_helpers/edit_helpers", "js/models/xblock_info", "js/views/xblock_string_field_editor"],
|
||||
function ($, create_sinon, view_helpers, edit_helpers, XBlockInfo, XBlockStringFieldEditor) {
|
||||
define(["jquery", "js/common_helpers/ajax_helpers", "js/common_helpers/template_helpers",
|
||||
"js/spec_helpers/edit_helpers", "js/models/xblock_info", "js/views/xblock_string_field_editor"],
|
||||
function ($, AjaxHelpers, TemplateHelpers, EditHelpers, XBlockInfo, XBlockStringFieldEditor) {
|
||||
describe("XBlockStringFieldEditorView", function () {
|
||||
var initialDisplayName, updatedDisplayName, getXBlockInfo, getFieldEditorView;
|
||||
|
||||
@@ -26,11 +27,13 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
beforeEach(function () {
|
||||
initialDisplayName = "Default Display Name";
|
||||
updatedDisplayName = "Updated Display Name";
|
||||
view_helpers.installTemplate('xblock-string-field-editor');
|
||||
TemplateHelpers.installTemplate('xblock-string-field-editor');
|
||||
appendSetFixtures(
|
||||
'<div class="wrapper-xblock-field incontext-editor is-editable"' +
|
||||
'data-field="display_name" data-field-display-name="Display Name">' +
|
||||
'<h1 class="page-header-title xblock-field-value incontext-editor-value"><span class="title-value">' + initialDisplayName + '</span></h1>' +
|
||||
'<h1 class="page-header-title xblock-field-value incontext-editor-value">' +
|
||||
'<span class="title-value">' + initialDisplayName + '</span>' +
|
||||
'</h1>' +
|
||||
'</div>'
|
||||
);
|
||||
});
|
||||
@@ -39,7 +42,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
var expectPostedNewDisplayName, expectEditCanceled;
|
||||
|
||||
expectPostedNewDisplayName = function (requests, displayName) {
|
||||
create_sinon.expectJsonRequest(requests, 'POST', '/xblock/my_xblock', {
|
||||
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/my_xblock', {
|
||||
metadata: {
|
||||
display_name: displayName
|
||||
}
|
||||
@@ -48,9 +51,9 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
|
||||
expectEditCanceled = function (test, fieldEditorView, options) {
|
||||
var requests, initialRequests, displayNameInput;
|
||||
requests = create_sinon.requests(test);
|
||||
requests = AjaxHelpers.requests(test);
|
||||
initialRequests = requests.length;
|
||||
displayNameInput = edit_helpers.inlineEdit(fieldEditorView.$el, options.newTitle);
|
||||
displayNameInput = EditHelpers.inlineEdit(fieldEditorView.$el, options.newTitle);
|
||||
if (options.pressEscape) {
|
||||
displayNameInput.simulate("keydown", { keyCode: $.simulate.keyCode.ESCAPE });
|
||||
displayNameInput.simulate("keyup", { keyCode: $.simulate.keyCode.ESCAPE });
|
||||
@@ -61,51 +64,51 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
|
||||
}
|
||||
// No requests should be made when the edit is cancelled client-side
|
||||
expect(initialRequests).toBe(requests.length);
|
||||
edit_helpers.verifyInlineEditChange(fieldEditorView.$el, initialDisplayName);
|
||||
EditHelpers.verifyInlineEditChange(fieldEditorView.$el, initialDisplayName);
|
||||
expect(fieldEditorView.model.get('display_name')).toBe(initialDisplayName);
|
||||
};
|
||||
|
||||
it('can inline edit the display name', function () {
|
||||
var requests, fieldEditorView;
|
||||
requests = create_sinon.requests(this);
|
||||
requests = AjaxHelpers.requests(this);
|
||||
fieldEditorView = getFieldEditorView().render();
|
||||
edit_helpers.inlineEdit(fieldEditorView.$el, updatedDisplayName);
|
||||
EditHelpers.inlineEdit(fieldEditorView.$el, updatedDisplayName);
|
||||
fieldEditorView.$('button[name=submit]').click();
|
||||
expectPostedNewDisplayName(requests, updatedDisplayName);
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, { });
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
// This is the response for the subsequent fetch operation.
|
||||
create_sinon.respondWithJson(requests, {display_name: updatedDisplayName});
|
||||
edit_helpers.verifyInlineEditChange(fieldEditorView.$el, updatedDisplayName);
|
||||
AjaxHelpers.respondWithJson(requests, {display_name: updatedDisplayName});
|
||||
EditHelpers.verifyInlineEditChange(fieldEditorView.$el, updatedDisplayName);
|
||||
});
|
||||
|
||||
it('does not change the title when a display name update fails', function () {
|
||||
var requests, fieldEditorView, initialRequests;
|
||||
requests = create_sinon.requests(this);
|
||||
requests = AjaxHelpers.requests(this);
|
||||
initialRequests = requests.length;
|
||||
fieldEditorView = getFieldEditorView().render();
|
||||
edit_helpers.inlineEdit(fieldEditorView.$el, updatedDisplayName);
|
||||
EditHelpers.inlineEdit(fieldEditorView.$el, updatedDisplayName);
|
||||
fieldEditorView.$('button[name=submit]').click();
|
||||
expectPostedNewDisplayName(requests, updatedDisplayName);
|
||||
create_sinon.respondWithError(requests);
|
||||
AjaxHelpers.respondWithError(requests);
|
||||
// No fetch operation should occur.
|
||||
expect(initialRequests + 1).toBe(requests.length);
|
||||
edit_helpers.verifyInlineEditChange(fieldEditorView.$el, initialDisplayName, updatedDisplayName);
|
||||
EditHelpers.verifyInlineEditChange(fieldEditorView.$el, initialDisplayName, updatedDisplayName);
|
||||
});
|
||||
|
||||
it('trims whitespace from the display name', function () {
|
||||
var requests, fieldEditorView;
|
||||
requests = create_sinon.requests(this);
|
||||
requests = AjaxHelpers.requests(this);
|
||||
fieldEditorView = getFieldEditorView().render();
|
||||
updatedDisplayName += ' ';
|
||||
edit_helpers.inlineEdit(fieldEditorView.$el, updatedDisplayName);
|
||||
EditHelpers.inlineEdit(fieldEditorView.$el, updatedDisplayName);
|
||||
fieldEditorView.$('button[name=submit]').click();
|
||||
expectPostedNewDisplayName(requests, updatedDisplayName.trim());
|
||||
// This is the response for the change operation.
|
||||
create_sinon.respondWithJson(requests, { });
|
||||
AjaxHelpers.respondWithJson(requests, { });
|
||||
// This is the response for the subsequent fetch operation.
|
||||
create_sinon.respondWithJson(requests, {display_name: updatedDisplayName.trim()});
|
||||
edit_helpers.verifyInlineEditChange(fieldEditorView.$el, updatedDisplayName.trim());
|
||||
AjaxHelpers.respondWithJson(requests, {display_name: updatedDisplayName.trim()});
|
||||
EditHelpers.verifyInlineEditChange(fieldEditorView.$el, updatedDisplayName.trim());
|
||||
});
|
||||
|
||||
it('does not change the title when input is the empty string', function () {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cms.runtime.v1"],
|
||||
function (edit_helpers, BaseModal) {
|
||||
function (EditHelpers, BaseModal) {
|
||||
|
||||
describe("Studio Runtime v1", function() {
|
||||
var runtime;
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installEditTemplates();
|
||||
EditHelpers.installEditTemplates();
|
||||
runtime = new window.StudioRuntime.v1();
|
||||
});
|
||||
|
||||
@@ -21,27 +21,27 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm
|
||||
|
||||
it('shows save notifications', function() {
|
||||
var title = "Mock saving...",
|
||||
notificationSpy = edit_helpers.createNotificationSpy();
|
||||
notificationSpy = EditHelpers.createNotificationSpy();
|
||||
runtime.notify('save', {
|
||||
state: 'start',
|
||||
message: title
|
||||
});
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, title);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, title);
|
||||
runtime.notify('save', {
|
||||
state: 'end'
|
||||
});
|
||||
edit_helpers.verifyNotificationHidden(notificationSpy);
|
||||
EditHelpers.verifyNotificationHidden(notificationSpy);
|
||||
});
|
||||
|
||||
it('shows error messages', function() {
|
||||
var title = "Mock Error",
|
||||
message = "This is a mock error.",
|
||||
notificationSpy = edit_helpers.createNotificationSpy("Error");
|
||||
notificationSpy = EditHelpers.createNotificationSpy("Error");
|
||||
runtime.notify('error', {
|
||||
title: title,
|
||||
message: message
|
||||
});
|
||||
edit_helpers.verifyNotificationShowing(notificationSpy, title);
|
||||
EditHelpers.verifyNotificationShowing(notificationSpy, title);
|
||||
});
|
||||
|
||||
describe("Modal Dialogs", function() {
|
||||
@@ -61,19 +61,19 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
edit_helpers.installEditTemplates();
|
||||
EditHelpers.installEditTemplates();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
edit_helpers.hideModalIfShowing(modal);
|
||||
EditHelpers.hideModalIfShowing(modal);
|
||||
});
|
||||
|
||||
it('cancels a modal dialog', function () {
|
||||
showMockModal();
|
||||
runtime.notify('modal-shown', modal);
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeTruthy();
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
|
||||
runtime.notify('cancel');
|
||||
expect(edit_helpers.isShowingModal(modal)).toBeFalsy();
|
||||
expect(EditHelpers.isShowingModal(modal)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
define(["sinon", "underscore"], function(sinon, _) {
|
||||
var fakeServer, fakeRequests, expectJsonRequest, respondWithJson, respondWithError, respondToDelete;
|
||||
|
||||
/* These utility methods are used by Jasmine tests to create a mock server or
|
||||
* get reference to mock requests. In either case, the cleanup (restore) is done with
|
||||
* an after function.
|
||||
*
|
||||
* This pattern is being used instead of the more common beforeEach/afterEach pattern
|
||||
* because we were seeing sporadic failures in the afterEach restore call. The cause of the
|
||||
* errors were that one test suite was incorrectly being linked as the parent of an unrelated
|
||||
* test suite (causing both suites' afterEach methods to be called). No solution for the root
|
||||
* cause has been found, but initializing sinon and cleaning it up on a method-by-method
|
||||
* basis seems to work. For more details, see STUD-1264.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a reference to the mocked server, and respond
|
||||
* to all requests with the specified statusCode.
|
||||
*/
|
||||
fakeServer = function (statusCode, that) {
|
||||
var server = sinon.fakeServer.create();
|
||||
that.after(function() {
|
||||
server.restore();
|
||||
});
|
||||
server.respondWith([statusCode, {}, '']);
|
||||
return server;
|
||||
};
|
||||
|
||||
/**
|
||||
* Keep track of all requests to a fake server, and
|
||||
* return a reference to the Array. This allows tests
|
||||
* to respond for individual requests.
|
||||
*/
|
||||
fakeRequests = function (that) {
|
||||
var requests = [],
|
||||
xhr = sinon.useFakeXMLHttpRequest();
|
||||
xhr.onCreate = function(request) {
|
||||
requests.push(request);
|
||||
};
|
||||
|
||||
that.after(function() {
|
||||
xhr.restore();
|
||||
});
|
||||
|
||||
return requests;
|
||||
};
|
||||
|
||||
expectJsonRequest = function(requests, method, url, jsonRequest, requestIndex) {
|
||||
var request;
|
||||
if (_.isUndefined(requestIndex)) {
|
||||
requestIndex = requests.length - 1;
|
||||
}
|
||||
request = requests[requestIndex];
|
||||
expect(request.url).toEqual(url);
|
||||
expect(request.method).toEqual(method);
|
||||
expect(JSON.parse(request.requestBody)).toEqual(jsonRequest);
|
||||
};
|
||||
|
||||
respondWithJson = function(requests, jsonResponse, requestIndex) {
|
||||
if (_.isUndefined(requestIndex)) {
|
||||
requestIndex = requests.length - 1;
|
||||
}
|
||||
requests[requestIndex].respond(200,
|
||||
{ "Content-Type": "application/json" },
|
||||
JSON.stringify(jsonResponse));
|
||||
};
|
||||
|
||||
respondWithError = function(requests, requestIndex) {
|
||||
if (_.isUndefined(requestIndex)) {
|
||||
requestIndex = requests.length - 1;
|
||||
}
|
||||
requests[requestIndex].respond(500,
|
||||
{ "Content-Type": "application/json" },
|
||||
JSON.stringify({ }));
|
||||
};
|
||||
|
||||
respondToDelete = function(requests, requestIndex) {
|
||||
if (_.isUndefined(requestIndex)) {
|
||||
requestIndex = requests.length - 1;
|
||||
}
|
||||
requests[requestIndex].respond(204,
|
||||
{ "Content-Type": "application/json" });
|
||||
};
|
||||
|
||||
return {
|
||||
"server": fakeServer,
|
||||
"requests": fakeRequests,
|
||||
"expectJsonRequest": expectJsonRequest,
|
||||
"respondWithJson": respondWithJson,
|
||||
"respondWithError": respondWithError,
|
||||
"respondToDelete": respondToDelete
|
||||
};
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Provides helper methods for invoking Studio editors in Jasmine tests.
|
||||
*/
|
||||
define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers",
|
||||
"js/views/modals/edit_xblock", "js/collections/component_template",
|
||||
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
function($, _, create_sinon, modal_helpers, EditXBlockModal, ComponentTemplates) {
|
||||
define(["jquery", "underscore", "js/common_helpers/ajax_helpers", "js/common_helpers/template_helpers",
|
||||
"js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock", "js/collections/component_template",
|
||||
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
|
||||
function($, _, AjaxHelpers, TemplateHelpers, modal_helpers, EditXBlockModal, ComponentTemplates) {
|
||||
|
||||
var installMockXBlock, uninstallMockXBlock, installMockXModule, uninstallMockXModule,
|
||||
mockComponentTemplates, installEditTemplates, showEditModal, verifyXBlockRequest;
|
||||
@@ -72,25 +72,25 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
|
||||
modal_helpers.installModalTemplates(append);
|
||||
|
||||
// Add templates needed by the add XBlock menu
|
||||
modal_helpers.installTemplate('add-xblock-component');
|
||||
modal_helpers.installTemplate('add-xblock-component-button');
|
||||
modal_helpers.installTemplate('add-xblock-component-menu');
|
||||
modal_helpers.installTemplate('add-xblock-component-menu-problem');
|
||||
TemplateHelpers.installTemplate('add-xblock-component');
|
||||
TemplateHelpers.installTemplate('add-xblock-component-button');
|
||||
TemplateHelpers.installTemplate('add-xblock-component-menu');
|
||||
TemplateHelpers.installTemplate('add-xblock-component-menu-problem');
|
||||
|
||||
// Add templates needed by the edit XBlock modal
|
||||
modal_helpers.installTemplate('edit-xblock-modal');
|
||||
modal_helpers.installTemplate('editor-mode-button');
|
||||
TemplateHelpers.installTemplate('edit-xblock-modal');
|
||||
TemplateHelpers.installTemplate('editor-mode-button');
|
||||
|
||||
// Add templates needed by the settings editor
|
||||
modal_helpers.installTemplate('metadata-editor');
|
||||
modal_helpers.installTemplate('metadata-number-entry', false, 'metadata-number-entry');
|
||||
modal_helpers.installTemplate('metadata-string-entry', false, 'metadata-string-entry');
|
||||
TemplateHelpers.installTemplate('metadata-editor');
|
||||
TemplateHelpers.installTemplate('metadata-number-entry', false, 'metadata-number-entry');
|
||||
TemplateHelpers.installTemplate('metadata-string-entry', false, 'metadata-string-entry');
|
||||
};
|
||||
|
||||
showEditModal = function(requests, xblockElement, model, mockHtml, options) {
|
||||
var modal = new EditXBlockModal({});
|
||||
modal.edit(xblockElement, model, options);
|
||||
create_sinon.respondWithJson(requests, {
|
||||
AjaxHelpers.respondWithJson(requests, {
|
||||
html: mockHtml,
|
||||
"resources": []
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/**
|
||||
* Provides helper methods for invoking Studio modal windows in Jasmine tests.
|
||||
*/
|
||||
define(["jquery", "js/spec_helpers/view_helpers"],
|
||||
function($, view_helpers) {
|
||||
define(["jquery", "js/common_helpers/template_helpers", "js/spec_helpers/view_helpers"],
|
||||
function($, TemplateHelpers, ViewHelpers) {
|
||||
var installModalTemplates, getModalElement, getModalTitle, isShowingModal, hideModalIfShowing,
|
||||
pressModalButton, cancelModal, cancelModalIfShowing;
|
||||
|
||||
installModalTemplates = function(append) {
|
||||
view_helpers.installViewTemplates(append);
|
||||
view_helpers.installTemplate('basic-modal');
|
||||
view_helpers.installTemplate('modal-button');
|
||||
ViewHelpers.installViewTemplates(append);
|
||||
TemplateHelpers.installTemplate('basic-modal');
|
||||
TemplateHelpers.installTemplate('modal-button');
|
||||
};
|
||||
|
||||
getModalElement = function(modal) {
|
||||
@@ -56,7 +56,7 @@ define(["jquery", "js/spec_helpers/view_helpers"],
|
||||
}
|
||||
};
|
||||
|
||||
return $.extend(view_helpers, {
|
||||
return $.extend(ViewHelpers, {
|
||||
'getModalElement': getModalElement,
|
||||
'getModalTitle': getModalTitle,
|
||||
'installModalTemplates': installModalTemplates,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* Provides helper methods for invoking Validation modal in Jasmine tests.
|
||||
*/
|
||||
define(['jquery', 'js/spec_helpers/modal_helpers', 'js/spec_helpers/view_helpers'],
|
||||
function($, modal_helpers, view_helpers) {
|
||||
define(['jquery', 'js/spec_helpers/modal_helpers', 'js/common_helpers/template_helpers'],
|
||||
function($, ModalHelpers, TemplateHelpers) {
|
||||
var installValidationTemplates, checkErrorContents, undoChanges;
|
||||
|
||||
installValidationTemplates = function () {
|
||||
modal_helpers.installModalTemplates();
|
||||
view_helpers.installTemplate('validation-error-modal');
|
||||
ModalHelpers.installModalTemplates();
|
||||
TemplateHelpers.installTemplate('validation-error-modal');
|
||||
};
|
||||
|
||||
checkErrorContents = function(validationModal, errorObjects) {
|
||||
@@ -23,10 +23,10 @@ define(['jquery', 'js/spec_helpers/modal_helpers', 'js/spec_helpers/view_helpers
|
||||
};
|
||||
|
||||
undoChanges = function(validationModal) {
|
||||
modal_helpers.pressModalButton('.action-undo', validationModal);
|
||||
ModalHelpers.pressModalButton('.action-undo', validationModal);
|
||||
};
|
||||
|
||||
return $.extend(modal_helpers, {
|
||||
return $.extend(ModalHelpers, {
|
||||
'installValidationTemplates': installValidationTemplates,
|
||||
'checkErrorContents': checkErrorContents,
|
||||
'undoChanges': undoChanges,
|
||||
|
||||
@@ -1,41 +1,15 @@
|
||||
/**
|
||||
* Provides helper methods for invoking Studio modal windows in Jasmine tests.
|
||||
*/
|
||||
define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt"],
|
||||
function($, NotificationView, Prompt) {
|
||||
var installTemplate, installTemplates, installViewTemplates, createFeedbackSpy, verifyFeedbackShowing,
|
||||
define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt", "js/common_helpers/template_helpers"],
|
||||
function($, NotificationView, Prompt, TemplateHelpers) {
|
||||
var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing,
|
||||
verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing,
|
||||
verifyNotificationHidden, createPromptSpy, confirmPrompt, inlineEdit, verifyInlineEditChange,
|
||||
installMockAnalytics, removeMockAnalytics, verifyPromptShowing, verifyPromptHidden;
|
||||
|
||||
installTemplate = function(templateName, isFirst, templateId) {
|
||||
var template = readFixtures(templateName + '.underscore');
|
||||
if (!templateId) {
|
||||
templateId = templateName + '-tpl';
|
||||
}
|
||||
|
||||
if (isFirst) {
|
||||
setFixtures($('<script>', { id: templateId, type: 'text/template' }).text(template));
|
||||
} else {
|
||||
appendSetFixtures($('<script>', { id: templateId, type: 'text/template' }).text(template));
|
||||
}
|
||||
};
|
||||
|
||||
installTemplates = function(templateNames, isFirst) {
|
||||
if (!$.isArray(templateNames)) {
|
||||
templateNames = [templateNames];
|
||||
}
|
||||
|
||||
$.each(templateNames, function(index, templateName) {
|
||||
installTemplate(templateName, isFirst);
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
installViewTemplates = function(append) {
|
||||
installTemplate('system-feedback', !append);
|
||||
TemplateHelpers.installTemplate('system-feedback', !append);
|
||||
appendSetFixtures('<div id="page-notification"></div>');
|
||||
};
|
||||
|
||||
@@ -69,11 +43,11 @@ define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt"],
|
||||
verifyNotificationHidden = function(notificationSpy) {
|
||||
verifyFeedbackHidden.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
createPromptSpy = function(type) {
|
||||
return createFeedbackSpy(Prompt, type || 'Warning');
|
||||
};
|
||||
|
||||
|
||||
confirmPrompt = function(promptSpy, pressSecondaryButton) {
|
||||
expect(promptSpy.constructor).toHaveBeenCalled();
|
||||
if (pressSecondaryButton) {
|
||||
@@ -90,7 +64,7 @@ define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt"],
|
||||
verifyPromptHidden = function(promptSpy) {
|
||||
verifyFeedbackHidden.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
installMockAnalytics = function() {
|
||||
window.analytics = jasmine.createSpyObj('analytics', ['track']);
|
||||
window.course_location_analytics = jasmine.createSpy();
|
||||
@@ -121,8 +95,6 @@ define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt"],
|
||||
};
|
||||
|
||||
return {
|
||||
'installTemplate': installTemplate,
|
||||
'installTemplates': installTemplates,
|
||||
'installViewTemplates': installViewTemplates,
|
||||
'createNotificationSpy': createNotificationSpy,
|
||||
'verifyNotificationShowing': verifyNotificationShowing,
|
||||
|
||||
@@ -67,6 +67,7 @@ lib_paths:
|
||||
src_paths:
|
||||
- coffee/src
|
||||
- js
|
||||
- js/common_helpers
|
||||
|
||||
# Paths to spec (test) JavaScript files
|
||||
spec_paths:
|
||||
|
||||
@@ -62,11 +62,13 @@ lib_paths:
|
||||
src_paths:
|
||||
- coffee/src
|
||||
- js
|
||||
- js/common_helpers
|
||||
|
||||
# Paths to spec (test) JavaScript files
|
||||
spec_paths:
|
||||
- coffee/spec/main.js
|
||||
- coffee/spec
|
||||
- js/spec
|
||||
|
||||
# Paths to fixture files (optional)
|
||||
# The fixture path will be set automatically when using jasmine-jquery.
|
||||
|
||||
Reference in New Issue
Block a user