From f2f16e2580d5b62ccfd061e4f3ae0346599ffc20 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 3 Jun 2019 15:19:07 +0000 Subject: [PATCH] carte: disable tiles layer during tests During integration tests, we don't want to load the tiles from OSM: - It hits OSM servers during every test run; - It it slow (Capybara waits for the tiles to be loaded to proceed); - It makes test time out when tiles cannot be loaded for some reason. Fix #3913 --- app/javascript/shared/carte.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/javascript/shared/carte.js b/app/javascript/shared/carte.js index 2ba1f7445..b6f76a27a 100644 --- a/app/javascript/shared/carte.js +++ b/app/javascript/shared/carte.js @@ -13,10 +13,13 @@ export function initMap(element, position, editable = false) { scrollWheelZoom: false }).setView([position.lat, position.lon], editable ? 18 : position.zoom); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: - '© OpenStreetMap contributors' - }).addTo(map); + const loadTilesLayer = process.env.RAILS_ENV != 'test'; + if (loadTilesLayer) { + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: + '© OpenStreetMap contributors' + }).addTo(map); + } if (editable) { const freeDraw = new FreeDraw({