Files
openfoodnetwork/spec/system/admin/multilingual_spec.rb
Maikel Linke 63988fff4f Configure test locales like other envs
The locale config is set in application.rb from environment variables
already. We don't need to repeat that logic in test.rb. And because it
was outdated, the language switcher was actually broken in the test
environment. We did have an English selector for the fallback `en` even
though we were already displaying English as en_TST. And after
switchting to Spanish, we could switch back because en_TST was not in
the available locales.

I now fixed the test with the right assumption and the config to solve
the problem.
2026-03-18 14:49:15 +11:00

39 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'system_helper'
RSpec.describe 'Multilingual' do
include AuthenticationHelper
include WebHelper
let(:admin_user) { create(:admin_user) }
before do
login_as admin_user
visit spree.admin_dashboard_path
end
it 'can switch language by params' do
expect(pick_i18n_locale).to eq 'en_TST'
expect(get_i18n_translation('spree_admin_overview_enterprises_header')).to eq 'My Enterprises'
expect(page).to have_content 'My Enterprises'
expect(admin_user.locale).to be_nil
visit spree.admin_dashboard_path(locale: 'es')
expect(pick_i18n_locale).to eq 'es'
expect(get_i18n_translation('spree_admin_overview_enterprises_header'))
.to eq 'Mis Organizaciones'
expect(page).to have_content 'Mis Organizaciones'
admin_user.reload
expect(admin_user.locale).to eq 'es'
end
it 'fallbacks to default_locale' do
visit spree.admin_dashboard_path(locale: 'it')
expect(pick_i18n_locale).to eq 'en_TST'
expect(get_i18n_translation('spree_admin_overview_enterprises_header')).to eq 'My Enterprises'
expect(page).to have_content 'My Enterprises'
expect(admin_user.locale).to be_nil
end
end