]> git.openstreetmap.org Git - rails.git/blob - test/system/resolve_note_test.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / test / system / resolve_note_test.rb
1 # frozen_string_literal: true
2
3 require "application_system_test_case"
4
5 class ResolveNoteTest < ApplicationSystemTestCase
6   test "can resolve an open note" do
7     note = create(:note_with_comments)
8     user = create(:user)
9     sign_in_as(user)
10     visit note_path(note)
11
12     within_sidebar do
13       assert_button "Resolve"
14       assert_no_button "Comment & Resolve"
15       assert_no_button "Reactivate"
16
17       click_on "Resolve"
18
19       assert_content "Resolved note ##{note.id}"
20     end
21   end
22
23   test "can resolve an open note with a comment" do
24     note = create(:note_with_comments)
25     user = create(:user)
26     sign_in_as(user)
27     visit note_path(note)
28
29     within_sidebar do
30       assert_button "Resolve"
31       assert_no_button "Comment & Resolve"
32       assert_no_button "Reactivate"
33
34       fill_in "text", :with => "Note resolve text"
35
36       assert_button "Comment & Resolve"
37
38       click_on "Comment & Resolve"
39
40       assert_content "Resolved note ##{note.id}"
41       assert_content "Note resolve text"
42     end
43   end
44
45   test "can reactivate a closed note" do
46     note = create(:note_with_comments, :closed)
47     user = create(:user)
48     sign_in_as(user)
49     visit note_path(note)
50
51     within_sidebar do
52       assert_no_button "Resolve"
53       assert_no_button "Comment & Resolve"
54       assert_button "Reactivate"
55
56       click_on "Reactivate"
57
58       assert_content "Unresolved note ##{note.id}"
59       assert_no_content "<iframe" # leak from share textarea
60     end
61   end
62
63   test "can hide an open note as moderator" do
64     note = create(:note_with_comments)
65     user = create(:moderator_user)
66     sign_in_as(user)
67     visit note_path(note)
68
69     within_sidebar do
70       assert_button "Hide"
71
72       click_on "Hide"
73
74       assert_content "Hidden note ##{note.id}"
75     end
76   end
77
78   test "can hide a closed note as moderator" do
79     note = create(:note_with_comments, :closed)
80     user = create(:moderator_user)
81     sign_in_as(user)
82     visit note_path(note)
83
84     within_sidebar do
85       assert_button "Hide"
86
87       click_on "Hide"
88
89       assert_content "Hidden note ##{note.id}"
90       assert_no_content "<iframe" # leak from share textarea
91       assert_no_content "undefined" # value from missing comment textarea
92     end
93   end
94
95   test "can't resolve a note when blocked" do
96     note = create(:note_with_comments)
97     user = create(:user)
98     sign_in_as(user)
99     visit note_path(note)
100     create(:user_block, :user => user)
101
102     within_sidebar do
103       assert_text "Unresolved note"
104       assert_no_text "Resolved note"
105       assert_no_text "Your access to the API has been blocked"
106       assert_button "Resolve", :disabled => false
107       assert_button "Comment", :disabled => true
108
109       click_on "Resolve"
110
111       assert_text "Unresolved note"
112       assert_no_text "Resolved note"
113       assert_text "Your access to the API has been blocked"
114       assert_button "Resolve", :disabled => false
115       assert_button "Comment", :disabled => true
116     end
117   end
118
119   test "can't reactivate a note when blocked" do
120     note = create(:note_with_comments, :closed)
121     user = create(:user)
122     sign_in_as(user)
123     visit note_path(note)
124     create(:user_block, :user => user)
125
126     within_sidebar do
127       assert_no_text "Unresolved note"
128       assert_text "Resolved note"
129       assert_no_text "Your access to the API has been blocked"
130       assert_button "Reactivate", :disabled => false
131
132       click_on "Reactivate"
133
134       assert_no_text "Unresolved note"
135       assert_text "Resolved note"
136       assert_text "Your access to the API has been blocked"
137       assert_button "Reactivate", :disabled => false
138     end
139   end
140 end