umap-project 2.1.1__py3-none-any.whl → 2.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/models.py +20 -11
- umap/static/umap/js/modules/request.js +1 -1
- umap/static/umap/js/umap.controls.js +29 -0
- umap/static/umap/js/umap.features.js +3 -1
- umap/static/umap/js/umap.importer.js +4 -5
- umap/static/umap/js/umap.js +27 -36
- umap/static/umap/js/umap.layer.js +7 -6
- umap/static/umap/test/Map.js +0 -304
- umap/static/umap/test/Polygon.js +0 -256
- umap/static/umap/test/Polyline.js +0 -116
- umap/static/umap/test/index.html +1 -4
- umap/tests/conftest.py +9 -0
- umap/tests/fixtures/test_upload_data.csv +2 -1
- umap/tests/fixtures/test_upload_data.umap +171 -0
- umap/tests/fixtures/test_upload_data_osm.json +33 -0
- umap/tests/integration/conftest.py +5 -0
- umap/tests/integration/test_anonymous_owned_map.py +3 -0
- umap/tests/integration/test_browser.py +4 -11
- umap/tests/integration/test_choropleth.py +89 -0
- umap/tests/integration/test_collaborative_editing.py +30 -1
- umap/tests/integration/test_datalayer.py +130 -0
- umap/tests/integration/test_edit_datalayer.py +134 -0
- umap/tests/integration/test_edit_map.py +15 -0
- umap/tests/integration/test_facets_browser.py +31 -0
- umap/tests/integration/test_import.py +347 -2
- umap/tests/integration/test_map.py +17 -37
- umap/tests/integration/test_owned_map.py +18 -0
- umap/tests/integration/test_picto.py +20 -33
- umap/tests/integration/test_polygon.py +363 -0
- umap/tests/integration/test_polyline.py +325 -0
- umap/tests/integration/test_tableeditor.py +27 -0
- umap/tests/test_datalayer.py +31 -17
- umap/views.py +2 -1
- {umap_project-2.1.1.dist-info → umap_project-2.1.3.dist-info}/METADATA +4 -4
- {umap_project-2.1.1.dist-info → umap_project-2.1.3.dist-info}/RECORD +39 -36
- umap/static/umap/test/Choropleth.js +0 -245
- umap/static/umap/test/DataLayer.js +0 -463
- umap/static/umap/test/Permissions.js +0 -74
- umap/static/umap/test/TableEditor.js +0 -104
- umap/tests/integration/test_drawing.py +0 -243
- {umap_project-2.1.1.dist-info → umap_project-2.1.3.dist-info}/WHEEL +0 -0
- {umap_project-2.1.1.dist-info → umap_project-2.1.3.dist-info}/entry_points.txt +0 -0
- {umap_project-2.1.1.dist-info → umap_project-2.1.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -4,8 +4,6 @@ from time import sleep
|
|
|
4
4
|
import pytest
|
|
5
5
|
from playwright.sync_api import expect
|
|
6
6
|
|
|
7
|
-
from umap.models import Map
|
|
8
|
-
|
|
9
7
|
from ..base import DataLayerFactory
|
|
10
8
|
|
|
11
9
|
pytestmark = pytest.mark.django_db
|
|
@@ -247,10 +245,8 @@ def test_should_sort_features_in_natural_order(live_server, map, page):
|
|
|
247
245
|
expect(features.nth(2)).to_have_text("100. a line")
|
|
248
246
|
|
|
249
247
|
|
|
250
|
-
def test_should_redraw_list_on_feature_delete(live_server,
|
|
251
|
-
|
|
252
|
-
map.save()
|
|
253
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
248
|
+
def test_should_redraw_list_on_feature_delete(live_server, openmap, page, bootstrap):
|
|
249
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
254
250
|
# Enable edit
|
|
255
251
|
page.get_by_role("button", name="Edit").click()
|
|
256
252
|
buttons = page.locator(".umap-browse-data li .feature-delete")
|
|
@@ -305,11 +301,8 @@ def test_should_allow_to_toggle_datalayer_visibility(live_server, map, page, boo
|
|
|
305
301
|
expect(paths).to_have_count(0)
|
|
306
302
|
|
|
307
303
|
|
|
308
|
-
def test_should_have_edit_buttons_in_edit_mode(live_server,
|
|
309
|
-
|
|
310
|
-
map.edit_status = Map.ANONYMOUS
|
|
311
|
-
map.save()
|
|
312
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
304
|
+
def test_should_have_edit_buttons_in_edit_mode(live_server, openmap, page, bootstrap):
|
|
305
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
313
306
|
browser = page.locator("#umap-ui-container")
|
|
314
307
|
edit_layer = browser.get_by_title("Edit", exact=True)
|
|
315
308
|
in_table = browser.get_by_title("Edit properties in a table")
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
from playwright.sync_api import expect
|
|
6
|
+
|
|
7
|
+
from ..base import DataLayerFactory
|
|
8
|
+
|
|
9
|
+
pytestmark = pytest.mark.django_db
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_basic_choropleth_map_with_default_color(map, live_server, page):
|
|
13
|
+
path = Path(__file__).parent.parent / "fixtures/choropleth_region_chomage.geojson"
|
|
14
|
+
data = json.loads(path.read_text())
|
|
15
|
+
DataLayerFactory(data=data, map=map)
|
|
16
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
17
|
+
# Hauts-de-France
|
|
18
|
+
expect(page.locator("path[fill='#08519c']")).to_have_count(1)
|
|
19
|
+
# Occitanie
|
|
20
|
+
expect(page.locator("path[fill='#3182bd']")).to_have_count(1)
|
|
21
|
+
# Grand-Est, PACA
|
|
22
|
+
expect(page.locator("path[fill='#6baed6']")).to_have_count(2)
|
|
23
|
+
# Bourgogne-Franche-Comté, Centre-Val-de-Loire, IdF, Normandie, Corse, Nouvelle-Aquitaine
|
|
24
|
+
expect(page.locator("path[fill='#bdd7e7']")).to_have_count(6)
|
|
25
|
+
# Bretagne, Pays de la Loire, AURA
|
|
26
|
+
expect(page.locator("path[fill='#eff3ff']")).to_have_count(3)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_basic_choropleth_map_with_custom_brewer(openmap, live_server, page):
|
|
30
|
+
path = Path(__file__).parent.parent / "fixtures/choropleth_region_chomage.geojson"
|
|
31
|
+
data = json.loads(path.read_text())
|
|
32
|
+
|
|
33
|
+
# Change brewer at load
|
|
34
|
+
data["_umap_options"]["choropleth"]["brewer"] = "Reds"
|
|
35
|
+
DataLayerFactory(data=data, map=openmap)
|
|
36
|
+
|
|
37
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
38
|
+
# Hauts-de-France
|
|
39
|
+
expect(page.locator("path[fill='#a50f15']")).to_have_count(1)
|
|
40
|
+
# Occitanie
|
|
41
|
+
expect(page.locator("path[fill='#de2d26']")).to_have_count(1)
|
|
42
|
+
# Grand-Est, PACA
|
|
43
|
+
expect(page.locator("path[fill='#fb6a4a']")).to_have_count(2)
|
|
44
|
+
# Bourgogne-Franche-Comté, Centre-Val-de-Loire, IdF, Normandie, Corse, Nouvelle-Aquitaine
|
|
45
|
+
expect(page.locator("path[fill='#fcae91']")).to_have_count(6)
|
|
46
|
+
# Bretagne, Pays de la Loire, AURA
|
|
47
|
+
expect(page.locator("path[fill='#fee5d9']")).to_have_count(3)
|
|
48
|
+
|
|
49
|
+
# Now change brewer from UI
|
|
50
|
+
page.get_by_role("button", name="Edit").click()
|
|
51
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
52
|
+
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click()
|
|
53
|
+
page.get_by_role("heading", name="Choropleth: settings").click()
|
|
54
|
+
page.locator('select[name="brewer"]').select_option("Greens")
|
|
55
|
+
|
|
56
|
+
# Hauts-de-France
|
|
57
|
+
expect(page.locator("path[fill='#006d2c']")).to_have_count(1)
|
|
58
|
+
# Occitanie
|
|
59
|
+
expect(page.locator("path[fill='#31a354']")).to_have_count(1)
|
|
60
|
+
# Grand-Est, PACA
|
|
61
|
+
expect(page.locator("path[fill='#74c476']")).to_have_count(2)
|
|
62
|
+
# Bourgogne-Franche-Comté, Centre-Val-de-Loire, IdF, Normandie, Corse, Nouvelle-Aquitaine
|
|
63
|
+
expect(page.locator("path[fill='#bae4b3']")).to_have_count(6)
|
|
64
|
+
# Bretagne, Pays de la Loire, AURA
|
|
65
|
+
expect(page.locator("path[fill='#edf8e9']")).to_have_count(3)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_basic_choropleth_map_with_custom_classes(openmap, live_server, page):
|
|
69
|
+
path = Path(__file__).parent.parent / "fixtures/choropleth_region_chomage.geojson"
|
|
70
|
+
data = json.loads(path.read_text())
|
|
71
|
+
|
|
72
|
+
# Change brewer at load
|
|
73
|
+
data["_umap_options"]["choropleth"]["classes"] = 6
|
|
74
|
+
DataLayerFactory(data=data, map=openmap)
|
|
75
|
+
|
|
76
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
77
|
+
|
|
78
|
+
# Hauts-de-France
|
|
79
|
+
expect(page.locator("path[fill='#08519c']")).to_have_count(1)
|
|
80
|
+
# Occitanie
|
|
81
|
+
expect(page.locator("path[fill='#3182bd']")).to_have_count(1)
|
|
82
|
+
# PACA
|
|
83
|
+
expect(page.locator("path[fill='#6baed6']")).to_have_count(1)
|
|
84
|
+
# Grand-Est
|
|
85
|
+
expect(page.locator("path[fill='#9ecae1']")).to_have_count(1)
|
|
86
|
+
# Bourgogne-Franche-Comté, Centre-Val-de-Loire, IdF, Normandie, Corse, Nouvelle-Aquitaine
|
|
87
|
+
expect(page.locator("path[fill='#c6dbef']")).to_have_count(6)
|
|
88
|
+
# Bretagne, Pays de la Loire, AURA
|
|
89
|
+
expect(page.locator("path[fill='#eff3ff']")).to_have_count(3)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import re
|
|
3
|
+
from pathlib import Path
|
|
2
4
|
from time import sleep
|
|
3
5
|
|
|
4
6
|
from playwright.sync_api import expect
|
|
5
7
|
|
|
6
|
-
from umap.models import DataLayer
|
|
8
|
+
from umap.models import DataLayer, Map
|
|
7
9
|
|
|
8
10
|
from ..base import DataLayerFactory, MapFactory
|
|
9
11
|
|
|
@@ -265,3 +267,30 @@ def test_same_second_edit_doesnt_conflict(context, live_server, tilelayer):
|
|
|
265
267
|
"id": str(datalayer.pk),
|
|
266
268
|
"permissions": {"edit_status": 1},
|
|
267
269
|
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def test_should_display_alert_on_conflict(context, live_server, datalayer, openmap):
|
|
273
|
+
# Open the map on two pages.
|
|
274
|
+
page_one = context.new_page()
|
|
275
|
+
page_one.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
276
|
+
page_two = context.new_page()
|
|
277
|
+
page_two.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
278
|
+
|
|
279
|
+
page_one.locator(".leaflet-marker-icon").click(modifiers=["Shift"])
|
|
280
|
+
page_one.locator('input[name="name"]').fill("new name")
|
|
281
|
+
with page_one.expect_response(re.compile(r".*/datalayer/update/.*")):
|
|
282
|
+
page_one.get_by_role("button", name="Save").click()
|
|
283
|
+
|
|
284
|
+
page_two.locator(".leaflet-marker-icon").click(modifiers=["Shift"])
|
|
285
|
+
page_two.locator('input[name="name"]').fill("custom name")
|
|
286
|
+
with page_two.expect_response(re.compile(r".*/datalayer/update/.*")):
|
|
287
|
+
page_two.get_by_role("button", name="Save").click()
|
|
288
|
+
saved = DataLayer.objects.last()
|
|
289
|
+
data = json.loads(Path(saved.geojson.path).read_text())
|
|
290
|
+
assert data["features"][0]["properties"]["name"] == "new name"
|
|
291
|
+
expect(page_two.get_by_text("Woops! Someone else seems to")).to_be_visible()
|
|
292
|
+
with page_two.expect_response(re.compile(r".*/datalayer/update/.*")):
|
|
293
|
+
page_two.get_by_role("button", name="Save anyway").click()
|
|
294
|
+
saved = DataLayer.objects.last()
|
|
295
|
+
data = json.loads(Path(saved.geojson.path).read_text())
|
|
296
|
+
assert data["features"][0]["properties"]["name"] == "custom name"
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from django.core.files.base import ContentFile
|
|
5
|
+
from playwright.sync_api import expect
|
|
6
|
+
|
|
7
|
+
from ..base import DataLayerFactory
|
|
8
|
+
|
|
9
|
+
pytestmark = pytest.mark.django_db
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def set_options(datalayer, **options):
|
|
13
|
+
# For now we need to change both the DB and the FS…
|
|
14
|
+
datalayer.settings.update(options)
|
|
15
|
+
data = json.load(datalayer.geojson.file)
|
|
16
|
+
data["_umap_options"].update(**options)
|
|
17
|
+
datalayer.geojson = ContentFile(json.dumps(data), "foo.json")
|
|
18
|
+
datalayer.save()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_honour_displayOnLoad_false(map, live_server, datalayer, page):
|
|
22
|
+
set_options(datalayer, displayOnLoad=False)
|
|
23
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
24
|
+
expect(page.locator(".leaflet-marker-icon")).to_be_hidden()
|
|
25
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
26
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
27
|
+
layers_off = page.locator(".umap-browse-datalayers li.off")
|
|
28
|
+
expect(layers).to_have_count(1)
|
|
29
|
+
expect(layers_off).to_have_count(1)
|
|
30
|
+
page.get_by_role("button", name="See data layers").click()
|
|
31
|
+
page.get_by_label("Zoom in").click()
|
|
32
|
+
expect(markers).to_be_hidden()
|
|
33
|
+
page.get_by_title("Show/hide layer").click()
|
|
34
|
+
expect(layers_off).to_have_count(0)
|
|
35
|
+
expect(markers).to_be_visible()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_should_honour_fromZoom(live_server, map, datalayer, page):
|
|
39
|
+
set_options(datalayer, displayOnLoad=True, fromZoom=6)
|
|
40
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}#5/48.55/14.68")
|
|
41
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
42
|
+
expect(markers).to_be_hidden()
|
|
43
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/48.55/14.68")
|
|
44
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
45
|
+
expect(markers).to_be_visible()
|
|
46
|
+
page.get_by_label("Zoom out").click()
|
|
47
|
+
expect(markers).to_be_hidden()
|
|
48
|
+
page.get_by_label("Zoom in").click()
|
|
49
|
+
expect(markers).to_be_visible()
|
|
50
|
+
page.get_by_label("Zoom in").click()
|
|
51
|
+
expect(markers).to_be_visible()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_should_honour_toZoom(live_server, map, datalayer, page):
|
|
55
|
+
set_options(datalayer, displayOnLoad=True, toZoom=6)
|
|
56
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}#7/48.55/14.68")
|
|
57
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
58
|
+
expect(markers).to_be_hidden()
|
|
59
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/48.55/14.68")
|
|
60
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
61
|
+
expect(markers).to_be_visible()
|
|
62
|
+
page.get_by_label("Zoom out").click()
|
|
63
|
+
expect(markers).to_be_visible()
|
|
64
|
+
page.get_by_label("Zoom in").click()
|
|
65
|
+
expect(markers).to_be_visible()
|
|
66
|
+
page.get_by_label("Zoom in").click()
|
|
67
|
+
# FIXME does not work (but works when using PWDEBUG=1), not sure why
|
|
68
|
+
# may be a race condition related to css transition
|
|
69
|
+
# expect(markers).to_be_hidden()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_should_honour_color_variable(live_server, map, page):
|
|
73
|
+
data = {
|
|
74
|
+
"type": "FeatureCollection",
|
|
75
|
+
"features": [
|
|
76
|
+
{
|
|
77
|
+
"type": "Feature",
|
|
78
|
+
"properties": {"mycolor": "aliceblue", "name": "Point 4"},
|
|
79
|
+
"geometry": {"type": "Point", "coordinates": [0.856934, 45.290347]},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "Feature",
|
|
83
|
+
"properties": {"name": "a polygon", "mycolor": "tomato"},
|
|
84
|
+
"geometry": {
|
|
85
|
+
"type": "Polygon",
|
|
86
|
+
"coordinates": [
|
|
87
|
+
[
|
|
88
|
+
[2.12, 49.57],
|
|
89
|
+
[1.08, 49.02],
|
|
90
|
+
[2.51, 47.55],
|
|
91
|
+
[3.19, 48.77],
|
|
92
|
+
[2.12, 49.57],
|
|
93
|
+
]
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
"_umap_options": {
|
|
99
|
+
"name": "Calque 2",
|
|
100
|
+
"color": "{mycolor}",
|
|
101
|
+
"fillColor": "{mycolor}",
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
DataLayerFactory(map=map, data=data)
|
|
105
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
106
|
+
expect(page.locator(".leaflet-overlay-pane path[fill='tomato']"))
|
|
107
|
+
markers = page.locator(".leaflet-marker-icon .icon_container")
|
|
108
|
+
expect(markers).to_have_css("background-color", "rgb(240, 248, 255)")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_datalayers_in_query_string(live_server, datalayer, map, page):
|
|
112
|
+
with_old_id = DataLayerFactory(old_id=134, map=map, name="with old id")
|
|
113
|
+
set_options(with_old_id, name="with old id")
|
|
114
|
+
visible = page.locator(".leaflet-control-browse li:not(.off) span")
|
|
115
|
+
hidden = page.locator(".leaflet-control-browse li.off span")
|
|
116
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
117
|
+
expect(visible).to_have_count(2)
|
|
118
|
+
expect(hidden).to_have_count(0)
|
|
119
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}?datalayers={datalayer.pk}")
|
|
120
|
+
expect(visible).to_have_count(1)
|
|
121
|
+
expect(visible).to_have_text(datalayer.name)
|
|
122
|
+
expect(hidden).to_have_count(1)
|
|
123
|
+
expect(hidden).to_have_text(with_old_id.name)
|
|
124
|
+
page.goto(
|
|
125
|
+
f"{live_server.url}{map.get_absolute_url()}?datalayers={with_old_id.old_id}"
|
|
126
|
+
)
|
|
127
|
+
expect(visible).to_have_count(1)
|
|
128
|
+
expect(visible).to_have_text(with_old_id.name)
|
|
129
|
+
expect(hidden).to_have_count(1)
|
|
130
|
+
expect(hidden).to_have_text(datalayer.name)
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
1
3
|
from playwright.sync_api import expect
|
|
2
4
|
|
|
5
|
+
from umap.models import DataLayer
|
|
6
|
+
|
|
7
|
+
from ..base import DataLayerFactory
|
|
8
|
+
|
|
3
9
|
|
|
4
10
|
def test_should_have_fieldset_for_layer_type_properties(page, live_server, tilelayer):
|
|
5
11
|
page.goto(f"{live_server.url}/en/map/new/")
|
|
@@ -44,3 +50,131 @@ def test_should_have_fieldset_for_layer_type_properties(page, live_server, tilel
|
|
|
44
50
|
expect(choropleth_header).to_be_hidden()
|
|
45
51
|
expect(heat_header).to_be_hidden()
|
|
46
52
|
expect(cluster_header).to_be_hidden()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_cancel_deleting_datalayer_should_restore(
|
|
56
|
+
live_server, openmap, datalayer, page
|
|
57
|
+
):
|
|
58
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
59
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
60
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
61
|
+
expect(layers).to_have_count(1)
|
|
62
|
+
expect(markers).to_have_count(1)
|
|
63
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
64
|
+
page.once("dialog", lambda dialog: dialog.accept())
|
|
65
|
+
page.locator("#umap-ui-container").get_by_title("Delete layer").click()
|
|
66
|
+
expect(markers).to_have_count(0)
|
|
67
|
+
page.get_by_role("button", name="See data layers").click()
|
|
68
|
+
expect(page.get_by_text("test datalayer")).to_be_hidden()
|
|
69
|
+
page.once("dialog", lambda dialog: dialog.accept())
|
|
70
|
+
page.get_by_role("button", name="Cancel edits").click()
|
|
71
|
+
expect(markers).to_have_count(1)
|
|
72
|
+
expect(
|
|
73
|
+
page.locator(".leaflet-control-browse").get_by_text("test datalayer")
|
|
74
|
+
).to_be_visible()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_can_clone_datalayer(live_server, openmap, login, datalayer, page):
|
|
78
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
79
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
80
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
81
|
+
expect(layers).to_have_count(1)
|
|
82
|
+
expect(markers).to_have_count(1)
|
|
83
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
84
|
+
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click()
|
|
85
|
+
page.get_by_role("heading", name="Advanced actions").click()
|
|
86
|
+
page.get_by_role("button", name="Clone").click()
|
|
87
|
+
expect(layers).to_have_count(2)
|
|
88
|
+
expect(markers).to_have_count(2)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_can_change_icon_class(live_server, openmap, page):
|
|
92
|
+
# Faster than doing a login
|
|
93
|
+
data = {
|
|
94
|
+
"type": "FeatureCollection",
|
|
95
|
+
"features": [
|
|
96
|
+
{
|
|
97
|
+
"type": "Feature",
|
|
98
|
+
"properties": {"name": "Point 4"},
|
|
99
|
+
"geometry": {"type": "Point", "coordinates": [0.856934, 45.290347]},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
}
|
|
103
|
+
DataLayerFactory(map=openmap, data=data)
|
|
104
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
105
|
+
expect(page.locator(".umap-div-icon")).to_be_visible()
|
|
106
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
107
|
+
expect(page.locator(".umap-circle-icon")).to_be_hidden()
|
|
108
|
+
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click()
|
|
109
|
+
page.get_by_role("heading", name="Shape properties").click()
|
|
110
|
+
page.locator(".umap-field-iconClass a.define").click()
|
|
111
|
+
page.get_by_text("Circle").click()
|
|
112
|
+
expect(page.locator(".umap-circle-icon")).to_be_visible()
|
|
113
|
+
expect(page.locator(".umap-div-icon")).to_be_hidden()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_can_change_name(live_server, openmap, page, datalayer):
|
|
117
|
+
page.goto(
|
|
118
|
+
f"{live_server.url}{openmap.get_absolute_url()}?edit&datalayersControl=expanded"
|
|
119
|
+
)
|
|
120
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
121
|
+
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click()
|
|
122
|
+
expect(page.locator(".umap-is-dirty")).to_be_hidden()
|
|
123
|
+
page.locator('input[name="name"]').click()
|
|
124
|
+
page.locator('input[name="name"]').press("Control+a")
|
|
125
|
+
page.locator('input[name="name"]').fill("new name")
|
|
126
|
+
expect(page.locator(".leaflet-control-browse li span")).to_contain_text("new name")
|
|
127
|
+
expect(page.locator(".umap-is-dirty")).to_be_visible()
|
|
128
|
+
with page.expect_response(re.compile(".*/datalayer/update/.*")):
|
|
129
|
+
page.get_by_role("button", name="Save").click()
|
|
130
|
+
saved = DataLayer.objects.last()
|
|
131
|
+
assert saved.name == "new name"
|
|
132
|
+
expect(page.locator(".umap-is-dirty")).to_be_hidden()
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def test_can_create_new_datalayer(live_server, openmap, page, datalayer):
|
|
136
|
+
page.goto(
|
|
137
|
+
f"{live_server.url}{openmap.get_absolute_url()}?edit&datalayersControl=expanded"
|
|
138
|
+
)
|
|
139
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
140
|
+
page.get_by_role("button", name="Add a layer").click()
|
|
141
|
+
page.locator('input[name="name"]').click()
|
|
142
|
+
page.locator('input[name="name"]').fill("my new layer")
|
|
143
|
+
expect(page.get_by_text("my new layer")).to_be_visible()
|
|
144
|
+
with page.expect_response(re.compile(".*/datalayer/create/.*")):
|
|
145
|
+
page.get_by_role("button", name="Save").click()
|
|
146
|
+
assert DataLayer.objects.count() == 2
|
|
147
|
+
saved = DataLayer.objects.last()
|
|
148
|
+
assert saved.name == "my new layer"
|
|
149
|
+
expect(page.locator(".umap-is-dirty")).to_be_hidden()
|
|
150
|
+
# Edit again, it should not create a new datalayer
|
|
151
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
152
|
+
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).first.click()
|
|
153
|
+
page.locator('input[name="name"]').click()
|
|
154
|
+
page.locator('input[name="name"]').fill("my new layer with a new name")
|
|
155
|
+
expect(page.get_by_text("my new layer with a new name")).to_be_visible()
|
|
156
|
+
page.get_by_role("button", name="Save").click()
|
|
157
|
+
with page.expect_response(re.compile(".*/datalayer/update/.*")):
|
|
158
|
+
page.get_by_role("button", name="Save").click()
|
|
159
|
+
assert DataLayer.objects.count() == 2
|
|
160
|
+
saved = DataLayer.objects.last()
|
|
161
|
+
assert saved.name == "my new layer with a new name"
|
|
162
|
+
expect(page.locator(".umap-is-dirty")).to_be_hidden()
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_can_restore_version(live_server, openmap, page, datalayer):
|
|
166
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
167
|
+
marker = page.locator(".leaflet-marker-icon")
|
|
168
|
+
expect(marker).to_have_class(re.compile(".*umap-ball-icon.*"))
|
|
169
|
+
marker.click(modifiers=["Shift"])
|
|
170
|
+
page.get_by_role("heading", name="Shape properties").click()
|
|
171
|
+
page.locator("#umap-feature-shape-properties").get_by_text("Default").click()
|
|
172
|
+
with page.expect_response(re.compile(".*/datalayer/update/.*")):
|
|
173
|
+
page.get_by_role("button", name="Save").click()
|
|
174
|
+
expect(marker).to_have_class(re.compile(".*umap-div-icon.*"))
|
|
175
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
176
|
+
page.locator("#umap-ui-container").get_by_title("Edit", exact=True).click()
|
|
177
|
+
page.get_by_role("heading", name="Versions").click()
|
|
178
|
+
page.once("dialog", lambda dialog: dialog.accept())
|
|
179
|
+
page.get_by_role("button", name="Restore this version").last.click()
|
|
180
|
+
expect(marker).to_have_class(re.compile(".*umap-ball-icon.*"))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from playwright.sync_api import expect
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_can_edit_name(page, live_server, tilelayer):
|
|
5
|
+
page.goto(f"{live_server.url}/en/map/new/")
|
|
6
|
+
|
|
7
|
+
page.get_by_title("Edit map properties").click()
|
|
8
|
+
name_input = page.locator('.map-metadata input[name="name"]')
|
|
9
|
+
expect(name_input).to_be_visible()
|
|
10
|
+
name_input.click()
|
|
11
|
+
name_input.press("Control+a")
|
|
12
|
+
name_input.fill("New map name")
|
|
13
|
+
expect(page.locator(".umap-main-edit-toolbox .map-name")).to_have_text(
|
|
14
|
+
"New map name"
|
|
15
|
+
)
|
|
@@ -46,6 +46,30 @@ DATALAYER_DATA2 = {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
DATALAYER_DATA3 = {
|
|
50
|
+
"type": "FeatureCollection",
|
|
51
|
+
"features": [
|
|
52
|
+
{
|
|
53
|
+
"type": "Feature",
|
|
54
|
+
"properties": {"name": "a polygon"},
|
|
55
|
+
"geometry": {
|
|
56
|
+
"type": "Polygon",
|
|
57
|
+
"coordinates": [
|
|
58
|
+
[
|
|
59
|
+
[2.12, 49.57],
|
|
60
|
+
[1.08, 49.02],
|
|
61
|
+
[2.51, 47.55],
|
|
62
|
+
[3.19, 48.77],
|
|
63
|
+
[2.12, 49.57],
|
|
64
|
+
]
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
"_umap_options": {"name": "Calque 2", "browsable": False},
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
49
73
|
@pytest.fixture
|
|
50
74
|
def bootstrap(map, live_server):
|
|
51
75
|
map.settings["properties"]["onLoadPanel"] = "facet"
|
|
@@ -54,11 +78,15 @@ def bootstrap(map, live_server):
|
|
|
54
78
|
map.save()
|
|
55
79
|
DataLayerFactory(map=map, data=DATALAYER_DATA1)
|
|
56
80
|
DataLayerFactory(map=map, data=DATALAYER_DATA2)
|
|
81
|
+
DataLayerFactory(map=map, data=DATALAYER_DATA3)
|
|
57
82
|
|
|
58
83
|
|
|
59
84
|
def test_simple_facet_search(live_server, page, bootstrap, map):
|
|
60
85
|
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
61
86
|
panel = page.locator(".umap-facet-search")
|
|
87
|
+
# From a non browsable datalayer, should not be impacted
|
|
88
|
+
paths = page.locator(".leaflet-overlay-pane path")
|
|
89
|
+
expect(paths).to_be_visible
|
|
62
90
|
expect(panel).to_be_visible()
|
|
63
91
|
# Facet name
|
|
64
92
|
expect(page.get_by_text("My type")).to_be_visible()
|
|
@@ -67,6 +95,7 @@ def test_simple_facet_search(live_server, page, bootstrap, map):
|
|
|
67
95
|
odd = page.get_by_text("odd")
|
|
68
96
|
expect(oven).to_be_visible()
|
|
69
97
|
expect(odd).to_be_visible()
|
|
98
|
+
expect(paths).to_be_visible
|
|
70
99
|
markers = page.locator(".leaflet-marker-icon")
|
|
71
100
|
expect(markers).to_have_count(4)
|
|
72
101
|
# Tooltips
|
|
@@ -81,6 +110,8 @@ def test_simple_facet_search(live_server, page, bootstrap, map):
|
|
|
81
110
|
expect(page.get_by_text("Point 4")).to_be_hidden()
|
|
82
111
|
expect(page.get_by_text("Point 1")).to_be_visible()
|
|
83
112
|
expect(page.get_by_text("Point 3")).to_be_visible()
|
|
113
|
+
expect(paths).to_be_visible
|
|
84
114
|
# Now let's filter
|
|
85
115
|
odd.click()
|
|
86
116
|
expect(markers).to_have_count(4)
|
|
117
|
+
expect(paths).to_be_visible
|