Browse Source

Refactoring: Capybara tests use wrong route check method.

Ryan Lue 6 years ago
parent
commit
ce27170434

+ 4 - 3
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)

+ 2 - 2
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

+ 4 - 4
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

+ 1 - 1
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)

+ 5 - 5
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