Hide OFN navigation also on small width screens

This commit is contained in:
Jean-Baptiste Bellet
2023-06-05 14:44:57 +02:00
parent a8b85a65e9
commit 7dc8c4b891
2 changed files with 40 additions and 8 deletions

View File

@@ -7,14 +7,15 @@
= image_tag @white_label_distributor.white_label_logo_url(:mobile)
- else
%img{src: ContentConfig.url_for(:logo_mobile), srcset: ContentConfig.url_for(:logo_mobile_svg), width: "75", height: "26"}
- [*1..7].each do |menu_number|
- menu_name = "menu_#{menu_number}"
- if ContentConfig[menu_name].present?
%li.li-menu
%a{href: t("#{menu_name}_url") }
%span.nav-primary
%i{class: ContentConfig["#{menu_name}_icon_name"]}
= t "#{menu_name}_title"
- unless @hide_ofn_navigation
- [*1..7].each do |menu_number|
- menu_name = "menu_#{menu_number}"
- if ContentConfig[menu_name].present?
%li.li-menu
%a{href: t("#{menu_name}_url") }
%span.nav-primary
%i{class: ContentConfig["#{menu_name}_icon_name"]}
= t "#{menu_name}_title"
- if OpenFoodNetwork::I18nConfig.selectable_locales.count > 1
%li.language-switcher.li-menu

View File

@@ -30,6 +30,29 @@ describe 'White label setting' do
let(:ofn_navigation) { 'ul.nav-main-menu' }
shared_examples "hides the OFN navigation for mobile view as well" do
context "mobile view" do
before do
browser_as_small
end
after do
browse_as_default
end
it "hides OFN navigation" do
find("a.left-off-canvas-toggle").click
within "aside.left-off-canvas-menu" do
expect(page).not_to have_selector "a[href='#{main_app.shops_path}']"
expect(page).not_to have_selector "a[href='#{main_app.map_path}']"
expect(page).not_to have_selector "a[href='#{main_app.producers_path}']"
expect(page).not_to have_selector "a[href='#{main_app.groups_path}']"
expect(page).not_to have_selector "a[href='#{I18n.t('.menu_5_url')}']"
end
end
end
end
shared_examples "does not hides the OFN navigation for mobile view as well" do
context "mobile view" do
before do
@@ -106,6 +129,8 @@ describe 'White label setting' do
it "hides the OFN navigation" do
expect(page).to have_no_selector ofn_navigation
end
it_behaves_like "hides the OFN navigation for mobile view as well"
end
context "for root path" do
@@ -116,6 +141,8 @@ describe 'White label setting' do
it "does not hide the OFN navigation when visiting root path" do
expect(page).to have_selector ofn_navigation
end
it_behaves_like "does not hides the OFN navigation for mobile view as well"
end
end
@@ -141,6 +168,8 @@ describe 'White label setting' do
it "hides the OFN navigation" do
expect(page).to have_no_selector ofn_navigation
end
it_behaves_like "hides the OFN navigation for mobile view as well"
end
context "for checkout path" do
@@ -153,6 +182,8 @@ describe 'White label setting' do
expect(page).to have_content "Order ready for "
expect(page).to have_no_selector ofn_navigation
end
it_behaves_like "hides the OFN navigation for mobile view as well"
end
end