From 2962538791641289ff10c068028a2a3080639a20 Mon Sep 17 00:00:00 2001 From: Iana Vasylieva Date: Wed, 13 Mar 2019 17:06:03 +0200 Subject: [PATCH] Fix bug: errors are not shown when modifying course team in Instructor Dashboard > Membership --- .../js/instructor_dashboard/membership.js | 4 +-- .../membership_auth_spec.js | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lms/static/js/instructor_dashboard/membership.js b/lms/static/js/instructor_dashboard/membership.js index fd8a1b69d5..1f3164dd4b 100644 --- a/lms/static/js/instructor_dashboard/membership.js +++ b/lms/static/js/instructor_dashboard/membership.js @@ -269,12 +269,12 @@ such that the value can be defined later than this assignment (file load order). this.clear_input(); if (data.userDoesNotExist) { msg = gettext("Could not find a user with username or email address '<%- identifier %>'."); - return this.show_errors(_.template(msg, { + return this.show_errors(_.template(msg)({ identifier: data.unique_student_identifier })); } else if (data.inactiveUser) { msg = gettext("Error: User '<%- username %>' has not yet activated their account. Users must create and activate their accounts before they can be assigned a role."); // eslint-disable-line max-len - return this.show_errors(_.template(msg, { + return this.show_errors(_.template(msg)({ username: data.unique_student_identifier })); } else if (data.removingSelfAsInstructor) { diff --git a/lms/static/js/spec/instructor_dashboard/membership_auth_spec.js b/lms/static/js/spec/instructor_dashboard/membership_auth_spec.js index 9da5b13ef8..d9acde8f74 100644 --- a/lms/static/js/spec/instructor_dashboard/membership_auth_spec.js +++ b/lms/static/js/spec/instructor_dashboard/membership_auth_spec.js @@ -63,6 +63,31 @@ define(['jquery', expect($('.auth-list-container.active .add-field').attr('disabled')).toBe(undefined); }); + it('Error message is shown if user with given identifier does not exist', function() { + var url, params; + var requests = AjaxHelpers.requests(this); + $('.active .add-field').val('smth'); + $('.active .add').click(); + expect(requests.length).toEqual(1); + + url = '/courses/course-v1:edx+ed202+2017_T3/instructor/api/modify_access'; + params = $.param({ + unique_student_identifier: 'smth', + rolename: 'staff', + action: 'allow' + }); + AjaxHelpers.expectPostRequest(requests, url, params); + + AjaxHelpers.respondWithJson(requests, { + unique_student_identifier: 'smth', + userDoesNotExist: true + }); + + expect($('.request-response-error').text()).toEqual( + "Could not find a user with username or email address 'smth'." + ); + }); + it('When no discussions division scheme is selected error is shown and inputs are disabled', function() { var requests = AjaxHelpers.requests(this), data,