FIX: Ensure deletion of product upon confirmation (#195)
Ensure deletion of product upon confirmation
This commit is contained in:
parent
7361721ec0
commit
0d28c9a56d
|
@ -56,7 +56,7 @@
|
|||
|
||||
<DButton
|
||||
@action={{route-action "destroyProduct"}}
|
||||
@actionParam="product"
|
||||
@actionParam={{product}}
|
||||
@icon="trash-alt"
|
||||
class="btn-danger btn no-text btn-icon"
|
||||
/>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:product, from: "DiscourseSubscriptions::Product")
|
||||
Fabricator(:customer, from: "DiscourseSubscriptions::Customer")
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:customer, from: "DiscourseSubscriptions::Customer")
|
||||
Fabricator(:product, from: "DiscourseSubscriptions::Product")
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Pages
|
||||
class AdminSubscriptionProduct < PageObjects::Pages::Base
|
||||
PRODUCTS_TABLE_SELECTOR = "table.discourse-patrons-table"
|
||||
|
||||
def visit_products
|
||||
visit("/admin/plugins/discourse-subscriptions/products")
|
||||
self
|
||||
end
|
||||
|
||||
def has_product?(name)
|
||||
has_css?("table.discourse-patrons-table tr", text: name)
|
||||
self
|
||||
end
|
||||
|
||||
def has_number_of_products?(count)
|
||||
has_css?("table.discourse-patrons-table tr", count:)
|
||||
self
|
||||
end
|
||||
|
||||
def click_trash_nth_row(row)
|
||||
find("table.discourse-patrons-table tr:nth-child(#{row}) button.btn-danger").click()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,9 +2,31 @@
|
|||
|
||||
describe "Subscription products", type: :system do
|
||||
fab!(:admin)
|
||||
fab!(:product) { Fabricate(:product, external_id: "prod_OiKyO6ZMFCIhQa") }
|
||||
fab!(:product) { Fabricate(:product, external_id: "prod_OiK") }
|
||||
let(:dialog) { PageObjects::Components::Dialog.new }
|
||||
let(:product_subscriptions_page) { PageObjects::Pages::AdminSubscriptionProduct.new }
|
||||
|
||||
before { SiteSetting.discourse_subscriptions_enabled = true }
|
||||
before do
|
||||
SiteSetting.discourse_subscriptions_enabled = true
|
||||
|
||||
SiteSetting.discourse_subscriptions_secret_key = "sk_test_51xuu"
|
||||
SiteSetting.discourse_subscriptions_public_key = "pk_test_51xuu"
|
||||
|
||||
# # this needs to be stubbed or it will try to make a request to stripe
|
||||
one_product = {
|
||||
id: "prod_OiK",
|
||||
active: true,
|
||||
name: "Tomtom",
|
||||
metadata: {
|
||||
description: "Photos of tomtom",
|
||||
repurchaseable: true,
|
||||
},
|
||||
}
|
||||
::Stripe::Product.stubs(:list).returns({ data: [one_product] })
|
||||
::Stripe::Product.stubs(:delete).returns({ id: "prod_OiK" })
|
||||
::Stripe::Product.stubs(:retrieve).returns(one_product)
|
||||
::Stripe::Price.stubs(:list).returns({ data: [] })
|
||||
end
|
||||
|
||||
it "shows the login modal" do
|
||||
visit("/s")
|
||||
|
@ -13,4 +35,15 @@ describe "Subscription products", type: :system do
|
|||
|
||||
expect(page).to have_css(".modal-container .login-modal")
|
||||
end
|
||||
|
||||
it "shows products on the products and allows deletion" do
|
||||
sign_in(admin)
|
||||
|
||||
product_subscriptions_page.visit_products.has_product?("Tomtom")
|
||||
|
||||
product_subscriptions_page.click_trash_nth_row(1)
|
||||
dialog.click_yes
|
||||
|
||||
product_subscriptions_page.has_number_of_products?(0)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue