discourse/spec/system/anon_language_switcher_spec.rb
Natalie Tay fe30ffa3f9
DEV: Remove 'experimental' prefix from settings (#33233)
This PR takes the localization features out of "experimental" to prep
for the announcement
- rename settings and gives them its own area
- `experimental_content_localization` to `content_localization_enabled`
- `experimental_content_localization_allowed_groups` to
`content_localization_allowed_groups`
- `experimental_content_localization_supported_locales` to
`content_localization_supported_locales`
- `experimental_anon_language_switcher` to
`content_localization_anon_language_switcher`
- migration
- related to https://github.com/discourse/discourse-ai/pull/1439

| screenshot 📸 |
|---|
| <img width="964" alt="Screenshot 2025-06-17 at 5 06 32 PM"
src="https://github.com/user-attachments/assets/9a8b2c38-c846-4fc9-8ddd-815c45cc3d0e"
/> |
2025-06-19 12:23:42 +08:00

47 lines
1.4 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Anonymous user language switcher", type: :system do
SWITCHER_SELECTOR = "button[data-identifier='language-switcher']"
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:switcher) { PageObjects::Components::DMenu.new(SWITCHER_SELECTOR) }
fab!(:japanese_user) { Fabricate(:user, locale: "ja") }
fab!(:topic) do
topic = Fabricate(:topic, title: "Life strategies from The Art of War")
Fabricate(:post, topic:)
topic
end
before do
SiteSetting.default_locale = "en"
SiteSetting.content_localization_supported_locales = "es|ja"
SiteSetting.content_localization_enabled = true
SiteSetting.allow_user_locale = true
SiteSetting.set_locale_from_cookie = true
end
it "only shows the language switcher based on what is in target languages" do
SiteSetting.content_localization_anon_language_switcher = false
visit("/")
expect(page).not_to have_css(SWITCHER_SELECTOR)
SiteSetting.content_localization_anon_language_switcher = true
visit("/")
switcher.expand
expect(switcher).to have_content("English (US)")
expect(switcher).to have_content("日本語")
expect(switcher).to have_content("Español")
SiteSetting.content_localization_supported_locales = "es"
visit("/")
switcher.expand
expect(switcher).not_to have_content("日本語")
sign_in(japanese_user)
expect(page).not_to have_css(SWITCHER_SELECTOR)
end
end