fix: JAVASCRIPT and HTMX configuration settings were ignored

This commit is contained in:
Éloi Rivard 2024-04-09 12:06:33 +02:00
parent f3bcdafb23
commit 4037c296cf
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184
4 changed files with 33 additions and 6 deletions

View file

@ -1,8 +1,11 @@
Added
^^^^^
- Sign in/out events are logged in :issuer:`177`
Fixed
^^^^^
- HTMX and JAVASCRIPT configuration settings.
[0.0.49] - 2024-04-08
---------------------

View file

@ -18,7 +18,7 @@
{% block style %}{% endblock %}
</head>
<body hx-boost="true">
<body{% if config["CANAILLE"]["JAVASCRIPT"] and config["CANAILLE"]["HTMX"] %} hx-boost="true"{% endif %}>
{% block menu %}
{% if user and menu %}
<div class="ui container menu-container">
@ -90,11 +90,11 @@
<footer>
<a href="{{ url_for('core.account.about') }}">{{ _("About Canaille") }}</a>
</footer>
{% if config.get("JAVASCRIPT", true) %}
{% if config["CANAILLE"]["JAVASCRIPT"] %}
{% if not is_boosted %}
<script src="{{ url_for("static", filename="jquery/jquery.min.js") }}" defer></script>
<script src="{{ url_for("static", filename="fomanticui/semantic.min.js") }}" defer></script>
{% if config.get("HTMX", true) %}
{% if config["CANAILLE"]["HTMX"] %}
<script src="{{ url_for("static", filename="htmx/htmx.min.js") }}" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function() {

View file

@ -1,2 +0,0 @@
def test_version(testclient):
testclient.get("/about", status=200)

26
tests/core/test_misc.py Normal file
View file

@ -0,0 +1,26 @@
def test_version(testclient):
testclient.get("/about", status=200)
def test_javascript(testclient):
testclient.app.config["CANAILLE"]["JAVASCRIPT"] = True
res = testclient.get("/about", status=200)
res.mustcontain("<script>")
testclient.app.config["CANAILLE"]["JAVASCRIPT"] = False
res = testclient.get("/about", status=200)
res.mustcontain(no="<script>")
def test_htmx(testclient):
testclient.app.config["CANAILLE"]["JAVASCRIPT"] = True
testclient.app.config["CANAILLE"]["HTMX"] = True
res = testclient.get("/about", status=200)
res.mustcontain("htmx.min.js")
res.mustcontain("hx-boost")
testclient.app.config["CANAILLE"]["JAVASCRIPT"] = True
testclient.app.config["CANAILLE"]["HTMX"] = False
res = testclient.get("/about", status=200)
res.mustcontain(no="htmx.min.js")
res.mustcontain(no="hx-boost")