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
This commit is contained in:
@@ -40,6 +40,10 @@ By default, it renders:
|
|||||||
<title><%= @portal.page_title%></title>
|
<title><%= @portal.page_title%></title>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if @portal.logo.present? %>
|
||||||
|
<link rel="icon" href="<%= url_for(@portal.logo) %>">
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% unless @theme_from_params.blank? %>
|
<% unless @theme_from_params.blank? %>
|
||||||
<%# this adds the theme from params, ensuring that there a localstorage value set %>
|
<%# this adds the theme from params, ensuring that there a localstorage value set %>
|
||||||
<%# this will further trigger the next script to ensure color mode is toggled without a FOUC %>
|
<%# this will further trigger the next script to ensure color mode is toggled without a FOUC %>
|
||||||
|
|||||||
@@ -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. \
|
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"
|
Please send us an email at support@chatwoot.com with the custom domain name and account API key"
|
||||||
end
|
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('<link rel="icon" href=')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when portal has no logo' do
|
||||||
|
it 'does not include a favicon link' do
|
||||||
|
# Ensure logo is not attached
|
||||||
|
portal.logo.purge if portal.logo.attached?
|
||||||
|
|
||||||
|
get "/hc/#{portal.slug}/en"
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
expect(response.body).not_to include('<link rel="icon" href=')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET /public/api/v1/portals/{portal_slug}/sitemap' do
|
describe 'GET /public/api/v1/portals/{portal_slug}/sitemap' do
|
||||||
|
|||||||
Reference in New Issue
Block a user