1 require "application_system_test_case"
3 class CreateNoteTest < ApplicationSystemTestCase
4 test "can create note" do
5 visit new_note_path(:anchor => "map=18/0/0")
8 assert_button "Add Note", :disabled => true
10 fill_in "text", :with => "Some newly added note description"
13 assert_content "Unresolved note ##{Note.last.id}"
14 assert_content "Some newly added note description"
18 test "cannot create new note when zoomed out" do
19 visit new_note_path(:anchor => "map=12/0/0")
22 assert_no_content "Zoom in to add a note"
23 assert_button "Add Note", :disabled => true
25 fill_in "text", :with => "Some newly added note description"
27 assert_no_content "Zoom in to add a note"
28 assert_button "Add Note", :disabled => false
31 find(".control-button.zoomout").click
34 assert_content "Zoom in to add a note"
35 assert_button "Add Note", :disabled => true
38 find(".control-button.zoomin").click
41 assert_no_content "Zoom in to add a note"
42 assert_button "Add Note", :disabled => false
46 assert_content "Unresolved note ##{Note.last.id}"
47 assert_content "Some newly added note description"
51 test "can open new note page when zoomed out" do
52 visit new_note_path(:anchor => "map=11/0/0")
55 assert_content "Zoom in to add a note"
56 assert_button "Add Note", :disabled => true
58 fill_in "text", :with => "Some newly added note description"
60 assert_content "Zoom in to add a note"
61 assert_button "Add Note", :disabled => true
64 find(".control-button.zoomin").click
67 assert_no_content "Zoom in to add a note"
68 assert_button "Add Note", :disabled => false
72 test "cannot create note when api is readonly" do
73 with_settings(:status => "api_readonly") do
74 visit new_note_path(:anchor => "map=18/0/0")
77 assert_no_button "Add Note", :disabled => true
82 test "encouragement to contribute appears after 10 created notes and disappears after login" do
83 encouragement_threshold = 10
85 encouragement_threshold.times do |n|
86 visit new_note_path(:anchor => "map=16/0/#{0.001 * n}")
89 assert_no_content(/already posted at least \d+ anonymous note/)
91 fill_in "text", :with => "new note ##{n + 1}"
94 assert_content "new note ##{n + 1}"
98 visit new_note_path(:anchor => "map=16/0/#{0.001 * encouragement_threshold}")
101 assert_content(/already posted at least #{encouragement_threshold} anonymous note/)
104 sign_in_as(create(:user))
105 visit new_note_path(:anchor => "map=16/0/#{0.001 * encouragement_threshold}")
108 assert_no_content(/already posted at least \d+ anonymous note/)
112 visit new_note_path(:anchor => "map=16/0/#{0.001 * encouragement_threshold}")
115 assert_no_content(/already posted at least \d+ anonymous note/)