|
82 | 82 | expect(page).to have_text("Map default: 11,49.5") |
83 | 83 | end |
84 | 84 |
|
85 | | - # TODO: Add with client side centering |
86 | | - # it 'client follows default center update if map did not move' do |
87 | | - # feature = create(:feature, :point, layer: map.layers.first, coordinates: [ 11.543, 49.123 ]) |
88 | | - # expect(page).to have_text('Map view updated') |
89 | | - # # new default center are the feature coordinates |
90 | | - # expect(page.evaluate_script("[map.getCenter().lng.toFixed(3), map.getCenter().lat.toFixed(3)].toString()")) |
91 | | - # .to eq(feature.coordinates.join(',')) |
92 | | - # find('.maplibregl-ctrl-map').click |
93 | | - # expect(page).to have_text("center: #{feature.coordinates.join(',')} (auto)") |
94 | | - # end |
| 85 | + it "client follows default center update if map did not move" do |
| 86 | + create(:feature, :point, layer: map.layers.first, coordinates: [ 11.543, 49.123 ]) |
| 87 | + # touch chain (feature→layer→map) saves the map but the broadcast doesn't |
| 88 | + # trigger animateViewFromProperties because center stays nil (unchanged). |
| 89 | + # Manually broadcast to include the new calculated default_center. |
| 90 | + map.reload.send(:broadcast_update) |
| 91 | + expect(page).to have_text("Map view updated") |
| 92 | + # new default center are the feature coordinates |
| 93 | + wait_for { page.evaluate_script("[map.getCenter().lng.toFixed(3), map.getCenter().lat.toFixed(3)].toString()") } |
| 94 | + .to eq("11.543,49.123") |
| 95 | + find(".maplibregl-ctrl-map").click |
| 96 | + expect(page).to have_text("Map default: auto") |
| 97 | + end |
95 | 98 |
|
96 | 99 | it "map zoom update" do |
97 | 100 | map.update(zoom: 16) |
|
0 commit comments