The personal finance app for everyone
Fix system test failures in API keys and trades tests
Josh Pigfordfc921c0cd2e8
diff --git a/test/system/settings/api_keys_test.rb b/test/system/settings/api_keys_test.rbindex f2e391cc..0c761377 100644--- a/test/system/settings/api_keys_test.rb+++ b/test/system/settings/api_keys_test.rb@@ -55,7 +55,7 @@ class Settings::ApiKeysTest < ApplicationSystemTestCaseuser: @user,name: "Production API Key",display_key: "test_plain_key_123",- scopes: [ "read", "read_write" ]+ scopes: [ "read_write" ])visit settings_api_key_path@@ -63,7 +63,6 @@ class Settings::ApiKeysTest < ApplicationSystemTestCaseassert_text "Your API Key"assert_text "Production API Key"assert_text "Active"- assert_text "Read Only"assert_text "Read/Write"assert_text "Never used"assert_link "Create New Key"@@ -96,12 +95,16 @@ class Settings::ApiKeysTest < ApplicationSystemTestCasevisit settings_api_key_pathclick_link "Create New Key"- assert_current_path new_settings_api_key_path+ # Should be on the new API key form+ assert_text "Create New API Key"+fill_in "API Key Name", with: "New API Key"choose "Read Only"click_button "Create API Key"+ # Should redirect to show page with new keyassert_text "New API Key"+ assert_text "Your API Key"# Old key should be revokedapi_key.reload@@ -118,13 +121,23 @@ class Settings::ApiKeysTest < ApplicationSystemTestCasevisit settings_api_key_path- # Mock the confirmation dialog- accept_confirm "Are you sure you want to revoke this API key?" do- click_button "Revoke Key"+ # 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++ 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.5assert_text "Create Your API Key"- assert_no_text "Your API Key"+ assert_text "Get programmatic access to your Maybe data"# Key should be revoked in the databaseapi_key.reload@@ -160,8 +173,9 @@ class Settings::ApiKeysTest < ApplicationSystemTestCaseclick_button "Create API Key"# Should stay on form with validation error- assert_current_path settings_api_key_path # POST path+ assert_current_path new_settings_api_key_pathassert_field "API Key Name" # Form should still be visible+ # The form might not show the validation error inline, but should remain on the formendtest "should show last used timestamp when API key has been used" dodiff --git a/test/system/trades_test.rb b/test/system/trades_test.rbindex 930ab296..22e45e1e 100644--- a/test/system/trades_test.rb+++ b/test/system/trades_test.rb@@ -42,7 +42,7 @@ class TradesTest < ApplicationSystemTestCaseopen_new_trade_modalselect "Sell", from: "Type"- fill_in "Ticker symbol", with: aapl.ticker+ fill_in "Ticker symbol", with: "AAPL"fill_in "Date", with: Date.currentfill_in "Quantity", with: qtyfill_in "entry[price]", with: 215.33