Skip to content
Snippets Groups Projects
Verified Commit e452b894 authored by Eduardo Sanz García's avatar Eduardo Sanz García :zero: Committed by GitLab
Browse files

Merge branch 'eduardosanz/email-tld-warning' into 'master'

Display bolder warning if email TLD is missing

See merge request !172716



Merged-by: default avatarEduardo Sanz García <esanz-garcia@gitlab.com>
Approved-by: default avatarFernando Cardenas <14022659-fernando-c@users.noreply.gitlab.com>
Approved-by: default avatarSmriti Garg <sgarg@gitlab.com>
parents 8cbadfca 2a9fb44e
No related branches found
No related tags found
1 merge request!172716Display bolder warning if email TLD is missing
Pipeline #1560488367 passed
import InputValidator from '~/validators/input_validator';
// It checks if email contains at least one character, number or whatever except
// another "@" or whitespace before "@", at least two characters except
// another "@" or whitespace after "@" and one dot in between
const emailRegexPattern = /[^@\s]+@[^@\s]+\.[^@\s]+/;
// The format of the email is validated by the default `type="email"` input field.
// In addition, the email should contain a top-level domain of at least two alphabetical characters.
const emailRegexPattern = /.+\.[a-zA-Z]{2,}/;
const hintMessageSelector = '.validation-hint';
const warningMessageSelector = '.validation-warning';
......
......@@ -64,8 +64,8 @@
title: _('Please provide a valid email address.')
%p.validation-hint.text-secondary
= _('We recommend a work email address.')
%p.validation-warning.gl-field-error-ignore.text-secondary.hide
= _('This email address does not look right, are you sure you typed it correctly?')
%p.validation-warning.gl-field-error-ignore.gl-text-red-500.hide
= _('Email address without top-level domain. Make sure that you have entered the correct email address.')
-# This is used for providing entry to Jihu on email verification
= render_if_exists 'devise/shared/signup_email_additional_info'
.form-group.gl-mb-5
......
......@@ -20928,6 +20928,9 @@ msgstr ""
msgid "Email address to use for Service Desk"
msgstr ""
 
msgid "Email address without top-level domain. Make sure that you have entered the correct email address."
msgstr ""
msgid "Email could not be sent"
msgstr ""
 
......@@ -56382,9 +56385,6 @@ msgstr ""
msgid "This domain is not verified. You will need to verify ownership before access is enabled."
msgstr ""
 
msgid "This email address does not look right, are you sure you typed it correctly?"
msgstr ""
msgid "This email supersedes any previous emails about scheduled deletion you may have received for %{project_link}."
msgstr ""
 
......@@ -42,6 +42,7 @@
RSpec.describe 'Signup', :with_current_organization, :js, feature_category: :user_management do
include TermsHelper
using RSpec::Parameterized::TableSyntax
let(:new_user) { build_stubbed(:user) }
......@@ -365,5 +366,82 @@
it_behaves_like 'user email validation' do
let(:path) { new_user_registration_path }
end
where(:email, :reason) do
'"A"@b.co' | 'quoted emails'
'a @b.co' | 'space in the local-part'
'ab.co' | 'no @ symbol'
'a@b@c.co' | 'several @ symbol'
'a@-b.co' | 'domain starting with hyphen'
'a@b-.co' | 'domain finishing with hyphen'
'a@example_me.co' | 'domain with underscore'
'a@example .com' | 'space in the domain'
'a@[123.123.123.123]' | 'IP addresses'
'a@b.' | 'invalid domain'
end
with_them do
cause = params[:reason]
it "doesn't accept emails with #{cause}" do
new_user.email = email
visit new_user_registration_path
fill_in_sign_up_form(new_user)
expect(page).to have_current_path new_user_registration_path
expect(page).to have_content(_("Please provide a valid email address."))
end
end
end
context 'with valid email with top-level-domain singularities' do
it_behaves_like 'user email validation' do
let(:path) { new_user_registration_path }
end
where(:email, :reason) do
'a@b' | 'no TLD'
'a@b.c' | 'TLD less than two characters'
end
with_them do
cause = params[:reason]
it "accept emails with #{cause} but displays a warning" do
new_user_password_ori = new_user.password
new_user.email = email
new_user.password = ''
visit new_user_registration_path
fill_in_sign_up_form(new_user)
expect(page).to have_current_path new_user_registration_path
expect(page).to have_content(
_('Email address without top-level domain. Make sure that you have entered the correct email address.')
)
new_user.password = new_user_password_ori
expect { fill_in_sign_up_form(new_user) }.to change { User.count }.by(1)
end
end
end
context 'with valid email' do
where(:email, :reason) do
'6@b.co' | 'alphanumerical first character in the local-part'
'012345678901234567890123456789@b.co' | 'long local-part'
'a@wwww.internal-site.co.uk' | 'several subdomains'
'a@3w.internal-site.co.uk' | 'several subdomains'
'a@b.example' | 'valid TLD'
end
with_them do
cause = params[:reason]
it "accepts emails with #{cause}" do
new_user.email = email
visit new_user_registration_path
expect { fill_in_sign_up_form(new_user) }.to change { User.count }.by(1)
end
end
end
end
......@@ -5,7 +5,7 @@
let(:email_error_message) { _('Please provide a valid email address.') }
let(:email_warning_message) do
_('This email address does not look right, are you sure you typed it correctly?')
_('Email address without top-level domain. Make sure that you have entered the correct email address.')
end
it 'shows an error message until a correct email is entered' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment