summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2018-01-25 23:15:33 -0800
committerMichael Kozono <mkozono@gmail.com>2018-01-26 09:33:05 -0800
commita1a458279489e6b95209a55f1878642d53218684 (patch)
treea44c3cbc663269a08442583e9b3c728d516685e5 /qa
parent6c978c8f287d2fc61c58ab59973e0015bfc2ac58 (diff)
downloadgitlab-ce-a1a458279489e6b95209a55f1878642d53218684.tar.gz
Fix intermittently failed click in dropdownqa/mk-fix-unable-to-click-new-project-in-dropdown
I haven’t seen `go_to_new_subgroup` fail in the same way, but it seems best to modify it also.
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/page/base.rb16
-rw-r--r--qa/qa/page/group/show.rb14
-rw-r--r--qa/qa/page/main/login.rb6
3 files changed, 25 insertions, 11 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 81ba80cdbaf..fa7a3760057 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -13,16 +13,18 @@ module QA
visit current_url
end
- def wait(css = '.application', time: 60)
- Time.now.tap do |start|
- while Time.now - start < time
- break if page.has_css?(css, wait: 5)
+ def wait(max: 60, time: 1, reload: true)
+ start = Time.now
- refresh
- end
+ while Time.now - start < max
+ return true if yield
+
+ sleep(time)
+
+ refresh if reload
end
- yield if block_given?
+ false
end
def scroll_to(selector, text: nil)
diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb
index 37ed3b35bce..f23294145dd 100644
--- a/qa/qa/page/group/show.rb
+++ b/qa/qa/page/group/show.rb
@@ -25,7 +25,12 @@ module QA
def go_to_new_subgroup
within '.new-project-subgroup' do
- find('.dropdown-toggle').click
+ # May need to click again because it is possible to click the button quicker than the JS is bound
+ wait(reload: false) do
+ find('.dropdown-toggle').click
+
+ page.has_css?("li[data-value='new-subgroup']")
+ end
find("li[data-value='new-subgroup']").click
end
@@ -34,7 +39,12 @@ module QA
def go_to_new_project
within '.new-project-subgroup' do
- find('.dropdown-toggle').click
+ # May need to click again because it is possible to click the button quicker than the JS is bound
+ wait(reload: false) do
+ find('.dropdown-toggle').click
+
+ page.has_css?("li[data-value='new-project']")
+ end
find("li[data-value='new-project']").click
end
diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb
index 9cff2c5c317..95880475ffa 100644
--- a/qa/qa/page/main/login.rb
+++ b/qa/qa/page/main/login.rb
@@ -10,12 +10,14 @@ module QA
view 'app/views/devise/sessions/_new_base.html.haml' do
element :login_field, 'text_field :login'
- element :passowrd_field, 'password_field :password'
+ element :password_field, 'password_field :password'
element :sign_in_button, 'submit "Sign in"'
end
def initialize
- wait('.application', time: 500)
+ wait(max: 500) do
+ page.has_css?('.application')
+ end
end
def sign_in_using_credentials