From ce27170434361029f6022fa29de15082bdac8c4d Mon Sep 17 00:00:00 2001 From: Ryan Lue Date: Mon, 14 Jan 2019 16:31:31 +0100 Subject: [PATCH] Refactoring: Capybara tests use wrong route check method. --- spec/support/capybara/common_actions.rb | 7 ++++--- spec/system/basic/authentication_spec.rb | 4 ++-- spec/system/basic/redirects_spec.rb | 8 ++++---- spec/system/setup/mail_accounts_spec.rb | 2 +- spec/system/setup/system_spec.rb | 10 +++++----- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/spec/support/capybara/common_actions.rb b/spec/support/capybara/common_actions.rb index c51122a8f..acf85a141 100644 --- a/spec/support/capybara/common_actions.rb +++ b/spec/support/capybara/common_actions.rb @@ -109,16 +109,17 @@ module CommonActions route = Regexp.new(Regexp.quote("/##{route}")) end - options.reverse_merge!(wait: 0, url: true) + # wait 1 sec by default because Firefox is slow + options.reverse_merge!(wait: 1, url: true) - have_current_path("/##{route}", **options) + have_current_path(route, **options) end # This is a convenient wrapper method around #have_current_route # which requires no previous `expect(page).to ` call. # # @example - # expect_current_routes('login') + # expect_current_route('login') # => checks for SPA route '/#login' # def expect_current_route(route, **options) diff --git a/spec/system/basic/authentication_spec.rb b/spec/system/basic/authentication_spec.rb index 720b14451..35afff7b4 100644 --- a/spec/system/basic/authentication_spec.rb +++ b/spec/system/basic/authentication_spec.rb @@ -8,11 +8,11 @@ RSpec.describe 'Authentication', type: :system do password: 'test', ) - have_current_route 'dashboard' + expect_current_route 'dashboard' end scenario 'Logout' do logout - have_current_route 'login', wait: 2 + expect_current_route 'login', wait: 2 end end diff --git a/spec/system/basic/redirects_spec.rb b/spec/system/basic/redirects_spec.rb index bd28238a1..152cc1e42 100644 --- a/spec/system/basic/redirects_spec.rb +++ b/spec/system/basic/redirects_spec.rb @@ -4,21 +4,21 @@ RSpec.describe 'Unauthenticated redirect', type: :system, authenticated: false d scenario 'Sessions' do visit 'system/sessions' - have_current_route 'login' + expect_current_route 'login' end scenario 'Profile' do visit 'profile/linked' - have_current_route 'login' + expect_current_route 'login' end scenario 'Ticket' do visit 'ticket/zoom/1' - have_current_route 'login' + expect_current_route 'login' end scenario 'Not existing route' do visit 'not_existing' - have_current_route 'not_existing' + expect_current_route 'not_existing' end end diff --git a/spec/system/setup/mail_accounts_spec.rb b/spec/system/setup/mail_accounts_spec.rb index 32687338f..d7919d171 100644 --- a/spec/system/setup/mail_accounts_spec.rb +++ b/spec/system/setup/mail_accounts_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Mail accounts', type: :system do # wait for verification process to finish expect(page).to have_css('.js-agent h2', text: 'Invite Colleagues', wait: 4.minutes) - have_current_route 'getting_started/agents' + expect_current_route 'getting_started/agents' end def fill_in_credentials(account) diff --git a/spec/system/setup/system_spec.rb b/spec/system/setup/system_spec.rb index 806737345..33b6b47ba 100644 --- a/spec/system/setup/system_spec.rb +++ b/spec/system/setup/system_spec.rb @@ -54,12 +54,12 @@ RSpec.describe 'System setup process', type: :system, set_up: false do # configure Email Notification expect(page).to have_css('.js-outbound h2', text: 'Email Notification') - have_current_route 'getting_started/email_notification' + expect_current_route 'getting_started/email_notification' click_on('Continue') # create email account expect(page).to have_css('.js-channel h2', text: 'Connect Channels') - have_current_route 'getting_started/channel' + expect_current_route 'getting_started/channel' click('.js-channel .btn.email') within('.js-intro') do @@ -75,7 +75,7 @@ RSpec.describe 'System setup process', type: :system, set_up: false do # wait for verification process to finish expect(page).to have_css('.js-agent h2', text: 'Invite Colleagues', wait: 2.minutes) - have_current_route 'getting_started/agents' + expect_current_route 'getting_started/agents' # invite agent1 within('.js-agent') do @@ -88,14 +88,14 @@ RSpec.describe 'System setup process', type: :system, set_up: false do expect(page).to have_css('body', text: 'Invitation sent!') # expect to still be on the same page - have_current_route 'getting_started/agents' + expect_current_route 'getting_started/agents' within('.js-agent') do click_on('Continue') end # expect Dashboard of a fresh system expect(page).to have_css('body', text: 'My Stats') - have_current_route 'clues' + expect_current_route 'clues' find(:clues_close, wait: 4).in_fixed_postion.click # verify organization and fqdn