Fix displayOnLoad not honoured at import

fix #1043
This commit is contained in:
Yohan Boniface 2023-10-27 12:25:40 +02:00
parent 9eea9f942d
commit 882cc74bcf
3 changed files with 111 additions and 0 deletions

View file

@ -1114,6 +1114,7 @@ L.U.DataLayer = L.Evented.extend({
}, },
redraw: function () { redraw: function () {
if (!this.isVisible()) return
this.hide() this.hide()
this.show() this.show()
}, },

View file

@ -0,0 +1,85 @@
{
"type": "umap",
"uri": "http://localhost:8020/fr/map/carte-sans-nom_128#6/50.233/6.910",
"properties": {
"easing": false,
"embedControl": true,
"fullscreenControl": true,
"searchControl": true,
"datalayersControl": true,
"zoomControl": true,
"permanentCreditBackground": true,
"slideshow": {},
"captionMenus": true,
"captionBar": false,
"limitBounds": {},
"overlay": null,
"licence": "",
"description": "",
"name": "Carte sans nom",
"displayPopupFooter": false,
"miniMap": false,
"moreControl": true,
"scaleControl": true,
"scrollWheelZoom": true,
"zoom": 6
},
"geometry": {
"type": "Point",
"coordinates": [
6.734619140625,
50.359480346298696
]
},
"layers": [
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
5.141602,
50.889174
]
}
}
],
"_umap_options": {
"displayOnLoad": true,
"inCaption": true,
"browsable": true,
"editMode": "advanced",
"name": "Visible",
"remoteData": {}
}
},
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
5.383301,
49.809632
]
}
}
],
"_umap_options": {
"displayOnLoad": false,
"inCaption": true,
"browsable": true,
"editMode": "advanced",
"remoteData": {},
"name": "Invisible",
"color": "DarkRed"
}
}
]
}

View file

@ -0,0 +1,25 @@
from pathlib import Path
import pytest
from playwright.sync_api import expect
pytestmark = pytest.mark.django_db
def test_umap_import(live_server, datalayer, page):
page.goto(f"{live_server.url}/map/new/")
button = page.get_by_title("Import data (Ctrl+I)")
expect(button).to_be_visible()
button.click()
with page.expect_file_chooser() as fc_info:
page.locator("input[type='file']").click()
file_chooser = fc_info.value
path = Path(__file__).parent.parent / "fixtures/display_on_load.umap"
file_chooser.set_files(path)
button = page.get_by_role("button", name="Import")
expect(button).to_be_visible()
button.click()
layers = page.locator(".umap-browse-datalayers li")
expect(layers).to_have_count(3)
nonloaded = page.locator(".umap-browse-datalayers li.off")
expect(nonloaded).to_have_count(1)