From 4eafe97d1a273036fe43d226d33961f4ce97478c Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 22 Jun 2025 15:50:02 +0300 Subject: [PATCH] Move way ui tests to system tests --- test/controllers/ways_controller_test.rb | 21 ----- test/system/element_current_version_test.rb | 92 +++++++++++++++++++++ 2 files changed, 92 insertions(+), 21 deletions(-) diff --git a/test/controllers/ways_controller_test.rb b/test/controllers/ways_controller_test.rb index 750f3f7ef..969577058 100644 --- a/test/controllers/ways_controller_test.rb +++ b/test/controllers/ways_controller_test.rb @@ -13,27 +13,6 @@ class WaysControllerTest < ActionDispatch::IntegrationTest def test_show way = create(:way) sidebar_browse_check :way_path, way.id, "elements/show" - assert_select "h4", /^Version/ do - assert_select "a[href='#{old_way_path way, 1}']", :text => "1", :count => 1 - end - assert_select ".secondary-actions a[href='#{api_way_path way}']", :count => 1 - assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1 - end - - def test_show_multiple_versions - way = create(:way, :with_history, :version => 2) - sidebar_browse_check :way_path, way.id, "elements/show" - assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1 - assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 1 - assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1 - end - - def test_show_relation_member - member = create(:way) - relation = create(:relation) - create(:relation_member, :relation => relation, :member => member) - sidebar_browse_check :way_path, member.id, "elements/show" - assert_select "a[href='#{relation_path relation}']", :count => 1 end def test_show_timeout diff --git a/test/system/element_current_version_test.rb b/test/system/element_current_version_test.rb index 4a5a464f8..7998151f1 100644 --- a/test/system/element_current_version_test.rb +++ b/test/system/element_current_version_test.rb @@ -20,6 +20,24 @@ class ElementCurrentVersionTest < ApplicationSystemTestCase end end + test "shows a way with one version" do + way = create(:way) + + visit way_path(way) + + within_sidebar do + assert_css "h2", :text => "Way: #{way.id}" + within "h4", :text => "Version #1" do + assert_link "1", :href => old_way_path(way, 1) + end + assert_no_text "Deleted" + + assert_link "Download XML", :href => api_way_path(way) + assert_link "View History", :href => way_history_path(way) + assert_no_link "View Unredacted History" + end + end + test "shows a node with two versions" do node = create(:node, :with_history, :lat => 60, :lon => 30, :version => 2) @@ -41,6 +59,26 @@ class ElementCurrentVersionTest < ApplicationSystemTestCase end end + test "shows a way with two versions" do + way = create(:way, :version => 2) + + visit way_path(way) + + within_sidebar do + assert_css "h2", :text => "Way: #{way.id}" + within "h4", :text => "Version #2" do + assert_link "2", :href => old_way_path(way, 2) + end + assert_no_text "Deleted" + + assert_link "Download XML", :href => api_way_path(way) + assert_link "View History", :href => way_history_path(way) + assert_no_link "View Unredacted History" + assert_link "Version #1", :href => old_way_path(way, 1) + assert_link "Version #2", :href => old_way_path(way, 2) + end + end + test "shows a deleted node" do node = create(:node, :with_history, :lat => 60, :lon => 30, :visible => false, :version => 2) @@ -60,6 +98,24 @@ class ElementCurrentVersionTest < ApplicationSystemTestCase end end + test "shows a deleted way" do + way = create(:way, :visible => false, :version => 2) + + visit way_path(way) + + within_sidebar do + assert_css "h2", :text => "Way: #{way.id}" + within "h4", :text => "Version #2" do + assert_link "2", :href => old_way_path(way, 2) + end + assert_text "Deleted" + + assert_no_link "Download XML" + assert_link "View History", :href => way_history_path(way) + assert_no_link "View Unredacted History" + end + end + test "shows node navigation to regular users" do node = create(:node, :with_history) @@ -72,6 +128,18 @@ class ElementCurrentVersionTest < ApplicationSystemTestCase end end + test "shows way navigation to regular users" do + way = create(:way, :with_history) + + sign_in_as(create(:user)) + visit way_path(way) + + within_sidebar do + assert_link "View History", :href => way_history_path(way) + assert_no_link "View Unredacted History" + end + end + test "shows node navigation to moderators" do node = create(:node, :with_history) @@ -84,6 +152,18 @@ class ElementCurrentVersionTest < ApplicationSystemTestCase end end + test "shows way navigation to moderators" do + way = create(:way, :with_history) + + sign_in_as(create(:moderator_user)) + visit way_path(way) + + within_sidebar do + assert_link "View History", :href => way_history_path(way) + assert_link "View Unredacted History", :href => way_history_path(way, :show_redactions => true) + end + end + test "shows a link to containing relation of a node" do node = create(:node) containing_relation = create(:relation) @@ -96,6 +176,18 @@ class ElementCurrentVersionTest < ApplicationSystemTestCase end end + test "shows a link to containing relation of a way" do + way = create(:way) + containing_relation = create(:relation) + create(:relation_member, :relation => containing_relation, :member => way) + + visit way_path(way) + + within_sidebar do + assert_link :href => relation_path(containing_relation) + end + end + test "relation member nodes should be visible on the map when viewing relations" do relation = create(:relation) node = create(:node) -- 2.39.5