Skip to content

Commit

Permalink
chore: afficher la bannière d'environnement systématiquement hors PROD (
Browse files Browse the repository at this point in the history
#881)

## Description

🎸 cf title

## Type de changement

🎨 changement d'UI
🚧 technique



### Captures d'écran (optionnel)

dev local

![image](https://github.com/user-attachments/assets/72a1c8c4-5c92-4461-bf1f-bb8911cf4158)

review app

![image](https://github.com/user-attachments/assets/705067f1-7909-45b5-a2cd-db7f222d25c9)
  • Loading branch information
vincentporte authored Jan 20, 2025
1 parent c6ac2a3 commit 84d9168
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
16 changes: 9 additions & 7 deletions lacommunaute/templates/layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@
</li>
</ul>
</nav>
{% if ENVIRONMENT == "DEV" %}
<div class="global-messages-container" id="debug-mode-banner">
<div class="alert alert-danger fade show" role="status">
<p class="mb-0">
<strong class="text-uppercase">DEV MODE</strong>
</p>
{% if ENVIRONMENT %}
{% if ENVIRONMENT != "PROD" %}
<div class="global-messages-container" id="debug-mode-banner">
<div class="alert alert-danger fade show" role="status">
<p class="mb-0">
<strong class="text-uppercase">{{ ENVIRONMENT }} MODE</strong>
</p>
</div>
</div>
</div>
{% endif %}
{% endif %}
{% block header %}
{% include "partials/header.html" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# serializer version: 1
# name: test_prod_environment[DEV-True][Dev]
'''
<div class="global-messages-container" id="debug-mode-banner">
<div class="alert alert-danger fade show" role="status">
<p class="mb-0">
<strong class="text-uppercase">DEV MODE</strong>
</p>
</div>
</div>
'''
# ---
# name: test_prod_environment[TEST-True][Test]
'''
<div class="global-messages-container" id="debug-mode-banner">
<div class="alert alert-danger fade show" role="status">
<p class="mb-0">
<strong class="text-uppercase">TEST MODE</strong>
</p>
</div>
</div>
'''
# ---
9 changes: 7 additions & 2 deletions lacommunaute/utils/tests/tests_context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
from django.test import override_settings

from lacommunaute.utils.enums import Environment
from lacommunaute.utils.testing import parse_response_to_soup


@pytest.mark.parametrize(
"env,expected",
[
(None, False),
(Environment.PROD, False),
(Environment.TEST, False),
(Environment.TEST, True),
(Environment.DEV, True),
],
)
def test_prod_environment(client, db, env, expected):
def test_prod_environment(client, db, env, expected, snapshot):
with override_settings(ENVIRONMENT=env):
response = client.get("/")
assert ('id="debug-mode-banner"' in response.content.decode()) == expected
if expected:
content = parse_response_to_soup(response, selector="#debug-mode-banner")
assert str(content) == snapshot(name=env.label)


def test_exposed_settings(client, db):
Expand Down

0 comments on commit 84d9168

Please sign in to comment.