chore: deactivate custom statics manager for test by default
And add one file that run it and check all js files are loaded.
This commit is contained in:
parent
1b8e6164ed
commit
96ae7ddbc7
3 changed files with 47 additions and 1 deletions
|
@ -28,7 +28,7 @@
|
||||||
<script src="{% static 'umap/vendors/colorbrewer/colorbrewer.js' %}" defer></script>
|
<script src="{% static 'umap/vendors/colorbrewer/colorbrewer.js' %}" defer></script>
|
||||||
<script src="{% static 'umap/vendors/simple-statistics/simple-statistics.min.js' %}" defer></script>
|
<script src="{% static 'umap/vendors/simple-statistics/simple-statistics.min.js' %}" defer></script>
|
||||||
{% if locale %}
|
{% if locale %}
|
||||||
{% with 'umap/locale/'|add:locale|add:'.js' as path %}
|
{% with "umap/locale/"|add:locale|add:".js" as path %}
|
||||||
<script src="{% static path %}" defer></script>
|
<script src="{% static path %}" defer></script>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
43
umap/tests/integration/test_statics.py
Normal file
43
umap/tests/integration/test_statics.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
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
|
||||||
|
try:
|
||||||
|
call_command("collectstatic", "--noinput")
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
shutil.rmtree(static_root)
|
||||||
|
|
||||||
|
|
||||||
|
def test_javascript_have_been_loaded(
|
||||||
|
map, live_server, datalayer, page, settings, staticfiles
|
||||||
|
):
|
||||||
|
settings.STORAGES["staticfiles"][
|
||||||
|
"BACKEND"
|
||||||
|
] = "umap.utils.UmapManifestStaticFilesStorage"
|
||||||
|
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_text("Voir les calques")
|
||||||
|
expect(button).to_be_visible()
|
||||||
|
layers = page.locator(".umap-browse-datalayers li")
|
||||||
|
expect(layers).to_have_count(1)
|
|
@ -5,6 +5,9 @@ from umap.settings.base import * # pylint: disable=W0614,W0401
|
||||||
SECRET_KEY = "justfortests"
|
SECRET_KEY = "justfortests"
|
||||||
FROM_EMAIL = "test@test.org"
|
FROM_EMAIL = "test@test.org"
|
||||||
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
||||||
|
STORAGES["staticfiles"][
|
||||||
|
"BACKEND"
|
||||||
|
] = "django.contrib.staticfiles.storage.StaticFilesStorage"
|
||||||
|
|
||||||
if os.environ.get("GITHUB_ACTIONS", False) == "true":
|
if os.environ.get("GITHUB_ACTIONS", False) == "true":
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
|
|
Loading…
Reference in a new issue