Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve performance of system test `sign_in` helper (#19579)

David Taylorb1b53da71d9d
diff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rb
index ce1a97a616a..ecc653c88d6 100644
--- a/app/controllers/session_controller.rb
+++ b/app/controllers/session_controller.rb
@@ -113,7 +113,12 @@ class SessionController < ApplicationController
raise "User #{params[:session_id]} not found" if user.blank?
log_on_user(user)
- redirect_to path("/")
+
+ if params[:redirect] == "false"
+ render plain: "Signed in to #{params[:session_id]} successfully"
+ else
+ redirect_to path("/")
+ end
end
end
diff --git a/plugins/chat/spec/system/channel_selector_modal_spec.rb b/plugins/chat/spec/system/channel_selector_modal_spec.rb
index 5aa834362b5..2cb9f5713fb 100644
--- a/plugins/chat/spec/system/channel_selector_modal_spec.rb
+++ b/plugins/chat/spec/system/channel_selector_modal_spec.rb
@@ -9,6 +9,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true do
before do
chat_system_bootstrap
sign_in(current_user)
+ visit("/")
end
KEY_MODIFIER = RUBY_PLATFORM =~ /darwin/i ? :meta : :control
diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rb
index 50f83a87073..7c86250da1d 100644
--- a/plugins/chat/spec/system/navigation_spec.rb
+++ b/plugins/chat/spec/system/navigation_spec.rb
@@ -19,6 +19,8 @@ RSpec.describe "Navigation", type: :system, js: true do
context "when clicking chat icon and drawer is viewing channel" do
it "navigates to index" do
+ visit("/")
+
chat_page.open_from_header
chat_drawer_page.open_channel(category_channel_2)
chat_page.open_from_header
diff --git a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
index 11616a6a4e0..33f7a9b78dd 100644
--- a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
+++ b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
@@ -158,6 +158,7 @@ RSpec.describe "Sidebar navigation menu", type: :system, js: true do
end
it "displays all participants names" do
+ visit("/")
expect(
page.find(
".sidebar-section-chat-dms a.sidebar-section-link:nth-child(1) .sidebar-section-link-content-text",
diff --git a/plugins/chat/spec/system/unfollow_dm_channel_spec.rb b/plugins/chat/spec/system/unfollow_dm_channel_spec.rb
index 361e7412970..aff4a419009 100644
--- a/plugins/chat/spec/system/unfollow_dm_channel_spec.rb
+++ b/plugins/chat/spec/system/unfollow_dm_channel_spec.rb
@@ -16,6 +16,7 @@ RSpec.describe "Unfollow dm channel", type: :system, js: true do
context "when receiving a message after unfollowing" do
it "correctly shows the channel" do
+ visit("/")
find(".channel-#{dm_channel_1.id}").hover
find(".channel-#{dm_channel_1.id} .sidebar-section-link-hover").click
diff --git a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
index 7ef58ab2fbd..1c4e2a71e00 100644
--- a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
+++ b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb
@@ -175,6 +175,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
using_session(:user_1) do
sign_in(other_user)
+ visit("/")
find(".header-dropdown-toggle.current-user").click
expect(find("#user-menu-button-chat-notifications")).to have_content(1)
diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb
index ee9faba604b..9d5054a75d5 100644
--- a/spec/support/system_helpers.rb
+++ b/spec/support/system_helpers.rb
@@ -12,7 +12,7 @@ module SystemHelpers
end
def sign_in(user)
- visit "/session/#{user.encoded_username}/become"
+ visit "/session/#{user.encoded_username}/become.json?redirect=false"
end
def sign_out