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:
@@ -34,7 +34,7 @@ shared_examples "milestoneable" do |factory_name|
|
|||||||
expect(page).to have_content(first_milestone.status.name)
|
expect(page).to have_content(first_milestone.status.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
find("#tab-milestones-label").click
|
find("#tab-milestones-label").click
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
scenario "should be present when current locale translation does not exists" do
|
||||||
visit path
|
visit path
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
expect(page).to have_button("Traducir página")
|
expect(page).to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -35,7 +35,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
visit path
|
visit path
|
||||||
expect(page).not_to have_button("Translate page")
|
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")
|
expect(page).not_to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -45,7 +45,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
resource.destroy!
|
resource.destroy!
|
||||||
visit path
|
visit path
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
expect(page).not_to have_button("Traducir página")
|
expect(page).not_to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -55,7 +55,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
create(:remote_translation, remote_translatable: resource, locale: :es)
|
create(:remote_translation, remote_translatable: resource, locale: :es)
|
||||||
visit path
|
visit path
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
expect(page).not_to have_button("Traducir página")
|
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")
|
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
|
visit path
|
||||||
expect(page).not_to have_button("Translate page")
|
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")
|
expect(page).not_to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -94,7 +94,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
visit path
|
visit path
|
||||||
expect(page).not_to have_button("Translate page")
|
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")
|
expect(page).to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -105,7 +105,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
visit path
|
visit path
|
||||||
expect(page).not_to have_button("Translate page")
|
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")
|
expect(page).not_to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -120,7 +120,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
visit path
|
visit path
|
||||||
expect(page).not_to have_button("Translate page")
|
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")
|
expect(page).to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -135,7 +135,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
visit path
|
visit path
|
||||||
expect(page).not_to have_button("Translate page")
|
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")
|
expect(page).to have_button("Traducir página")
|
||||||
end
|
end
|
||||||
@@ -146,7 +146,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
describe "with delayed jobs", :delay_jobs do
|
describe "with delayed jobs", :delay_jobs do
|
||||||
scenario "the remote translation button should not be present" do
|
scenario "the remote translation button should not be present" do
|
||||||
visit path
|
visit path
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
click_button "Traducir página"
|
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
|
scenario "the remote translation is pending to translate" do
|
||||||
visit path
|
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)
|
expect { click_button "Traducir página" }.to change { RemoteTranslation.count }.from(0).to(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "should be present enqueued notice and informative text" do
|
scenario "should be present enqueued notice and informative text" do
|
||||||
visit path
|
visit path
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
click_button "Traducir página"
|
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
|
scenario "should be present only informative text when user visit page with all content enqueued" do
|
||||||
visit path
|
visit path
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
click_button "Traducir página"
|
click_button "Traducir página"
|
||||||
expect(page).to have_content("Se han solicitado correctamente las traducciones.")
|
expect(page).to have_content("Se han solicitado correctamente las traducciones.")
|
||||||
|
|
||||||
visit path
|
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_button "Traducir página"
|
||||||
expect(page).not_to have_content("Se han solicitado correctamente las traducciones.")
|
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)
|
microsoft_translate_client_response = generate_response(resource)
|
||||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
|
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
|
||||||
visit path
|
visit path
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
click_button "Traducir página"
|
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)
|
microsoft_translate_client_response = generate_response(resource)
|
||||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
|
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
|
||||||
visit path
|
visit path
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
click_button "Traducir página"
|
click_button "Traducir página"
|
||||||
|
|
||||||
|
|||||||
@@ -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])
|
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",
|
expect(page).to have_select("poll_question_poll_id",
|
||||||
options: ["Seleccionar votación", poll.name_es])
|
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])
|
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",
|
expect(page).to have_select("poll_question_poll_id",
|
||||||
options: ["Sélectionner un vote", poll.name_es])
|
options: ["Sélectionner un vote", poll.name_es])
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ describe "Admin edit translatable records", :admin do
|
|||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
visit path
|
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"
|
expect(page).to have_field "Questão", with: "Português"
|
||||||
end
|
end
|
||||||
@@ -205,7 +205,7 @@ describe "Admin edit translatable records", :admin do
|
|||||||
|
|
||||||
expect(page).to have_field "Title", with: "Title in English"
|
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 "Título", with: "Título corregido"
|
||||||
expect(page).to have_field "Descripción", with: "Descripción corregida"
|
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"
|
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_field "Respuesta", with: "Respuesta corregida"
|
||||||
expect(page).to have_ckeditor "Descripción", with: "Descripción 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"
|
expect_to_have_language_selected "English"
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
expect_to_have_language_selected "Español"
|
expect_to_have_language_selected "Español"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ describe "Admin Budgets", :admin do
|
|||||||
name_fr: "Budget pour le changement climatique")
|
name_fr: "Budget pour le changement climatique")
|
||||||
|
|
||||||
visit admin_budgets_path
|
visit admin_budgets_path
|
||||||
select("Français", from: "locale-switcher")
|
select "Français", from: "Language:"
|
||||||
|
|
||||||
click_link "Bulletins de l’admin"
|
click_link "Bulletins de l’admin"
|
||||||
|
|
||||||
|
|||||||
@@ -19,31 +19,26 @@ describe "Localization" do
|
|||||||
scenario "Available locales appear in the locale switcher" do
|
scenario "Available locales appear in the locale switcher" do
|
||||||
visit "/"
|
visit "/"
|
||||||
|
|
||||||
within(".locale-form .js-location-changer") do
|
expect(page).to have_select "Language:", with_options: %w[Español English]
|
||||||
expect(page).to have_content "Español"
|
|
||||||
expect(page).to have_content "English"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "The current locale is selected" do
|
scenario "The current locale is selected" do
|
||||||
visit "/"
|
visit "/"
|
||||||
expect(page).to have_select("locale-switcher", selected: "English")
|
expect(page).to have_select "Language:", selected: "English"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Changing the locale" do
|
scenario "Changing the locale" do
|
||||||
visit "/"
|
visit "/"
|
||||||
expect(page).to have_content("Language")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
expect(page).not_to have_select "Language:"
|
||||||
expect(page).to have_content("Idioma")
|
expect(page).to have_select "Idioma:", selected: "Español"
|
||||||
expect(page).not_to have_content("Language")
|
|
||||||
expect(page).to have_select("locale-switcher", selected: "Español")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Keeps query parameters while using protected redirects" do
|
scenario "Keeps query parameters while using protected redirects" do
|
||||||
visit "/debates?order=created_at&host=evil.dev"
|
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(current_host).to eq "http://127.0.0.1"
|
||||||
expect(page).to have_current_path "/debates?locale=es&order=created_at"
|
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
|
scenario "Available locales without language translation display locale key" do
|
||||||
visit "/"
|
visit "/"
|
||||||
|
|
||||||
within(".locale-form .js-location-changer") do
|
expect(page).to have_select "Language:", with_options: ["wl"]
|
||||||
expect(page).to have_content "wl"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -12,26 +12,21 @@ describe "Localization" do
|
|||||||
scenario "Available locales appear in the locale switcher" do
|
scenario "Available locales appear in the locale switcher" do
|
||||||
login_as_manager
|
login_as_manager
|
||||||
|
|
||||||
within(".locale-form .js-location-changer") do
|
expect(page).to have_select "Language:", with_options: %w[Español English]
|
||||||
expect(page).to have_content "Español"
|
|
||||||
expect(page).to have_content "English"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "The current locale is selected" do
|
scenario "The current locale is selected" do
|
||||||
login_as_manager
|
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")
|
expect(page).to have_text("Management")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Changing the locale" do
|
scenario "Changing the locale" do
|
||||||
login_as_manager
|
login_as_manager
|
||||||
expect(page).to have_content("Language")
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
expect(page).not_to have_select "Language:"
|
||||||
expect(page).to have_content("Idioma")
|
expect(page).to have_select "Idioma:", selected: "Español"
|
||||||
expect(page).not_to have_content("Language")
|
|
||||||
expect(page).to have_select("locale-switcher", selected: "Español")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Locale switcher not present if only one locale" do
|
scenario "Locale switcher not present if only one locale" do
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ describe "Public area translatable records" do
|
|||||||
scenario "Highlight new locale added" do
|
scenario "Highlight new locale added" do
|
||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
|
|
||||||
select "Español", from: "locale-switcher"
|
select "Español", from: "Language:"
|
||||||
|
|
||||||
expect_to_have_language_selected "Español"
|
expect_to_have_language_selected "Español"
|
||||||
end
|
end
|
||||||
@@ -206,7 +206,7 @@ describe "Public area translatable records" do
|
|||||||
|
|
||||||
expect(page).to have_field "Debate title", with: "Title in English"
|
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_field "Título del debate", with: "Título corregido"
|
||||||
expect(page).to have_ckeditor "Texto inicial del debate", with: "Texto corregido"
|
expect(page).to have_ckeditor "Texto inicial del debate", with: "Texto corregido"
|
||||||
|
|||||||
Reference in New Issue
Block a user