Merge pull request #3699 from consul/upgrade_turbolinks
Bump turbolinks to 5.2.1
This commit is contained in:
@@ -79,6 +79,95 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
expect(page).to have_content "Map location can't be blank"
|
||||
end
|
||||
|
||||
describe "When restoring the page from browser history" do
|
||||
scenario "map should not be duplicated", :js do
|
||||
do_login_for user
|
||||
visit send(mappable_new_path, arguments)
|
||||
|
||||
if management
|
||||
click_link "Select user"
|
||||
|
||||
expect(page).to have_content "User management"
|
||||
else
|
||||
click_link "Help"
|
||||
|
||||
expect(page).to have_content "CONSUL is a platform for citizen participation"
|
||||
end
|
||||
|
||||
go_back
|
||||
|
||||
within ".map_location" do
|
||||
expect(page).to have_css(".leaflet-map-pane", count: 1)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "keeps marker and zoom defined by the user", :js do
|
||||
do_login_for user
|
||||
visit send(mappable_new_path, arguments)
|
||||
|
||||
within ".map_location" do
|
||||
expect(page).not_to have_css(".map-icon")
|
||||
end
|
||||
expect(page.execute_script("return App.Map.maps[0].getZoom();")).to eq(10)
|
||||
|
||||
map_zoom_in
|
||||
find("#new_map_location").click
|
||||
|
||||
within ".map_location" do
|
||||
expect(page).to have_css(".map-icon")
|
||||
end
|
||||
|
||||
if management
|
||||
click_link "Select user"
|
||||
|
||||
expect(page).to have_content "User management"
|
||||
else
|
||||
click_link "Help"
|
||||
|
||||
expect(page).to have_content "CONSUL is a platform for citizen participation"
|
||||
end
|
||||
|
||||
go_back
|
||||
|
||||
within ".map_location" do
|
||||
expect(page).to have_css(".map-icon")
|
||||
expect(page.execute_script("return App.Map.maps[0].getZoom();")).to eq(11)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "shows marker at map center", :js do
|
||||
do_login_for user
|
||||
visit send(mappable_new_path, arguments)
|
||||
|
||||
within ".map_location" do
|
||||
expect(page).not_to have_css(".map-icon")
|
||||
end
|
||||
|
||||
place_map_at(-68.592487, -62.391357)
|
||||
find("#new_map_location").click
|
||||
|
||||
within ".map_location" do
|
||||
expect(page).to have_css(".map-icon")
|
||||
end
|
||||
|
||||
if management
|
||||
click_link "Select user"
|
||||
|
||||
expect(page).to have_content "User management"
|
||||
else
|
||||
click_link "Help"
|
||||
|
||||
expect(page).to have_content "CONSUL is a platform for citizen participation"
|
||||
end
|
||||
|
||||
go_back
|
||||
|
||||
within ".map_location" do
|
||||
expect(page).to have_css(".map-icon")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Skip map", :js do
|
||||
do_login_for user
|
||||
visit send(mappable_new_path, arguments)
|
||||
@@ -270,3 +359,19 @@ def set_arguments(arguments, mappable, mappable_path_arguments)
|
||||
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
|
||||
|
||||
@@ -55,4 +55,13 @@ module Verifications
|
||||
within_frame(0) { find("body").set(with) }
|
||||
end
|
||||
end
|
||||
|
||||
def fill_in_markdown_editor(label, with:)
|
||||
click_link "Launch text editor"
|
||||
fill_in label, with: with
|
||||
|
||||
within(".fullscreen") do
|
||||
click_link "Close text editor"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -190,6 +190,34 @@ describe "Admin banners magement" do
|
||||
expect(page).to have_field "Post started at", with: "22/02/2002"
|
||||
end
|
||||
|
||||
scenario "when date picker is opened and click on browser history back datepicker is closed", :js do
|
||||
banner = create(:banner)
|
||||
visit admin_banners_path(banner)
|
||||
click_link "Edit banner"
|
||||
find_field("Post started at").click
|
||||
|
||||
expect(page).to have_css "#ui-datepicker-div"
|
||||
|
||||
go_back
|
||||
|
||||
expect(page).to have_content("Banners")
|
||||
expect(page).not_to have_css "#ui-datepicker-div"
|
||||
end
|
||||
|
||||
scenario "date picker works after using the browser back button", :js do
|
||||
banner = create(:banner)
|
||||
|
||||
visit edit_admin_banner_path(banner)
|
||||
click_link "Manage banners"
|
||||
|
||||
expect(page).to have_link "Edit banner"
|
||||
|
||||
go_back
|
||||
find_field("Post started at").click
|
||||
|
||||
expect(page).to have_css "#ui-datepicker-div"
|
||||
end
|
||||
|
||||
scenario "Delete a banner" do
|
||||
create(:banner, title: "Ugly banner",
|
||||
description: "Bad text",
|
||||
|
||||
@@ -1877,5 +1877,27 @@ describe "Admin budget investments" do
|
||||
expect(page).not_to have_content "Don't display me, please!"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "When restoring the page from browser history renders columns selectors only once", :js do
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
click_link "Proposals"
|
||||
|
||||
expect(page).to have_content("There are no proposals.")
|
||||
|
||||
go_back
|
||||
|
||||
within("#js-columns-selector") do
|
||||
find("strong", text: "Columns").click
|
||||
end
|
||||
|
||||
within("#js-columns-selector-wrapper") do
|
||||
selectable_columns.each do |column|
|
||||
check_text = I18n.t("admin.budget_investments.index.list.#{column}")
|
||||
|
||||
expect(page).to have_content(check_text, count: 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,18 +83,74 @@ describe "Admin legislation draft versions" do
|
||||
click_link "Version 1"
|
||||
|
||||
fill_in "Version title", with: "Version 1b"
|
||||
|
||||
click_link "Launch text editor"
|
||||
|
||||
fill_in "Text", with: "# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote"
|
||||
|
||||
within(".fullscreen") do
|
||||
click_link "Close text editor"
|
||||
end
|
||||
fill_in_markdown_editor "Text", with: "# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote"
|
||||
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Version 1b"
|
||||
end
|
||||
end
|
||||
|
||||
context "Changing content with the markdown editor", :js do
|
||||
let(:prompt) { "You've edited the text without saving it. Do you confirm to leave the page?" }
|
||||
let(:version) { create(:legislation_draft_version, body: "Version 1") }
|
||||
let(:path) do
|
||||
edit_admin_legislation_process_draft_version_path(version.process, version)
|
||||
end
|
||||
|
||||
scenario "asks for confimation when the content is modified" do
|
||||
visit path
|
||||
fill_in_markdown_editor "Text", with: "Version 1b"
|
||||
|
||||
expect(page).to have_content "You've edited the text"
|
||||
|
||||
dismiss_confirm(prompt) do
|
||||
click_link "Proposals", match: :first
|
||||
end
|
||||
|
||||
expect(page).to have_current_path(path)
|
||||
end
|
||||
|
||||
scenario "asks for confimation after the page is restored from browser history" do
|
||||
visit path
|
||||
fill_in_markdown_editor "Text", with: "Version 1b"
|
||||
|
||||
accept_confirm(prompt) do
|
||||
click_link "Proposals", match: :first
|
||||
end
|
||||
|
||||
expect(page).to have_css("h2", text: "Proposals")
|
||||
|
||||
go_back
|
||||
|
||||
expect(page).to have_content version.process.title
|
||||
|
||||
accept_confirm(prompt) do
|
||||
click_link "Proposals", match: :first
|
||||
end
|
||||
|
||||
expect(page).to have_css("h2", text: "Proposals")
|
||||
end
|
||||
|
||||
scenario "does not ask for confirmation when restoring the original content" do
|
||||
visit path
|
||||
fill_in_markdown_editor "Text", with: "Version 1b"
|
||||
|
||||
accept_confirm(prompt) do
|
||||
click_link "Proposals", match: :first
|
||||
end
|
||||
|
||||
expect(page).to have_css("h2", text: "Proposals")
|
||||
|
||||
go_back
|
||||
|
||||
fill_in_markdown_editor "Text", with: "Version 1"
|
||||
|
||||
expect(page).not_to have_content "You've edited the text"
|
||||
|
||||
click_link "Proposals", match: :first
|
||||
|
||||
expect(page).to have_css("h2", text: "Proposals")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -237,6 +237,45 @@ describe "Legislation Draft Versions" do
|
||||
|
||||
expect(page).to have_content "Comment can't be blank"
|
||||
end
|
||||
|
||||
scenario "When page is restored from browser cache do not duplicate annotation handlers" do
|
||||
create(:legislation_annotation, draft_version: draft_version, text: "my annotation")
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
|
||||
expect(page).to have_css(".annotator-hl", count: 1)
|
||||
|
||||
click_link "Help"
|
||||
|
||||
expect(page).to have_content "CONSUL is a platform for citizen participation"
|
||||
|
||||
go_back
|
||||
|
||||
expect(page).to have_content "A collaborative legislation process"
|
||||
expect(page).to have_css(".annotator-hl", count: 1)
|
||||
end
|
||||
|
||||
scenario "When page is restored from browser cache publish comment button keeps working" do
|
||||
create(:legislation_annotation, draft_version: draft_version, text: "my annotation")
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
|
||||
find(:css, ".annotator-hl").click
|
||||
|
||||
click_link "Help"
|
||||
|
||||
expect(page).to have_content "CONSUL is a platform for citizen participation"
|
||||
|
||||
go_back
|
||||
|
||||
expect(page).to have_content "A collaborative legislation process"
|
||||
|
||||
click_link "Publish Comment"
|
||||
fill_in "comment[body]", with: "My interesting comment"
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "My interesting comment"
|
||||
end
|
||||
end
|
||||
|
||||
context "Merged annotations", :js do
|
||||
|
||||
@@ -198,6 +198,18 @@ describe "Proposals" do
|
||||
expect(page).not_to have_link("No comments", href: "#comments")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "After using the browser's back button, social buttons will have one screen reader", :js do
|
||||
proposal = create(:proposal)
|
||||
visit proposal_path(proposal)
|
||||
click_link "Help"
|
||||
|
||||
expect(page).to have_content "CONSUL is a platform for citizen participation"
|
||||
|
||||
go_back
|
||||
|
||||
expect(page).to have_css "span.show-for-sr", text: "twitter", count: 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "Show sticky support button on mobile screens", :js do
|
||||
@@ -233,6 +245,42 @@ describe "Proposals" do
|
||||
expect(page).not_to have_css(".is-anchored")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "After using the browser's back button" do
|
||||
proposal = create(:proposal)
|
||||
|
||||
visit proposal_path(proposal)
|
||||
click_link "Go back"
|
||||
|
||||
expect(page).to have_link proposal.title
|
||||
|
||||
go_back
|
||||
|
||||
within("#proposal_sticky") do
|
||||
expect(page).to have_css(".is-stuck")
|
||||
expect(page).not_to have_css(".is-anchored")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "After using the browser's forward button" do
|
||||
proposal = create(:proposal)
|
||||
|
||||
visit proposals_path
|
||||
click_link proposal.title
|
||||
|
||||
expect(page).not_to have_link proposal.title
|
||||
|
||||
go_back
|
||||
|
||||
expect(page).to have_link proposal.title
|
||||
|
||||
go_forward
|
||||
|
||||
within("#proposal_sticky") do
|
||||
expect(page).to have_css(".is-stuck")
|
||||
expect(page).not_to have_css(".is-anchored")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Embedded video" do
|
||||
|
||||
Reference in New Issue
Block a user