From 78a40114ef42344b05d8d93f053098b0367b628f Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Mon, 14 Apr 2025 19:59:56 -0700 Subject: [PATCH] feat: Use portal logo as favicon in helpcenter pages (#11289) - Added favicon link to portal layout when logo is present - Added tests to verify favicon behavior with and without logo --- app/views/layouts/portal.html.erb | 4 +++ .../public/api/v1/portals_controller_spec.rb | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/app/views/layouts/portal.html.erb b/app/views/layouts/portal.html.erb index 5d8983621..c4135fd37 100644 --- a/app/views/layouts/portal.html.erb +++ b/app/views/layouts/portal.html.erb @@ -39,6 +39,10 @@ By default, it renders: <% else %> <%= @portal.page_title%> <% end %> + + <% if @portal.logo.present? %> + + <% end %> <% unless @theme_from_params.blank? %> <%# this adds the theme from params, ensuring that there a localstorage value set %> diff --git a/spec/controllers/public/api/v1/portals_controller_spec.rb b/spec/controllers/public/api/v1/portals_controller_spec.rb index 004d013ea..92ab56e5b 100644 --- a/spec/controllers/public/api/v1/portals_controller_spec.rb +++ b/spec/controllers/public/api/v1/portals_controller_spec.rb @@ -30,6 +30,32 @@ RSpec.describe Public::Api::V1::PortalsController, type: :request do expect(json_response['error']).to eql "Domain: www.example.com is not registered with us. \ Please send us an email at support@chatwoot.com with the custom domain name and account API key" end + + context 'when portal has a logo' do + it 'includes the logo as favicon' do + # Attach a test image to the portal + file = Rails.root.join('spec/assets/sample.png').open + portal.logo.attach(io: file, filename: 'sample.png', content_type: 'image/png') + file.close + + get "/hc/#{portal.slug}/en" + + expect(response).to have_http_status(:success) + expect(response.body).to include('