Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Sign goal chart system tests in on the real clock (#5511)

jaysbeekay306f87f3b239
diff --git a/test/system/goal_projection_chart_test.rb b/test/system/goal_projection_chart_test.rb
index c2baa2d6a4..dfe81fdbc2 100644
--- a/test/system/goal_projection_chart_test.rb
+++ b/test/system/goal_projection_chart_test.rb
@@ -18,7 +18,12 @@ class GoalProjectionChartTest < ApplicationSystemTestCase
preferences: (@user.preferences || {}).merge("preview_features_enabled" => true),
show_ai_sidebar: false
)
- travel_to(TODAY) { sign_in @user }
+ # Sign in on the real clock. A session dated TODAY is idle past
+ # Session::INACTIVITY_TIMEOUT by the real clock, so any request the browser
+ # makes between travel_to blocks would end it and land on the login page.
+ # TODAY is in the past, so a session from the real clock never looks idle
+ # inside travel_to(TODAY).
+ sign_in @user
end
test "a target on a gridline keeps its full label inside the chart" do
@@ -89,7 +94,7 @@ class GoalProjectionChartTest < ApplicationSystemTestCase
test "a window of daily ticks keeps the label of every month it covers" do
travel_to Date.new(2027, 1, 25) do
- # The setup session is three months old by now.
+ # By this date the setup session can be idle past the timeout.
sign_in @user
visit_goal(target: 10_000, target_date: Date.new(2027, 2, 1))
resize_chart(428)
@@ -145,6 +150,10 @@ class GoalProjectionChartTest < ApplicationSystemTestCase
# draws a halo'd shortfall label beside the halo'd target label.
test "in the dark theme every halo and ring matches the card" do
@user.update!(theme: "dark")
+ # A request on the real clock, between the setup sign-in and travel_to:
+ # the setup session must still be live for it.
+ visit root_path
+ assert_no_current_path new_session_path
travel_to TODAY do
visit_goal(target: 10_000, saved: 3_000, pace: 200)
assert_selector "html[data-theme='dark']"
diff --git a/test/system/loan_payoff_chart_test.rb b/test/system/loan_payoff_chart_test.rb
index 09c93887ae..defd253804 100644
--- a/test/system/loan_payoff_chart_test.rb
+++ b/test/system/loan_payoff_chart_test.rb
@@ -20,11 +20,12 @@ class LoanPayoffChartTest < ApplicationSystemTestCase
TODAY = Date.new(2027, 1, 15)
SERIES = %w[actual scheduled projected].freeze
- # Sign in on the pinned date: a session signed in at the real clock would
- # count as idle beyond Session::INACTIVITY_TIMEOUT once the tests travel to
- # TODAY, and every visit would land on the login page.
+ # Sign in at the later of TODAY and the real clock. The session must not
+ # count as idle beyond Session::INACTIVITY_TIMEOUT inside travel_to(TODAY),
+ # nor on the real clock, which serves any request the browser makes between
+ # travel_to blocks. Either way an idle session lands on the login page.
setup do
- travel_to(TODAY) { sign_in @user = users(:family_admin) }
+ travel_to([ Date.current, TODAY ].max) { sign_in @user = users(:family_admin) }
end
test "the chart paints all three lines, in the light theme and the dark" do