Show a message when logging in with no internet connection.

ECOM-2890
This commit is contained in:
Peter Fogg
2015-11-13 14:53:24 -05:00
parent b05c4af41c
commit c8fbadb24a
2 changed files with 23 additions and 2 deletions

View File

@@ -265,6 +265,21 @@
expect(view.$errors).toHaveClass('hidden');
expect(authComplete).toBe(true);
});
it('displays an error if there is no internet connection', function () {
createLoginView(this);
// Submit the form, with successful validation
submitForm(true);
// Simulate an error from the LMS servers
AjaxHelpers.respondWithError(requests, 0);
// 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.');
});
});
});
}).call(this, define || RequireJS.define);

View File

@@ -3,9 +3,10 @@
define([
'jquery',
'underscore',
'gettext',
'js/student_account/views/FormView'
],
function($, _, FormView) {
function($, _, gettext, FormView) {
return FormView.extend({
el: '#login-form',
@@ -102,7 +103,12 @@
},
saveError: function( error ) {
this.errors = ['<li>' + error.responseText + '</li>'];
if (error.status === 0) {
this.errors = ['<li>' + gettext('Please check your internet connection and try again.') + '</li>'];
}
else {
this.errors = ['<li>' + error.responseText + '</li>'];
}
this.setErrors();
this.element.hide( this.$resetSuccess );