Do not show white label logo is hide_ofn_navigation is not checked

They are both strongly linked
This commit is contained in:
Jean-Baptiste Bellet
2023-03-16 17:03:37 +01:00
parent 470761da86
commit 54342254b6
2 changed files with 59 additions and 16 deletions

View File

@@ -4,7 +4,7 @@
.three.columns.alpha
= f.label :hide_ofn_navigation, t('.hide_ofn_navigation')
.three.columns
= f.check_box :hide_ofn_navigation
= f.check_box :hide_ofn_navigation, { "data-controller": "checkbox-display", "data-checkbox-display-target-id-value": "white_label_logo" }
.row{id: "white_label_logo"}
.three.columns.alpha

View File

@@ -647,30 +647,73 @@ describe '
end
end
context "when white label is active via `hide_ofn_navigation`" do
context "when the feature is enabled" do
before do
distributor1.update_attribute(:preferred_hide_ofn_navigation, true)
Flipper.enable(:white_label)
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
end
it "can updload the white label logo for the current shop" do
attach_file "enterprise_white_label_logo", white_logo_path
it "set the hide_ofn_navigation preference for the current shop" do
expect(page).not_to have_content "LOGO USED IN SHOPFRONT"
check "Hide OFN navigation"
click_button 'Update'
expect(flash_message).to eq('Enterprise "First Distributor" has been successfully updated!')
expect(distributor1.reload.white_label_logo_blob.filename).to eq("logo-white.png")
end
expect(distributor1.reload.hide_ofn_navigation).to be true
context "when enterprise has a white label logo" do
before do
distributor1.update white_label_logo: white_logo_file
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
it "can remove the white label logo for the current shop" do
click_button "Remove"
within ".reveal-modal" do
click_button "Confirm"
expect(page).to have_content "LOGO USED IN SHOPFRONT"
uncheck "Hide OFN navigation"
click_button 'Update'
expect(flash_message).to eq('Enterprise "First Distributor" has been successfully updated!')
expect(distributor1.reload.hide_ofn_navigation).to be false
end
context "when white label is active via `hide_ofn_navigation`" do
before do
distributor1.update_attribute(:hide_ofn_navigation, true)
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
end
it "can updload the white label logo for the current shop" do
attach_file "enterprise_white_label_logo", white_logo_path
click_button 'Update'
expect(flash_message).to eq('Enterprise "First Distributor" has been successfully updated!')
expect(distributor1.reload.white_label_logo_blob.filename).to eq("logo-white.png")
end
context "when enterprise has a white label logo" do
before do
distributor1.update white_label_logo: white_logo_file
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
end
it "can remove the white label logo for the current shop" do
expect(page).to have_selector("img[src*='logo-white.png']")
expect(distributor1.white_label_logo).to be_attached
click_button "Remove"
within ".reveal-modal" do
click_button "Confirm"
end
expect(flash_message).to match(/Logo removed/)
distributor1.reload
expect(distributor1.white_label_logo).to_not be_attached
end
expect(flash_message).to eq("Logo removed")
expect(distributor1.reload.white_label_logo).to be_nil
end
end
end