mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-31 06:31:41 +00:00
Updates checkout tests
Adds out of stock check as helper
This commit is contained in:
@@ -66,4 +66,12 @@ module CheckoutHelper
|
||||
click_on "Complete order"
|
||||
expect(page).to have_content "Back To Store"
|
||||
end
|
||||
|
||||
def out_of_stock_check(step)
|
||||
visit checkout_step_path(step)
|
||||
|
||||
expect(page).not_to have_selector 'closing', text: "Checkout now"
|
||||
expect(page).to have_selector 'closing', text: "Your shopping cart"
|
||||
expect(page).to have_content "An item in your cart has become unavailable"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,6 +82,18 @@ describe "As a consumer, I want to checkout my order" do
|
||||
visit checkout_path
|
||||
end
|
||||
|
||||
context "when a line item is out of stock" do
|
||||
before do
|
||||
variant.on_demand = false
|
||||
variant.on_hand = 0
|
||||
variant.save!
|
||||
end
|
||||
|
||||
it "returns me to the cart with an error message" do
|
||||
out_of_stock_check(:details)
|
||||
end
|
||||
end
|
||||
|
||||
context "when no selecting a shipping method" do
|
||||
before do
|
||||
fill_out_details
|
||||
|
||||
@@ -27,7 +27,6 @@ describe "As a consumer, I want to checkout my order" do
|
||||
ship_address_id: nil, state: "cart",
|
||||
line_items: [create(:line_item, variant:)])
|
||||
}
|
||||
|
||||
let(:fee_tax_rate) { create(:tax_rate, amount: 0.10, zone:, included_in_price: true) }
|
||||
let(:fee_tax_category) { create(:tax_category, tax_rates: [fee_tax_rate]) }
|
||||
let(:enterprise_fee) { create(:enterprise_fee, amount: 1.23, tax_category: fee_tax_category) }
|
||||
@@ -58,6 +57,18 @@ describe "As a consumer, I want to checkout my order" do
|
||||
visit checkout_path
|
||||
end
|
||||
|
||||
context "when a line item is out of stock" do
|
||||
before do
|
||||
variant.on_demand = false
|
||||
variant.on_hand = 0
|
||||
variant.save!
|
||||
end
|
||||
|
||||
it "returns me to the cart with an error message" do
|
||||
out_of_stock_check(:payment)
|
||||
end
|
||||
end
|
||||
|
||||
context "payment step" do
|
||||
let(:order) { create(:order_ready_for_payment, distributor:) }
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ describe "As a consumer, I want to checkout my order" do
|
||||
create(:shipping_method, require_ship_address: true,
|
||||
name: "A Free Shipping with required address")
|
||||
}
|
||||
let!(:payment_with_fee) {
|
||||
create(:payment_method, distributors: [distributor],
|
||||
name: "Payment with Fee", description: "Payment with fee",
|
||||
calculator: Calculator::FlatRate.new(preferred_amount: 1.23))
|
||||
}
|
||||
|
||||
before do
|
||||
add_enterprise_fee enterprise_fee
|
||||
@@ -51,6 +56,18 @@ describe "As a consumer, I want to checkout my order" do
|
||||
visit checkout_path
|
||||
end
|
||||
|
||||
context "when a line item is out of stock" do
|
||||
before do
|
||||
variant.on_demand = false
|
||||
variant.on_hand = 0
|
||||
variant.save!
|
||||
end
|
||||
|
||||
it "returns me to the cart with an error message" do
|
||||
out_of_stock_check(:summary)
|
||||
end
|
||||
end
|
||||
|
||||
context "summary step" do
|
||||
let(:order) {
|
||||
create(:order_ready_for_confirmation, distributor:)
|
||||
|
||||
Reference in New Issue
Block a user