Handle dark/light/contrast theme modes in common CSS (#37095)

This commit is contained in:
diondiondion
2025-12-04 16:56:35 +01:00
committed by GitHub
parent 0dac31dfd5
commit 65b216353e
17 changed files with 148 additions and 127 deletions

View File

@@ -3,8 +3,8 @@
require 'rails_helper'
RSpec.describe ApplicationHelper do
describe 'body_classes' do
context 'with a body class string from a controller' do
describe 'html_classes' do
context 'with non-default user settings' do
before do
user = Fabricate :user
user.settings['web.use_system_font'] = true
@@ -15,19 +15,11 @@ RSpec.describe ApplicationHelper do
end
it 'uses the current theme and user settings classes in the result' do
expect(helper.body_classes)
.to match(/theme-default/)
.and match(/system-font/)
expect(helper.html_classes)
.to match(/system-font/)
.and match(/reduce-motion/)
end
it 'includes values set via content_for' do
helper.content_for(:body_classes) { 'admin' }
expect(helper.body_classes)
.to match(/admin/)
end
private
def controller_helpers
@@ -35,13 +27,22 @@ RSpec.describe ApplicationHelper do
def current_account
@current_account ||= Fabricate(:account, user: User.last)
end
def current_theme = 'default'
end
end
end
end
describe 'body_classes' do
context 'with a body class string from a controller' do
it 'includes values set via content_for' do
helper.content_for(:body_classes) { 'admin' }
expect(helper.body_classes)
.to match(/admin/)
end
end
end
describe 'locale_direction' do
it 'adds rtl body class if locale is Arabic' do
I18n.with_locale(:ar) do