We weren't checking that the request caused by clicking on the "Send
instructions" button had finished before continuing with the test.
Perhaps that's why this test has recently failed on our CI:
```
3) Emails Reset password
Failure/Error: email = open_last_email
RuntimeError:
No email has been sent!
```
We're also adding an expectation to the `login_as_manager` method and
the methods to submit proposal and investment forms to make sure that,
when these method finish, the request finishes as well.
53 lines
1.7 KiB
Ruby
53 lines
1.7 KiB
Ruby
module Maps
|
|
def fill_in_proposal_form
|
|
fill_in_new_proposal_title with: "Help refugees"
|
|
fill_in "Proposal summary", with: "In summary, what we want is..."
|
|
end
|
|
|
|
def submit_proposal_form
|
|
check :proposal_terms_of_service
|
|
click_button "Create proposal"
|
|
expect(page).to have_content "Proposal created successfully."
|
|
|
|
if page.has_content?("Not now, go to my proposal")
|
|
click_link "Not now, go to my proposal"
|
|
|
|
expect(page).not_to have_link "Not now, go to my proposal"
|
|
end
|
|
end
|
|
|
|
def fill_in_budget_investment_form
|
|
fill_in_new_investment_title with: "Budget investment title"
|
|
fill_in_ckeditor "Description", with: "Budget investment description"
|
|
check :budget_investment_terms_of_service
|
|
end
|
|
|
|
def submit_budget_investment_form
|
|
check :budget_investment_terms_of_service
|
|
click_button "Create Investment"
|
|
expect(page).to have_content "Budget Investment created successfully"
|
|
end
|
|
|
|
def set_arguments(arguments, mappable, mappable_path_arguments)
|
|
mappable_path_arguments&.each do |argument_name, path_to_value|
|
|
arguments.merge!("#{argument_name}": mappable.send(path_to_value))
|
|
end
|
|
end
|
|
|
|
def map_zoom_in
|
|
initial_zoom = page.execute_script("return App.Map.maps[0].getZoom();")
|
|
find(".leaflet-control-zoom-in").click
|
|
until page.execute_script("return App.Map.maps[0].getZoom() === #{initial_zoom + 1};") do
|
|
sleep 0.01
|
|
end
|
|
end
|
|
|
|
def place_map_at(latitude, longitude)
|
|
page.execute_script("App.Map.maps[0].setView(new L.LatLng(#{latitude}, #{longitude}))")
|
|
|
|
until page.execute_script("return App.Map.maps[0].getCenter().lat === #{latitude};") do
|
|
sleep 0.01
|
|
end
|
|
end
|
|
end
|