bifroest/tests/test_breadcrumbs.py
2026-10-27 08:34:17 +01:00

55 lines
2.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Brotkrumen in der Topbar: Workspaces › Workspace › Bereich › Detail."""
from types import SimpleNamespace
from app.web import Crumb, breadcrumbs
from helpers import create_workspace
WS = SimpleNamespace(id=7, name="Analyse")
def labels(path: str, **context) -> list[str]:
return [c.label for c in breadcrumbs(path, context)]
def test_workspace_bereiche():
assert breadcrumbs("/workspaces/7", {"current_workspace": WS}) == [
Crumb("Workspaces", "/workspaces"), Crumb("Analyse", "/workspaces/7", workspace=True)]
assert labels("/workspaces/7/data", current_workspace=WS) == ["Workspaces", "Analyse", "Daten"]
assert labels("/workspaces/7/settings", current_workspace=WS)[-1] == "Einstellungen"
assert labels("/workspaces/7/hugin/catalog", current_workspace=WS)[-3:] == ["Einstellungen", "Hugin", "Katalog"]
assert labels("/workspaces/7/connections/new", current_workspace=WS)[-2:] == ["MCP-Server", "MCP-Server hinzufügen"]
def test_chat_fuehrt_zurueck_zur_chat_liste():
crumbs = breadcrumbs("/chats/3", {"current_workspace": WS, "chat": SimpleNamespace(title="Umsatz Q3")})
assert crumbs[-2:] == [Crumb("Chats", "/workspaces/7#chats"), Crumb("Umsatz Q3")]
def test_repository_mit_quelle_und_commit():
source = SimpleNamespace(name="app repo")
crumbs = breadcrumbs("/workspaces/7/repo/commits/0123456789abcdef", {"current_workspace": WS, "source": source})
assert crumbs[-2:] == [Crumb("Repository", "/workspaces/7/repo?source=app%20repo"), Crumb("Commit 0123456")]
crumbs = breadcrumbs("/workspaces/7/repo/compare", {"current_workspace": WS, "source": source, "pr": "12"})
assert crumbs[-2:] == [Crumb("Repository", "/workspaces/7/repo?source=app%20repo&tab=prs"),
Crumb("Pull Request #12")]
def test_administration_und_freigaben():
assert labels("/admin/teams/2", team=SimpleNamespace(name="Demo")) == ["Administration", "Teams", "Demo"]
driver = SimpleNamespace(role="database", label="PostgreSQL")
assert labels("/admin/mcp/4", server=driver) == ["Administration", "Datenbank-Treiber", "PostgreSQL"]
approval = SimpleNamespace(arguments={"title": "Branch anlegen"}, tool="git_branch")
assert labels("/approvals/5", a=approval, current_workspace=WS) == ["Freigaben", "Branch anlegen"]
assert labels("/workspaces") == ["Workspaces"]
assert labels("/login") == []
def test_topbar_zeigt_pfad(browser, people):
anna = browser("anna")
workspace_id = create_workspace(anna, people["team_demo"], "Analyse")
page = anna.get(f"/workspaces/{workspace_id}/settings").text
nav = page.split('class="breadcrumbs aiw-crumbs"')[1].split("</nav>")[0]
assert '<a href="/workspaces" title="Workspaces">Workspaces</a>' in nav
assert f'href="/workspaces/{workspace_id}" class="aiw-crumb-ws"' in nav
assert '<span aria-current="page" title="Einstellungen">Einstellungen</span>' in nav