The absence of labels in these controls made them hard to use, particularly for people who use screen readers. Note we're removing the "Choose language" prompt, since we always automatically choose a language and not choosing a language doesn't really make sense. The only scenario where the prompt was used took place when all languages had been removed but, in that case, the "Choose language" prompt was misleading because there were no languages to choose from.
50 lines
1.3 KiB
Ruby
50 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Shared::GlobalizeLocalesComponent do
|
|
describe "Language selector" do
|
|
it "only includes enabled locales" do
|
|
Setting["locales.enabled"] = "en nl"
|
|
|
|
I18n.with_locale(:en) do
|
|
render_inline Shared::GlobalizeLocalesComponent.new
|
|
|
|
expect(page).to have_select "Current language", options: ["English"]
|
|
end
|
|
|
|
I18n.with_locale(:es) do
|
|
render_inline Shared::GlobalizeLocalesComponent.new
|
|
|
|
expect(page).to have_select "Idioma actual", options: []
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "links to destroy languages" do
|
|
it "only includes enabled locales" do
|
|
Setting["locales.enabled"] = "en nl"
|
|
|
|
I18n.with_locale(:en) do
|
|
render_inline Shared::GlobalizeLocalesComponent.new
|
|
|
|
expect(page).to have_css "a[data-locale]", count: 1
|
|
end
|
|
|
|
I18n.with_locale(:es) do
|
|
render_inline Shared::GlobalizeLocalesComponent.new
|
|
|
|
expect(page).not_to have_css "a[data-locale]"
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "Add language selector" do
|
|
it "only includes enabled locales" do
|
|
Setting["locales.enabled"] = "en nl"
|
|
|
|
render_inline Shared::GlobalizeLocalesComponent.new
|
|
|
|
expect(page).to have_select "Add language", options: ["", "English", "Nederlands"]
|
|
end
|
|
end
|
|
end
|