Make proposals map test more robust
We were testing what happens when clicking on a geozone without HTML coordinates, which won't happen in a real browser. So we're now defining the HTML coordinates and clicking on the area in the test, which is what real people will do. We also avoid having two consecutive `visit` calls, which will interfere with the way we plan to test the presence of the <main> tag after every `visit`. Note that, the test didn't work with the HTML coordinates defined in the `with_html_coordinates` trait, with Capybara showing the following error: ``` Selenium::WebDriver::Error::ElementClickInterceptedError: element click intercepted: Element <area shape="poly" coords="30,139,45,153,77,148,107,165" href="/proposals?search=California" title="California" alt="California"> is not clickable at point (413, 456). Other element would receive the click: <img usemap="#map" src="/assets/map.jpg"> ``` The cause of this error was the strange shape of the polygon, which was greatly concave and and so the middle of its area wasn't part of it. We're changing the polygon so it's now convex and when Capybara clicks on its middle point everything will work as expected.
This commit is contained in:
@@ -15,7 +15,7 @@ FactoryBot.define do
|
|||||||
end
|
end
|
||||||
|
|
||||||
trait :with_html_coordinates do
|
trait :with_html_coordinates do
|
||||||
html_map_coordinates { "30,139,45,153,77,148,107,165" }
|
html_map_coordinates { "30,139,45,153,77,148,107,125" }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_geojson do
|
trait :with_geojson do
|
||||||
|
|||||||
@@ -1353,8 +1353,8 @@ describe "Proposals" do
|
|||||||
|
|
||||||
context "Filter" do
|
context "Filter" do
|
||||||
context "By geozone" do
|
context "By geozone" do
|
||||||
let(:california) { Geozone.create(name: "California") }
|
let(:california) { create(:geozone, :with_html_coordinates, name: "California") }
|
||||||
let(:new_york) { Geozone.create(name: "New York") }
|
let(:new_york) { create(:geozone, name: "New York") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
create(:proposal, geozone: california, title: "Bigger sequoias")
|
create(:proposal, geozone: california, title: "Bigger sequoias")
|
||||||
@@ -1362,14 +1362,11 @@ describe "Proposals" do
|
|||||||
create(:proposal, geozone: new_york, title: "Sully monument")
|
create(:proposal, geozone: new_york, title: "Sully monument")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "From map", :no_js do
|
scenario "From map" do
|
||||||
visit proposals_path
|
visit proposals_path
|
||||||
|
|
||||||
click_link "map"
|
click_link "map"
|
||||||
within("#html_map") do
|
within("#html_map") { find("area[title='California']").click }
|
||||||
url = find("area[title='California']")[:href]
|
|
||||||
visit url
|
|
||||||
end
|
|
||||||
|
|
||||||
within("#proposals") do
|
within("#proposals") do
|
||||||
expect(page).to have_css(".proposal", count: 2)
|
expect(page).to have_css(".proposal", count: 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user