From db558e38eac5703a853010300ef7a2a6bd867269 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 17 Jun 2015 22:56:02 +0100 Subject: [PATCH] Provide a more intuitive error message on sign-in for missing email issue 4651#issuecomment-112141801 - display "Please enter an email" validation message rather than "Invalid Email" when no email is entered --- core/client/app/validators/signin.js | 4 +++- core/test/functional/client/signin_test.js | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/client/app/validators/signin.js b/core/client/app/validators/signin.js index 2ac408d7c2..7b101fe5ad 100644 --- a/core/client/app/validators/signin.js +++ b/core/client/app/validators/signin.js @@ -4,7 +4,9 @@ var SigninValidator = Ember.Object.create({ var data = model.getProperties('identification', 'password'), validationErrors = []; - if (!validator.isEmail(data.identification)) { + if (validator.empty(data.identification)) { + validationErrors.push('Please enter an email'); + } else if (!validator.isEmail(data.identification)) { validationErrors.push('Invalid Email'); } diff --git a/core/test/functional/client/signin_test.js b/core/test/functional/client/signin_test.js index 3447217803..9b24112abc 100644 --- a/core/test/functional/client/signin_test.js +++ b/core/test/functional/client/signin_test.js @@ -111,7 +111,7 @@ CasperTest.begin('Authenticated user is redirected', 6, function suite(test) { }); }, true); -CasperTest.begin('Ensure email field form validation', 3, function suite(test) { +CasperTest.begin('Ensure email field form validation', 4, function suite(test) { CasperTest.Routines.signout.run(test); casper.thenOpenAndWaitForPageLoad('signin', function testTitleAndUrl() { @@ -134,4 +134,16 @@ CasperTest.begin('Ensure email field form validation', 3, function suite(test) { }, function onTimeout() { test.fail('Email validation error did not appear'); }, 2000); + + casper.then(function testMissingEmail() { + this.fillAndSave('form.gh-signin', { + identification: '' + }); + }); + + casper.waitForSelectorTextChange('.notification-error', function onSuccess() { + test.assertSelectorHasText('.notification-error', 'Please enter an email', '.notification-error text is correct'); + }, function onTimeout() { + test.fail('Missing Email validation error did not appear'); + }, 2000); }, true);