Commit 4f003d30 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'qa-shl-fix-register-spec' into 'master'

Stablize register spec

See merge request gitlab-org/gitlab!50675
parents 046c804b 0699f7a7
......@@ -6,36 +6,34 @@ module QA
module_function
def sign_up!(user)
Page::Main::Menu.perform(&:sign_out_if_signed_in)
Page::Main::Login.perform(&:switch_to_register_page)
Page::Registration::SignUp.perform do |sign_up|
sign_up.fill_new_user_first_name_field(user.first_name)
sign_up.fill_new_user_last_name_field(user.last_name)
sign_up.fill_new_user_username_field(user.username)
sign_up.fill_new_user_email_field(user.email)
sign_up.fill_new_user_password_field(user.password)
# Because invisible_captcha would prevent submitting this form
# within 4 seconds, sleep here. This can be removed once we
# implement invisible_captcha as an application setting instead
# of a feature flag, so we can turn it off while testing.
# Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/284113
sleep 5
sign_up.click_new_user_register_button
end
success = Support::Retrier.retry_until(raise_on_failure: false) do
Page::Registration::SignUp.perform do |sign_up|
sign_up.fill_new_user_first_name_field(user.first_name)
sign_up.fill_new_user_last_name_field(user.last_name)
sign_up.fill_new_user_username_field(user.username)
sign_up.fill_new_user_email_field(user.email)
sign_up.fill_new_user_password_field(user.password)
# Because invisible_captcha would prevent submitting this form
# within 4 seconds, sleep here. This can be removed once we
# implement invisible_captcha as an application setting instead
# of a feature flag, so we can turn it off while testing.
# Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/284113
sleep 5
sign_up.click_new_user_register_button
end
Page::Registration::Welcome.perform(&:click_get_started_button_if_available)
Page::Registration::Welcome.perform(&:click_get_started_button_if_available)
if user.expect_fabrication_success
Page::Main::Menu.perform(&:has_personal_area?)
else
Page::Main::Menu.perform(&:not_signed_in?)
end
success = if user.expect_fabrication_success
Page::Main::Menu.perform(&:has_personal_area?)
else
Page::Main::Menu.perform(&:not_signed_in?)
end
raise "Failed to register the user" unless success
raise "Failed user registration attempt. Registration was expected to #{ user.expect_fabrication_success ? 'succeed' : 'fail'} but #{success ? 'succeeded' : 'failed'}." unless success
end
def disable_sign_ups
......
......@@ -135,8 +135,11 @@ module QA
def check_element(name)
retry_until(sleep_interval: 1) do
find_element(name).set(true)
checked = find_element(name).checked?
find_element(name).checked?
QA::Runtime::Logger.debug(checked ? "#{name} was checked" : "#{name} was not checked")
checked
end
end
......
......@@ -98,8 +98,10 @@ module QA
before do
enable_require_admin_approval_after_user_signup_via_ui
@user = Resource::User.fabricate_via_browser_ui! do |user|
user.expect_fabrication_success = false
Support::Retrier.retry_on_exception do
@user = Resource::User.fabricate_via_browser_ui! do |user|
user.expect_fabrication_success = false
end
end
end
......@@ -148,26 +150,34 @@ module QA
end
def set_require_admin_approval_after_user_signup_via_api(enable_or_disable)
return if Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup] == enable_or_disable
return if get_require_admin_approval_after_user_signup_via_api == enable_or_disable
Runtime::ApplicationSettings.set_application_settings(require_admin_approval_after_user_signup: enable_or_disable)
sleep 10 # It takes a moment for the setting to come into effect
end
def get_require_admin_approval_after_user_signup_via_api
Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup]
end
def enable_require_admin_approval_after_user_signup_via_ui
unless Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup]
Flow::Login.while_signed_in_as_admin do
Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_general_settings)
Page::Admin::Settings::General.perform do |setting|
setting.expand_sign_up_restrictions do |settings|
settings.require_admin_approval_after_user_signup
unless get_require_admin_approval_after_user_signup_via_api
QA::Support::Retrier.retry_until do
Flow::Login.while_signed_in_as_admin do
Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_general_settings)
Page::Admin::Settings::General.perform do |setting|
setting.expand_sign_up_restrictions do |settings|
settings.require_admin_approval_after_user_signup
end
end
end
end
sleep 10 # It takes a moment for the setting to come into effect
sleep 15 # It takes a moment for the setting to come into effect
get_require_admin_approval_after_user_signup_via_api
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