diff --git a/app/views/admin/enterprises/form/_white_label.html.haml b/app/views/admin/enterprises/form/_white_label.html.haml index c4fcc63a7f..9ce938b250 100644 --- a/app/views/admin/enterprises/form/_white_label.html.haml +++ b/app/views/admin/enterprises/form/_white_label.html.haml @@ -56,4 +56,5 @@ .three.columns.alpha = custom_tab_form.label :content, t('.custom_tab_content') .eight.columns - = custom_tab_form.text_area :content, rows: 5 + = custom_tab_form.hidden_field :content, id: "custom_tab_content" + %trix-editor{ input: "custom_tab_content" } diff --git a/app/views/shopping_shared/tabs/_custom.html.haml b/app/views/shopping_shared/tabs/_custom.html.haml index 5c6cf17465..68b2fec9ba 100644 --- a/app/views/shopping_shared/tabs/_custom.html.haml +++ b/app/views/shopping_shared/tabs/_custom.html.haml @@ -1,3 +1,3 @@ .content .row - = @distributor.custom_tab.content + = @distributor.custom_tab.content.html_safe if @distributor.custom_tab&.content.present? diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index 7986a3b639..f8b6bad42f 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -182,5 +182,6 @@ RSpec.configure do |config| config.include Devise::Test::IntegrationHelpers, type: :request config.include Features::DatepickerHelper, type: :system + config.include Features::TrixEditorHelper, type: :system config.include DownloadsHelper, type: :system end diff --git a/spec/support/features/trixeditor_helper.rb b/spec/support/features/trixeditor_helper.rb new file mode 100644 index 0000000000..c54b9037f2 --- /dev/null +++ b/spec/support/features/trixeditor_helper.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Features + module TrixEditorHelper + def fill_in_trix_editor(id, with:) + find(:xpath, "//trix-editor[@input='#{id}']").click.set(with) + end + end +end diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index a75e006c34..20fa1518ac 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -737,19 +737,17 @@ describe ' it "display a form with the custom tab fields: title and content" do expect(page).to have_content "TITLE FOR CUSTOM TAB" - expect(page).to have_field "enterprise_custom_tab_attributes_title" expect(page).to have_content "CONTENT FOR CUSTOM TAB" - expect(page).to have_field "enterprise_custom_tab_attributes_content" end it "can save custom tab fields" do fill_in "enterprise_custom_tab_attributes_title", with: "Custom tab title" - fill_in "enterprise_custom_tab_attributes_content", with: "Custom tab content" + fill_in_trix_editor "custom_tab_content", with: "Custom tab content" click_button 'Update' expect(flash_message) .to eq('Enterprise "First Distributor" has been successfully updated!') expect(distributor1.reload.custom_tab.title).to eq("Custom tab title") - expect(distributor1.reload.custom_tab.content).to eq("Custom tab content") + expect(distributor1.reload.custom_tab.content).to eq("