fix: localize admin UI and simplify employees navigation
This commit is contained in:
@@ -4,12 +4,21 @@ from app.models import CrawlRun, Employee
|
||||
from app.services.admin_data import (
|
||||
employee_detail_payload,
|
||||
employee_display_payload,
|
||||
format_admin_datetime,
|
||||
list_employees_page,
|
||||
run_payload,
|
||||
stats_payload,
|
||||
)
|
||||
|
||||
|
||||
def test_format_admin_datetime_handles_datetime_string_and_none():
|
||||
value = datetime(2026, 4, 28, 17, 13, 34, tzinfo=timezone.utc)
|
||||
|
||||
assert format_admin_datetime(value) == "28.04.2026 20:13"
|
||||
assert format_admin_datetime("2026-04-28T17:13:34.448605+00:00") == "28.04.2026 20:13"
|
||||
assert format_admin_datetime(None) == "Не указано"
|
||||
|
||||
|
||||
def test_employee_display_payload_extracts_common_fields(db_session):
|
||||
employee = Employee(
|
||||
profile_key="staff:person",
|
||||
@@ -32,9 +41,11 @@ def test_employee_display_payload_extracts_common_fields(db_session):
|
||||
payload = employee_display_payload(employee)
|
||||
|
||||
assert payload["positions_text"] == "Professor"
|
||||
assert payload["status_display"] == "Работает"
|
||||
assert payload["email_text"] == "person@hse.ru"
|
||||
assert payload["publications_count"] == 1
|
||||
assert payload["courses_count"] == 1
|
||||
assert payload["first_seen_display"] != "Не указано"
|
||||
|
||||
|
||||
def test_employee_detail_payload_normalizes_human_readable_sections(db_session):
|
||||
@@ -180,3 +191,4 @@ def test_run_payload_calculates_progress():
|
||||
|
||||
assert payload["processed_count"] == 5
|
||||
assert payload["progress_percent"] == 50.0
|
||||
assert payload["status_display"] == "Выполняется"
|
||||
|
||||
32
tests/test_admin_templates.py
Normal file
32
tests/test_admin_templates.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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 ">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 "Найдено:" 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
|
||||
@@ -18,7 +18,7 @@ def test_health_returns_versions():
|
||||
response = client.get("/api/health")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["backend_version"] == "0.2.5"
|
||||
assert response.json()["backend_version"] == "0.2.6"
|
||||
|
||||
|
||||
def test_mcp_requires_token_and_lists_tools():
|
||||
|
||||
@@ -14,4 +14,15 @@ def test_employee_detail_template_is_human_readable():
|
||||
assert "Основная информация" in template
|
||||
assert "Контакты" in template
|
||||
assert "Разделы профиля" in template
|
||||
assert "Snapshots" in template
|
||||
assert "Parser version" not in template
|
||||
assert "First seen" not in template
|
||||
assert "Last seen" not in template
|
||||
assert "Dismissed at" not in template
|
||||
assert "Profile type" not in template
|
||||
assert "Profile ID" not in template
|
||||
assert "Впервые найден" in template
|
||||
assert "Последний раз найден" in template
|
||||
assert "Дата увольнения" in template
|
||||
assert "Тип профиля" in template
|
||||
assert "ID профиля" in template
|
||||
assert "Снапшоты" in template
|
||||
|
||||
Reference in New Issue
Block a user