Skip to content

Commit

Permalink
Fix build errors on lel version bump to 2.1.9 (#7340)
Browse files Browse the repository at this point in the history
* bump LEL to 2.1.9

* Increase wait time in map test

* Add baselayer and comment out layers

* copying in @VladimirMikulic's system test optimizations

Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
  • Loading branch information
crisner and jywarren committed Jan 24, 2020
1 parent 23e83cd commit aa3b864
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
7 changes: 5 additions & 2 deletions app/views/map/map.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
layersname = layersname.split(',')
<% end %>

L.tileLayer(
var baseLayer = L.tileLayer(
"https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png",
{
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
Expand All @@ -101,7 +101,10 @@


L.LayerGroup.EnvironmentalLayers({
include: layersname,
baseLayers: {
'Gray-scale': baselayer
},
// include: layersname,
hash: false,
embed: true,
hostname: 'publiclab.org',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"junction": "theleagueof/junction#*",
"leaflet": "^1.6.0",
"leaflet-blurred-location": "^1.6.0",
"leaflet-environmental-layers": "^2.1.7",
"leaflet-environmental-layers": "^2.1.9",
"leaflet-hash": "^0.2.1",
"leaflet-spin": "1.1.0",
"leaflet.fullscreen": "1.6.0",
Expand Down
29 changes: 20 additions & 9 deletions test/system/map_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,46 @@
# https://guides.rubyonrails.org/testing.html#implementing-a-system-test

class MapTest < ApplicationSystemTestCase
Capybara.default_max_wait_time = 90
Capybara.default_max_wait_time = 60

test 'correct url hash for wiki map' do
visit '/map/chicago'

url_hash = page.evaluate_script("window.location.hash")

# Wait for any potential asynchronous operations to complete
wait_for_ajax

# check that the url hash is correct
assert_equal("#13/41.87/-87.64", page.evaluate_script("window.location.hash"))

assert_equal("#13/41.87/-87.64", url_hash)
end

test 'show map by hash location' do
visit '/map#9/-25/-13'

lat = page.evaluate_script("Math.round(map.getCenter().lat)")
assert_equal(-25, lat)
assert_equal(-25, page.evaluate_script("Math.round(map.getCenter().lat)"))
assert_equal(-13, page.evaluate_script("Math.round(map.getCenter().lng)"))
assert_equal(9, page.evaluate_script("map.getZoom()"))
lng = page.evaluate_script("Math.round(map.getCenter().lng)")
zoom = page.evaluate_script("map.getZoom()")

# Wait for any potential asynchronous operations to complete
wait_for_ajax

assert_equal(-25, lat)
assert_equal(-13, lng)
assert_equal(9, zoom)
end

test 'url hash updates when map panned' do
visit '/map'

page.execute_script("map.setView([13, 60], 15)")
url_hash = page.evaluate_script("window.location.hash")

# Wait for any potential asynchronous operations to complete
wait_for_ajax

# check that the url hash is correct
assert_equal("#15/13/60", page.evaluate_script("window.location.hash"))

assert_equal("#15/13/60", url_hash)
end

end
17 changes: 13 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3528,10 +3528,19 @@ leaflet-blurred-location@^1.5.1, leaflet-blurred-location@^1.6.0:
jquery "^3.2.1"
leaflet "^1.3.3"

leaflet-environmental-layers@^2.1.7:
version "2.1.7"
resolved "https://registry.yarnpkg.com/leaflet-environmental-layers/-/leaflet-environmental-layers-2.1.7.tgz#3d866404929db76b34b68d87460a6f5584bebccc"
integrity sha512-/lNjVMVZQBAydTWnTScWpDIx/1iPBlYp3MKI9sSKnU973Zj72du4VG7BPdlYxC6aPkKa3pHhWYNmk72E69SCSw==
"leaflet-blurred-location@git://github.com/publiclab/leaflet-blurred-location.git#main":
version "1.6.0"
uid ef66dcb768094680e92d4f972b68f18cd4db6ccc
resolved "git://github.com/publiclab/leaflet-blurred-location.git#ef66dcb768094680e92d4f972b68f18cd4db6ccc"
dependencies:
haversine-distance "^1.1.4"
jquery "^3.2.1"
leaflet "^1.3.3"

leaflet-environmental-layers@^2.1.9:
version "2.1.9"
resolved "https://registry.yarnpkg.com/leaflet-environmental-layers/-/leaflet-environmental-layers-2.1.9.tgz#48487bb7a2489d72411bd4112e00b3f5d21d4a7c"
integrity sha512-ur2ZtF/H17RIkKkTjc5Uhc7A3WAEkc9O2xfaFW1XS7hBiij6nkH1sckHZ9kZmkNFLHC0ifoymUi7n9k7p1VA+g==
dependencies:
jquery "^3.3.1"
leaflet "^1.3.1"
Expand Down

0 comments on commit aa3b864

Please sign in to comment.