diff options
-rw-r--r-- | qa/qa/factory/resource/fork.rb | 37 | ||||
-rw-r--r-- | qa/qa/page/main/sign_up.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/menu/main.rb | 9 |
3 files changed, 44 insertions, 4 deletions
diff --git a/qa/qa/factory/resource/fork.rb b/qa/qa/factory/resource/fork.rb index 01969c31438..92050eaba2a 100644 --- a/qa/qa/factory/resource/fork.rb +++ b/qa/qa/factory/resource/fork.rb @@ -13,8 +13,43 @@ module QA product(:user) { |factory| factory.user } + def visit_project_with_retry + # The user intermittently fails to stay signed in after visiting the + # project page. The new user is registered and then signs in and a + # screenshot shows that signing in was successful. Then the project + # page is visited but a screenshot shows the user is no longer signed + # in. It's difficult to reproduce locally but GDK logs don't seem to + # show anything unexpected. This method attempts to work around the + # problem and capture data to help troubleshoot. + + Capybara::Screenshot.screenshot_and_save_page + + start = Time.now + + while Time.now - start < 20 + push.project.visit! + + puts "Visited project page" + Capybara::Screenshot.screenshot_and_save_page + + return if Page::Menu::Main.act { has_personal_area?(wait: 0) } + + puts "Not signed in. Attempting to sign in again." + Capybara::Screenshot.screenshot_and_save_page + + Page::Menu::Main.act { sign_out } + + Page::Main::Login.perform do |login| + login.sign_in_using_credentials(user) + end + end + + raise "Failed to load project page and stay logged in" + end + def fabricate! - push.project.visit! + visit_project_with_retry + Page::Project::Show.act { fork_project } Page::Project::Fork::New.perform do |fork_new| diff --git a/qa/qa/page/main/sign_up.rb b/qa/qa/page/main/sign_up.rb index 33ab56236f4..64cd395de78 100644 --- a/qa/qa/page/main/sign_up.rb +++ b/qa/qa/page/main/sign_up.rb @@ -19,7 +19,7 @@ module QA fill_in :new_user_password, with: user.password click_button 'Register' - Page::Menu::Main.act { has_personal_area? } + Page::Menu::Main.act { assert_has_personal_area } end end end diff --git a/qa/qa/page/menu/main.rb b/qa/qa/page/menu/main.rb index 36e7285f7b7..2ae86bbc7dc 100644 --- a/qa/qa/page/menu/main.rb +++ b/qa/qa/page/menu/main.rb @@ -61,8 +61,13 @@ module QA end def has_personal_area?(wait: Capybara.default_max_wait_time) - # No need to wait, either we're logged-in, or not. - using_wait_time(wait) { page.has_selector?('.qa-user-avatar') } + using_wait_time(wait) do + page.has_selector?(element_selector_css(:user_avatar)) + end + end + + def assert_has_personal_area + raise "Failed to sign in" unless has_personal_area? end private |