]> git.openstreetmap.org Git - rails.git/blob - test/system/note_layer_test.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / test / system / note_layer_test.rb
1 # frozen_string_literal: true
2
3 require "application_system_test_case"
4
5 class NoteLayerTest < ApplicationSystemTestCase
6   test "note marker should have description as a title" do
7     position = (1.1 * GeoRecord::SCALE).to_i
8     create(:note, :latitude => position, :longitude => position) do |note|
9       create(:note_comment, :note => note, :body => "Note description", :event => "opened")
10     end
11
12     visit root_path(:anchor => "map=18/1.1/1.1&layers=N")
13     all ".leaflet-marker-icon", :count => 1 do |marker|
14       assert_equal "Note description", marker["title"]
15     end
16   end
17
18   test "note marker should not have a title if the note has no visible description" do
19     position = (1.1 * GeoRecord::SCALE).to_i
20     create(:note, :latitude => position, :longitude => position) do |note|
21       create(:note_comment, :note => note, :body => "Note description is hidden", :event => "opened", :visible => false)
22       create(:note_comment, :note => note, :body => "Note comment visible")
23     end
24
25     visit root_path(:anchor => "map=18/1.1/1.1&layers=N")
26     all ".leaflet-marker-icon", :count => 1 do |marker|
27       assert_equal "", marker["title"]
28     end
29   end
30
31   test "note marker should not have a title if the note has no visible description and comments" do
32     position = (1.1 * GeoRecord::SCALE).to_i
33     create(:note, :latitude => position, :longitude => position) do |note|
34       create(:note_comment, :note => note, :body => "Note description is hidden", :event => "opened", :visible => false)
35     end
36
37     visit root_path(:anchor => "map=18/1.1/1.1&layers=N")
38     all ".leaflet-marker-icon", :count => 1 do |marker|
39       assert_equal "", marker["title"]
40     end
41   end
42 end