summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-10-10 16:18:36 +0000
committerRémy Coutable <remy@rymai.me>2018-10-10 16:18:36 +0000
commit62bd3045a3c0c3ad979f795ca891a7a641d4e478 (patch)
tree240c8cb38f18485a642823cc58b9b9098fc6eca2 /qa
parent69ea38dcadfbf190b2d8d06af9651b6a675233cc (diff)
parenta9f6d55e79ccab1e1f54cb9a605b32d5f15e7465 (diff)
downloadgitlab-ce-62bd3045a3c0c3ad979f795ca891a7a641d4e478.tar.gz
Merge branch 'ml-qa-register-user-failure' into 'master'
QA: Retry registration before failing See merge request gitlab-org/gitlab-ce!22033
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/page/base.rb15
-rw-r--r--qa/qa/page/main/menu.rb4
-rw-r--r--qa/qa/page/main/sign_up.rb33
3 files changed, 35 insertions, 17 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 826cfe6b198..160ec58cf2c 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -32,6 +32,21 @@ module QA
false
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)
page.execute_script <<~JS
var elements = Array.from(document.querySelectorAll('#{selector}'));
diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb
index e18b95bde9f..a2ee696e1b3 100644
--- a/qa/qa/page/main/menu.rb
+++ b/qa/qa/page/main/menu.rb
@@ -68,10 +68,6 @@ module QA
end
end
- def assert_has_personal_area
- raise "Failed to sign in" unless has_personal_area?
- end
-
private
def within_top_menu
diff --git a/qa/qa/page/main/sign_up.rb b/qa/qa/page/main/sign_up.rb
index dddda4f2bdf..b33ea03fc55 100644
--- a/qa/qa/page/main/sign_up.rb
+++ b/qa/qa/page/main/sign_up.rb
@@ -1,25 +1,32 @@
+# frozen_string_literal: true
+
module QA
module Page
module Main
class SignUp < Page::Base
view 'app/views/devise/shared/_signup_box.html.haml' do
- element :name, 'text_field :name'
- element :username, 'text_field :username'
- element :email_field, 'email_field :email'
- element :email_confirmation, 'email_field :email_confirmation'
- element :password, 'password_field :password'
- element :register_button, 'submit "Register"'
+ element :new_user_name
+ element :new_user_username
+ element :new_user_email
+ element :new_user_email_confirmation
+ element :new_user_password
+ element :new_user_register_button
end
def sign_up!(user)
- fill_in :new_user_name, with: user.name
- fill_in :new_user_username, with: user.username
- fill_in :new_user_email, with: user.email
- fill_in :new_user_email_confirmation, with: user.email
- fill_in :new_user_password, with: user.password
- click_button 'Register'
+ fill_element :new_user_name, user.name
+ fill_element :new_user_username, user.username
+ fill_element :new_user_email, user.email
+ fill_element :new_user_email_confirmation, user.email
+ fill_element :new_user_password, user.password
+
+ 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