Сотрудники не найдены
- {% if filters.q or filters.status or filters.has_email or filters.has_academic_degree or filters.pps or filters.started_from or filters.started_to %}
+ {% if has_filters %}
Попробуйте изменить запрос или сбросить фильтры.
Сбросить фильтры
{% else %}
diff --git a/app/version.py b/app/version.py
index ff9070f..14ac4fa 100644
--- a/app/version.py
+++ b/app/version.py
@@ -1,3 +1,3 @@
-APP_VERSION = "1.6.2"
-FRONTEND_VERSION = "1.6.2"
-BACKEND_VERSION = "1.6.2"
+APP_VERSION = "1.7.0"
+FRONTEND_VERSION = "1.7.0"
+BACKEND_VERSION = "1.7.0"
diff --git a/pyproject.toml b/pyproject.toml
index f049e28..b33a1a8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "miem-workers"
-version = "1.6.2"
+version = "1.7.0"
description = "MIEM employees parser, admin API, and web admin"
requires-python = ">=3.11"
dependencies = [
diff --git a/tests/browser_admin.py b/tests/browser_admin.py
index eb7972c..425489c 100644
--- a/tests/browser_admin.py
+++ b/tests/browser_admin.py
@@ -75,6 +75,12 @@ def main():
page.keyboard.press("Tab")
assert skip_link.evaluate("e => getComputedStyle(e).left === '-999px'")
+ filters = page.locator(".directory__filter-panel")
+ expect(filters).not_to_have_attribute("open", "")
+ expect(page.get_by_label("ФИО или ссылка")).to_be_hidden()
+ filters.locator("summary").focus()
+ page.keyboard.press("Enter")
+ expect(page.get_by_label("ФИО или ссылка")).to_be_visible()
for width in (1440, 1024, 921, 920, 768, 621, 620, 390, 320):
page.set_viewport_size({"width": width, "height": 844})
assert page.locator(".directory__filters").evaluate("e => e.scrollWidth <= e.clientWidth")
@@ -88,6 +94,7 @@ def main():
page.get_by_role("button", name="Применить фильтры").click()
expect(page.get_by_role("status")).to_have_text("Показаны 1–1 из 1")
assert "offset=" not in page.url
+ expect(filters).not_to_have_attribute("open", "")
trigger = page.get_by_role("button", name="Настроить колонки")
trigger.focus()
page.keyboard.press("Enter")
@@ -116,6 +123,7 @@ def main():
assert dialog.evaluate("e => e.getBoundingClientRect().right <= innerWidth")
page.screenshot(path=str(output / "mobile-dialog.png"), full_page=True)
page.keyboard.press("Escape")
+ filters.locator("summary").click()
page.get_by_label("ФИО или ссылка").fill("Нет совпадений")
page.get_by_role("button", name="Применить фильтры").click()
expect(page.get_by_text("Сотрудники не найдены", exact=True)).to_be_visible()
diff --git a/tests/test_api.py b/tests/test_api.py
index 81a7c80..d9c17df 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -18,7 +18,7 @@ def test_health_returns_versions():
response = TestClient(app).get("/api/health")
assert response.status_code == 200
- assert response.json()["backend_version"] == "1.6.2"
+ assert response.json()["backend_version"] == "1.7.0"
def test_api_employees_and_stats_require_admin_session():
diff --git a/tests/test_council.py b/tests/test_council.py
index b3959d1..f62d04a 100644
--- a/tests/test_council.py
+++ b/tests/test_council.py
@@ -230,7 +230,7 @@ def test_public_page_data_minimization_and_safe_links(db_session, export):
assert "javascript:" not in fragment.text and "private@example.org" not in fragment.text
assert "javascript:" not in response.text and "private@example.org" not in response.text
assert "/admin/employees/" not in response.text and "/admin/logout" not in response.text
- assert "Backend 1.6.2 · Frontend 1.6.2" in response.text
+ assert "Backend 1.7.0 · Frontend 1.7.0" in response.text
assert "Вход в систему" in response.text
assert client.get("/admin/directory", follow_redirects=False).status_code in (302, 303, 401, 403)
assert "Сотрудники не найдены" in client.get("/admin/council?q=missing").text
diff --git a/tests/test_training_filter.py b/tests/test_training_filter.py
new file mode 100644
index 0000000..a193bf6
--- /dev/null
+++ b/tests/test_training_filter.py
@@ -0,0 +1,79 @@
+from bs4 import BeautifulSoup
+from fastapi.testclient import TestClient
+
+from app.config import Settings, get_settings
+from app.db import get_db
+from app.main import app
+from app.models import Employee
+from app.parser.profile import extract_sections
+from app.security import SESSION_COOKIE, sign_session
+from app.services.admin_data import list_employees_page
+
+
+def test_training_filter_uses_course_year_and_kind_before_pagination(db_session):
+ title = "Дополнительное образование / Повышение квалификации / Стажировки"
+ profiles = [
+ (title, "2023", "«Курс 2024», повышение квалификации"),
+ (title, "2024", "«Курс», повышение квалификации, НИУ ВШЭ"),
+ (title, "2025", "«Курс», Повышение квалификации"),
+ (title, "2025", "«Стажировка», стажировка"),
+ ("Конференции", "2025", "«Доклад», повышение квалификации"),
+ (title, "", "«Курс без года», повышение квалификации"),
+ ]
+ for index, (section_title, year, text) in enumerate(profiles):
+ soup = BeautifulSoup(
+ f'{section_title}',
+ "html.parser",
+ )
+ url = f"https://example.test/{index}"
+ db_session.add(Employee(
+ profile_key=f"training:{index}", canonical_url=url, full_name=f"Person {index}",
+ current_data={
+ "sections": extract_sections(soup, url),
+ "positions": ["Доцент: кафедра"] if index == 1 else ["Инженер"],
+ },
+ ))
+ db_session.add(Employee(profile_key="training:6", canonical_url="https://example.test/6", full_name="Person 6"))
+ db_session.commit()
+
+ def names(**filters):
+ return [item["full_name"] for item in list_employees_page(db_session, **filters)["employees"]]
+
+ assert names(has_training=True) == ["Person 0", "Person 1", "Person 2", "Person 5"]
+ assert names(has_training=False) == ["Person 3", "Person 4", "Person 6"]
+ assert names(training_since_year=2024) == ["Person 1", "Person 2"]
+ assert names(training_since_year=2024, has_training=False) == [
+ "Person 0", "Person 3", "Person 4", "Person 5", "Person 6",
+ ]
+ assert names(training_since_year=2024, pps=True) == ["Person 1"]
+ assert names(training_since_year=2024, offset=1) == ["Person 2"]
+ assert names(training_since_year=2024, offset=25) == ["Person 1", "Person 2"]
+
+ settings = Settings(_env_file=None, admin_username="admin", admin_password="password", session_secret="test-training")
+ app.dependency_overrides[get_db] = lambda: db_session
+ app.dependency_overrides[get_settings] = lambda: settings
+ try:
+ with TestClient(app) as client:
+ client.cookies.set(SESSION_COOKIE, sign_session("admin", settings))
+ response = client.get("/api/employees?has_training=false&training_since_year=2024")
+ assert response.status_code == 200
+ assert response.json()["total"] == 5
+
+ response = client.get("/admin/directory?has_training=true&training_since_year=2024&offset=1")
+ assert response.status_code == 200
+ page = BeautifulSoup(response.text, "html.parser")
+ panel = page.select_one(".directory__filter-panel")
+ assert not panel.has_attr("open")
+ assert panel.summary.get_text(strip=True) == "Фильтры · применены"
+ assert panel.select_one('select[name="has_training"] option[selected]')["value"] == "true"
+ assert panel.select_one('input[name="training_since_year"]')["value"] == "2024"
+ assert "Person 1" not in response.text
+ assert "Person 2" in response.text
+ previous = page.select_one(".directory__pagination a")["href"]
+ assert "has_training=true" in previous
+ assert "training_since_year=2024" in previous
+ assert client.get("/admin/directory?has_training=&training_since_year=").status_code == 200
+ assert client.get("/admin/directory?training_since_year=bad").status_code == 422
+ finally:
+ app.dependency_overrides.clear()
|