From 78c2f54c5d0081bbbcc4756af145a163902975b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 25 Jan 2019 11:26:39 +0100 Subject: [PATCH] Fix proposal specs After adding proposal translatable fields to forms, they will be generated with nested translations names and ids so we can no longer use standard id locator. Using input label text to fill in fields works with both types of forms. --- spec/features/management/proposals_spec.rb | 6 +- spec/features/proposals_spec.rb | 72 ++++++++++----------- spec/features/tags/proposals_spec.rb | 22 +++---- spec/shared/features/mappable.rb | 8 +-- spec/shared/features/nested_documentable.rb | 4 +- spec/shared/features/nested_imageable.rb | 4 +- spec/support/common_actions.rb | 6 +- 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/spec/features/management/proposals_spec.rb b/spec/features/management/proposals_spec.rb index 3f3ef2840..e2a808af2 100644 --- a/spec/features/management/proposals_spec.rb +++ b/spec/features/management/proposals_spec.rb @@ -21,9 +21,9 @@ describe "Proposals" do expect(page).to have_content user.document_number.to_s end - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "This is very important because..." fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yRYFKcMa_Ek" check "proposal_terms_of_service" diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index f477ad7ba..d2ecf5776 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -238,9 +238,9 @@ describe "Proposals" do visit new_proposal_path - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "This is very important because..." fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" fill_in "proposal_responsible_name", with: "Isabel Garcia" fill_in "proposal_tag_list", with: "Refugees, Solidarity" @@ -272,10 +272,10 @@ describe "Proposals" do login_as(author) visit new_proposal_path - fill_in "proposal_title", with: "I am a bot" + fill_in "Proposal title", with: "I am a bot" fill_in "proposal_subtitle", with: "This is the honeypot field" - fill_in "proposal_summary", with: "This is the summary" - fill_in "proposal_description", with: "This is the description" + fill_in "Proposal summary", with: "This is the summary" + fill_in "Proposal text", with: "This is the description" fill_in "proposal_responsible_name", with: "Some other robot" check "proposal_terms_of_service" @@ -293,9 +293,9 @@ describe "Proposals" do login_as(author) visit new_proposal_path - fill_in "proposal_title", with: "I am a bot" - fill_in "proposal_summary", with: "This is the summary" - fill_in "proposal_description", with: "This is the description" + fill_in "Proposal title", with: "I am a bot" + fill_in "Proposal summary", with: "This is the summary" + fill_in "Proposal text", with: "This is the description" fill_in "proposal_responsible_name", with: "Some other robot" check "proposal_terms_of_service" @@ -311,9 +311,9 @@ describe "Proposals" do login_as(author) visit new_proposal_path - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "This is very important because..." fill_in "proposal_responsible_name", with: "Isabel Garcia" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -334,9 +334,9 @@ describe "Proposals" do visit new_proposal_path expect(page).not_to have_selector("#proposal_responsible_name") - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "This is very important because..." check "proposal_terms_of_service" click_button "Create proposal" @@ -362,9 +362,9 @@ describe "Proposals" do login_as(author) visit new_proposal_path - fill_in "proposal_title", with: "Testing an attack" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "

This is

" + fill_in "Proposal title", with: "Testing an attack" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "

This is

" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -385,9 +385,9 @@ describe "Proposals" do login_as(author) visit new_proposal_path - fill_in "proposal_title", with: "Testing auto link" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "

This is a link www.example.org

" + fill_in "Proposal title", with: "Testing auto link" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "

This is a link www.example.org

" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -407,9 +407,9 @@ describe "Proposals" do login_as(author) visit new_proposal_path - fill_in "proposal_title", with: "Testing auto link" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: js_injection_string + fill_in "Proposal title", with: "Testing auto link" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: js_injection_string fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -465,9 +465,9 @@ describe "Proposals" do visit new_proposal_path - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "This is very important because..." fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -622,9 +622,9 @@ describe "Proposals" do visit edit_proposal_path(proposal) expect(page).to have_current_path(edit_proposal_path(proposal)) - fill_in "proposal_title", with: "End child poverty" - fill_in "proposal_summary", with: "Basically..." - fill_in "proposal_description", with: "Let's do something to end child poverty" + fill_in "Proposal title", with: "End child poverty" + fill_in "Proposal summary", with: "Basically..." + fill_in "Proposal text", with: "Let's do something to end child poverty" fill_in "proposal_responsible_name", with: "Isabel Garcia" click_button "Save changes" @@ -640,7 +640,7 @@ describe "Proposals" do login_as(proposal.author) visit edit_proposal_path(proposal) - fill_in "proposal_title", with: "" + fill_in "Proposal title", with: "" click_button "Save changes" expect(page).to have_content error_message @@ -1719,7 +1719,7 @@ describe "Proposals" do create(:proposal, title: "Seventh proposal, has search term") visit new_proposal_path - fill_in "proposal_title", with: "search" + fill_in "Proposal title", with: "search" check "proposal_terms_of_service" within("div#js-suggest") do @@ -1735,7 +1735,7 @@ describe "Proposals" do create(:proposal, title: "Second proposal").update_column(:confidence_score, 8) visit new_proposal_path - fill_in "proposal_title", with: "debate" + fill_in "Proposal title", with: "debate" check "proposal_terms_of_service" within("div#js-suggest") do @@ -1913,9 +1913,9 @@ describe "Successful proposals" do expect(current_path).to eq(new_proposal_path) - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary what we want is..." + fill_in "Proposal text", with: "This is very important because..." fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" fill_in "proposal_tag_list", with: "Refugees, Solidarity" check "proposal_terms_of_service" diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index d471b01e0..db0f02d83 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -69,9 +69,9 @@ describe "Tags" do login_as(user) visit new_proposal_path - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "This is very important because..." fill_in "proposal_responsible_name", with: "Isabel Garcia" fill_in "proposal_tag_list", with: "Economía, Hacienda" check "proposal_terms_of_service" @@ -95,9 +95,9 @@ describe "Tags" do visit new_proposal_path - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in_ckeditor "proposal_description", with: "A description with enough characters" + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in_ckeditor "Proposal text", with: "A description with enough characters" fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=Ae6gQmhaMn4" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" @@ -120,8 +120,8 @@ describe "Tags" do login_as(user) visit new_proposal_path - fill_in "proposal_title", with: "Title" - fill_in "proposal_description", with: "Description" + fill_in "Proposal title", with: "Title" + fill_in "Proposal text", with: "Description" check "proposal_terms_of_service" fill_in "proposal_tag_list", with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" @@ -138,9 +138,9 @@ describe "Tags" do visit new_proposal_path - fill_in "proposal_title", with: "A test of dangerous strings" - fill_in "proposal_summary", with: "In summary, what we want is..." - fill_in "proposal_description", with: "A description suitable for this test" + fill_in "Proposal title", with: "A test of dangerous strings" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "A description suitable for this test" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service" diff --git a/spec/shared/features/mappable.rb b/spec/shared/features/mappable.rb index bce1071f3..eb426bc34 100644 --- a/spec/shared/features/mappable.rb +++ b/spec/shared/features/mappable.rb @@ -147,7 +147,7 @@ shared_examples "mappable" do |mappable_factory_name, do_login_for mappable.author visit send(mappable_edit_path, id: mappable.id) - fill_in "#{mappable_factory_name}_title", with: "New title" + fill_in "#{mappable_factory_name.camelize} title", with: "New title" click_on("Save changes") mappable.reload @@ -172,7 +172,7 @@ shared_examples "mappable" do |mappable_factory_name, do_login_for mappable.author visit send(mappable_edit_path, id: mappable.id) - fill_in "#{mappable_factory_name}_title", with: "New title" + fill_in "#{mappable_factory_name.camelize} title", with: "New title" click_on("Save changes") expect(page).not_to have_css(".map_location") @@ -249,8 +249,8 @@ def do_login_for(user) end def fill_in_proposal_form - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." end def submit_proposal_form diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index e07b26680..9111d085b 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -363,8 +363,8 @@ def expect_document_has_cached_attachment(index, extension) end def documentable_fill_new_valid_proposal - fill_in :proposal_title, with: "Proposal title #{rand(9999)}" - fill_in :proposal_summary, with: "Proposal summary" + fill_in "Proposal title", with: "Proposal title #{rand(9999)}" + fill_in "Proposal summary", with: "Proposal summary" check :proposal_terms_of_service end diff --git a/spec/shared/features/nested_imageable.rb b/spec/shared/features/nested_imageable.rb index 1e5d9ec34..41819fba6 100644 --- a/spec/shared/features/nested_imageable.rb +++ b/spec/shared/features/nested_imageable.rb @@ -289,8 +289,8 @@ def imageable_attach_new_file(_imageable_factory_name, path, success = true) end def imageable_fill_new_valid_proposal - fill_in :proposal_title, with: "Proposal title" - fill_in :proposal_summary, with: "Proposal summary" + fill_in "Proposal title", with: "Proposal title" + fill_in "Proposal summary", with: "Proposal summary" check :proposal_terms_of_service end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index efabd1532..2a2d2e3b7 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -27,9 +27,9 @@ module CommonActions end def fill_in_proposal - fill_in "proposal_title", with: "Help refugees" - fill_in "proposal_summary", with: "In summary what we want is..." - fill_in "proposal_description", with: "This is very important because..." + fill_in "Proposal title", with: "Help refugees" + fill_in "Proposal summary", with: "In summary, what we want is..." + fill_in "Proposal text", with: "This is very important because..." fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" fill_in "proposal_responsible_name", with: "Isabel Garcia" check "proposal_terms_of_service"