diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index 9a564c70..7e14560f 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/test-docs.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgis/postgis:13-3.4 + image: postgis/postgis:14-3.4 ports: - 5432:5432 env: diff --git a/pyproject.toml b/pyproject.toml index e8b1169e..f0913814 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] dependencies = [ - "Django==5.0.8", + "Django==5.1", "django-agnocomplete==2.2.0", "django-environ==0.11.2", "django-probes==1.7.0", diff --git a/umap/storage.py b/umap/storage.py index 1ca63a86..94295661 100644 --- a/umap/storage.py +++ b/umap/storage.py @@ -8,6 +8,7 @@ from rjsmin import jsmin class UmapManifestStaticFilesStorage(ManifestStaticFilesStorage): support_js_module_import_aggregation = True + max_post_process_passes = 15 # We remove `;` at the end of all regexps to match our biome config. _js_module_import_aggregation_patterns = ( diff --git a/umap/tests/integration/test_statics.py b/umap/tests/integration/test_statics.py deleted file mode 100644 index 4df25705..00000000 --- a/umap/tests/integration/test_statics.py +++ /dev/null @@ -1,47 +0,0 @@ -import re -import shutil -import tempfile -from copy import deepcopy - -import pytest -from django.core.management import call_command -from django.utils.translation import override -from playwright.sync_api import expect - - -@pytest.fixture -def staticfiles(settings): - static_root = tempfile.mkdtemp(prefix="test_static") - settings.STATIC_ROOT = static_root - # Make sure settings are properly reset after the test - settings.STORAGES = deepcopy(settings.STORAGES) - settings.STORAGES["staticfiles"]["BACKEND"] = ( - "umap.storage.UmapManifestStaticFilesStorage" - ) - try: - call_command("collectstatic", "--noinput") - yield - finally: - shutil.rmtree(static_root) - - -def test_javascript_have_been_loaded( - map, live_server, datalayer, page, settings, staticfiles -): - datalayer.settings["displayOnLoad"] = False - datalayer.save() - map.settings["properties"]["defaultView"] = "latest" - map.save() - with override("fr"): - url = f"{live_server.url}{map.get_absolute_url()}" - assert "/fr/" in url - page.goto(url) - # Hash is defined, so map is initialized - expect(page).to_have_url(re.compile(r".*#7/48\..+/13\..+")) - expect(page).to_have_url(re.compile(r".*/fr/")) - # Should be in French, so hashed locale file has been loaded correctly - button = page.get_by_role("button", name="Explorateur") - expect(button).to_be_visible() - button.click() - layers = page.locator(".umap-browser .datalayer") - expect(layers).to_have_count(1) diff --git a/umap/tests/test_statics.py b/umap/tests/test_statics.py new file mode 100644 index 00000000..c29b57d7 --- /dev/null +++ b/umap/tests/test_statics.py @@ -0,0 +1,40 @@ +import json +import shutil +import tempfile +from copy import deepcopy +from pathlib import Path + +import pytest +from django.core.management import call_command + + +@pytest.fixture +def staticfiles(settings): + static_root = tempfile.mkdtemp(prefix="test_static") + settings.STATIC_ROOT = static_root + # Make sure settings are properly reset after the test + settings.STORAGES = deepcopy(settings.STORAGES) + settings.STORAGES["staticfiles"]["BACKEND"] = ( + "umap.storage.UmapManifestStaticFilesStorage" + ) + try: + call_command("collectstatic", "--noinput") + yield + finally: + shutil.rmtree(static_root) + + +def test_collectstatic_ran_successfully_with_hashes(settings, staticfiles): + static_root = settings.STATIC_ROOT + manifest = Path(static_root) / "staticfiles.json" + assert manifest.exists() + json_manifest = json.loads(manifest.read_text()) + assert "hash" in json_manifest.keys() + assert "umap/base.css" in json_manifest["paths"] + # Hash + the dot ("umap/base..css"). + md5_hash_lenght = 12 + 1 + # The value of the manifest must contain the hash (length). + assert ( + len(json_manifest["paths"]["umap/base.css"]) + == len("umap/base.css") + md5_hash_lenght + )