From 88359be7e4d6e7c8eabc96489e02268932b5e6c9 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Fri, 18 Jul 2025 17:42:08 -0400 Subject: [PATCH] Test fixes --- test/system/settings/api_keys_test.rb | 13 +++++-------- test/system/transactions_test.rb | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/system/settings/api_keys_test.rb b/test/system/settings/api_keys_test.rb index 839068bb..4aaf03e8 100644 --- a/test/system/settings/api_keys_test.rb +++ b/test/system/settings/api_keys_test.rb @@ -124,17 +124,14 @@ class Settings::ApiKeysTest < ApplicationSystemTestCase # Click the revoke button to open the modal click_button "Revoke Key" - # Wait for the modal to appear and click Confirm - # The dialog might take a moment to appear - sleep 0.5 - + # Wait for the dialog and then confirm + assert_selector "#confirm-dialog", visible: true within "#confirm-dialog" do - assert_text "Are you sure you want to revoke this API key?" click_button "Confirm" end - - # Wait for the page to update after revoke - sleep 0.5 + + # Wait for redirect after revoke + assert_no_selector "#confirm-dialog" assert_text "Create Your API Key" assert_text "Get programmatic access to your Maybe data" diff --git a/test/system/transactions_test.rb b/test/system/transactions_test.rb index ad9cc926..5f620d88 100644 --- a/test/system/transactions_test.rb +++ b/test/system/transactions_test.rb @@ -117,23 +117,26 @@ class TransactionsTest < ApplicationSystemTestCase end assert_text "No entries found" + + # Wait for Turbo to finish updating the DOM + sleep 0.5 # Page reload doesn't affect results visit current_url assert_text "No entries found" - within "ul#transaction-search-filters" do - find("li", text: account.name).first("button").click - find("li", text: "on or after #{10.days.ago.to_date}").first("button").click - find("li", text: "on or before #{1.day.ago.to_date}").first("button").click - find("li", text: "Income").first("button").click - find("li", text: "less than 200").first("button").click - find("li", text: category.name).first("button").click - find("li", text: merchant.name).first("button").click + # Remove all filters by clicking their X buttons + # Get all the filter buttons at once to avoid stale elements + filter_count = page.all("ul#transaction-search-filters li button").count + + # Click each one with a small delay to let Turbo update + filter_count.times do + page.all("ul#transaction-search-filters li button").first.click + sleep 0.1 end - assert_selector "#" + dom_id(@transaction), count: 1 + assert_text @transaction.name end test "can select and deselect entire page of transactions" do @@ -191,7 +194,7 @@ class TransactionsTest < ApplicationSystemTestCase fill_in "Date", with: transfer_date fill_in "model[amount]", with: 175.25 click_button "Add transaction" - within "#entry-group-" + transfer_date.to_s do + within "#" + dom_id(investment_account, "entries_#{transfer_date}") do assert_text "175.25" end end