Refactoring: Capybara tests use wrong route check method.

This commit is contained in:
Ryan Lue 2019-01-14 16:31:31 +01:00 committed by Thorsten Eckel
parent 6faaee3a97
commit ce27170434
5 changed files with 16 additions and 15 deletions

View file

@ -109,16 +109,17 @@ module CommonActions
route = Regexp.new(Regexp.quote("/##{route}")) route = Regexp.new(Regexp.quote("/##{route}"))
end 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 end
# This is a convenient wrapper method around #have_current_route # This is a convenient wrapper method around #have_current_route
# which requires no previous `expect(page).to ` call. # which requires no previous `expect(page).to ` call.
# #
# @example # @example
# expect_current_routes('login') # expect_current_route('login')
# => checks for SPA route '/#login' # => checks for SPA route '/#login'
# #
def expect_current_route(route, **options) def expect_current_route(route, **options)

View file

@ -8,11 +8,11 @@ RSpec.describe 'Authentication', type: :system do
password: 'test', password: 'test',
) )
have_current_route 'dashboard' expect_current_route 'dashboard'
end end
scenario 'Logout' do scenario 'Logout' do
logout logout
have_current_route 'login', wait: 2 expect_current_route 'login', wait: 2
end end
end end

View file

@ -4,21 +4,21 @@ RSpec.describe 'Unauthenticated redirect', type: :system, authenticated: false d
scenario 'Sessions' do scenario 'Sessions' do
visit 'system/sessions' visit 'system/sessions'
have_current_route 'login' expect_current_route 'login'
end end
scenario 'Profile' do scenario 'Profile' do
visit 'profile/linked' visit 'profile/linked'
have_current_route 'login' expect_current_route 'login'
end end
scenario 'Ticket' do scenario 'Ticket' do
visit 'ticket/zoom/1' visit 'ticket/zoom/1'
have_current_route 'login' expect_current_route 'login'
end end
scenario 'Not existing route' do scenario 'Not existing route' do
visit 'not_existing' visit 'not_existing'
have_current_route 'not_existing' expect_current_route 'not_existing'
end end
end end

View file

@ -13,7 +13,7 @@ RSpec.describe 'Mail accounts', type: :system do
# wait for verification process to finish # wait for verification process to finish
expect(page).to have_css('.js-agent h2', text: 'Invite Colleagues', wait: 4.minutes) 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 end
def fill_in_credentials(account) def fill_in_credentials(account)

View file

@ -54,12 +54,12 @@ RSpec.describe 'System setup process', type: :system, set_up: false do
# configure Email Notification # configure Email Notification
expect(page).to have_css('.js-outbound h2', text: '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') click_on('Continue')
# create email account # create email account
expect(page).to have_css('.js-channel h2', text: 'Connect Channels') 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') click('.js-channel .btn.email')
within('.js-intro') do 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 # wait for verification process to finish
expect(page).to have_css('.js-agent h2', text: 'Invite Colleagues', wait: 2.minutes) 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 # invite agent1
within('.js-agent') do 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(page).to have_css('body', text: 'Invitation sent!')
# expect to still be on the same page # expect to still be on the same page
have_current_route 'getting_started/agents' expect_current_route 'getting_started/agents'
within('.js-agent') do within('.js-agent') do
click_on('Continue') click_on('Continue')
end end
# expect Dashboard of a fresh system # expect Dashboard of a fresh system
expect(page).to have_css('body', text: 'My Stats') 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 find(:clues_close, wait: 4).in_fixed_postion.click
# verify organization and fqdn # verify organization and fqdn