From 9781f6eb9c7288e74b2c8f640acb2a6df4f8502e Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 23 Nov 2023 13:07:18 +0100 Subject: [PATCH 1/2] Restore missing buttons in caption bar Those button, being width: 100% and display: block were not displayed AND were pushing out also the slideshow buttons. --- umap/static/umap/base.css | 2 ++ umap/static/umap/js/umap.js | 8 ++++---- umap/static/umap/map.css | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/base.css b/umap/static/umap/base.css index f13cf110..dc504a30 100644 --- a/umap/static/umap/base.css +++ b/umap/static/umap/base.css @@ -202,6 +202,8 @@ button.flat, padding: 0; text-align: left; min-height: inherit; + width: initial; + display: initial; text-decoration: underline; } .help-text, .helptext { diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index ed54f43b..eeeccf0b 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1744,16 +1744,16 @@ L.U.Map.include({ this.permissions.addOwnerLink('span', container) if (this.options.captionMenus) { L.DomUtil.createButton( - 'umap-about-link', + 'umap-about-link flat', container, - ` — ${L._('About')}`, + L._('About'), this.displayCaption, this ) L.DomUtil.createButton( - 'umap-open-browser-link', + 'umap-open-browser-link flat', container, - ` | ${L._('Browse data')}`, + L._('Browse data'), this.openBrowser, this ) diff --git a/umap/static/umap/map.css b/umap/static/umap/map.css index 434faae4..68bdecf5 100644 --- a/umap/static/umap/map.css +++ b/umap/static/umap/map.css @@ -600,6 +600,13 @@ ul.photon-autocomplete { .umap-main-edit-toolbox h3 { display: inline; } +.umap-caption-bar button { + margin-left: 10px; +} +.umap-caption-bar button + button:before { + content: '|'; + padding-right: 10px; +} .umap-main-edit-toolbox .umap-user { color: #fff; } From 42ebe4369833a241f509df120d8b1e469c491390 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 23 Nov 2023 14:53:52 +0100 Subject: [PATCH 2/2] Add minimal playwright test case for slideshow --- umap/tests/base.py | 1 + umap/tests/integration/test_slideshow.py | 70 ++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 umap/tests/integration/test_slideshow.py diff --git a/umap/tests/base.py b/umap/tests/base.py index ddfa21e5..42b03ab7 100644 --- a/umap/tests/base.py +++ b/umap/tests/base.py @@ -124,6 +124,7 @@ class DataLayerFactory(factory.django.DjangoModelFactory): **DataLayerFactory.settings._defaults, **kwargs["settings"], } + data.setdefault("_umap_options", {}) data["_umap_options"]["name"] = kwargs["name"] kwargs["geojson"] = ContentFile(json.dumps(data), "foo.json") return kwargs diff --git a/umap/tests/integration/test_slideshow.py b/umap/tests/integration/test_slideshow.py new file mode 100644 index 00000000..1911defc --- /dev/null +++ b/umap/tests/integration/test_slideshow.py @@ -0,0 +1,70 @@ +from pathlib import Path + +import pytest +from playwright.sync_api import expect +from django.core.files.base import ContentFile + +from umap.models import Map, Pictogram + +from ..base import DataLayerFactory + +pytestmark = pytest.mark.django_db + + +DATALAYER_DATA = { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.6, 48.5], + }, + "properties": {"name": "1st Point"}, + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.7, 48.4], + }, + "properties": {"name": "2d Point"}, + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [13.5, 48.6], + }, + "properties": {"name": "3d Point"}, + }, + ], +} + + +def test_can_use_slideshow_manually(map, live_server, page): + map.settings["properties"]["slideshow"] = {"active": True, "delay": 5000} + map.save() + DataLayerFactory(map=map, data=DATALAYER_DATA) + page.goto(f"{live_server.url}{map.get_absolute_url()}") + first_point = page.get_by_text("1st Point") + second_point = page.get_by_text("2d Point") + third_point = page.get_by_text("3d Point") + expect(first_point).to_be_hidden() + expect(second_point).to_be_hidden() + expect(third_point).to_be_hidden() + next_ = page.get_by_title("Zoom to the next") + expect(next_).to_be_visible() + next_.click() + expect(first_point).to_be_visible() + next_.click() + expect(first_point).to_be_hidden() + expect(second_point).to_be_visible() + next_.click() + expect(first_point).to_be_hidden() + expect(second_point).to_be_hidden() + expect(third_point).to_be_visible() + next_.click() + expect(first_point).to_be_visible() + expect(second_point).to_be_hidden() + expect(third_point).to_be_hidden()