]> git.openstreetmap.org Git - rails.git/blob - test/system/index_test.rb
Add frozen_string_literal comments to ruby files
[rails.git] / test / system / index_test.rb
1 # frozen_string_literal: true
2
3 require "application_system_test_case"
4
5 class IndexTest < ApplicationSystemTestCase
6   test "should remove and add an overlay on share button click" do
7     node = create(:node)
8
9     visit node_path(node)
10
11     assert_selector "#content.overlay-right-sidebar"
12
13     within "#map" do
14       click_on "Share"
15     end
16
17     assert_no_selector "#content.overlay-right-sidebar"
18
19     within "#map" do
20       click_on "Share"
21     end
22
23     assert_selector "#content.overlay-right-sidebar"
24   end
25
26   test "should add an overlay on close" do
27     node = create(:node)
28
29     visit node_path(node)
30
31     within "#map" do
32       click_on "Share"
33     end
34
35     assert_no_selector "#content.overlay-right-sidebar"
36
37     within "#map-ui" do
38       click_on "Close"
39     end
40
41     assert_selector "#content.overlay-right-sidebar"
42   end
43
44   test "should not add overlay when not closing right menu popup" do
45     node = create(:node)
46
47     visit node_path(node)
48
49     within "#map" do
50       click_on "Share"
51       click_on "Map Key"
52     end
53
54     assert_no_selector "#content.overlay-right-sidebar"
55
56     within "#map" do
57       click_on "Layers"
58     end
59
60     assert_no_selector "#content.overlay-right-sidebar"
61
62     within "#map" do
63       click_on "Map Key"
64     end
65
66     assert_no_selector "#content.overlay-right-sidebar"
67
68     within "#map" do
69       click_on "Map Key"
70     end
71
72     assert_selector "#content.overlay-right-sidebar"
73   end
74
75   test "node included in edit link" do
76     node = create(:node)
77     visit node_path(node)
78     assert_selector "#editanchor[href*='?node=#{node.id}#']"
79
80     find("#sidebar .btn-close").click
81     assert_no_selector "#editanchor[href*='?node=#{node.id}#']"
82   end
83
84   test "note included in edit link" do
85     note = create(:note_with_comments)
86     visit note_path(note)
87     assert_selector "#editanchor[href*='?note=#{note.id}#']"
88
89     find("#sidebar .btn-close").click
90     assert_no_selector "#editanchor[href*='?note=#{note.id}#']"
91   end
92
93   test "can navigate from hidden note to visible note" do
94     sign_in_as(create(:moderator_user))
95     hidden_note = create(:note, :status => "hidden", :description => "Hidden Note Description")
96     create(:note_comment, :note => hidden_note, :body => "this-is-a-hidden-note", :event => "opened")
97     position = (1.003 * GeoRecord::SCALE).to_i
98     visible_note = create(:note, :latitude => position, :longitude => position, :description => "Visible Note Description")
99     create(:note_comment, :note => visible_note, :body => "this-is-a-visible-note", :event => "opened")
100
101     visit root_path(:anchor => "map=15/1/1") # view place of hidden note in case it is not rendered during note_path(hidden_note)
102     visit note_path(hidden_note)
103
104     within "#map" do
105       click_on "Layers"
106     end
107     within "#map-ui" do
108       check "Map Notes"
109     end
110
111     within_sidebar do
112       assert_text "Hidden Note Description"
113     end
114
115     visible_note_marker = find(".leaflet-marker-icon[title=this-is-a-visible-note]")
116     visible_note_marker.click
117
118     within_sidebar do
119       assert_text "Visible Note Description"
120     end
121   end
122 end