Files
chatwoot/spec/controllers/dashboard_custom_domain_spec.rb
f9cc702030 fix(help-center): documentation layout on custom domain root, locale (#14850)
Help centers using the documentation layout now render correctly in two
cases that previously fell back to the wrong output. Opening a portal at
its custom-domain root (e.g. docs.example.com/ ) now shows the full
documentation home
in place instead of the classic layout, and portals whose locale is a
region variant that Chatwoot doesn't ship a
translation for (e.g. th_TH , fr_ML ) now show their categories in the
sidebar on article pages.

Closes
https://linear.app/chatwoot/issue/CW-7437/portal-layout-is-not-properly-working-in-custom-domain

## How to test

1. Create a portal with the documentation layout and a custom domain
(e.g. example.chat.test ), with at least one
category containing a published article.
2. Visit the custom-domain root ( http://example.chat.test:3000/ ) → it
should show the full documentation home
(sidebar, topbar), not the classic layout, with no redirect.
3. Set the portal's locale to a region variant Chatwoot doesn't
translate, e.g. th_TH , with categories/articles
under that locale.
4. Open an article → the sidebar should list the article's category and
sibling articles. Before the fix the sidebar
was empty for these locales.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:12:55 -07:00

51 lines
1.7 KiB
Ruby

require 'rails_helper'
describe 'GET / on a help center custom domain', type: :request do
let(:account) { create(:account) }
let(:agent) { create(:user, account: account, role: :agent) }
around do |example|
with_modified_env FRONTEND_URL: 'http://www.chatwoot.test' do
example.run
end
end
context 'when the portal uses the documentation layout' do
let!(:portal) do
create(:portal, account: account, slug: 'doc-portal', custom_domain: 'docs.example.com',
config: { allowed_locales: ['en'], default_locale: 'en', layout: 'documentation' })
end
let!(:category) do
create(:category, name: 'Getting Started', portal: portal, account_id: account.id, locale: 'en', slug: 'getting-started')
end
before do
create(:article, category: category, portal: portal, account: account, author: agent, locale: 'en', status: :published)
end
it 'renders the documentation home in place without redirecting' do
host! portal.custom_domain
get '/'
expect(response).to have_http_status(:success)
expect(response.body).to include('sidebar-drawer-checkbox')
expect(response.body).to include('Getting Started')
end
end
context 'when the portal uses the classic layout' do
let!(:portal) do
create(:portal, account: account, slug: 'classic-portal', custom_domain: 'classic.example.com',
config: { allowed_locales: ['en'], default_locale: 'en', layout: 'classic' })
end
it 'renders the classic home without the documentation layout' do
host! portal.custom_domain
get '/'
expect(response).to have_http_status(:success)
expect(response.body).not_to include('sidebar-drawer-checkbox')
end
end
end