Skip to content

Commit

Permalink
Adds content for Stripe Account settings component when Stripe utilit…
Browse files Browse the repository at this point in the history
…y missing (#1842)
  • Loading branch information
rosschapman authored Oct 24, 2023
1 parent 1632384 commit 2c2f531
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
<%= render CardComponent.new(classes: "flex flex-col h-full
<%= render CardComponent.new(dom_id: "stripe_overview", classes: "flex flex-col h-full
") do %>
<header class="flex font-bold">
<%= marketplace_stripe_utility&.name %>
</header>
<footer class="flex flex-row justify-between mt-3">
<%= render ButtonComponent.new(
<%- if marketplace.stripe_api_key? %>
<header class="flex font-bold">
<%= marketplace_stripe_utility.name %>
</header>
<footer class="flex flex-row justify-between mt-3">
<%= render ButtonComponent.new(
label: "View #{t('marketplace.stripe_accounts.show.link_to')}",
title: t('marketplace.stripe_accounts.show.link_to'),
title: "View #{t('marketplace.stripe_accounts.show.link_to')}",
href: marketplace.location(:index, child: :stripe_account),
method: :get,
scheme: :secondary) %>
</footer>
</footer>
<%- else %>
<header class="flex"
>To start accepting payments, add your Stripe Account.</header>
<footer class="flex flex-row justify-between mt-3
">
<%= render ButtonComponent.new(
label: "Add #{t('marketplace.stripe_accounts.show.link_to')}",
title: "Add #{t('marketplace.stripe_accounts.show.link_to')}",
href: marketplace.location(:index, child: :stripe_account),
method: :get,
scheme: :secondary
)
%>
</footer>
<%- end %>
<%- end %>
29 changes: 20 additions & 9 deletions spec/components/marketplace/stripe_overview_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
end

click_on("Payment Settings")
click_on("View Stripe Account")
within("#stripe_overview") do
click_on("Add Stripe Account")
end
click_on("Add a Stripe API key to #{space.name}")
click_on("Add Utility")
select("stripe", from: "Type")
Expand Down

0 comments on commit 2c2f531

Please sign in to comment.