Skip to content

Commit 7c292fa

Browse files
committed
test todos
1 parent 9a1dd45 commit 7c292fa

4 files changed

Lines changed: 19 additions & 20 deletions

File tree

app/javascript/maplibre/controls/shared.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import * as functions from 'helpers/functions'
2-
import { map, mapProperties } from 'maplibre/map'
31
import * as dom from 'helpers/dom'
42
import { animateElement, initTooltips } from 'helpers/dom'
53
import * as f from 'helpers/functions'
4+
import * as functions from 'helpers/functions'
65
import MaplibreGeocoder from 'maplibre-gl-geocoder'
6+
import { hideContextMenu } from 'maplibre/controls/context_menu'
77
import { resetEditControls } from 'maplibre/controls/edit'
88
import { initializeGeoLocateControl } from 'maplibre/controls/geolocate'
99
import { draw, unselect } from 'maplibre/edit'
1010
import { featureIcon, resetHighlightedFeature } from 'maplibre/feature'
1111
import { layers } from 'maplibre/layers/layers'
12-
import { hideContextMenu } from 'maplibre/controls/context_menu'
12+
import { map, mapProperties } from 'maplibre/map'
1313

1414
export class ControlGroup {
1515
constructor (controls) {

spec/features/feature_edit_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,7 @@
196196
find("#edit-button-style").click
197197
expect(find("#fill-color-transparent")).not_to be_checked
198198

199-
# TODO: did not find a better solution to check the box and trigger stimulus
200-
js = "document.getElementById('fill-color-transparent')"
201-
page.driver.execute_script("#{js}.checked = true")
202-
page.driver.execute_script("#{js}.dispatchEvent(new Event('input'))")
203-
page.driver.execute_script("#{js}.dispatchEvent(new Event('change'))")
199+
find("#fill-color-transparent").check
204200

205201
wait_for { point.reload.properties["marker-color"] }.to eq("transparent")
206202
end

spec/features/map_layers_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@
8181
wait_for { map.reload.features.count }.to eq 1
8282
# flyTo is finished when the feature details are shown
8383
expect(page).to have_text("Properties")
84-
# TODO: For some reason the map doesn't flyTo() in test env
84+
# flyToFeature() after async image upload doesn't complete in headless test env
8585
# expect(page.evaluate_script("[map.getCenter().lng.toFixed(4), map.getCenter().lat.toFixed(4)].toString()"))
86-
# .to eq("11.0769,49.4475")
86+
# .to eq("9.9749,53.5445")
8787
expect(map.features.first.image.public_id).to match(/image_with_exif-\d+.jpeg/)
8888
expect(map.features.first.geometry["coordinates"]).to eq([ 9.9749, 53.5445 ])
8989
end

spec/features/map_settings_spec.rb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,19 @@
8282
expect(page).to have_text("Map default: 11,49.5")
8383
end
8484

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
9598

9699
it "map zoom update" do
97100
map.update(zoom: 16)

0 commit comments

Comments
 (0)