Consolidate system specs for efficiency

And test for literal strings. It's more readable and robust.
This commit is contained in:
Maikel Linke
2023-12-08 09:44:44 +11:00
committed by Arun
parent f88a3122ee
commit 29ef444f36
3 changed files with 13 additions and 28 deletions

View File

@@ -389,6 +389,10 @@ describe "As a consumer, I want to checkout my order" do
end
it "pre-fills address details" do
# Check for the right title first. This is a random place here but
# we don't have a standard success checkout flow case to add this to.
expect(page).to have_title "Checkout Details - Open Food Network"
visit checkout_path
expect(page).to have_select(
"order_bill_address_attributes_state_id", selected: "Testville"
@@ -396,12 +400,6 @@ describe "As a consumer, I want to checkout my order" do
expect(page).to have_field "order_bill_address_attributes_zipcode", with: "TST01"
end
end
describe "show page title as Checkout Details - Open Food Network" do
it "should display title as Checkout Details - Open Food Network" do
expect(page).to have_title "Checkout Details - Open Food Network"
end
end
end
end
end

View File

@@ -62,14 +62,12 @@ describe "As a consumer, I want to checkout my order" do
let(:order) { create(:order_ready_for_payment, distributor:) }
context "with one payment method, with a fee" do
before do
visit checkout_step_path(:payment)
end
it "preselect the payment method if only one is available" do
expect(page).to have_checked_field "payment_method_#{payment_with_fee.id}"
end
it "displays the transaction fee" do
expect(page).to have_content("#{payment_with_fee.name} " + with_currency(1.23).to_s)
visit checkout_step_path(:payment)
expect(page).to have_title "Checkout Payment - Open Food Network"
expect(page).to have_checked_field "Payment with Fee"
expect(page).to have_content "Payment with Fee $1.23"
end
end
@@ -331,12 +329,6 @@ describe "As a consumer, I want to checkout my order" do
end
end
end
describe "show page title as Checkout Payment - Open Food Network" do
it "should display title as Checkout Payment - Open Food Network" do
expect(page).to have_title "Checkout Payment - Open Food Network"
end
end
end
end

View File

@@ -66,15 +66,16 @@ describe "As a consumer, I want to checkout my order" do
visit checkout_step_path(:summary)
end
it "displays the ship address" do
it "displays title and ship address" do
expect(page).to have_title "Checkout Summary - Open Food Network"
expect(page).to have_content "Delivery address"
expect(page).to have_content order.ship_address.address1
expect(page).to have_content order.ship_address.city
expect(page).to have_content order.ship_address.zipcode
expect(page).to have_content order.ship_address.phone
end
it "and not the billing address" do
# but not the billing address
expect(page).not_to have_content order.bill_address.address1
expect(page).not_to have_content order.bill_address.city
expect(page).not_to have_content order.bill_address.zipcode
@@ -404,12 +405,6 @@ describe "As a consumer, I want to checkout my order" do
end
end
end
describe "show page title as Checkout Summary - Open Food Network" do
it "should display title as Checkout Summary - Open Food Network" do
expect(page).to have_title "Checkout Summary - Open Food Network"
end
end
end
def add_voucher_to_order(voucher, order)