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,9 +6,8 @@ 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)
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)
......@@ -28,14 +27,13 @@ module QA
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?)
else
Page::Main::Menu.perform(&:not_signed_in?)
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
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,10 +98,12 @@ module QA
before do
enable_require_admin_approval_after_user_signup_via_ui
Support::Retrier.retry_on_exception do
@user = Resource::User.fabricate_via_browser_ui! do |user|
user.expect_fabrication_success = false
end
end
end
it 'allows user login after approval', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1076' do
expect(page).to have_text(signed_up_waiting_approval_text)
......@@ -148,15 +150,20 @@ 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]
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)
......@@ -167,7 +174,10 @@ module QA
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