Skip to content

Commit

Permalink
Reduce locales used in remote translations tests
Browse files Browse the repository at this point in the history
This way we can reduce the number of locales used in the test
environment as well, while still testing every possible scenario for
remote translations.
  • Loading branch information
javierm authored and PierreMesure committed Sep 11, 2019
1 parent 4cdf57f commit 592c0de
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions spec/features/remote_translations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
before do
Setting["feature.remote_translations"] = true
create(:proposal)
available_locales_response = ["ar", "de", "en", "es", "fa", "fr", "he", "it", "nl", "pl",
"pt", "sv", "zh-Hans", "zh-Hant"]
available_locales_response = %w[de en es fr pt zh-Hans]
expect(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales).
and_return(available_locales_response)
end
Expand All @@ -27,18 +26,14 @@
end

scenario "should display text in English" do
available_locales_with_fallback_en = [:ar, :de, :fa, :he, :nl, :pl, :sv]

visit root_path(locale: available_locales_with_fallback_en.sample)
visit root_path(locale: :de)

expect(page).to have_css ".remote-translations-button"
expect(page).to have_content "The content of this page is not available in your language"
end

scenario "should display text in English after parse key" do
available_locales_with_fallback_en = [:"zh-CN", :"zh-TW"]

visit root_path(locale: available_locales_with_fallback_en.sample)
visit root_path(locale: :"zh-CN")

expect(page).to have_css ".remote-translations-button"
expect(page).to have_content "The content of this page is not available in your language"
Expand All @@ -53,9 +48,7 @@
end

scenario "with locale that has :es fallback" do
available_locales_with_fallback_es = [:es, :fr, :it]

visit root_path(locale: available_locales_with_fallback_es.sample)
visit root_path(locale: :fr)

expect(page).to have_css ".remote-translations-button"
expect(page).to have_content "El contenido de esta página no está disponible en tu idioma"
Expand All @@ -72,9 +65,7 @@
end

scenario "Not display remote translation button when locale is not included in microsoft translate client" do
not_available_locales = [:val, :gl, :sq]

visit root_path(locale: not_available_locales.sample)
visit root_path(locale: :nl)

expect(page).not_to have_css ".remote-translations-button"
end
Expand Down

0 comments on commit 592c0de

Please sign in to comment.