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