Skip to content

Commit

Permalink
Match capy click selectors with underlying html (#1856)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosschapman authored Oct 26, 2023
1 parent 64e6c56 commit 9c4568b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,3 @@ Style/TrailingCommaInArrayLiteral:
Rails/CreateTableWithTimestamps:
Exclude:
- db/schema.rb

Capybara/ClickLinkOrButtonStyle:
EnforcedStyle: link_or_button
10 changes: 5 additions & 5 deletions spec/furniture/marketplace/buying_products_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def url_options
it "Works for Guests" do # rubocop:disable RSpec/ExampleLength
visit(polymorphic_path(marketplace.room.location))
select(marketplace.delivery_areas.first.label, from: "cart[delivery_area_id]")
click_on("Save changes")
click_button("Save changes")

add_product_to_cart(marketplace.products.first)

expect(page).to have_content("Total: #{humanized_money_with_symbol(marketplace.products.first.price + marketplace.delivery_areas.first.price)}")

click_on("Checkout")
click_link("Checkout")

set_delivery_details(delivery_address: "123 N West St Oakland, CA",
contact_email: "[email protected]",
Expand Down Expand Up @@ -62,19 +62,19 @@ def url_options

def add_product_to_cart(product)
within("##{dom_id(product).gsub("product", "cart_product")}") do
click_on(t("marketplace.cart_product_component.add"))
click_link(t("marketplace.cart_product_component.add"))
end
end

def set_delivery_details(delivery_address:, contact_phone_number:, contact_email:)
fill_in("Delivery address", with: delivery_address)
fill_in("Contact phone number", with: contact_phone_number)
fill_in("Contact email", with: contact_email)
click_on("Save changes")
click_button("Save changes")
end

def pay(card_number:, card_expiry:, card_cvc:, billing_name:, email:, billing_postal_code:)
click_on("Make Payment")
click_button("Make Payment")
fill_in("cardNumber", with: card_number)
fill_in("cardExpiry", with: card_expiry)
fill_in("cardCvc", with: card_cvc)
Expand Down
26 changes: 13 additions & 13 deletions spec/furniture/marketplace/collecting_payments_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
visit polymorphic_path(marketplace.room.location)

within("##{dom_id(marketplace, :onboarding)}") do
click_on("Manage Marketplace")
click_link("Manage Marketplace")
end

click_on("Payment Settings")
click_link("Payment Settings")
within("#stripe_overview") do
click_on("Add Stripe Account")
click_link("Add Stripe Account")
end
click_on("Add a Stripe API key to #{space.name}")
click_on("Add Utility")
click_link("Add a Stripe API key to #{space.name}")
click_link("Add Utility")
select("stripe", from: "Type")
fill_in("Name", with: "Test Stripe Account")
click_on("Create")
click_on("Edit stripe 'Test Stripe Account'")
click_button("Create")
click_link("Edit stripe 'Test Stripe Account'")
fill_in("Api token", with: ENV.fetch("STRIPE_API_KEY", "not-a-real-key"))
click_on("Save changes to Stripe Utility")
click_button("Save changes to Stripe Utility")

expect(page).to have_content("Test Stripe Account")
expect(space.utilities).to exist(utility_slug: "stripe")
expect(space.utilities.find_by(utility_slug: "stripe").utility.api_token).to eq(ENV.fetch("STRIPE_API_KEY", "not-a-real-key"))

visit polymorphic_path(marketplace.location(:edit))
click_on("Payment Settings")
click_on("View Stripe Account")
click_link("Payment Settings")
click_link("View Stripe Account")
expect(page).to have_content("Connect to Stripe")
end

Expand All @@ -46,10 +46,10 @@
visit polymorphic_path(marketplace.room.location)

within("##{dom_id(marketplace, :onboarding)}") do
click_on("Manage Marketplace")
click_link("Manage Marketplace")
end
click_on("Payment Settings")
click_on("View Stripe Account")
click_link("Payment Settings")
click_link("View Stripe Account")
expect(page).to have_content("Connect to Stripe")
# @todo actually figure out how to do the connect to stripe bit :X
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/system_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Spec
module SystemHelpers
def sign_in(user, space)
visit(polymorphic_path(space.location))
click_link_or_button("Sign in")
click_link("Sign in")
fill_in("authenticated_session[contact_location]", with: user.email)
find('input[type="submit"]').click
perform_enqueued_jobs
Expand Down
6 changes: 3 additions & 3 deletions spec/system/furniture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
def add_gizmo(type, room:)
visit(polymorphic_path(room.location(:edit)))
select(type, from: "Type of gizmo")
click_link_or_button("Add Gizmo")
click_button("Add Gizmo")
end

def remove_gizmo(type, room:)
visit(polymorphic_path(room.location(:edit)))
expect(page).to have_text("Markdown Text Block")
within("##{dom_id(room.gizmos.first)}") do
click_link_or_button "Configure Markdown Text Block"
click_link "Configure Markdown Text Block"
end
click_link_or_button "Remove Gizmo"
click_link "Remove Gizmo"
end
end
4 changes: 2 additions & 2 deletions spec/system/sections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

context "when the Section has no Gizmos" do
it "deletes the Section from the Database" do
click_on(I18n.t("rooms.destroy.link_to"))
click_button(I18n.t("rooms.destroy.link_to"))

expect(page).to have_content(I18n.t("rooms.destroy.success", room_name: section.name))
expect(space.rooms).not_to be_exist(id: section.id)
Expand All @@ -41,7 +41,7 @@
# moment - ZS 10/18/23
it "requires confirmation" do
accept_alert(I18n.t("rooms.destroy.confirm", room_name: section.name)) do
click_on(I18n.t("rooms.destroy.link_to"))
click_button(I18n.t("rooms.destroy.link_to"))
end

expect(page).to have_content(I18n.t("rooms.destroy.success", room_name: section.name))
Expand Down

0 comments on commit 9c4568b

Please sign in to comment.