From 3ab9fb1d27d33b65e0e756495bfef2baf5d824da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 21 Sep 2024 21:26:52 +0200 Subject: [PATCH] Simplify similar remotely translatable tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were using the same setup in these tests, and we were only changing the expectations or adding an extra step. Note we're also using `refresh` to simplify the code and because we were using `select "Español", from: "Idioma:"` when that language was already selected. --- spec/shared/system/remotely_translatable.rb | 47 +++++---------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/spec/shared/system/remotely_translatable.rb b/spec/shared/system/remotely_translatable.rb index 6411f3300..3ad197d49 100644 --- a/spec/shared/system/remotely_translatable.rb +++ b/spec/shared/system/remotely_translatable.rb @@ -135,15 +135,6 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume context "After click remote translations button" do describe "with delayed jobs", :delay_jobs do - scenario "the remote translation button should not be present" do - visit path - select "Español", from: "Language:" - - click_button "Traducir página" - - expect(page).not_to have_button "Traducir página" - end - scenario "the remote translation is pending to translate" do visit path select "Español", from: "Language:" @@ -151,45 +142,27 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume 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 + scenario "shows informative text when content is enqueued" do visit path select "Español", from: "Language:" click_button "Traducir página" - expect(page).to have_content "Se han solicitado correctamente las traducciones." - expect(page).to have_content "En un breve periodo de tiempo refrescando la página " \ - "podrá ver todo el contenido en su idioma" - end - - scenario "should be present only informative text when user visit page with all content enqueued" do - visit path - 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: "Idioma:" - - 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).not_to have_button "Traducir página" + expect(page).to have_content "Se han solicitado correctamente las traducciones." + expect(page).to have_content "En un breve periodo de tiempo refrescando la página " \ + "podrá ver todo el contenido en su idioma" + + refresh + expect(page).not_to have_content "Se han solicitado correctamente las traducciones." + 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" end end describe "without delayed jobs" do - scenario "the remote translation button should not be present" do - response = generate_response(resource) - expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response) - visit path - select "Español", from: "Language:" - - click_button "Traducir página" - - expect(page).not_to have_button "Traducir página" - end - scenario "the remote translation has been translated and destoyed" do response = generate_response(resource) expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)