DEV: Improve performance of system test `sign_in` helper (#19579)
Previously, calling `sign_in` would cause the browser to be redirected to `/`, and would cause the Ember app to boot. We would then call `visit()`, causing the app to boot for a second time. This commit adds a `redirect=false` option to the `/session/username/become` route. This avoids the unnecessary boot of the app, and leads to significantly faster system spec run times. In local testing, this takes the full system-spec suite for chat from ~6min to ~4min.
This commit is contained in:
parent
b11e7fb901
commit
b1b53da71d
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue