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 ...@@ -6,36 +6,34 @@ module QA
module_function module_function
def sign_up!(user) def sign_up!(user)
Page::Main::Menu.perform(&:sign_out_if_signed_in)
Page::Main::Login.perform(&:switch_to_register_page) 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::Welcome.perform(&:click_get_started_button_if_available)
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)
if user.expect_fabrication_success success = if user.expect_fabrication_success
Page::Main::Menu.perform(&:has_personal_area?) Page::Main::Menu.perform(&:has_personal_area?)
else else
Page::Main::Menu.perform(&:not_signed_in?) Page::Main::Menu.perform(&:not_signed_in?)
end
end 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 end
def disable_sign_ups def disable_sign_ups
......
...@@ -135,8 +135,11 @@ module QA ...@@ -135,8 +135,11 @@ module QA
def check_element(name) def check_element(name)
retry_until(sleep_interval: 1) do retry_until(sleep_interval: 1) do
find_element(name).set(true) 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
end end
......
...@@ -98,8 +98,10 @@ module QA ...@@ -98,8 +98,10 @@ module QA
before do before do
enable_require_admin_approval_after_user_signup_via_ui enable_require_admin_approval_after_user_signup_via_ui
@user = Resource::User.fabricate_via_browser_ui! do |user| Support::Retrier.retry_on_exception do
user.expect_fabrication_success = false @user = Resource::User.fabricate_via_browser_ui! do |user|
user.expect_fabrication_success = false
end
end end
end end
...@@ -148,26 +150,34 @@ module QA ...@@ -148,26 +150,34 @@ module QA
end end
def set_require_admin_approval_after_user_signup_via_api(enable_or_disable) 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) 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 sleep 10 # It takes a moment for the setting to come into effect
end 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 def enable_require_admin_approval_after_user_signup_via_ui
unless Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup] unless get_require_admin_approval_after_user_signup_via_api
Flow::Login.while_signed_in_as_admin do QA::Support::Retrier.retry_until do
Page::Main::Menu.perform(&:go_to_admin_area) Flow::Login.while_signed_in_as_admin do
QA::Page::Admin::Menu.perform(&:go_to_general_settings) Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Settings::General.perform do |setting| QA::Page::Admin::Menu.perform(&:go_to_general_settings)
setting.expand_sign_up_restrictions do |settings| Page::Admin::Settings::General.perform do |setting|
settings.require_admin_approval_after_user_signup setting.expand_sign_up_restrictions do |settings|
settings.require_admin_approval_after_user_signup
end
end 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 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