From bfdb7ce3d26034d9175c6c0e80ce2ebb6b0ae1fc Mon Sep 17 00:00:00 2001 From: anor Date: Tue, 10 Nov 2026 01:28:04 +1000 Subject: [PATCH] =?UTF-8?q?fix(=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA=D0=B0)?= =?UTF-8?q?:=20=D0=BC=D0=B5=D1=82=D0=BA=D0=B0=20=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B2=20=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D0=B0?= =?UTF-8?q?=D1=85=20=D0=B2=D1=85=D0=BE=D0=B4=D0=B0=20=E2=80=94=20=D1=81?= =?UTF-8?q?=D0=B2=D0=B5=D0=B6=D0=B8=D0=B9=20app.js=20=D0=B1=D0=B5=D0=B7=20?= =?UTF-8?q?=D1=80=D1=83=D1=87=D0=BD=D0=BE=D0=B9=20=D1=87=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BA=D0=B5=D1=88=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- main.py | 8 +++++++- tests/test_admin_v2_e2e_api.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 6bb48e9..151bb85 100644 --- a/main.py +++ b/main.py @@ -464,7 +464,7 @@ MAX_MESSAGE_LEN = 10_000 # ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква). # Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version). -APP_VERSION = "2026-11-10c" +APP_VERSION = "2026-11-10d" # Audit: path → action name mapping _AUDIT_MAP = [ @@ -4286,7 +4286,13 @@ ADMIN_HTML_VERSION = "20261001c" @app.get("/admin/v2/{section:path}", response_class=HTMLResponse) async def admin_v2_page(section: str | None = None): # SPA: deep link отдаёт ту же оболочку; маршрут разбирает router.js. + # Метка версии в адресах входа — чтобы браузер не взял старый app.js из своего + # кеша: без неё правки «не появлялись» до ручной очистки. html = Path("static/admin2/index.html").read_text(encoding="utf-8") + html = html.replace("/static/admin2/styles.css", + f"/static/admin2/styles.css?v={APP_VERSION}") + html = html.replace("/static/admin2/app.js", + f"/static/admin2/app.js?v={APP_VERSION}") return HTMLResponse(html, headers={"Cache-Control": "no-store"}) diff --git a/tests/test_admin_v2_e2e_api.py b/tests/test_admin_v2_e2e_api.py index d3bf401..9d05044 100644 --- a/tests/test_admin_v2_e2e_api.py +++ b/tests/test_admin_v2_e2e_api.py @@ -46,6 +46,16 @@ def test_legacy_and_v2_sections(env): assert client.get(path, headers=h).status_code == 200, path +def test_admin2_shell_versions_entry_assets(env): + """Вход в админку ссылается на файлы с меткой версии: старый app.js из кеша + браузера не перекроет свежий выкат.""" + client, h, db = env + import main + text = client.get("/admin/v2").text + assert f"/static/admin2/app.js?v={main.APP_VERSION}" in text + assert f"/static/admin2/styles.css?v={main.APP_VERSION}" in text + + def test_admin2_static_revalidates(env): """Модули админки v2 обязаны перепроверяться: без no-cache браузер держал старые файлы по своей эвристике, и правки не появлялись после выката.