94 lines
3.8 KiB
Python
94 lines
3.8 KiB
Python
from pathlib import Path
|
||
|
||
|
||
def test_base_navigation_is_russian_and_has_no_legacy_employees_link():
|
||
template = Path("app/templates/base.html").read_text(encoding="utf-8")
|
||
|
||
assert "Обзор" in template
|
||
assert "Сотрудники" in template
|
||
assert "Запуски" in template
|
||
assert "Выйти" in template
|
||
assert '<a class="admin__brand-link" href="/admin">MIEM Employees</a>' in template
|
||
assert ">Employees<" not in template
|
||
assert "/admin/employees" not in template
|
||
|
||
|
||
def test_directory_template_is_russian_and_uses_display_dates():
|
||
template = Path("app/templates/directory.html").read_text(encoding="utf-8")
|
||
|
||
assert "Сотрудники" in template
|
||
assert "Колонки" in template
|
||
assert "Применить" in template
|
||
assert "На странице: {{ value }}" in template
|
||
assert "{% for value in [25, 50, 100] %}" in template
|
||
assert "Найдено:" in template
|
||
assert "employee.first_seen_display" in template
|
||
assert "employee.last_seen_display" in template
|
||
assert "employee.dismissed_display" in template
|
||
assert "Directory" not in template
|
||
assert "employees found" not in template
|
||
|
||
|
||
def test_admin_employees_route_redirects_to_directory():
|
||
source = Path("app/admin.py").read_text(encoding="utf-8")
|
||
|
||
assert 'RedirectResponse("/admin/directory", status_code=303)' in source
|
||
|
||
|
||
def test_dashboard_limits_latest_runs_to_five():
|
||
source = Path("app/admin.py").read_text(encoding="utf-8")
|
||
|
||
assert "order_by(desc(CrawlRun.started_at)).limit(5)" in source
|
||
assert "order_by(desc(CrawlRun.started_at)).limit(10)" not in source
|
||
|
||
|
||
def test_runs_template_links_to_run_detail():
|
||
template = Path("app/templates/runs.html").read_text(encoding="utf-8")
|
||
|
||
assert 'onclick="window.location.href=\'/admin/runs/{{ run.id }}\'"' in template
|
||
assert "onkeydown=\"if (event.key === 'Enter' || event.key === ' ')" in template
|
||
assert 'role="link"' in template
|
||
assert 'tabindex="0"' in template
|
||
assert 'data-row-href="/admin/runs/{{ run.id }}"' not in template
|
||
assert '<a class="admin__link" href="/admin/runs/{{ run.id }}">' not in template
|
||
|
||
|
||
def test_run_detail_template_extends_base_and_shows_change_groups():
|
||
template = Path("app/templates/run_detail.html").read_text(encoding="utf-8")
|
||
|
||
assert '{% extends "base.html" %}' in template
|
||
assert 'id="new-employees"' in template
|
||
assert "Новые сотрудники" in template
|
||
assert "Потеряшки" in template
|
||
assert "Уволенные" in template
|
||
assert "Детализация сотрудников для этого запуска недоступна" in template
|
||
|
||
|
||
def test_dashboard_metric_cards_link_to_admin_targets():
|
||
template = Path("app/templates/dashboard.html").read_text(encoding="utf-8")
|
||
|
||
assert 'href="/admin/directory"' in template
|
||
assert 'href="/admin/directory?status=active"' in template
|
||
assert '/admin/runs/{{ latest_run.id }}#new-employees' in template
|
||
assert 'href="/admin/directory?status=dismissed"' in template
|
||
assert 'href="/admin/runs"' in template
|
||
|
||
|
||
def test_dashboard_latest_run_rows_link_to_run_detail():
|
||
template = Path("app/templates/dashboard.html").read_text(encoding="utf-8")
|
||
|
||
assert 'onclick="window.location.href=\'/admin/runs/{{ run.id }}\'"' in template
|
||
assert "onkeydown=\"if (event.key === 'Enter' || event.key === ' ')" in template
|
||
assert 'role="link"' in template
|
||
assert 'tabindex="0"' in template
|
||
assert 'data-row-href="/admin/runs/{{ run.id }}"' not in template
|
||
assert '<a class="admin__link" href="/admin/runs/{{ run.id }}">' not in template
|
||
|
||
|
||
def test_admin_js_supports_keyboard_activation_for_clickable_rows():
|
||
source = Path("app/static/admin.js").read_text(encoding="utf-8")
|
||
|
||
assert 'addEventListener("keydown"' in source
|
||
assert '"Enter"' in source
|
||
assert '" "' in source
|