From a8b9d9d8af7eab6d25430c1711e2f857cc457ed3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 10 Jul 2023 16:31:33 +0200 Subject: [PATCH] Check the custom tab checkbox if any errors (ie. title is blank) --- app/views/admin/enterprises/form/_white_label.html.haml | 3 ++- spec/system/admin/enterprises_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/admin/enterprises/form/_white_label.html.haml b/app/views/admin/enterprises/form/_white_label.html.haml index 76d1135b7b..4c74ed6885 100644 --- a/app/views/admin/enterprises/form/_white_label.html.haml +++ b/app/views/admin/enterprises/form/_white_label.html.haml @@ -46,7 +46,8 @@ = label_tag :custom_tab, t('.create_custom_tab') .thirteen.columns = hidden_field_tag :custom_tab, "false" # submit `true` if checkbox is checked, `false` otherwise - = check_box_tag :custom_tab, "true", @object.custom_tab&.title.present?, { "data-controller": "checkbox-display", "data-checkbox-display-target-id-value": "custom_tab_form" } + - checked = @object.custom_tab&.title.present? || @object.errors["custom_tab.title"].present? + = check_box_tag :custom_tab, "true", checked, { "data-controller": "checkbox-display", "data-checkbox-display-target-id-value": "custom_tab_form" } %div{id: "custom_tab_form"} = f.fields_for :custom_tab, @object.custom_tab do |custom_tab_form| diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index 9e521481be..25723c7a61 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -760,6 +760,11 @@ describe ' click_button 'Update' expect(page).to have_content("Custom tab title can't be blank") expect(distributor1.reload.custom_tab).to be_nil + + within(".side_menu") do + click_link "White Label" + end + expect(page).to have_checked_field "Create custom tab in shopfront" end it "can't save custom tab fields if title is too long" do