Files
discourse/spec/system/locale_spec.rb
David Taylor 8074c8dadd FIX: Moment locale loading in type=module (#33128)
The moment locale files expect `this.` to be the window object. In a
type=module, `this` is `undefined`. This commit wraps the
moment-timezone definitions in an IIFE to resolve that.

Also adds a system spec to prevent future moment-timezone regressions.

Followup to a2b0c193dff40278c0a93995cc9b97b05dc8abb2
2025-06-09 14:20:04 +01:00

25 lines
748 B
Ruby

# frozen_string_literal: true
RSpec.describe "Locale choice", type: :system do
it "loads english locale successfully" do
visit "/"
expect(page).to have_css("html[lang='en']")
expect(page).to have_css(
"#navigation-bar .categories",
text: I18n.t("js.filters.categories.title", locale: :en),
)
expect(page.evaluate_script("moment.locale()")).to eq("en")
end
it "loads french locale successfully" do
SiteSetting.default_locale = "fr"
visit "/"
expect(page).to have_css("html[lang='fr']")
expect(page).to have_css(
"#navigation-bar .categories",
text: I18n.t("js.filters.categories.title", locale: :fr),
)
expect(page.evaluate_script("moment.locale()")).to eq("fr")
end
end