From 8f703d16696e2d61e3f11bf756f2c946358a6ab6 Mon Sep 17 00:00:00 2001 From: Ross Chapman Date: Mon, 23 Oct 2023 18:01:47 -0700 Subject: [PATCH] Updates markup and adds tests --- .../stripe_overview_component.html.erb | 27 +++++++++++++---- .../stripe_overview_component_spec.rb | 29 +++++++++++++------ .../collecting_payments_system_spec.rb | 6 ++-- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/app/components/marketplace/stripe_overview_component/stripe_overview_component.html.erb b/app/components/marketplace/stripe_overview_component/stripe_overview_component.html.erb index f67c97130..d8382010d 100644 --- a/app/components/marketplace/stripe_overview_component/stripe_overview_component.html.erb +++ b/app/components/marketplace/stripe_overview_component/stripe_overview_component.html.erb @@ -1,14 +1,29 @@ <%= render CardComponent.new(classes: "flex flex-col h-full ") do %> -
- <%= marketplace_stripe_utility&.name %> -
- + <%- else %> +
To start accepting payments, add your Stripe Account.
+ + <%- end %> <%- end %> diff --git a/spec/components/marketplace/stripe_overview_component_spec.rb b/spec/components/marketplace/stripe_overview_component_spec.rb index a9295d606..91550e636 100644 --- a/spec/components/marketplace/stripe_overview_component_spec.rb +++ b/spec/components/marketplace/stripe_overview_component_spec.rb @@ -3,13 +3,24 @@ require "rails_helper" RSpec.describe Marketplace::StripeOverviewComponent, type: :component do - pending "add some examples to (or delete) #{__FILE__}" - - # it "renders something useful" do - # expect( - # render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html - # ).to include( - # "Hello, components!" - # ) - # end + # pending "add some examples to (or delete) #{__FILE__}" + subject(:output) { render_inline(component) } + + let(:component) { described_class.new(marketplace: marketplace) } + + context "when the Marketplace has a Stripe Utility" do + let(:marketplace) { create(:marketplace, :with_stripe_utility) } + + it { is_expected.to have_content marketplace.stripe_utility.name } + + it { is_expected.to have_link "View #{I18n.t("marketplace.stripe_accounts.show.link_to")}" } + end + + context "when the Marketplace is missing a Stripe Utility" do + let(:marketplace) { create(:marketplace) } + + it { is_expected.to have_link "Add #{I18n.t("marketplace.stripe_accounts.show.link_to")}" } + + it { is_expected.to have_content "To start accepting payments, add your Stripe Account." } + end end diff --git a/spec/furniture/marketplace/collecting_payments_system_spec.rb b/spec/furniture/marketplace/collecting_payments_system_spec.rb index 52f677949..d5fc28e9b 100644 --- a/spec/furniture/marketplace/collecting_payments_system_spec.rb +++ b/spec/furniture/marketplace/collecting_payments_system_spec.rb @@ -19,7 +19,7 @@ end click_on("Payment Settings") - click_on("View Stripe Account") + click_on("Stripe Account") click_on("Add a Stripe API key to #{space.name}") click_on("Add Utility") select("stripe", from: "Type") @@ -35,7 +35,7 @@ visit polymorphic_path(marketplace.location(:edit)) click_on("Payment Settings") - click_on("View Stripe Account") + click_on("Stripe Account") expect(page).to have_content("Connect to Stripe") end @@ -47,7 +47,7 @@ click_on("Manage Marketplace") end click_on("Payment Settings") - click_on("View Stripe Account") + click_on("Stripe Account") expect(page).to have_content("Connect to Stripe") # @todo actually figure out how to do the connect to stripe bit :X end