Commit 5fe397f8 by alisan617

change Instructor Dashboard coffeeScript bundle path and move fixtures to JS folder, plus eslint

parent 7b9c566f
......@@ -1319,10 +1319,7 @@ discussion_vendor_js = [
]
notes_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/notes/**/*.js'))
instructor_dash_js = (
sorted(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/instructor_dashboard/**/*.js')) +
sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/instructor_dashboard/**/*.js'))
)
instructor_dash_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/instructor_dashboard/**/*.js'))
verify_student_js = [
'js/sticky_filter.js',
......
describe 'AutoEnrollment', ->
beforeEach ->
loadFixtures 'coffee/fixtures/autoenrollment.html'
@autoenrollment = new AutoEnrollmentViaCsv $('.auto_enroll_csv')
it 'binds the ajax call and the result will be success', ->
spyOn($, "ajax").and.callFake((params) =>
params.success({row_errors: [], general_errors: [], warnings: []})
{always: ->}
)
# mock the render_notification_view which returns the html (since we are only using the existing notification model)
@autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").and.callFake =>
return '<div><div class="message message-confirmation"><h3 class="message-title">Success</h3><div class="message-copy"><p>All accounts were created successfully.</p></div></div><div>'
submitCallback = jasmine.createSpy().and.returnValue()
@autoenrollment.$student_enrollment_form.submit(submitCallback)
@autoenrollment.$enrollment_signup_button.click()
expect($('.results .message-copy').text()).toEqual('All accounts were created successfully.')
expect(submitCallback).toHaveBeenCalled()
it 'binds the ajax call and the result will be error', ->
spyOn($, "ajax").and.callFake((params) =>
params.success({
row_errors: [{
'username': 'testuser1',
'email': 'testemail1@email.com',
'response': 'Username already exists'
}],
general_errors: [{
'response': 'cannot read the line 2'
}],
warnings: []
})
{always: ->}
)
# mock the render_notification_view which returns the html (since we are only using the existing notification model)
@autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").and.callFake =>
return '<div><div class="message message-error"><h3 class="message-title">Errors</h3><div class="message-copy"><p>The following errors were generated:</p><ul class="list-summary summary-items"><li class="summary-item">cannot read the line 2</li><li class="summary-item">testuser1 (testemail1@email.com): (Username already exists)</li></ul></div></div></div>'
submitCallback = jasmine.createSpy().and.returnValue()
@autoenrollment.$student_enrollment_form.submit(submitCallback)
@autoenrollment.$enrollment_signup_button.click()
expect($('.results .list-summary').text()).toEqual('cannot read the line 2testuser1 (testemail1@email.com): (Username already exists)');
expect(submitCallback).toHaveBeenCalled()
it 'binds the ajax call and the result will be warnings', ->
spyOn($, "ajax").and.callFake((params) =>
params.success({
row_errors: [],
general_errors: [],
warnings: [{
'username': 'user1',
'email': 'user1email',
'response': 'email is in valid'
}]
})
{always: ->}
)
# mock the render_notification_view which returns the html (since we are only using the existing notification model)
@autoenrollment.render_notification_view = jasmine.createSpy("render_notification_view(type, title, message, details) spy").and.callFake =>
return '<div><div class="message message-warning"><h3 class="message-title">Warnings</h3><div class="message-copy"><p>The following warnings were generated:</p><ul class="list-summary summary-items"><li class="summary-item">user1 (user1email): (email is in valid)</li></ul></div></div></div>'
submitCallback = jasmine.createSpy().and.returnValue()
@autoenrollment.$student_enrollment_form.submit(submitCallback)
@autoenrollment.$enrollment_signup_button.click()
expect($('.results .list-summary').text()).toEqual('user1 (user1email): (email is in valid)')
expect(submitCallback).toHaveBeenCalled()
\ No newline at end of file
describe "Bulk Email Queueing", ->
beforeEach ->
testSubject = "Test Subject"
testBody = "Hello, World! This is a test email message!"
loadFixtures 'coffee/fixtures/send_email.html'
@send_email = new SendEmail $('.send-email')
@send_email.$subject.val(testSubject)
@send_email.$send_to.first().prop("checked", true)
@send_email.$emailEditor =
save: ->
{"data": testBody}
@ajax_params = {
type: "POST",
dataType: "json",
url: undefined,
data: {
action: "send",
send_to: JSON.stringify([@send_email.$send_to.first().val()]),
subject: testSubject,
message: testBody,
},
success: jasmine.any(Function),
error: jasmine.any(Function),
}
it 'cannot send an email with no target', ->
spyOn(window, "alert")
spyOn($, "ajax")
for target in @send_email.$send_to
target.checked = false
@send_email.$btn_send.click()
expect(window.alert).toHaveBeenCalledWith("Your message must have at least one target.")
expect($.ajax).not.toHaveBeenCalled()
it 'cannot send an email with no subject', ->
spyOn(window, "alert")
spyOn($, "ajax")
@send_email.$subject.val("")
@send_email.$btn_send.click()
expect(window.alert).toHaveBeenCalledWith("Your message must have a subject.")
expect($.ajax).not.toHaveBeenCalled()
it 'cannot send an email with no message', ->
spyOn(window, "alert")
spyOn($, "ajax")
@send_email.$emailEditor =
save: ->
{"data": ""}
@send_email.$btn_send.click()
expect(window.alert).toHaveBeenCalledWith("Your message cannot be blank.")
expect($.ajax).not.toHaveBeenCalled()
it 'can send a simple message to a single target', ->
spyOn($, "ajax").and.callFake((params) =>
params.success()
)
@send_email.$btn_send.click()
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.')
expect($.ajax).toHaveBeenCalledWith(@ajax_params)
it 'can send a simple message to a multiple targets', ->
spyOn($, "ajax").and.callFake((params) =>
params.success()
)
@ajax_params.data.send_to = JSON.stringify(target.value for target in @send_email.$send_to)
for target in @send_email.$send_to
target.checked = true
@send_email.$btn_send.click()
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.')
expect($.ajax).toHaveBeenCalledWith(@ajax_params)
it 'can handle an error result from the bulk email api', ->
spyOn($, "ajax").and.callFake((params) =>
params.error()
)
spyOn(console, "warn")
@send_email.$btn_send.click()
expect($('.request-response-error').text()).toEqual('Error sending email.')
expect(console.warn).toHaveBeenCalled()
it 'selecting all learners disables cohort selections', ->
@send_email.$send_to.filter("[value='learners']").click
@send_email.$cohort_targets.each ->
expect(this.disabled).toBe(true)
@send_email.$send_to.filter("[value='learners']").click
@send_email.$cohort_targets.each ->
expect(this.disabled).toBe(false)
it 'selected targets are listed after "send to:"', ->
@send_email.$send_to.click
$('input[name="send_to"]:checked+label').each ->
expect($('.send_to_list'.text())).toContain(this.innerText.replace(/\s*\n.*/g,''))
###
Course Info Section
imports from other modules.
wrap in (-> ... apply) to defer evaluation
such that the value can be defined later than this assignment (file load order).
###
# Load utilities
PendingInstructorTasks = -> window.InstructorDashboard.util.PendingInstructorTasks
# A typical section object.
# constructed with $section, a jquery object
# which holds the section body container.
class CourseInfo
constructor: (@$section) ->
# attach self to html so that instructor_dashboard.coffee can find
# this object to call event handlers like 'onClickTitle'
@$section.data 'wrapper', @
# gather elements
@instructor_tasks = new (PendingInstructorTasks()) @$section
@$course_errors_wrapper = @$section.find '.course-errors-wrapper'
# if there are errors
if @$course_errors_wrapper.length
@$course_error_toggle = @$course_errors_wrapper.find '.toggle-wrapper'
@$course_error_toggle_text = @$course_error_toggle.find 'h2'
@$course_error_visibility_wrapper = @$course_errors_wrapper.find '.course-errors-visibility-wrapper'
@$course_errors = @$course_errors_wrapper.find '.course-error'
# append "(34)" to the course errors label
@$course_error_toggle_text.text @$course_error_toggle_text.text() + " (#{@$course_errors.length})"
# toggle .open class on errors
# to show and hide them.
@$course_error_toggle.click (e) =>
e.preventDefault()
if @$course_errors_wrapper.hasClass 'open'
@$course_errors_wrapper.removeClass 'open'
else
@$course_errors_wrapper.addClass 'open'
# handler for when the section title is clicked.
onClickTitle: -> @instructor_tasks.task_poller.start()
# handler for when the section is closed
onExit: -> @instructor_tasks.task_poller.stop()
# export for use
# create parent namespaces if they do not already exist.
_.defaults window, InstructorDashboard: {}
_.defaults window.InstructorDashboard, sections: {}
_.defaults window.InstructorDashboard.sections,
CourseInfo: CourseInfo
(function() {
'use strict';
var InstructorDashboardCourseInfo, PendingInstructorTasks;
PendingInstructorTasks = function() {
return window.InstructorDashboard.util.PendingInstructorTasks;
};
InstructorDashboardCourseInfo = (function() {
function CourseInfo($section) {
var courseInfo = this;
this.$section = $section;
this.$section.data('wrapper', this);
this.instructor_tasks = new (PendingInstructorTasks())(this.$section);
this.$course_errors_wrapper = this.$section.find('.course-errors-wrapper');
if (this.$course_errors_wrapper.length) {
this.$course_error_toggle = this.$course_errors_wrapper.find('.toggle-wrapper');
this.$course_error_toggle_text = this.$course_error_toggle.find('h2');
this.$course_errors = this.$course_errors_wrapper.find('.course-error');
this.$course_error_toggle_text.text(
this.$course_error_toggle_text.text() + (" (' + this.$course_errors.length + ')")
);
this.$course_error_toggle.click(function(e) {
e.preventDefault();
if (courseInfo.$course_errors_wrapper.hasClass('open')) {
return courseInfo.$course_errors_wrapper.removeClass('open');
} else {
return courseInfo.$course_errors_wrapper.addClass('open');
}
});
}
}
CourseInfo.prototype.onClickTitle = function() {
return this.instructor_tasks.task_poller.start();
};
CourseInfo.prototype.onExit = function() {
return this.instructor_tasks.task_poller.stop();
};
return CourseInfo;
}());
window.InstructorDashboard.sections.CourseInfo = InstructorDashboardCourseInfo;
}).call(this);
###
E-Commerce Section
###
/* globals _ */
# Load utilities
PendingInstructorTasks = -> window.InstructorDashboard.util.PendingInstructorTasks
ReportDownloads = -> window.InstructorDashboard.util.ReportDownloads
(function() {
'use strict';
var ECommerce, PendingInstructorTasks, ReportDownloads;
class ECommerce
# E-Commerce Section
constructor: (@$section) ->
# attach self to html so that instructor_dashboard.coffee can find
# this object to call event handlers like 'onClickTitle'
@$section.data 'wrapper', @
# gather elements
@$list_sale_csv_btn = @$section.find("input[name='list-sale-csv']")
@$list_order_sale_csv_btn = @$section.find("input[name='list-order-sale-csv']")
@$download_company_name = @$section.find("input[name='download_company_name']")
@$active_company_name = @$section.find("input[name='active_company_name']")
@$spent_company_name = @$section.find('input[name="spent_company_name"]')
@$download_coupon_codes = @$section.find('input[name="download-coupon-codes-csv"]')
@$download_registration_codes_form = @$section.find("form#download_registration_codes")
@$active_registration_codes_form = @$section.find("form#active_registration_codes")
@$spent_registration_codes_form = @$section.find("form#spent_registration_codes")
PendingInstructorTasks = function() {
return window.InstructorDashboard.util.PendingInstructorTasks;
};
@$reports = @$section.find '.reports-download-container'
@$reports_request_response = @$reports.find '.request-response'
@$reports_request_response_error = @$reports.find '.request-response-error'
ReportDownloads = function() {
return window.InstructorDashboard.util.ReportDownloads;
};
@report_downloads = new (ReportDownloads()) @$section
@instructor_tasks = new (PendingInstructorTasks()) @$section
ECommerce = (function() {
function eCommerce($section) {
var eCom = this;
this.$section = $section;
this.$section.data('wrapper', this);
this.$list_sale_csv_btn = this.$section.find("input[name='list-sale-csv']");
this.$list_order_sale_csv_btn = this.$section.find("input[name='list-order-sale-csv']");
this.$download_company_name = this.$section.find("input[name='download_company_name']");
this.$active_company_name = this.$section.find("input[name='active_company_name']");
this.$spent_company_name = this.$section.find('input[name="spent_company_name"]');
this.$download_coupon_codes = this.$section.find('input[name="download-coupon-codes-csv"]');
this.$download_registration_codes_form = this.$section.find('form#download_registration_codes');
this.$active_registration_codes_form = this.$section.find('form#active_registration_codes');
this.$spent_registration_codes_form = this.$section.find('form#spent_registration_codes');
this.$reports = this.$section.find('.reports-download-container');
this.$reports_request_response = this.$reports.find('.request-response');
this.$reports_request_response_error = this.$reports.find('.request-response-error');
this.report_downloads = new (ReportDownloads())(this.$section);
this.instructor_tasks = new (PendingInstructorTasks())(this.$section);
this.$error_msg = this.$section.find('#error-msg');
this.$list_sale_csv_btn.click(function() {
location.href = eCom.$list_sale_csv_btn.data('endpoint') + '/csv';
return location.href;
});
this.$list_order_sale_csv_btn.click(function() {
location.href = eCom.$list_order_sale_csv_btn.data('endpoint');
return location.href;
});
this.$download_coupon_codes.click(function() {
location.href = eCom.$download_coupon_codes.data('endpoint');
return location.href;
});
this.$download_registration_codes_form.submit(function() {
eCom.$error_msg.attr('style', 'display: none');
return true;
});
this.$active_registration_codes_form.submit(function() {
eCom.$error_msg.attr('style', 'display: none');
return true;
});
this.$spent_registration_codes_form.submit(function() {
eCom.$error_msg.attr('style', 'display: none');
return true;
});
}
@$error_msg = @$section.find('#error-msg')
# attach click handlers
# this handler binds to both the download
# and the csv button
@$list_sale_csv_btn.click (e) =>
url = @$list_sale_csv_btn.data 'endpoint'
url += '/csv'
location.href = url
eCommerce.prototype.onClickTitle = function() {
this.clear_display();
this.instructor_tasks.task_poller.start();
return this.report_downloads.downloads_poller.start();
};
@$list_order_sale_csv_btn.click (e) =>
url = @$list_order_sale_csv_btn.data 'endpoint'
location.href = url
eCommerce.prototype.onExit = function() {
this.clear_display();
this.instructor_tasks.task_poller.stop();
return this.report_downloads.downloads_poller.stop();
};
@$download_coupon_codes.click (e) =>
url = @$download_coupon_codes.data 'endpoint'
location.href = url
eCommerce.prototype.clear_display = function() {
this.$error_msg.attr('style', 'display: none');
this.$download_company_name.val('');
this.$reports_request_response.empty();
this.$reports_request_response_error.empty();
this.$active_company_name.val('');
return this.$spent_company_name.val('');
};
@$download_registration_codes_form.submit (e) =>
@$error_msg.attr('style', 'display: none')
return true
return eCommerce;
}());
@$active_registration_codes_form.submit (e) =>
@$error_msg.attr('style', 'display: none')
return true
_.defaults(window, {
InstructorDashboard: {}
});
@$spent_registration_codes_form.submit (e) =>
@$error_msg.attr('style', 'display: none')
return true
_.defaults(window.InstructorDashboard, {
sections: {}
});
# handler for when the section title is clicked.
onClickTitle: ->
@clear_display()
@instructor_tasks.task_poller.start()
@report_downloads.downloads_poller.start()
# handler for when the section is closed
onExit: ->
@clear_display()
@instructor_tasks.task_poller.stop()
@report_downloads.downloads_poller.stop()
clear_display: ->
@$error_msg.attr('style', 'display: none')
@$download_company_name.val('')
@$reports_request_response.empty()
@$reports_request_response_error.empty()
@$active_company_name.val('')
@$spent_company_name.val('')
isInt = (n) -> return n % 1 == 0;
# Clear any generated tables, warning messages, etc.
# export for use
# create parent namespaces if they do not already exist.
_.defaults window, InstructorDashboard: {}
_.defaults window.InstructorDashboard, sections: {}
_.defaults window.InstructorDashboard.sections,
ECommerce: ECommerce
_.defaults(window.InstructorDashboard.sections, {
ECommerce: ECommerce
});
}).call(this);
# METRICS Section
(function() {
'use strict';
var Metrics;
# imports from other modules.
# wrap in (-> ... apply) to defer evaluation
# such that the value can be defined later than this assignment (file load order).
plantTimeout = -> window.InstructorDashboard.util.plantTimeout.apply this, arguments
std_ajax_err = -> window.InstructorDashboard.util.std_ajax_err.apply this, arguments
Metrics = (function() {
function metrics($section) {
this.$section = $section;
this.$section.data('wrapper', this);
}
#Metrics Section
class Metrics
constructor: (@$section) ->
@$section.data 'wrapper', @
# handler for when the section title is clicked.
onClickTitle: ->
metrics.prototype.onClickTitle = function() {};
# export for use
# create parent namespaces if they do not already exist.
# abort if underscore can not be found.
if _?
_.defaults window, InstructorDashboard: {}
_.defaults window.InstructorDashboard, sections: {}
_.defaults window.InstructorDashboard.sections,
Metrics: Metrics
return metrics;
}());
window.InstructorDashboard.sections.Metrics = Metrics;
}).call(this);
/* global define */
define(['jquery',
'coffee/src/instructor_dashboard/data_download',
'js/instructor_dashboard/data_download',
'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers',
'slick.grid'],
function($, DataDownload, AjaxHelpers) {
......
// Generated by CoffeeScript 1.6.1
(function() {
'use strict';
describe('AutoEnrollment', function() {
beforeEach(function() {
loadFixtures('../../fixtures/autoenrollment.html');
this.autoenrollment = new window.AutoEnrollmentViaCsv($('.auto_enroll_csv'));
return this.autoenrollment;
});
it('binds the ajax call and the result will be success', function() {
var submitCallback;
spyOn($, 'ajax').and.callFake(function(params) {
params.success({
row_errors: [],
general_errors: [],
warnings: []
});
return {
always: function() {}
};
});
this.autoenrollment.render_notification_view = jasmine.createSpy(
'render_notification_view(type, title, message, details) spy').and.callFake(function() {
return '<div><div class="message message-confirmation"><h3 class="message-title">Success</h3><div class="message-copy"><p>All accounts were created successfully.</p></div></div><div>'; // eslint-disable-line max-len
});
submitCallback = jasmine.createSpy().and.returnValue();
this.autoenrollment.$student_enrollment_form.submit(submitCallback);
this.autoenrollment.$enrollment_signup_button.click();
expect($('.results .message-copy').text()).toEqual('All accounts were created successfully.');
return expect(submitCallback).toHaveBeenCalled();
});
it('binds the ajax call and the result will be error', function() {
var submitCallback;
spyOn($, 'ajax').and.callFake(function(params) {
params.success({
row_errors: [
{
username: 'testuser1',
email: 'testemail1@email.com',
response: 'Username already exists'
}
],
general_errors: [
{
response: 'cannot read the line 2'
}
],
warnings: []
});
return {
always: function() {}
};
});
this.autoenrollment.render_notification_view = jasmine.createSpy(
'render_notification_view(type, title, message, details) spy').and.callFake(function() {
return '<div><div class="message message-error"><h3 class="message-title">Errors</h3><div class="message-copy"><p>The following errors were generated:</p><ul class="list-summary summary-items"><li class="summary-item">cannot read the line 2</li><li class="summary-item">testuser1 (testemail1@email.com): (Username already exists)</li></ul></div></div></div>'; // eslint-disable-line max-len
});
submitCallback = jasmine.createSpy().and.returnValue();
this.autoenrollment.$student_enrollment_form.submit(submitCallback);
this.autoenrollment.$enrollment_signup_button.click();
expect($('.results .list-summary').text()).toEqual('cannot read the line 2testuser1 (testemail1@email.com): (Username already exists)'); // eslint-disable-line max-len
return expect(submitCallback).toHaveBeenCalled();
});
return it('binds the ajax call and the result will be warnings', function() {
var submitCallback;
spyOn($, 'ajax').and.callFake(function(params) {
params.success({
row_errors: [],
general_errors: [],
warnings: [
{
username: 'user1',
email: 'user1email',
response: 'email is in valid'
}
]
});
return {
always: function() {}
};
});
this.autoenrollment.render_notification_view = jasmine.createSpy(
'render_notification_view(type, title, message, details) spy').and.callFake(function() {
return '<div><div class="message message-warning"><h3 class="message-title">Warnings</h3><div class="message-copy"><p>The following warnings were generated:</p><ul class="list-summary summary-items"><li class="summary-item">user1 (user1email): (email is in valid)</li></ul></div></div></div>'; // eslint-disable-line max-len
});
submitCallback = jasmine.createSpy().and.returnValue();
this.autoenrollment.$student_enrollment_form.submit(submitCallback);
this.autoenrollment.$enrollment_signup_button.click();
expect($('.results .list-summary').text()).toEqual('user1 (user1email): (email is in valid)');
return expect(submitCallback).toHaveBeenCalled();
});
});
}).call(this);
(function() {
'use strict';
describe('Bulk Email Queueing', function() {
beforeEach(function() {
var testBody, testSubject;
testSubject = 'Test Subject';
testBody = 'Hello, World! This is a test email message!';
loadFixtures('../../fixtures/send_email.html');
this.send_email = new window.SendEmail($('.send-email'));
this.send_email.$subject.val(testSubject);
this.send_email.$send_to.first().prop('checked', true);
this.send_email.$emailEditor = {
save: function() {
return {
data: testBody
};
}
};
this.ajax_params = {
type: 'POST',
dataType: 'json',
url: void 0,
data: {
action: 'send',
send_to: JSON.stringify([this.send_email.$send_to.first().val()]),
subject: testSubject,
message: testBody
},
success: jasmine.any(Function),
error: jasmine.any(Function)
};
return this.ajax_params;
});
it('cannot send an email with no target', function() {
var target, i, len, ref;
spyOn(window, 'alert');
spyOn($, 'ajax');
ref = this.send_email.$send_to;
for (i = 0, len = ref.length; i < len; i++) {
target = ref[i];
target.checked = false;
}
this.send_email.$btn_send.click();
expect(window.alert).toHaveBeenCalledWith('Your message must have at least one target.');
return expect($.ajax).not.toHaveBeenCalled();
});
it('cannot send an email with no subject', function() {
spyOn(window, 'alert');
spyOn($, 'ajax');
this.send_email.$subject.val('');
this.send_email.$btn_send.click();
expect(window.alert).toHaveBeenCalledWith('Your message must have a subject.');
return expect($.ajax).not.toHaveBeenCalled();
});
it('cannot send an email with no message', function() {
spyOn(window, 'alert');
spyOn($, 'ajax');
this.send_email.$emailEditor = {
save: function() {
return {
data: ''
};
}
};
this.send_email.$btn_send.click();
expect(window.alert).toHaveBeenCalledWith('Your message cannot be blank.');
return expect($.ajax).not.toHaveBeenCalled();
});
it('can send a simple message to a single target', function() {
spyOn($, 'ajax').and.callFake(function(params) {
return params.success();
});
this.send_email.$btn_send.click();
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.'); // eslint-disable-line max-len
return expect($.ajax).toHaveBeenCalledWith(this.ajax_params);
});
it('can send a simple message to a multiple targets', function() {
var target, i, len, ref;
spyOn($, 'ajax').and.callFake(function(params) {
return params.success();
});
this.ajax_params.data.send_to = JSON.stringify((function() {
var j, len1, ref1, results;
ref1 = this.send_email.$send_to;
results = [];
for (j = 0, len1 = ref.length; j < len1; j++) {
target = ref1[j];
results.push(target.value);
}
return results;
}).call(this));
ref = this.send_email.$send_to;
for (i = 0, len = ref.length; i < len; i++) {
target = ref[i];
target.checked = true;
}
this.send_email.$btn_send.click();
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.'); // eslint-disable-line max-len
return expect($.ajax).toHaveBeenCalledWith(this.ajax_params);
});
it('can handle an error result from the bulk email api', function() {
spyOn($, 'ajax').and.callFake(function(params) {
return params.error();
});
spyOn(console, 'warn');
this.send_email.$btn_send.click();
return expect($('.request-response-error').text()).toEqual('Error sending email.');
});
it('selecting all learners disables cohort selections', function() {
this.send_email.$send_to.filter("[value='learners']").click();
this.send_email.$cohort_targets.each(function() {
return expect(this.disabled).toBe(true);
});
this.send_email.$send_to.filter("[value='learners']").click();
return this.send_email.$cohort_targets.each(function() {
return expect(this.disabled).toBe(false);
});
});
return it('selected targets are listed after "send to:"', function() {
this.send_email.$send_to.click();
return $('input[name="send_to"]:checked+label').each(function() {
return expect($('.send_to_list'.text())).toContain(this.innerText.replace(/\s*\n.*/g, ''));
});
});
});
}).call(this);
......@@ -54,7 +54,7 @@
mathjax: '//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_SVG&delayStartupUntil=configured', // eslint-disable-line max-len
'youtube': '//www.youtube.com/player_api?noext',
'coffee/src/ajax_prefix': 'xmodule_js/common_static/coffee/src/ajax_prefix',
'coffee/src/instructor_dashboard/student_admin': 'coffee/src/instructor_dashboard/student_admin',
'js/instructor_dashboard/student_admin': 'js/instructor_dashboard/student_admin',
'xmodule_js/common_static/js/test/add_ajax_prefix': 'xmodule_js/common_static/js/test/add_ajax_prefix',
'xblock/lms.runtime.v1': 'lms/js/xblock/lms.runtime.v1',
'xblock': 'common/js/xblock',
......@@ -283,8 +283,8 @@
exports: 'AjaxPrefix',
deps: ['coffee/src/ajax_prefix']
},
'coffee/src/instructor_dashboard/util': {
exports: 'coffee/src/instructor_dashboard/util',
'js/instructor_dashboard/util': {
exports: 'js/instructor_dashboard/util',
deps: ['jquery', 'underscore', 'slick.core', 'slick.grid'],
init: function() {
// Set global variables that the util code is expecting to be defined
......@@ -298,9 +298,9 @@
});
}
},
'coffee/src/instructor_dashboard/student_admin': {
exports: 'coffee/src/instructor_dashboard/student_admin',
deps: ['jquery', 'underscore', 'coffee/src/instructor_dashboard/util', 'string_utils']
'js/instructor_dashboard/student_admin': {
exports: 'js/instructor_dashboard/student_admin',
deps: ['jquery', 'underscore', 'js/instructor_dashboard/util', 'string_utils']
},
'js/instructor_dashboard/certificates': {
exports: 'js/instructor_dashboard/certificates',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment