From 646d538a3d2658e75495abf0db29f2c37b0dd4d0 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 20 Aug 2025 11:54:47 +1000 Subject: [PATCH 1/2] Fix broken link This link would go to the enterprise edit screen, but didn't successfully select the payment methods panel. Ideally, the spec would try to follow the link and verify that you can see the Connect with Stripe button. But it opens the link in a new tab and I'm not sure how to test that. --- .../payment_methods/controllers/stripe_controller.js.coffee | 2 +- spec/system/admin/payment_method_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/admin/payment_methods/controllers/stripe_controller.js.coffee b/app/assets/javascripts/admin/payment_methods/controllers/stripe_controller.js.coffee index 92884d7d38..adcbc83f85 100644 --- a/app/assets/javascripts/admin/payment_methods/controllers/stripe_controller.js.coffee +++ b/app/assets/javascripts/admin/payment_methods/controllers/stripe_controller.js.coffee @@ -15,4 +15,4 @@ angular.module("admin.paymentMethods").controller "StripeController", ($scope, $ permalink = shops.filter((shop) -> shop.id == $scope.paymentMethod.preferred_enterprise_id )[0].permalink - "/admin/enterprises/#{permalink}/edit#/payment_methods" + "/admin/enterprises/#{permalink}/edit#/payment_methods_panel" diff --git a/spec/system/admin/payment_method_spec.rb b/spec/system/admin/payment_method_spec.rb index e441c9c2be..6cb29d2a3a 100644 --- a/spec/system/admin/payment_method_spec.rb +++ b/spec/system/admin/payment_method_spec.rb @@ -76,7 +76,7 @@ RSpec.describe ' connect_one = 'Connect One' expect(page).to have_link connect_one, href: edit_admin_enterprise_path(missing_account_enterprise, - anchor: "/payment_methods") + anchor: "/payment_methods_panel") select2_select "Revoked", from: "payment_method_preferred_enterprise_id" expect(page).to have_selector "#stripe-account-status .alert-box.error", From f79c1879bde6bf5a81a2707c5b744beef3220d42 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 20 Aug 2025 12:32:31 +1000 Subject: [PATCH 2/2] Test that you can actually get to Stripe to connect your account Well.. almost. --- spec/system/admin/payment_method_spec.rb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/payment_method_spec.rb b/spec/system/admin/payment_method_spec.rb index 6cb29d2a3a..1a6c519a59 100644 --- a/spec/system/admin/payment_method_spec.rb +++ b/spec/system/admin/payment_method_spec.rb @@ -73,10 +73,24 @@ RSpec.describe ' select2_select "Missing", from: "payment_method_preferred_enterprise_id" expect(page).to have_selector "#stripe-account-status .alert-box.error", text: 'No Stripe account exists for this enterprise.' - connect_one = 'Connect One' - expect(page).to have_link connect_one, - href: edit_admin_enterprise_path(missing_account_enterprise, - anchor: "/payment_methods_panel") + click_link 'Connect One' # opens in new tab + + new_window = windows.last + page.within_window new_window do + expect(page).to have_content "Settings: Missing" + # we should be on the Payment Methods tab already + expect(page).to have_content "Use the button to the right to get started." + page.find("a", text: "Connect with Stripe").click # it's not a proper link without href + + expect(page).to have_content "connect your Stripe account to the OFN." + href = connect_admin_stripe_accounts_path(enterprise_id: missing_account_enterprise) + expect(page).to have_link "I Agree", href: + + # Blocked by capybara. probably don't need to test this. + # click_link "I Agree" + # expect(page).to have_current_path("https://connect.stripe.com/", url: true) + end + new_window.close select2_select "Revoked", from: "payment_method_preferred_enterprise_id" expect(page).to have_selector "#stripe-account-status .alert-box.error",