diff --git a/app/templates/base.html b/app/templates/base.html index 7406a33..ee5874b 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -28,10 +28,19 @@ {{ item.label }} {% endfor %} -
- +
+ {% if current_user | default(None) %} + {{ current_user.username }} + + Abmelden + + {% else %} + + Anmelden + + {% endif %}
@@ -46,4 +55,4 @@ - \ No newline at end of file + diff --git a/tests/test_landing.py b/tests/test_landing.py index 57498f4..1266d91 100644 --- a/tests/test_landing.py +++ b/tests/test_landing.py @@ -77,3 +77,16 @@ def test_landing_contains_title(client): def test_landing_info_strip_shows_db_mode(client, auth_cookies): response = client.get("/", cookies=auth_cookies) assert "SQLite" in response.text or "MariaDB" in response.text + + +def test_navbar_shows_login_button_for_anonymous(client): + response = client.get("/") + assert "Anmelden" in response.text + assert "Abmelden" not in response.text + + +def test_navbar_shows_username_and_logout_when_logged_in(client, auth_cookies): + response = client.get("/", cookies=auth_cookies) + assert "testuser" in response.text + assert "Abmelden" in response.text + assert "Anmelden" not in response.text