From 0fcb97a78f4ac64ae4187a713c07c78b78fef716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 27 Mar 2021 14:43:14 +0100 Subject: [PATCH] Specify we're testing validation on the server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Testing the validation on the server side doesn't work with chromedriver because HTML valdations result in the browser not even submitting the form, so we're adding a `:no_js` tag to indicate we deliberately choose to use the Rack driver. The following test checking client side validation passes on my machine but fails on Github Actions: ``` scenario "Validates price formats on the client side", :js do investment.update!(visible_to_valuators: true) visit edit_valuation_budget_budget_investment_path(budget, investment) fill_in "Price (€)", with: "12345,98" click_button "Save changes" validation_message = find_field("Price (€)").native.attribute("validationMessage") expect(validation_message).to be_present end ``` --- spec/system/valuation/budget_investments_spec.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/spec/system/valuation/budget_investments_spec.rb b/spec/system/valuation/budget_investments_spec.rb index b685ef346..df45282b6 100644 --- a/spec/system/valuation/budget_investments_spec.rb +++ b/spec/system/valuation/budget_investments_spec.rb @@ -442,17 +442,13 @@ describe "Valuation budget investments" do end end - scenario "Validates price formats" do + scenario "Validates price formats on the server side", :no_js do investment.update!(visible_to_valuators: true) - visit valuation_budget_budget_investments_path(budget) + visit edit_valuation_budget_budget_investment_path(budget, investment) - within("#budget_investment_#{investment.id}") do - click_link "Edit dossier" - end - - fill_in "budget_investment_price", with: "12345,98" - fill_in "budget_investment_price_first_year", with: "9876.6" + fill_in "Price (€)", with: "12345,98" + fill_in "Cost during the first year (€) (optional, data not public)", with: "9876.6" click_button "Save changes" expect(page).to have_content("2 errors")