1 # frozen_string_literal: true
3 require "application_system_test_case"
5 class NoteCommentsTest < ApplicationSystemTestCase
6 test "open note has login notice" do
7 note = create(:note_with_comments)
11 assert_no_button "Resolve"
12 assert_no_button "Comment"
13 assert_link "Log in to comment on this note", :href => login_path(:referer => note_path(note))
17 test "closed note has no login notice" do
18 note = create(:note_with_comments, :closed)
22 assert_no_button "Reactivate"
23 assert_no_link "Log in to comment on this note"
27 test "can add comment" do
28 note = create(:note_with_comments)
34 assert_no_content "Comment from #{user.display_name}"
35 assert_no_content "Some newly added note comment"
36 assert_button "Resolve"
37 assert_button "Comment", :disabled => true
39 fill_in "text", :with => "Some newly added note comment"
41 assert_button "Comment & Resolve"
42 assert_button "Comment", :disabled => false
46 assert_content "Comment from #{user.display_name}"
47 assert_content "Some newly added note comment"
51 test "can't add a comment when blocked" do
52 note = create(:note_with_comments)
56 block = create(:user_block, :user => user)
59 fill_in "text", :with => "Comment that won't be added while blocked"
61 assert_no_text "Comment from #{user.display_name}"
62 assert_no_text "Comment that won't be added while blocked"
63 assert_no_text "Your access to the API has been blocked"
64 assert_button "Comment & Resolve", :disabled => false
65 assert_button "Comment", :disabled => false
69 assert_no_text "Comment from #{user.display_name}"
70 assert_no_text "Comment that won't be added while blocked"
71 assert_text "Your access to the API has been blocked"
72 assert_button "Comment & Resolve", :disabled => false
73 assert_button "Comment", :disabled => false
75 block.revoke! block.creator
79 assert_text "Comment from #{user.display_name}"
80 assert_text "Comment that won't be added while blocked"
81 assert_no_text "Your access to the API has been blocked"
85 test "no subscribe button when not logged in" do
86 note = create(:note_with_comments)
90 assert_no_button "Subscribe"
91 assert_no_button "Unsubscribe"
95 test "can subscribe" do
96 note = create(:note_with_comments)
102 assert_button "Subscribe"
103 assert_no_button "Unsubscribe"
107 assert_no_button "Subscribe"
108 assert_button "Unsubscribe"
112 test "can unsubscribe" do
113 note = create(:note_with_comments)
115 create(:note_subscription, :note => note, :user => user)
117 visit note_path(note)
120 assert_no_button "Subscribe"
121 assert_button "Unsubscribe"
123 click_on "Unsubscribe"
125 assert_button "Subscribe"
126 assert_no_button "Unsubscribe"