Directly select language in remotely translatable tests
The test "request a translation of an already translated text" was failing sometimes on our CI since August 29, maybe due to a change in GitHub Actions since the test had been passing for a year and a half and we didn't change any code around that time (we were updating the documentation). While the root cause is unknown, debugging shows that sometimes (usually the first time this test is executed on our CI, and only the first time, since running it 600 tests in a row also resulted in only one failure) the request done by clicking on "Traducir página" is done with a user session where the locale is in English. This doesn't make much sense, since both user sessions are already in Spanish (and we had either explicit or implicit expectations to confirm that), and debugging shows that the session is indeed in Spanish during the previous request. In any case, we're solving it by never using English during the test, since it wasn't necessary; it was only done that way because all the tests on this file used the language selector to get to the Spanish pages. We're simplifying some of the other tests the same way. The test failure was: ``` Failure/Error: expect(page).to have_content "Se han solicitado correctamente las traducciones" expected to find text "Se han solicitado correctamente las traducciones" in "Idioma: \n \nEnglish\nDeutsch\nEspañol\nFrançais\nNederlands\nPortuguês brasileiro\n中文\n Entrar\nRegistrarse\nDebates\nPropuestas\nVotaciones\nLegislación colaborativa\nPresupuestos participativos\nODS\nAyuda\n×\nTranslations have been correctly requested.\nPropuestas más activas\nAhora mismo no hay propuestas\nDebates más activos\nndfrrqufrp\nVer todos los debates\nProcesos abiertos\nAhora mismo no hay procesos abiertos\nGobierno abierto\nEste portal usa la aplicación CONSUL DEMOCRACY que es software de código abierto.\nParticipación\nDecide cómo debe ser la ciudad que quieres.\nCONSUL DEMOCRACY, 2024 Política de privacidad Condiciones de uso Accesibilidad" ``` Note that most of the text is in Spanish (as expected) but the flash message itself is in English.
This commit is contained in:
@@ -5,6 +5,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
path_arguments.transform_values { |path_to_value| resource.send(path_to_value) }
|
path_arguments.transform_values { |path_to_value| resource.send(path_to_value) }
|
||||||
end
|
end
|
||||||
let(:path) { send(path_name, arguments) }
|
let(:path) { send(path_name, arguments) }
|
||||||
|
let(:path_in_spanish) { send(path_name, arguments.merge(locale: :es)) }
|
||||||
let!(:resource) { create(factory_name) }
|
let!(:resource) { create(factory_name) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@@ -24,9 +25,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
end
|
end
|
||||||
|
|
||||||
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_in_spanish
|
||||||
|
|
||||||
select "Español", from: "Language:"
|
|
||||||
|
|
||||||
expect(page).to have_button "Traducir página"
|
expect(page).to have_button "Traducir página"
|
||||||
end
|
end
|
||||||
@@ -44,20 +43,15 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
|
|
||||||
scenario "should not be present when there are no resources to translate", if: index_path?(path_name) do
|
scenario "should not be present when there are no resources to translate", if: index_path?(path_name) do
|
||||||
resource.destroy!
|
resource.destroy!
|
||||||
visit path
|
visit path_in_spanish
|
||||||
|
|
||||||
select "Español", from: "Language:"
|
|
||||||
|
|
||||||
expect(page).to have_select "Idioma:"
|
|
||||||
expect(page).not_to have_button "Traducir página"
|
expect(page).not_to have_button "Traducir página"
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with delayed job active", :delay_jobs do
|
describe "with delayed job active", :delay_jobs do
|
||||||
scenario "should not be present when an equal RemoteTranslation is enqueued" do
|
scenario "should not be present when an equal RemoteTranslation is enqueued" do
|
||||||
create(:remote_translation, remote_translatable: resource, locale: :es)
|
create(:remote_translation, remote_translatable: resource, locale: :es)
|
||||||
visit path
|
visit path_in_spanish
|
||||||
|
|
||||||
select "Español", from: "Language:"
|
|
||||||
|
|
||||||
expect(page).to have_content "En un breve periodo de tiempo refrescando la 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"
|
"podrá ver todo el contenido en su idioma"
|
||||||
@@ -136,8 +130,7 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
context "After click remote translations button" do
|
context "After click remote translations button" do
|
||||||
describe "with delayed jobs", :delay_jobs do
|
describe "with delayed jobs", :delay_jobs do
|
||||||
scenario "shows informative text when content is enqueued" do
|
scenario "shows informative text when content is enqueued" do
|
||||||
visit path
|
visit path_in_spanish
|
||||||
select "Español", from: "Language:"
|
|
||||||
|
|
||||||
click_button "Traducir página"
|
click_button "Traducir página"
|
||||||
|
|
||||||
@@ -159,10 +152,8 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
scenario "content is immediately translated" do
|
scenario "content is immediately translated" do
|
||||||
response = generate_response(resource)
|
response = generate_response(resource)
|
||||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||||
visit path
|
visit path_in_spanish
|
||||||
select "Español", from: "Language:"
|
|
||||||
|
|
||||||
expect(page).to have_select "Idioma:"
|
|
||||||
expect(page).not_to have_content response.first
|
expect(page).not_to have_content response.first
|
||||||
|
|
||||||
click_button "Traducir página"
|
click_button "Traducir página"
|
||||||
@@ -176,15 +167,13 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
|
|||||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||||
|
|
||||||
in_browser(:one) do
|
in_browser(:one) do
|
||||||
visit path
|
visit path_in_spanish
|
||||||
select "Español", from: "Language:"
|
|
||||||
|
|
||||||
expect(page).to have_button "Traducir página"
|
expect(page).to have_button "Traducir página"
|
||||||
end
|
end
|
||||||
|
|
||||||
in_browser(:two) do
|
in_browser(:two) do
|
||||||
visit path
|
visit path_in_spanish
|
||||||
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user