Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Improve chat tracking and system test assertions

Juan José Matab438a1c8ddef
diff --git a/test/controllers/chats_controller_test.rb b/test/controllers/chats_controller_test.rb
index a3f7f58ebe..79b3641f3a 100644
--- a/test/controllers/chats_controller_test.rb
+++ b/test/controllers/chats_controller_test.rb
@@ -21,8 +21,13 @@ class ChatsControllerTest < ActionDispatch::IntegrationTest
end
test "shows chat" do
- get chat_url(chats(:one))
+ chat = chats(:one)
+ @user.update!(last_viewed_chat: nil)
+
+ get chat_url(chat)
+
assert_response :success
+ assert_equal chat, @user.reload.last_viewed_chat
end
test "destroys chat" do
diff --git a/test/system/chats_test.rb b/test/system/chats_test.rb
index 3796211078..23aa48aec8 100644
--- a/test/system/chats_test.rb
+++ b/test/system/chats_test.rb
@@ -31,24 +31,13 @@ class ChatsTest < ApplicationSystemTestCase
test "sidebar shows last viewed chat" do
with_env_overrides OPENAI_ACCESS_TOKEN: "test-token" do
- @user.update!(ai_enabled: true)
- chat_title = @user.chats.first.title
-
- visit root_url
-
- click_on chat_title
-
- # Wait for the chat to actually load before refreshing
- within "#chat-container" do
- assert_selector "h1", text: chat_title
- end
+ chat = @user.chats.first
+ @user.update!(ai_enabled: true, last_viewed_chat: chat)
- # Page refresh
visit root_url
- # After page refresh, we're still on the last chat we were viewing
within "#chat-container" do
- assert_selector "h1", text: chat_title
+ assert_selector "h1", text: chat.title
end
end
end
diff --git a/test/system/property_test.rb b/test/system/property_test.rb
index 19941144f6..7e905b645a 100644
--- a/test/system/property_test.rb
+++ b/test/system/property_test.rb
@@ -14,7 +14,7 @@ class PropertiesEditTest < ApplicationSystemTestCase
test "can persist property subtype" do
click_link "[system test] Property Account"
open_account_edit_dialog
- assert_equal "single_family_home", find("#account_accountable_attributes_subtype").value
+ assert_field "account_accountable_attributes_subtype", with: "single_family_home"
end
private
diff --git a/test/system/transaction_category_select_test.rb b/test/system/transaction_category_select_test.rb
index c219cdbec5..1ae2b9fc07 100644
--- a/test/system/transaction_category_select_test.rb
+++ b/test/system/transaction_category_select_test.rb
@@ -17,7 +17,11 @@ class TransactionCategorySelectTest < ApplicationSystemTestCase
assert_text 'Create "Inline Test Category"'
click_button 'Create "Inline Test Category"'
- assert_text "Inline Test Category"
+ assert_selector(
+ "[data-category-select-target='option'][aria-selected='true']",
+ text: "Inline Test Category",
+ visible: :all
+ )
end
end