From 4e408d404b6382561bfc45f9a9d6b3fa0f4ec973 Mon Sep 17 00:00:00 2001 From: Arun Guleria Date: Thu, 7 Dec 2023 20:33:45 +0530 Subject: [PATCH 1/4] 11599-Change page title on checkout pages --- app/helpers/checkout_helper.rb | 6 ++++++ app/views/checkout/edit.html.haml | 2 +- config/locales/en.yml | 3 +++ spec/system/consumer/checkout/details_spec.rb | 6 ++++++ spec/system/consumer/checkout/payment_spec.rb | 6 ++++++ spec/system/consumer/checkout/summary_spec.rb | 6 ++++++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index dabbf3d4a6..be967e70ee 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -148,4 +148,10 @@ module CheckoutHelper ] end end + + # Set the Page title of checkout process as step based like + # Checkout Details, Checkout Payment and Checkout Summary + def checkout_page_title + t("checkout_#{checkout_step}_title") + end end diff --git a/app/views/checkout/edit.html.haml b/app/views/checkout/edit.html.haml index b9dab1817f..990c8387b5 100644 --- a/app/views/checkout/edit.html.haml +++ b/app/views/checkout/edit.html.haml @@ -1,5 +1,5 @@ - content_for(:title) do - = t :checkout_title + = checkout_page_title .darkswarm.footer-pad{"data-turbo": "true"} - content_for :order_cycle_form do diff --git a/config/locales/en.yml b/config/locales/en.yml index 7a51352b98..05ee256012 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2227,6 +2227,9 @@ en: order_back_to_store: Back To Store order_back_to_cart: Back To Cart order_back_to_website: Back To Website + checkout_details_title: Checkout Details + checkout_payment_title: Checkout Payment + checkout_summary_title: Checkout Summary bom_tip: "Use this page to alter product quantities across multiple orders. Products may also be removed from orders entirely, if required." diff --git a/spec/system/consumer/checkout/details_spec.rb b/spec/system/consumer/checkout/details_spec.rb index 7492b4721d..218d755301 100644 --- a/spec/system/consumer/checkout/details_spec.rb +++ b/spec/system/consumer/checkout/details_spec.rb @@ -396,6 +396,12 @@ 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 + page.has_title? "Checkout Details - Open Food Network" + end + end end end end diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index e97bb2e683..ae7529814e 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -331,6 +331,12 @@ 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 + page.has_title? "Checkout Payment - Open Food Network" + end + end end end diff --git a/spec/system/consumer/checkout/summary_spec.rb b/spec/system/consumer/checkout/summary_spec.rb index ac17de5f31..0ddb4905eb 100644 --- a/spec/system/consumer/checkout/summary_spec.rb +++ b/spec/system/consumer/checkout/summary_spec.rb @@ -404,6 +404,12 @@ 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 + page.has_title? "Checkout Summary - Open Food Network" + end + end end def add_voucher_to_order(voucher, order) From d60216787b98a6e0f15fd10d5e0c30b04314a58f Mon Sep 17 00:00:00 2001 From: Arun Guleria Date: Thu, 7 Dec 2023 23:57:25 +0530 Subject: [PATCH 2/4] 11599 Remove whitespace trailing --- app/helpers/checkout_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index be967e70ee..eb96a28dd7 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -149,7 +149,7 @@ module CheckoutHelper end end - # Set the Page title of checkout process as step based like + # Set the Page title of checkout process as step based like # Checkout Details, Checkout Payment and Checkout Summary def checkout_page_title t("checkout_#{checkout_step}_title") From f88a3122eeee93cde3740e3dad3c3703756961ad Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 8 Dec 2023 09:32:07 +1100 Subject: [PATCH 3/4] Fix expectation of checkout title --- spec/system/consumer/checkout/details_spec.rb | 2 +- spec/system/consumer/checkout/payment_spec.rb | 2 +- spec/system/consumer/checkout/summary_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/system/consumer/checkout/details_spec.rb b/spec/system/consumer/checkout/details_spec.rb index 218d755301..eb7a4fe423 100644 --- a/spec/system/consumer/checkout/details_spec.rb +++ b/spec/system/consumer/checkout/details_spec.rb @@ -399,7 +399,7 @@ describe "As a consumer, I want to checkout my order" do describe "show page title as Checkout Details - Open Food Network" do it "should display title as Checkout Details - Open Food Network" do - page.has_title? "Checkout Details - Open Food Network" + expect(page).to have_title "Checkout Details - Open Food Network" end end end diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index ae7529814e..4cf612a4ff 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -334,7 +334,7 @@ describe "As a consumer, I want to checkout my order" do describe "show page title as Checkout Payment - Open Food Network" do it "should display title as Checkout Payment - Open Food Network" do - page.has_title? "Checkout Payment - Open Food Network" + expect(page).to have_title "Checkout Payment - Open Food Network" end end end diff --git a/spec/system/consumer/checkout/summary_spec.rb b/spec/system/consumer/checkout/summary_spec.rb index 0ddb4905eb..e4d231fd0b 100644 --- a/spec/system/consumer/checkout/summary_spec.rb +++ b/spec/system/consumer/checkout/summary_spec.rb @@ -407,7 +407,7 @@ describe "As a consumer, I want to checkout my order" do describe "show page title as Checkout Summary - Open Food Network" do it "should display title as Checkout Summary - Open Food Network" do - page.has_title? "Checkout Summary - Open Food Network" + expect(page).to have_title "Checkout Summary - Open Food Network" end end end From 29ef444f36f72d7a246e24c97a603d05c81ad8ff Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 8 Dec 2023 09:44:44 +1100 Subject: [PATCH 4/4] Consolidate system specs for efficiency And test for literal strings. It's more readable and robust. --- spec/system/consumer/checkout/details_spec.rb | 10 ++++------ spec/system/consumer/checkout/payment_spec.rb | 18 +++++------------- spec/system/consumer/checkout/summary_spec.rb | 13 ++++--------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/spec/system/consumer/checkout/details_spec.rb b/spec/system/consumer/checkout/details_spec.rb index eb7a4fe423..d44b0cc2ad 100644 --- a/spec/system/consumer/checkout/details_spec.rb +++ b/spec/system/consumer/checkout/details_spec.rb @@ -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 diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index 4cf612a4ff..65f18d271b 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -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 diff --git a/spec/system/consumer/checkout/summary_spec.rb b/spec/system/consumer/checkout/summary_spec.rb index e4d231fd0b..2f2767d7dd 100644 --- a/spec/system/consumer/checkout/summary_spec.rb +++ b/spec/system/consumer/checkout/summary_spec.rb @@ -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)