Commit 62bd3045 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ml-qa-register-user-failure' into 'master'

QA: Retry registration before failing

See merge request gitlab-org/gitlab-ce!22033
parents 69ea38dc a9f6d55e
...@@ -5,22 +5,22 @@ ...@@ -5,22 +5,22 @@
= devise_error_messages! = devise_error_messages!
.form-group .form-group
= f.label :name, 'Full name', class: 'label-bold' = f.label :name, 'Full name', class: 'label-bold'
= f.text_field :name, class: "form-control top", required: true, title: "This field is required." = f.text_field :name, class: "form-control top qa-new-user-name", required: true, title: "This field is required."
.username.form-group .username.form-group
= f.label :username, class: 'label-bold' = f.label :username, class: 'label-bold'
= f.text_field :username, class: "form-control middle", pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS, required: true, title: 'Please create a username with only alphanumeric characters.' = f.text_field :username, class: "form-control middle qa-new-user-username", pattern: Gitlab::PathRegex::NAMESPACE_FORMAT_REGEX_JS, required: true, title: 'Please create a username with only alphanumeric characters.'
%p.validation-error.hide Username is already taken. %p.validation-error.hide Username is already taken.
%p.validation-success.hide Username is available. %p.validation-success.hide Username is available.
%p.validation-pending.hide Checking username availability... %p.validation-pending.hide Checking username availability...
.form-group .form-group
= f.label :email, class: 'label-bold' = f.label :email, class: 'label-bold'
= f.email_field :email, class: "form-control middle", required: true, title: "Please provide a valid email address." = f.email_field :email, class: "form-control middle qa-new-user-email", required: true, title: "Please provide a valid email address."
.form-group .form-group
= f.label :email_confirmation, class: 'label-bold' = f.label :email_confirmation, class: 'label-bold'
= f.email_field :email_confirmation, class: "form-control middle", required: true, title: "Please retype the email address." = f.email_field :email_confirmation, class: "form-control middle qa-new-user-email-confirmation", required: true, title: "Please retype the email address."
.form-group.append-bottom-20#password-strength .form-group.append-bottom-20#password-strength
= f.label :password, class: 'label-bold' = f.label :password, class: 'label-bold'
= f.password_field :password, class: "form-control bottom", required: true, pattern: ".{#{@minimum_password_length},}", title: "Minimum length is #{@minimum_password_length} characters." = f.password_field :password, class: "form-control bottom qa-new-user-password", required: true, pattern: ".{#{@minimum_password_length},}", title: "Minimum length is #{@minimum_password_length} characters."
%p.gl-field-hint.text-secondary Minimum length is #{@minimum_password_length} characters %p.gl-field-hint.text-secondary Minimum length is #{@minimum_password_length} characters
- if Gitlab::CurrentSettings.current_application_settings.enforce_terms? - if Gitlab::CurrentSettings.current_application_settings.enforce_terms?
.form-group .form-group
...@@ -33,4 +33,4 @@ ...@@ -33,4 +33,4 @@
- if Gitlab::Recaptcha.enabled? - if Gitlab::Recaptcha.enabled?
= recaptcha_tags = recaptcha_tags
.submit-container .submit-container
= f.submit "Register", class: "btn-register btn" = f.submit "Register", class: "btn-register btn qa-new-user-register-button"
...@@ -32,6 +32,21 @@ module QA ...@@ -32,6 +32,21 @@ module QA
false false
end end
def with_retry(max_attempts: 3, reload: false)
attempts = 0
while attempts < max_attempts
result = yield
return result if result
refresh if reload
attempts += 1
end
false
end
def scroll_to(selector, text: nil) def scroll_to(selector, text: nil)
page.execute_script <<~JS page.execute_script <<~JS
var elements = Array.from(document.querySelectorAll('#{selector}')); var elements = Array.from(document.querySelectorAll('#{selector}'));
......
...@@ -68,10 +68,6 @@ module QA ...@@ -68,10 +68,6 @@ module QA
end end
end end
def assert_has_personal_area
raise "Failed to sign in" unless has_personal_area?
end
private private
def within_top_menu def within_top_menu
......
# frozen_string_literal: true
module QA module QA
module Page module Page
module Main module Main
class SignUp < Page::Base class SignUp < Page::Base
view 'app/views/devise/shared/_signup_box.html.haml' do view 'app/views/devise/shared/_signup_box.html.haml' do
element :name, 'text_field :name' element :new_user_name
element :username, 'text_field :username' element :new_user_username
element :email_field, 'email_field :email' element :new_user_email
element :email_confirmation, 'email_field :email_confirmation' element :new_user_email_confirmation
element :password, 'password_field :password' element :new_user_password
element :register_button, 'submit "Register"' element :new_user_register_button
end end
def sign_up!(user) def sign_up!(user)
fill_in :new_user_name, with: user.name fill_element :new_user_name, user.name
fill_in :new_user_username, with: user.username fill_element :new_user_username, user.username
fill_in :new_user_email, with: user.email fill_element :new_user_email, user.email
fill_in :new_user_email_confirmation, with: user.email fill_element :new_user_email_confirmation, user.email
fill_in :new_user_password, with: user.password fill_element :new_user_password, user.password
click_button 'Register'
signed_in = with_retry do
click_element :new_user_register_button
Page::Main::Menu.act { has_personal_area? }
end
Page::Main::Menu.act { assert_has_personal_area } raise "Failed to register and sign in" unless signed_in
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment