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:
David Taylor
2022-12-22 16:03:27 +00:00
committed by GitHub
parent b11e7fb901
commit b1b53da71d
7 changed files with 13 additions and 2 deletions

View File

@@ -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