Use JavaScript in tests opening modal dialogs

This way we reproduce the user experience in the tests, and we can make
sure modal dialogs open when we expect it.
This commit is contained in:
Javi Martín
2021-03-29 13:28:41 +02:00
parent fbc78984dc
commit b2bc4d19f5
38 changed files with 221 additions and 178 deletions

View File

@@ -365,7 +365,7 @@ describe "Emails" do
expect(email).to have_body_text(budget_path(budget))
end
scenario "Unfeasible investment" do
scenario "Unfeasible investment", :js do
budget.update!(phase: "valuating")
valuator = create(:valuator)
investment = create(:budget_investment, author: author, budget: budget, valuators: [valuator])
@@ -375,7 +375,7 @@ describe "Emails" do
within_fieldset("Feasibility") { choose "Unfeasible" }
fill_in "Feasibility explanation", with: "This is not legal as stated in Article 34.9"
check "Valuation finished"
accept_confirm { check "Valuation finished" }
click_button "Save changes"
expect(page).to have_content "Dossier updated"
@@ -478,6 +478,8 @@ describe "Emails" do
click_link "Send"
expect(page).to have_content "Newsletter sent successfully"
expect(unread_emails_for(user_with_newsletter_in_segment_1.email).count).to eq 1
expect(unread_emails_for(user_with_newsletter_in_segment_2.email).count).to eq 1
expect(unread_emails_for(user_with_newsletter_not_in_segment.email).count).to eq 0