Use labels in language selector tests

This way the test verifies there's a label associated to that form
field.
This commit is contained in:
Javi Martín
2021-06-25 20:05:31 +02:00
parent 554bc926c7
commit 93c521bd29
8 changed files with 38 additions and 50 deletions

View File

@@ -34,7 +34,7 @@ shared_examples "milestoneable" do |factory_name|
expect(page).to have_content(first_milestone.status.name)
end
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
find("#tab-milestones-label").click

View File

@@ -25,7 +25,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
scenario "should be present when current locale translation does not exists" do
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).to have_button("Traducir página")
end
@@ -35,7 +35,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
visit path
expect(page).not_to have_button("Translate page")
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).not_to have_button("Traducir página")
end
@@ -45,7 +45,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
resource.destroy!
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).not_to have_button("Traducir página")
end
@@ -55,7 +55,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
create(:remote_translation, remote_translatable: resource, locale: :es)
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).not_to have_button("Traducir página")
expect(page).to have_content("En un breve periodo de tiempo refrescando la página podrá ver todo el contenido en su idioma")
@@ -75,7 +75,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
visit path
expect(page).not_to have_button("Translate page")
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).not_to have_button("Traducir página")
end
@@ -94,7 +94,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
visit path
expect(page).not_to have_button("Translate page")
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).to have_button("Traducir página")
end
@@ -105,7 +105,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
visit path
expect(page).not_to have_button("Translate page")
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).not_to have_button("Traducir página")
end
@@ -120,7 +120,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
visit path
expect(page).not_to have_button("Translate page")
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).to have_button("Traducir página")
end
@@ -135,7 +135,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
visit path
expect(page).not_to have_button("Translate page")
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).to have_button("Traducir página")
end
@@ -146,7 +146,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
describe "with delayed jobs", :delay_jobs do
scenario "the remote translation button should not be present" do
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
click_button "Traducir página"
@@ -155,14 +155,14 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
scenario "the remote translation is pending to translate" do
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect { click_button "Traducir página" }.to change { RemoteTranslation.count }.from(0).to(1)
end
scenario "should be present enqueued notice and informative text" do
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
click_button "Traducir página"
@@ -172,12 +172,12 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
scenario "should be present only informative text when user visit page with all content enqueued" do
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
click_button "Traducir página"
expect(page).to have_content("Se han solicitado correctamente las traducciones.")
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Idioma:"
expect(page).not_to have_button "Traducir página"
expect(page).not_to have_content("Se han solicitado correctamente las traducciones.")
@@ -190,7 +190,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
microsoft_translate_client_response = generate_response(resource)
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
click_button "Traducir página"
@@ -201,7 +201,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
microsoft_translate_client_response = generate_response(resource)
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
visit path
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
click_button "Traducir página"

View File

@@ -161,7 +161,7 @@ describe "Admin poll questions", :admin do
expect(page).to have_select("poll_question_poll_id", options: ["Select Poll", poll.name_en])
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).to have_select("poll_question_poll_id",
options: ["Seleccionar votación", poll.name_es])
@@ -180,7 +180,7 @@ describe "Admin poll questions", :admin do
expect(page).to have_select("poll_question_poll_id", options: ["Select Poll", poll.name_en])
select("Français", from: "locale-switcher")
select "Français", from: "Language:"
expect(page).to have_select("poll_question_poll_id",
options: ["Sélectionner un vote", poll.name_es])

View File

@@ -112,7 +112,7 @@ describe "Admin edit translatable records", :admin do
click_button "Save changes"
visit path
select "Português brasileiro", from: "locale-switcher"
select "Português brasileiro", from: "Language:"
expect(page).to have_field "Questão", with: "Português"
end
@@ -205,7 +205,7 @@ describe "Admin edit translatable records", :admin do
expect(page).to have_field "Title", with: "Title in English"
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).to have_field "Título", with: "Título corregido"
expect(page).to have_field "Descripción", with: "Descripción corregida"
@@ -234,7 +234,7 @@ describe "Admin edit translatable records", :admin do
expect(page).to have_field "Answer", with: "Answer in English"
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(page).to have_field "Respuesta", with: "Respuesta corregida"
expect(page).to have_ckeditor "Descripción", with: "Descripción corregida"
@@ -466,7 +466,7 @@ describe "Admin edit translatable records", :admin do
expect_to_have_language_selected "English"
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect_to_have_language_selected "Español"
end

View File

@@ -22,7 +22,7 @@ describe "Admin Budgets", :admin do
name_fr: "Budget pour le changement climatique")
visit admin_budgets_path
select("Français", from: "locale-switcher")
select "Français", from: "Language:"
click_link "Bulletins de ladmin"

View File

@@ -19,31 +19,26 @@ describe "Localization" do
scenario "Available locales appear in the locale switcher" do
visit "/"
within(".locale-form .js-location-changer") do
expect(page).to have_content "Español"
expect(page).to have_content "English"
end
expect(page).to have_select "Language:", with_options: %w[Español English]
end
scenario "The current locale is selected" do
visit "/"
expect(page).to have_select("locale-switcher", selected: "English")
expect(page).to have_select "Language:", selected: "English"
end
scenario "Changing the locale" do
visit "/"
expect(page).to have_content("Language")
select "Español", from: "Language:"
select("Español", from: "locale-switcher")
expect(page).to have_content("Idioma")
expect(page).not_to have_content("Language")
expect(page).to have_select("locale-switcher", selected: "Español")
expect(page).not_to have_select "Language:"
expect(page).to have_select "Idioma:", selected: "Español"
end
scenario "Keeps query parameters while using protected redirects" do
visit "/debates?order=created_at&host=evil.dev"
select("Español", from: "locale-switcher")
select "Español", from: "Language:"
expect(current_host).to eq "http://127.0.0.1"
expect(page).to have_current_path "/debates?locale=es&order=created_at"
@@ -83,9 +78,7 @@ describe "Localization" do
scenario "Available locales without language translation display locale key" do
visit "/"
within(".locale-form .js-location-changer") do
expect(page).to have_content "wl"
end
expect(page).to have_select "Language:", with_options: ["wl"]
end
end

View File

@@ -12,26 +12,21 @@ describe "Localization" do
scenario "Available locales appear in the locale switcher" do
login_as_manager
within(".locale-form .js-location-changer") do
expect(page).to have_content "Español"
expect(page).to have_content "English"
end
expect(page).to have_select "Language:", with_options: %w[Español English]
end
scenario "The current locale is selected" do
login_as_manager
expect(page).to have_select("locale-switcher", selected: "English")
expect(page).to have_select "Language:", selected: "English"
expect(page).to have_text("Management")
end
scenario "Changing the locale" do
login_as_manager
expect(page).to have_content("Language")
select "Español", from: "Language:"
select("Español", from: "locale-switcher")
expect(page).to have_content("Idioma")
expect(page).not_to have_content("Language")
expect(page).to have_select("locale-switcher", selected: "Español")
expect(page).not_to have_select "Language:"
expect(page).to have_select "Idioma:", selected: "Español"
end
scenario "Locale switcher not present if only one locale" do

View File

@@ -115,7 +115,7 @@ describe "Public area translatable records" do
scenario "Highlight new locale added" do
visit new_proposal_path
select "Español", from: "locale-switcher"
select "Español", from: "Language:"
expect_to_have_language_selected "Español"
end
@@ -206,7 +206,7 @@ describe "Public area translatable records" do
expect(page).to have_field "Debate title", with: "Title in English"
select "Español", from: "locale-switcher"
select "Español", from: "Language:"
expect(page).to have_field "Título del debate", with: "Título corregido"
expect(page).to have_ckeditor "Texto inicial del debate", with: "Texto corregido"