diff --git a/lms/static/js/spec/student_account/login_spec.js b/lms/static/js/spec/student_account/login_spec.js index f95e1a9d00..a94ada61a0 100644 --- a/lms/static/js/spec/student_account/login_spec.js +++ b/lms/static/js/spec/student_account/login_spec.js @@ -278,7 +278,25 @@ // Expect that an error is displayed and that auth complete is not triggered expect(view.$errors).not.toHaveClass('hidden'); expect(authComplete).toBe(false); - expect(view.$errors.text()).toContain('Please check your internet connection and try again.'); + expect(view.$errors.text()).toContain( + 'An error has occurred. Check your Internet connection and try again.' + ); + }); + it('displays an error if there is a server error', function () { + createLoginView(this); + + // Submit the form, with successful validation + submitForm(true); + + // Simulate an error from the LMS servers + AjaxHelpers.respondWithError(requests, 500); + + // Expect that an error is displayed and that auth complete is not triggered + expect(view.$errors).not.toHaveClass('hidden'); + expect(authComplete).toBe(false); + expect(view.$errors.text()).toContain( + 'An error has occurred. Try refreshing the page, or check your Internet connection.' + ); }); }); }); diff --git a/lms/static/js/student_account/views/LoginView.js b/lms/static/js/student_account/views/LoginView.js index 68ff04fa1b..265455e13f 100644 --- a/lms/static/js/student_account/views/LoginView.js +++ b/lms/static/js/student_account/views/LoginView.js @@ -103,12 +103,13 @@ }, saveError: function( error ) { + var msg = error.responseText; if (error.status === 0) { - this.errors = ['
  • ' + gettext('Please check your internet connection and try again.') + '
  • ']; - } - else { - this.errors = ['
  • ' + error.responseText + '
  • ']; + msg = gettext('An error has occurred. Check your Internet connection and try again.'); + } else if(error.status === 500){ + msg = gettext('An error has occurred. Try refreshing the page, or check your Internet connection.'); } + this.errors = ['
  • ' + msg + '
  • ']; this.setErrors(); this.element.hide( this.$resetSuccess );